index.vue 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461
  1. <template>
  2. <!-- 提交订单 -->
  3. <view class="order-confirm-container">
  4. <JHeader title="购买宝贝" width="50" height="50" style="padding: 24upx 0 0;"></JHeader>
  5. <view class="content">
  6. <view style="text-align: right;">
  7. <tui-button
  8. type="danger" plain width="180rpx" height="54rpx"
  9. style="display: inline-block;" shape="circle"
  10. @click="handleShare"
  11. >
  12. 一键分享
  13. </tui-button>
  14. </view>
  15. <view v-if="settlement.shopType !== 2">
  16. <view class="address-box" @click="go(`/another-tf/another-serve/address/index?type=${fromType}`)">
  17. <tui-icon name="position" :size="66" unit="upx" color="#333333" margin="0 20upx 0 0"></tui-icon>
  18. <!-- 有地址的 -->
  19. <view v-if="userAddressInfo.receiveId" class="address-r">
  20. <view class="address-name-box">
  21. <text>{{ userAddressInfo.receiveName }}</text>
  22. <text class="phone">{{ userAddressInfo.receivePhone }}</text>
  23. </view>
  24. <view class="address-info">
  25. <text>{{ userAddressInfo.receiveAdress }} {{ userAddressInfo.address }}</text>
  26. </view>
  27. </view>
  28. <!-- 没有地址的 -->
  29. <view v-else class="address-r">
  30. <text>你还没有收货地址哦,点击这里添加</text>
  31. </view>
  32. <tui-icon name="arrowright" :size="62" unit="upx" color="#999999" margin="0 0 0 20upx"></tui-icon>
  33. </view>
  34. </view>
  35. <view class="order-list-box">
  36. <view v-for="(item, sIndex) in settlement.shops" :key="item.shopId" class="item">
  37. <view class="order-list-top">
  38. <view class="top-l">
  39. <tui-icon name="shop" :size="34" unit="upx" color="#2b2b2b" margin="0 20upx 0 0"></tui-icon>
  40. <text class="shop-name">{{ item.shopName }}</text>
  41. </view>
  42. </view>
  43. <view class="order-info-box">
  44. <view class="order-info">
  45. <view v-for="(cItem, index) in item.skus" :key="cItem.productId" class="order-info-item">
  46. <image :src="common.seamingImgUrl(cItem.image)" class="product-img"></image>
  47. <view class="info-box">
  48. <text class="product-name">{{ cItem.productName }}</text>
  49. <view class="product-sku">
  50. <view v-for="(vItem, index) in cItem.values">
  51. <label class="mar-left-20">{{ vItem }}</label>
  52. </view>
  53. </view>
  54. <view class="price-sku-box flex-display flex-sp-between">
  55. <view class="product-price">
  56. <text class="fuhao">¥</text>
  57. {{ cItem.price }}
  58. </view>
  59. <view class="product-num">x {{ cItem.number }}</view>
  60. </view>
  61. </view>
  62. </view>
  63. <view v-if="item.receiveNotMatch" class="adressTips">
  64. 当前地址不支持配送,可更换其他地址试试
  65. </view>
  66. <view class="delivery-way-box">
  67. <view>
  68. <view class="item">
  69. <view class="flex-items">
  70. <text>配送方式</text>
  71. </view>
  72. <view>
  73. <text v-if="item.distribution.distributionPrice > 0" style="white-space: nowrap;">
  74. 快递 ¥ {{ item.distribution.distributionPrice }}
  75. </text>
  76. <text v-else>快递 免邮</text>
  77. </view>
  78. </view>
  79. <view class="flex-item">
  80. <text v-for="(hItem, hIndex) in item.skuDiscountInfoMap" class="font-color-666 fs24">
  81. {{ hItem[0] }}
  82. </text>
  83. </view>
  84. </view>
  85. </view>
  86. </view>
  87. <view v-if="item.shopCoupons.length > 0" class="discount-item1" @click="showShopCoupons(item, sIndex)">
  88. <view class="discount-label">店铺优惠</view>
  89. <view class="discount-info-box flex-items">
  90. <view v-if="item.currentCoupon && item.currentCoupon.couponType === 1" class="discount-info2">
  91. -¥{{ item.currentCoupon.reduceMoney }}
  92. </view>
  93. <view v-if="item.currentCoupon && item.currentCoupon.couponType === 2" class="discount-info2">
  94. {{ item.currentCoupon.reduceMoney }}折券
  95. </view>
  96. <tui-icon name="arrowright" :size="30" unit="upx" color="#999999" margin="0 0 0 20upx"></tui-icon>
  97. </view>
  98. </view>
  99. <view class="order-total-box">
  100. <text class="total-num">共{{ item.number }}件</text>
  101. <text class="total-num ml10">总计</text>
  102. <text v-if="item.totalAfterDiscount > 0" class="total-price ml10">
  103. ¥{{
  104. (parseFloat(item.totalAfterDiscount) + parseFloat(item.distribution.distributionPrice || 0)).toFixed(2)
  105. }}
  106. </text>
  107. <text v-else class="total-price ml10">¥0.00</text>
  108. </view>
  109. </view>
  110. </view>
  111. </view>
  112. <view class="discount-item" @click="showDiscount">
  113. <view class="discount-label">平台优惠</view>
  114. <view class="discount-info-box flex-items">
  115. <view v-if="promotionInfoDTO.couponId" class="discount-info2">
  116. <text v-if="promotionInfoDTO.couponType === 2">{{ promotionInfoDTO.reduceMoney }}折</text>
  117. <text v-else> -¥{{ promotionInfoDTO.reduceMoney | clip2Decimal }}</text>
  118. </view>
  119. <view v-else-if="!settlement.coupons || !settlement.coupons.length" class="discount-label">无</view>
  120. <view v-else class="discount-label">不使用</view>
  121. <tui-icon name="arrowright" :size="30" unit="upx" color="#999999" margin="0 0 0 20upx"></tui-icon>
  122. </view>
  123. </view>
  124. <!-- 积分支付 -->
  125. <view v-if="integralNum" class="integralPayBox">
  126. <view class="integralBg">
  127. <view class="integralTit fs26">可用 {{ integralNum }} 积分抵扣 {{ integralPrice.toFixed(2) }} 元</view>
  128. <view class="maxIntegral">
  129. <checkbox-group style="width: 50rpx" @change="changeIntegral">
  130. <checkbox
  131. style="transform:scale(0.7);" class="integralCheckbox" color="#C5AA7B" value="1"
  132. :checked="selectIntegral"
  133. />
  134. </checkbox-group>
  135. </view>
  136. </view>
  137. </view>
  138. <VoucherUse
  139. v-if="settlement.userVoucherDeductLimit && settlement.voucherTotalAll" ref="refVoucherUse"
  140. :voucher-list="settlement.voucherList" :voucher-num="settlement.userVoucherDeductLimit"
  141. @choose="handleChooseVoucher"
  142. ></VoucherUse>
  143. <view style="margin-top: 20upx;">
  144. <CashierList show :show-platform-pay="!!totalPrice" :price-pay="totalPrice" :shop-id-pay="totalPrice ? shopIdPay : 0" @change="(e) => payInfo = e" />
  145. </view>
  146. <view class="order-flow-box">
  147. <view class="flow-word">交易流程:</view>
  148. <view class="flow-word mt25">
  149. <text>1、填写收货信息并完成支付</text>
  150. <text>2、双方根据物品的交易方式进行交易</text>
  151. <text>3、拿到物品,交易结束</text>
  152. </view>
  153. <!-- 实付款不含邮费,涉及邮寄双方协定好费用,提醒发起人修改价格再完成支付; -->
  154. <view class="flow-word mt50">
  155. 注:应国家邮政总局的要求,即日起涉及到个人快递包裹必须收件人实名制,否则将影响到收寄配送。请避免使用「先生,男士,小姐,女士,昵称」等模糊称谓。
  156. </view>
  157. </view>
  158. </view>
  159. <view class="order-confirm-box" style="padding-bottom:30upx;">
  160. <view class="flex-items flex-sp-between">
  161. <text class="num-box">共{{ totalCount }}件</text>
  162. <view>
  163. <text class="total">合计:</text>
  164. <text v-if="totalPrice > 0" class="price">
  165. ¥{{ totalPrice.toFixed(2) }}
  166. </text>
  167. <text v-else class="price">
  168. ¥0.00
  169. </text>
  170. </view>
  171. </view>
  172. <!-- active 当有地址时按钮加上active选中的样式 -->
  173. <button v-if="isRegionalScope" class="btn unActive" type="default" :disabled="false">
  174. 提交订单
  175. </button>
  176. <button v-else class="btn active" @click="submitOrder">提交订单</button>
  177. </view>
  178. <!-- 活动弹框,平台优惠券 -->
  179. <tui-bottom-popup class="activity-con" :show="isShowDiscount" @close="isShowDiscount = false">
  180. <view class="activity-box" style="height: 1000rpx;">
  181. <view class="title-box">
  182. <tui-icon
  183. name="close" :size="30" unit="upx" color="#999999"
  184. style="padding: 30upx;position: absolute;top: 0;right: 0;" @click="isShowDiscount = false"
  185. ></tui-icon>
  186. </view>
  187. <view class="activity-coupon-box">
  188. <scroll-view scroll-y="true" style="height: 900rpx;">
  189. <view class="content-box">
  190. <view v-if="settlement.coupons && settlement.coupons.length">
  191. <view class="label-lingqu">可用优惠券列表</view>
  192. <view class="couponBox">
  193. <view
  194. v-for="(usableItem, index) in settlement.coupons" :key="index" class="coupon-item"
  195. @click="couponItemTap(index, usableItem)"
  196. >
  197. <view v-if="usableItem.couponType === 1" class="money-box">
  198. ¥{{ usableItem.reduceMoney }}
  199. </view>
  200. <view v-else class="money-box">
  201. {{ usableItem.reduceMoney }}折券
  202. </view>
  203. <view class="info-box">
  204. <view class="date font-color-999" style="font-size:22upx;margin-top: 20upx;">
  205. {{
  206. getDate(usableItem.startTime.replace(/-/g, '.')).split(' ')[0]
  207. }}-{{ getDate(usableItem.endTime.replace(/-/g, '.')).split(' ')[0] }}
  208. </view>
  209. <view class="info font-color-999">满{{ usableItem.fullMoney }}元可用</view>
  210. </view>
  211. <tui-icon
  212. v-if="usableItem.checked" name="circle-fill" :size="40" unit="upx"
  213. color="#c5aa7b"
  214. margin="40upx 0 0 0"
  215. ></tui-icon>
  216. <tui-icon v-else name="circle" :size="40" unit="upx" color="#cccccc" margin="40upx 0 0 0"></tui-icon>
  217. </view>
  218. </view>
  219. </view>
  220. </view>
  221. </scroll-view>
  222. </view>
  223. </view>
  224. </tui-bottom-popup>
  225. <tui-bottom-popup class="activity-con" :show="isShopCoupons" @close="isShopCoupons = false">
  226. <view class="activity-box">
  227. <view class="title-box">
  228. <tui-icon
  229. name="close" :size="100" unit="upx" color="#999999"
  230. style="padding: 30upx;position: absolute;top: 0;right: 0;" @click="isShopCoupons = false"
  231. ></tui-icon>
  232. </view>
  233. <view class="activity-coupon-box">
  234. <scroll-view scroll-y="true" style="height: 900rpx;">
  235. <view class="content-box">
  236. <view v-if="shopCouponsLength">
  237. <view class="label-lingqu">可用优惠券列表</view>
  238. <view class="couponBox">
  239. <view
  240. v-for="(sItem, index) in shopCouponslist.shopCoupons" :key="sItem.id" class="coupon-item"
  241. @click="shopCouponItemTap(index, sItem)"
  242. >
  243. <view v-if="sItem.couponType === 1" class="money-box">
  244. ¥{{ sItem.reduceMoney }}
  245. </view>
  246. <view v-else class="money-box">{{ sItem.reduceMoney }}折券</view>
  247. <view class="date font-color-999" style="font-size:22upx;margin-top: 10upx;">
  248. {{ getDate(sItem.startTime.replace(/-/g, '.')).split(' ')[0] }}-{{
  249. getDate(sItem.endTime.replace(/-/g, '.')).split(' ')[0] }}
  250. </view>
  251. <view class="info-box">
  252. <view class="info font-color-999">满{{ sItem.fullMoney }}元可用</view>
  253. </view>
  254. <tui-icon
  255. v-if="sItem.checked" name="circle-fill" :size="40" unit="upx"
  256. color="#c5aa7b"
  257. margin="40upx 0 0 0"
  258. ></tui-icon>
  259. <tui-icon v-else name="circle" :size="40" unit="upx" color="#cccccc" margin="40upx 0 0 0"></tui-icon>
  260. </view>
  261. </view>
  262. </view>
  263. </view>
  264. </scroll-view>
  265. </view>
  266. </view>
  267. </tui-bottom-popup>
  268. <!-- 分享订单商品海报 -->
  269. <OrderPoster ref="refOrderPoster"></OrderPoster>
  270. </view>
  271. </template>
  272. <script>
  273. import { handleDoPay } from '../../../utils/payUtil'
  274. import { getQueryDictByNameApi, getGroupSettlementWorkApi, getSettlementOrderApi, updatePlaceOrderSubmitApi, addUserTrackReportDoPointerApi } from '../../../api/anotherTFInterface'
  275. import { T_RECEIVE_ITEM, T_SKU_ITEM_DTO_LIST, T_SKU_ITEM_LIST } from '../../../constant'
  276. export default {
  277. name: 'OrderConfirm',
  278. filters: {
  279. clip2Decimal(value) {
  280. if (value === undefined || value === null) {
  281. return '0.00'
  282. }
  283. return (parseInt(value * 100) / 100).toFixed(2)
  284. }
  285. },
  286. data() {
  287. return {
  288. settlement: {
  289. voucherList: []
  290. },
  291. fromType: 0,
  292. brandId: 0,
  293. skuItemDTOList: [],
  294. totalPrice: 0, // 合计
  295. totalCount: 0,
  296. userAddressInfo: {},
  297. isRegionalScope: false, // 是否在商家配置范围内地址
  298. payInfo: {}, // 支付相关
  299. shopIdPay: '', // 某商家的‘用户的商家充值的余额支付’对应的商家Id
  300. oneClickSubmit: true, // 只提交订单一次
  301. // 拼团相关
  302. skuItemList: {},
  303. shopGroupWorkId: 0,
  304. sumitType: '',
  305. collageId: null,
  306. // 店铺优惠券相关
  307. isShopCoupons: false,
  308. shopCouponsLength: 0,
  309. shopCouponslist: [],
  310. selectShopCoupon: [], // 已选择店铺优惠券
  311. // 代金券相关
  312. voucherObj: {
  313. voucherTotalAll: 0,
  314. isVoucher: false,
  315. voucherId: 0
  316. },
  317. // 平台优惠券相关
  318. isShowDiscount: false,
  319. promotionInfoDTO: {
  320. couponId: 0,
  321. ifAdd: 1,
  322. reduceMoney: 0
  323. },
  324. shopIndex: 0, // 选中的店铺使用店铺优惠券
  325. checkedPlatformCoupon: undefined,
  326. // 积分相关
  327. selectIntegral: true,
  328. integralNum: 0,
  329. integralRatio: 0, // 积分兑换比例
  330. integralPrice: 0, // 总积分可减多少元
  331. // 埋点ID
  332. pointProductIds: ''
  333. }
  334. },
  335. onLoad(options) {
  336. getQueryDictByNameApi({ name: 'credit_exchange_rate' })
  337. .then((res) => {
  338. this.integralRatio = parseFloat(res.data.dictDescribe)
  339. })
  340. this.fromType = options.type
  341. this.brandId = options.brandId || ''
  342. },
  343. onShow() {
  344. this.handleOnShow()
  345. },
  346. methods: {
  347. handleOnShow() {
  348. if (uni.getStorageSync(T_RECEIVE_ITEM)) this.userAddressInfo = uni.getStorageSync(T_RECEIVE_ITEM)
  349. if (uni.getStorageSync(T_SKU_ITEM_DTO_LIST)) { // 1立即购买,2购物车结算
  350. this.skuItemDTOList = uni.getStorageSync(T_SKU_ITEM_DTO_LIST)
  351. if (this.skuItemDTOList[0].shopDiscountId > 0) {
  352. this.sumitType = 4 // 4限时折扣活动
  353. } else if (this.skuItemDTOList[0].shopSeckillId > 0) {
  354. this.sumitType = 3 // 3秒杀活动
  355. }
  356. this.getSettlement(false)
  357. } else if (uni.getStorageSync(T_SKU_ITEM_LIST)) { // 3拼团商品立即购买
  358. this.skuItemList = uni.getStorageSync(T_SKU_ITEM_LIST)
  359. this.shopGroupWorkId = this.skuItemList.shopGroupWorkId
  360. this.sumitType = this.skuItemList.type // 1发起拼团(单独开团),2参与拼团(拼团)
  361. this.collageId = this.skuItemList.collageId
  362. this.getSettlement(true)
  363. }
  364. },
  365. // 积分价格计算
  366. changeIntegral() {
  367. this.selectIntegral = !this.selectIntegral
  368. if (this.voucherObj.voucherId) {
  369. this.$nextTick(() => {
  370. this.selectIntegral = false
  371. })
  372. return this.$showToast('已选择代金券,无法使用其它优惠')
  373. }
  374. if (this.selectIntegral) {
  375. this.totalPrice = this.totalPrice - this.integralPrice
  376. } else {
  377. this.totalPrice = this.totalPrice + this.integralPrice
  378. }
  379. },
  380. // 获取订单信息
  381. getSettlement(isGroup) {
  382. uni.showLoading({
  383. title: '加载中...'
  384. })
  385. let _url = ''
  386. let _data = ''
  387. // 是否是拼团
  388. if (isGroup) {
  389. _url = getGroupSettlementWorkApi
  390. _data = this.skuItemList
  391. } else {
  392. _url = getSettlementOrderApi
  393. _data = {
  394. type: this.fromType,
  395. shopId: this.brandId,
  396. shops: this.skuItemDTOList,
  397. receiveId: this.userAddressInfo.receiveId,
  398. ...this.voucherObj
  399. }
  400. }
  401. _url(_data).then((res) => {
  402. uni.hideLoading()
  403. this.settlement = res.data
  404. if (this.settlement.shops.length === 1) this.shopIdPay = this.settlement.shops[0].shopId
  405. this.settlement.shops.forEach((value) => {
  406. value.totalNum = value.total
  407. value.pricing = 0
  408. })
  409. // 如果没有地址时进入购买宝贝页面对下面的商品件数和总计进行赋值
  410. if (!this.settlement.receive.receiveAdress) {
  411. this.settlement.shops.map((item) => {
  412. this.totalCount += item.number
  413. this.totalPrice += item.total || item.totalNum
  414. })
  415. }
  416. // 初始化平台券选中状态
  417. this.settlement.coupons && this.settlement.coupons.forEach((item) => {
  418. item.checked = false
  419. })
  420. this.settlement.shops.forEach((item) => {
  421. item.totalAfterDiscount = item.total
  422. })
  423. // 默认选中商家的第一张优惠券
  424. for (let s = 0; s < this.settlement.shops.length; s++) {
  425. this.shopIndex = s
  426. const curShop = this.settlement.shops[s]
  427. curShop.skus.forEach((item) => {
  428. item.skuTotalNum = item.total
  429. })
  430. if (curShop.shopCoupons.length > 0) {
  431. curShop.shopCoupons.forEach((item) => {
  432. item.checked = false
  433. })
  434. const firstShopCoupon = curShop.shopCoupons[0]
  435. this.shopCouponItemTap(0, firstShopCoupon)
  436. // let useCoupon = this.useShopCoupon(s, 0)
  437. // if (useCoupon) {
  438. // firstShopCoupon.checked = true
  439. // this.selectShopCoupon.push(firstShopCoupon)
  440. // curShop['currentCoupon'] = firstShopCoupon
  441. // } else {
  442. // curShop.totalNum = curShop.total
  443. // }
  444. }
  445. }
  446. this.shopIndex = 0
  447. if (this.settlement.shopType !== 2) { // 1品牌商家,2商圈商家
  448. if (uni.getStorageSync(T_RECEIVE_ITEM)) {
  449. this.userAddressInfo = uni.getStorageSync(T_RECEIVE_ITEM)
  450. this.userAddressInfo.receivePhone = this.userAddressInfo.receivePhone.replace(/(\d{3})\d+(\d{4})$/, '$1****$2')
  451. } else if (res.data.receive) {
  452. this.userAddressInfo = res.data.receive || {}
  453. this.userAddressInfo.receivePhone = this.userAddressInfo.receivePhone.replace(/(\d{3})\d+(\d{4})$/, '$1****$2')
  454. }
  455. } else {
  456. this.userAddressInfo = { receiveId: 485 }
  457. }
  458. uni.removeStorageSync(T_RECEIVE_ITEM)
  459. this.settlement.shops.some((item) => { // 根据地址判断是否能下单
  460. if (item.receiveNotMatch) {
  461. this.isRegionalScope = item.receiveNotMatch
  462. this.$showToast('当前地址不支持配送,请参考红色字提示')
  463. }
  464. return item.receiveNotMatch
  465. })
  466. this.getTotal()
  467. console.log(this.settlement)
  468. })
  469. .catch((e) => {
  470. uni.hideLoading()
  471. })
  472. },
  473. // 平台优惠券选择
  474. couponItemTap(index, coupon) {
  475. if (!coupon.checked && this.selectShopCoupon.length) { // 判断商家券情况
  476. this.$showToast('不可与商家券叠加使用!')
  477. return false
  478. }
  479. // 已选中的情况下取消选中
  480. if (coupon.checked) {
  481. const promotionInfoDTO = {}
  482. if (coupon.couponId) {
  483. promotionInfoDTO.couponId = 0
  484. promotionInfoDTO.ifAdd = 1
  485. promotionInfoDTO.reduceMoney = 0
  486. }
  487. this.promotionInfoDTO = promotionInfoDTO
  488. coupon.checked = false
  489. this.isShowDiscount = false
  490. this.checkedPlatformCoupon = undefined
  491. this.settlement.shops.forEach((shopItem) => {
  492. if (shopItem.skus) {
  493. shopItem.skus.forEach((skuItem) => {
  494. skuItem.buyerCouponId = null
  495. })
  496. }
  497. })
  498. this.getTotal()
  499. } else {
  500. // 先把所有已选中的平台优惠券改为未选中
  501. this.settlement.coupons && this.settlement.coupons.forEach((item) => {
  502. item.checked = false
  503. })
  504. let totalPrice = 0 // 订单总价
  505. const shopsLen = this.settlement.shops.length // 结算页店铺数量
  506. let matchCouponSkuList = []
  507. for (let i = 0; i < shopsLen; i++) {
  508. let matchCouponNormalPrice = 0
  509. let priceCount = 0
  510. const curShop = this.settlement.shops[i]
  511. const skuLen = curShop.skus.length
  512. const tmpPriceSkuList = []
  513. for (let j = 0; j < skuLen; j++) {
  514. const curSku = curShop.skus[j]
  515. if (curSku.priceId > 0) {
  516. priceCount++
  517. }
  518. const ids = coupon.ids
  519. if (ids.indexOf(curSku.productId) > -1) {
  520. if (curSku.priceId > 0) {
  521. tmpPriceSkuList.push(curSku)
  522. } else {
  523. matchCouponSkuList.push(curSku)
  524. matchCouponNormalPrice = matchCouponNormalPrice + curSku.price * curSku.number
  525. }
  526. }
  527. }
  528. if (priceCount === tmpPriceSkuList.length) {
  529. totalPrice += curShop.priceAfterDiscount
  530. matchCouponSkuList = matchCouponSkuList.concat(tmpPriceSkuList)
  531. }
  532. totalPrice += matchCouponNormalPrice
  533. }
  534. if (this.settlement.shops[this.shopIndex].total < coupon.fullMoney) {
  535. this.$showToast('不满足优惠券使用条件!')
  536. return false
  537. }
  538. if (coupon.couponType === 1 && coupon.reduceMoney >= totalPrice) {
  539. this.$showToast('不可使用大于等于合计金额的优惠劵!')
  540. return false
  541. }
  542. // 如果是折扣券,需要记录,在什么基数上打折
  543. coupon.useMoney = totalPrice
  544. const promotionInfoDTO = {}
  545. if (coupon.couponId) {
  546. promotionInfoDTO.couponId = coupon.couponId
  547. promotionInfoDTO.ifAdd = coupon.ifAdd
  548. promotionInfoDTO.couponType = coupon.couponType
  549. promotionInfoDTO.reduceMoney = coupon.reduceMoney
  550. }
  551. this.promotionInfoDTO = promotionInfoDTO
  552. this.isShowDiscount = false
  553. this.checkedPlatformCoupon = coupon
  554. matchCouponSkuList.forEach((item) => {
  555. item.buyerCouponId = coupon.couponId
  556. })
  557. this.getTotal()
  558. // 选中优惠券
  559. coupon.checked = true
  560. }
  561. },
  562. // 店铺优惠券选择
  563. shopCouponItemTap(index, coupon) {
  564. // 取消选择优惠券
  565. if (coupon.checked) {
  566. coupon.checked = false
  567. this.settlement.shops[this.shopIndex].totalAfterDiscount = this.settlement.shops[this.shopIndex].total
  568. this.settlement.shops[this.shopIndex].currentCoupon = {}
  569. this.settlement.shops[this.shopIndex].skus.forEach((item) => {
  570. item.buyerShopCouponId = null
  571. })
  572. this.isShopCoupons = false
  573. this.selectShopCoupon = []
  574. this.getTotal()
  575. return
  576. }
  577. if (this.settlement.shops[this.shopIndex].total < coupon.fullMoney) {
  578. this.$showToast('不满足优惠券使用条件!')
  579. } else if (coupon.couponType === 1 && this.settlement.shops[this.shopIndex].total < coupon.reduceMoney) {
  580. this.$showToast('不可使用大于商品金额的优惠劵!')
  581. } else {
  582. // 选择优惠券
  583. if (this.promotionInfoDTO.couponId !== 0) return this.$showToast('此券不可与平台券叠加!')
  584. if ((coupon.couponType === 1) && (coupon.reduceMoney >= this.settlement.shops[this.shopIndex].total)) return this.$showToast('优惠券优惠金额不能大于等于合计金额!')
  585. this.isShopCoupons = false
  586. if (this.useShopCoupon(this.shopIndex, index)) {
  587. for (let i = 0; i < this.settlement.shops[this.shopIndex].shopCoupons.length; i++) {
  588. this.settlement.shops[this.shopIndex].shopCoupons[i].checked = false
  589. }
  590. this.selectShopCoupon = this.selectShopCoupon.filter((item) => item.id !== coupon.id)
  591. coupon.checked = true
  592. this.settlement.shops[this.shopIndex].currentCoupon = coupon
  593. this.settlement.shops[this.shopIndex].skus.forEach((item) => {
  594. if (item.buyerShopCouponId > 0 && item.buyerShopCouponId !== coupon.shopCouponId) item.buyerShopCouponId = null
  595. })
  596. this.selectShopCoupon.push(coupon)
  597. } else {
  598. this.settlement.shops[this.shopIndex].totalAfterDiscount = this.settlement.shops[this.shopIndex].total
  599. }
  600. this.getTotal()
  601. }
  602. },
  603. useShopCoupon(shopIndex, couponIndex) {
  604. const curShop = this.settlement.shops[shopIndex]
  605. curShop.totalAfterDiscount = 0
  606. let curCoupon
  607. if (curShop.shopCoupons && curShop.shopCoupons.length > 0) {
  608. curCoupon = curShop.shopCoupons[couponIndex]
  609. }
  610. if (!curCoupon) return false
  611. let useCoupon = false
  612. const matchCouponNormalSkuList = []
  613. const matchCouponPriceSkuList = []
  614. if (curCoupon.applyType !== 1) {
  615. const ids = curCoupon.ids
  616. const skuLength = curShop.skus.length
  617. // 符合优惠券商品列表中的普通sku价格综合
  618. let matchCouponNormalPrice = 0
  619. // 符合定价捆绑且在优惠券商品列表中的价格综合
  620. let matchCouponPricePrice = 0
  621. // 符合定价捆绑活动的sku数量
  622. let priceCount = 0
  623. for (let idx = 0; idx < skuLength; idx++) {
  624. const curSku = curShop.skus[idx]
  625. if (curSku.priceId > 0) {
  626. priceCount++
  627. }
  628. if (ids.indexOf(curSku.productId) > -1) {
  629. if (curSku.priceId > 0) {
  630. matchCouponPriceSkuList.push(curSku)
  631. } else {
  632. matchCouponNormalSkuList.push(curSku)
  633. matchCouponNormalPrice = matchCouponNormalPrice + curSku.price * curSku.number
  634. }
  635. }
  636. }
  637. // 如果定价捆绑的所有sku都符合优惠券
  638. if (priceCount === matchCouponPriceSkuList.length) {
  639. matchCouponPricePrice = curShop.priceAfterDiscount
  640. }
  641. // 符合的sku的price加起来是否满足满减的条件
  642. const priceFinal = matchCouponPricePrice + matchCouponNormalPrice
  643. if (priceFinal < curCoupon.fullMoney || (curCoupon.couponType === 1 && priceFinal <= curCoupon.reduceMoney)) return false
  644. // 判断是满减,还是折扣
  645. if (curCoupon.couponType === 1) {
  646. curShop.totalAfterDiscount = curShop.total - curCoupon.reduceMoney
  647. useCoupon = true
  648. } else {
  649. // 打折后优惠抵扣的金额
  650. const priceDiscount = (priceFinal * ((10 - curCoupon.reduceMoney) / 10)).toFixed(2)
  651. const tmpTotal = curShop.total - priceDiscount
  652. if (tmpTotal.toFixed(2) >= 0.01) {
  653. curShop.totalAfterDiscount = tmpTotal.toFixed(2)
  654. useCoupon = true
  655. }
  656. }
  657. if (useCoupon) {
  658. // 满足的sku设置buyerShopCouponId
  659. if (priceCount === matchCouponPriceSkuList.length) {
  660. const length1 = matchCouponPriceSkuList.length
  661. for (let idx = 0; idx < length1; idx++) {
  662. matchCouponPriceSkuList[idx].buyerShopCouponId = curCoupon.shopCouponId
  663. }
  664. }
  665. const length2 = matchCouponNormalSkuList.length
  666. for (let idx = 0; idx < length2; idx++) {
  667. matchCouponNormalSkuList[idx].buyerShopCouponId = curCoupon.shopCouponId
  668. }
  669. }
  670. } else {
  671. if (curCoupon.couponType === 1) {
  672. if (curShop.total > curCoupon.reduceMoney) {
  673. curShop.totalAfterDiscount = curShop.total - curCoupon.reduceMoney
  674. useCoupon = true
  675. }
  676. } else if (curShop.total > curCoupon.fullMoney) {
  677. const priceDiscount = (curShop.total * ((10 - curCoupon.reduceMoney) / 10)).toFixed(2)
  678. const tmpTotal = curShop.total - priceDiscount
  679. if (tmpTotal.toFixed(2) >= 0.01) {
  680. curShop.totalAfterDiscount = tmpTotal.toFixed(2)
  681. useCoupon = true
  682. }
  683. }
  684. if (useCoupon) {
  685. const skuLength = curShop.skus.length
  686. for (let idx = 0; idx < skuLength; idx++) {
  687. curShop.skus[idx].buyerShopCouponId = curCoupon.shopCouponId
  688. }
  689. }
  690. }
  691. return useCoupon
  692. },
  693. // 计算总价,商家券的优惠计算,在调用本方法之前已经计算好在shops[].totalAfterDiscount
  694. getTotal() {
  695. this.totalPrice = 0
  696. this.totalCount = 0
  697. this.integralPrice = 0
  698. this.integralNum = 0
  699. let shopSumPrice = 0
  700. const shopsLen = this.settlement.shops.length
  701. for (let i = 0; i < shopsLen; i++) {
  702. this.totalPrice += parseFloat(this.settlement.shops[i].totalAfterDiscount)
  703. shopSumPrice += parseFloat(this.settlement.shops[i].totalAfterDiscount)
  704. this.totalCount += this.settlement.shops[i].number
  705. }
  706. if (this.voucherObj.voucherId) {
  707. this.totalPrice = shopSumPrice - this.settlement.voucherTotalAll
  708. } else if (this.checkedPlatformCoupon) {
  709. const couponType = this.checkedPlatformCoupon.couponType
  710. const reduceMoney = this.checkedPlatformCoupon.reduceMoney
  711. if (couponType === 1 && this.totalPrice - reduceMoney > 0) { // 满减
  712. this.totalPrice = shopSumPrice - reduceMoney
  713. } else if (couponType === 2 && reduceMoney > 0) { // 折扣
  714. const useMoney = this.checkedPlatformCoupon.useMoney
  715. this.totalPrice = (shopSumPrice - useMoney) + useMoney * reduceMoney / 10
  716. }
  717. }
  718. // 积分支付计算
  719. this.calcCredit()
  720. // 加上每个商家的运费
  721. this.settlement.shops.forEach((item) => {
  722. this.totalPrice = this.totalPrice + (item.distribution.distributionPrice || 0)
  723. })
  724. },
  725. // eslint-disable-next-line complexity
  726. calcCredit() {
  727. const shopsLen = this.settlement.shops.length
  728. const skuRemainMap = this.calcSkuRemainMap()
  729. const skuCreditMap = this.settlement.skuCreditMap
  730. if (skuCreditMap && Object.values(skuCreditMap).length && this.integralRatio > 0) {
  731. // 只有订单金额达到阈值,并且用户还有剩余的积分,才能进行积分抵扣
  732. if (this.totalPrice >= this.settlement.orderCreditThreshold && this.settlement.userTotalCredit > 0 && this.settlement.creditDeductLimit > 0) { // orderCreditThreshold: 0, // 满多少元可以抵扣
  733. for (let i = 0; i < shopsLen; i++) {
  734. const curShop = this.settlement.shops[i]
  735. const skuLen = curShop.skus.length
  736. for (let j = 0; j < skuLen; j++) {
  737. const curSku = curShop.skus[j]
  738. const skuId = curSku.skuId
  739. if (skuCreditMap[skuId] > 0 && skuRemainMap[skuId] > 0 && this.settlement.userTotalCredit > 0 && (Math.round((this.totalPrice + Number.EPSILON) * 100) / 100) > 0) {
  740. // 抵扣之后,必须保证整个订单至少还有0.01元,可用于支付
  741. if ((this.settlement.creditDeductLimit - skuRemainMap[skuId]) < 0.01) skuRemainMap[skuId] -= 0.01
  742. // 按照比例换算成需要多少积分抵扣(取整)
  743. let finalSkuCredit = parseInt((skuRemainMap[skuId] / this.integralRatio).toString())
  744. // 优先以商家配置的商品可抵扣积分为准
  745. if (skuCreditMap[skuId] < finalSkuCredit) finalSkuCredit = skuCreditMap[skuId]
  746. // 不能超过用户剩余积分
  747. if (finalSkuCredit > this.settlement.userTotalCredit) finalSkuCredit = this.settlement.userTotalCredit
  748. // 不能超过整个订单可抵扣积分
  749. if (finalSkuCredit > this.settlement.creditDeductLimit) finalSkuCredit = this.settlement.creditDeductLimit
  750. curSku.cachedCredit = finalSkuCredit
  751. this.integralNum += finalSkuCredit
  752. }
  753. }
  754. }
  755. }
  756. // 计算抵扣价格
  757. this.integralNum = parseInt(this.integralNum)
  758. if (this.integralNum) { // 有积分抵扣
  759. this.integralPrice = this.integralNum * this.integralRatio
  760. if (this.selectIntegral) {
  761. this.totalPrice = this.totalPrice - this.integralPrice
  762. }
  763. }
  764. }
  765. if (!this.integralNum && this.selectIntegral) this.selectIntegral = false // 没积分抵扣
  766. },
  767. // 计算sku在整个运单价格中的剩余价值 1元的订单,打1折优惠之后,剩余价值就是0.1元
  768. calcSkuRemainMap() {
  769. const skuRemainMap = {}
  770. const shopsLen = this.settlement.shops.length
  771. const skuCreditMap = this.settlement.skuCreditMap
  772. for (let i = 0; i < shopsLen; i++) {
  773. const curShop = this.settlement.shops[i]
  774. const skuLen = curShop.skus.length
  775. let checkedShopCoupon
  776. curShop.shopCoupons.forEach((item) => {
  777. if (item.checked) checkedShopCoupon = item
  778. })
  779. for (let j = 0; j < skuLen; j++) {
  780. const curSku = curShop.skus[j]
  781. const skuId = curSku.skuId
  782. // 不是定价捆绑,并且有配置可抵扣的积分,才有必要计算比例
  783. if (!curSku.priceId > 0 && skuCreditMap[skuId] > 0) {
  784. let remainSkuMoney = curSku.price * curSku.number
  785. if (checkedShopCoupon) {
  786. const skuShopPercent = remainSkuMoney / curShop.total
  787. let curReduceMoney = 0
  788. if (checkedShopCoupon.couponType === 1) {
  789. curReduceMoney = checkedShopCoupon.reduceMoney * skuShopPercent
  790. } else {
  791. curReduceMoney = remainSkuMoney * (10 - checkedShopCoupon.reduceMoney) / 10
  792. }
  793. remainSkuMoney = remainSkuMoney - curReduceMoney
  794. }
  795. // 使用平台券
  796. if (this.checkedPlatformCoupon && remainSkuMoney > 0) {
  797. // 满减
  798. if (this.checkedPlatformCoupon.couponType === 1) {
  799. const skuTotalPercent = remainSkuMoney / this.totalPrice
  800. remainSkuMoney -= this.checkedPlatformCoupon.reduceMoney * skuTotalPercent
  801. }
  802. // 折扣
  803. else {
  804. remainSkuMoney = remainSkuMoney * this.checkedPlatformCoupon.reduceMoney / 10
  805. }
  806. }
  807. skuRemainMap[skuId] = remainSkuMoney
  808. }
  809. }
  810. }
  811. return skuRemainMap
  812. },
  813. // 展示平台端优惠券
  814. showDiscount() {
  815. if (this.voucherObj.voucherId) return this.$showToast('已选择代金券,无法使用其它优惠')
  816. // let shopifAdd = 1
  817. // if(this.settlement.shops[this.shopIndex].shopCoupons.length>0){
  818. // shopifAdd = this.settlement.shops[this.shopIndex].shopCoupons[this.shopCouIndex].ifAdd // shopCouIndex: 0, // 优惠券index
  819. // }
  820. if (this.settlement.coupons && this.settlement.coupons.length > 0) {
  821. for (let i = 0; i < this.selectShopCoupon.length; i++) {
  822. if (this.selectShopCoupon[i].ifAdd == 0) {
  823. this.$showToast('不可叠加已选择的店铺券')
  824. return false
  825. }
  826. }
  827. this.isShowDiscount = true
  828. } else {
  829. this.$showToast('暂无可用优惠券')
  830. }
  831. },
  832. // 显示店铺优惠券
  833. showShopCoupons(item, sIndex) {
  834. if (this.voucherObj.voucherId) return this.$showToast('已选择代金券,无法使用其它优惠')
  835. if (item.shopCoupons.length > 0) {
  836. this.isShopCoupons = true
  837. this.shopCouponslist = item
  838. this.shopCouponsLength = item.shopCoupons.length
  839. this.shopIndex = sIndex
  840. } else {
  841. this.$showToast('暂无可用优惠券')
  842. }
  843. },
  844. // 选择代金券
  845. handleChooseVoucher(e) {
  846. console.log(e)
  847. if (e.id) {
  848. if (this.settlement.voucherTotalAll) {
  849. if (this.settlement.shops.some((item) => this.settlement.userVoucherDeductLimit >= item.voucherTotal)) {
  850. // 清除店铺优惠券数据
  851. for (let index = 0; index < this.settlement.shops.length; index++) {
  852. for (let i = 0; i < this.settlement.shops[index].shopCoupons.length; i++) {
  853. this.settlement.shops[index].shopCoupons[i].checked = false
  854. }
  855. this.settlement.shops[index].currentCoupon = {}
  856. this.settlement.shops[index].totalAfterDiscount = this.settlement.shops[index].total
  857. }
  858. this.selectShopCoupon = []
  859. // 清除平台优惠券数据
  860. this.settlement.coupons && this.settlement.coupons.forEach((item) => {
  861. item.checked = false
  862. })
  863. this.promotionInfoDTO = { couponId: 0, ifAdd: 1, reduceMoney: 0 }
  864. this.checkedPlatformCoupon = undefined
  865. this.settlement.shops.forEach((shopItem) => {
  866. if (shopItem.skus) {
  867. shopItem.skus.forEach((skuItem) => {
  868. skuItem.buyerCouponId = null
  869. })
  870. }
  871. })
  872. // 取消选择积分
  873. this.selectIntegral = false
  874. } else {
  875. this.$showToast('代金券数量不足!')
  876. this.$refs.refVoucherUse.handleReset()
  877. return
  878. }
  879. } else {
  880. this.$showToast('商品不支持代金券!')
  881. this.$refs.refVoucherUse.handleReset()
  882. return
  883. }
  884. }
  885. this.voucherObj.voucherTotalAll = e.id === 0 ? 0 : this.settlement.voucherTotalAll
  886. this.voucherObj.isVoucher = e.id !== 0
  887. this.voucherObj.voucherId = e.id
  888. this.getTotal()
  889. },
  890. // 组装结算数据
  891. handlePackageData() {
  892. uni.showLoading({
  893. mask: true,
  894. title: '订单提交中...'
  895. })
  896. let couponIdinfo = 0
  897. if (this.promotionInfoDTO.couponId) {
  898. couponIdinfo = this.promotionInfoDTO.couponId
  899. }
  900. const data = {
  901. shopDiscountId: null,
  902. collageId: this.collageId,
  903. type: this.sumitType, // 1发起拼团,2参与拼团,3秒杀活动,4限时折扣活动
  904. // type: this.fromType, // 1立即购买,2购物车结算,3拼团商品立即购买
  905. shopGroupWorkId: null,
  906. receiveId: this.userAddressInfo.receiveId,
  907. couponId: couponIdinfo,
  908. price: this.totalPrice,
  909. remark: '',
  910. shops: [],
  911. discountPrice: 0,
  912. shopSeckillId: null,
  913. ...this.voucherObj
  914. }
  915. if (this.shopGroupWorkId > 0) {
  916. data.shopGroupWorkId = this.shopGroupWorkId
  917. }
  918. if (this.skuItemDTOList && this.skuItemDTOList.length) {
  919. if (this.skuItemDTOList[0].shopDiscountId > 0) {
  920. data.shopDiscountId = this.skuItemDTOList[0].shopDiscountId
  921. } else if (this.skuItemDTOList[0].shopSeckillId > 0) {
  922. data.shopSeckillId = this.skuItemDTOList[0].shopSeckillId
  923. }
  924. }
  925. const datashopslen = this.settlement.shops.length
  926. for (let n = 0; n < datashopslen; n++) {
  927. const shopsobj = {}
  928. shopsobj.shopId = this.settlement.shops[n].shopId
  929. shopsobj.sceneId = this.settlement.shops[n].sceneId
  930. shopsobj.distribution = {}
  931. shopsobj.skus = []
  932. if (this.settlement.shops[n].currentCoupon) {
  933. shopsobj.id = this.settlement.shops[n].currentCoupon.id
  934. }
  935. data.shops.push(shopsobj)
  936. data.shops[n].distribution.distributionPrice = this.settlement.shops[n].distribution.distributionPrice
  937. data.shops[n].distribution.distributionName = this.settlement.shops[n].distribution.distributionName
  938. const dataskuslen = this.settlement.shops[n].skus.length
  939. for (let m = 0; m < dataskuslen; m++) {
  940. const skusobj = {}
  941. const curSku = this.settlement.shops[n].skus[m]
  942. skusobj.skuId = curSku.skuId
  943. skusobj.number = curSku.number
  944. skusobj.ifLogistics = curSku.ifLogistics
  945. skusobj.selected = curSku.selected
  946. skusobj.platformSeckillId = curSku.platformSeckillId
  947. skusobj.platformDiscountId = curSku.platformDiscountId
  948. skusobj.shopSeckillId = curSku.shopSeckillId
  949. skusobj.shopDiscountId = curSku.shopDiscountId
  950. skusobj.sceneId = curSku.sceneId
  951. skusobj.priceId = curSku.priceId
  952. skusobj.useMember = curSku.useMember
  953. skusobj.composeId = curSku.composeId
  954. // 处理埋点id
  955. this.pointProductIds += curSku.productId + ','
  956. // 积分传参
  957. if (this.selectIntegral && curSku.cachedCredit) {
  958. skusobj.useCredit = curSku.cachedCredit
  959. skusobj.useCreditAmount = (curSku.cachedCredit * this.integralRatio).toFixed(2)
  960. }
  961. data.shops[n].skus.push(skusobj)
  962. }
  963. }
  964. if (this.pointProductIds.endsWith(',')) this.pointProductIds = this.pointProductIds.slice(0, -1) // 去除最后一个,
  965. this.handleSetPayMode(data)
  966. uni.hideLoading()
  967. return data
  968. },
  969. // 根据环境设置下单的支付信息@param data handlePackageData返回值
  970. handleSetPayMode(data) {
  971. // subPaymentMode 1-小程序支付 2-app支付 3-H5支付
  972. // paymentMode 1-微信 2-支付宝
  973. data.paymentMode = this.payInfo.paymentMode
  974. // #ifdef H5
  975. data.subPaymentMode = 3
  976. // #endif
  977. // #ifdef MP-WEIXIN
  978. data.subPaymentMode = 1
  979. // #endif
  980. // #ifdef APP
  981. data.paymentMode = 1
  982. // #endif
  983. // #ifdef MP-ALIPAY
  984. data.subPaymentMode = 2
  985. // #endif
  986. },
  987. // 提交订单@return {Promise<void>}
  988. async submitOrder() {
  989. // 检查提交表单
  990. if (!this.payInfo.paymentMode) return this.$showToast('请选择支付方式')
  991. if (!this.oneClickSubmit) return this.$showToast('已提交,请勿重新操作!')
  992. if (!this.userAddressInfo.receiveId) return this.$showToast('请选择收货地址')
  993. this.oneClickSubmit = false
  994. // 处理表单
  995. const data = this.handlePackageData()
  996. uni.showLoading({
  997. mask: true,
  998. title: '结算中...'
  999. })
  1000. try {
  1001. const res = await updatePlaceOrderSubmitApi(data)
  1002. // 下单成功处理埋点
  1003. addUserTrackReportDoPointerApi({
  1004. eventType: 3,
  1005. productIds: this.pointProductIds
  1006. })
  1007. if (this.fromType == 2) {
  1008. const carSkusData = data.shops
  1009. const skusArr = []
  1010. for (let i = 0; i < carSkusData.length; i++) {
  1011. carSkusData[i].skus.map((item) => {
  1012. skusArr.push(item.skuId)
  1013. })
  1014. }
  1015. }
  1016. const submitResult = res.data
  1017. submitResult.type = 1
  1018. submitResult.paymentMode = data.paymentMode
  1019. if (this.payInfo.paymentMode && this.payInfo.huabeiPeriod) {
  1020. submitResult.huabeiPeriod = this.payInfo.huabeiPeriod
  1021. }
  1022. await handleDoPay.call(this, submitResult, 1)
  1023. } catch (e) {
  1024. this.oneClickSubmit = true
  1025. this.$showToast(`${e.message}-${e.errorData}`)
  1026. } finally {
  1027. uni.hideLoading()
  1028. }
  1029. },
  1030. // 点击分享
  1031. handleShare() {
  1032. if (this.settlement.shops && this.settlement.shops.length) {
  1033. const nickName = this.$store.getters.userInfo.name
  1034. this.$refs.refOrderPoster.show({
  1035. headerTitle: nickName ? nickName + '的订单商品' : '订单商品',
  1036. brandList: this.settlement.shops.map((brand) => ({
  1037. brandName: brand.shopName,
  1038. goodsList: brand.skus.map((item) => ({
  1039. picUrl: item.image,
  1040. goodsName: item.productName,
  1041. specifications: item.value,
  1042. price: item.price
  1043. }))
  1044. }))
  1045. })
  1046. } else {
  1047. return this.$showToast('缺少商品数据')
  1048. }
  1049. }
  1050. }
  1051. }
  1052. </script>
  1053. <style lang="less" scoped>
  1054. .order-confirm-container {
  1055. min-height: 100vh;
  1056. background-color: #F7F7F7;
  1057. box-sizing: border-box;
  1058. .info-box {
  1059. flex: 1;
  1060. font-size: 24upx;
  1061. font-weight: 400;
  1062. margin: 10rpx;
  1063. }
  1064. .content {
  1065. padding: 0 30upx 198upx;
  1066. .discount-label {
  1067. font-size: 26upx;
  1068. color: #333;
  1069. }
  1070. .discount-info-box {
  1071. display: flex;
  1072. flex-direction: row;
  1073. }
  1074. .discount-info2 {
  1075. color: #C5AA7B;
  1076. }
  1077. .address-box {
  1078. margin-top: 20upx;
  1079. background: #fff;
  1080. border-radius: 10upx;
  1081. width: 100%;
  1082. padding: 30upx;
  1083. box-sizing: border-box;
  1084. display: flex;
  1085. flex-direction: row;
  1086. align-items: center;
  1087. .address-r {
  1088. flex: 1;
  1089. display: flex;
  1090. flex-direction: column;
  1091. font-size: 28upx;
  1092. color: #333;
  1093. .address-name-box {
  1094. font-size: 30upx;
  1095. color: #333;
  1096. .phone {
  1097. font-size: 24upx;
  1098. color: #999;
  1099. margin-left: 20upx;
  1100. }
  1101. }
  1102. .address-info {
  1103. font-size: 28upx;
  1104. color: #333;
  1105. margin-top: 15upx;
  1106. }
  1107. }
  1108. }
  1109. .order-list-box {
  1110. margin-top: 20upx;
  1111. .item {
  1112. background: #fff;
  1113. border-radius: 10upx;
  1114. .order-list-top {
  1115. height: 96upx;
  1116. padding: 0 30upx;
  1117. box-sizing: border-box;
  1118. display: flex;
  1119. flex-direction: row;
  1120. align-items: center;
  1121. justify-content: space-between;
  1122. border-bottom: 2rpx solid #eee;
  1123. .top-l {
  1124. display: flex;
  1125. flex-direction: row;
  1126. align-items: center;
  1127. .shop-name {
  1128. font-size: 30upx;
  1129. color: #333;
  1130. font-weight: bold;
  1131. }
  1132. }
  1133. }
  1134. .order-info-box {
  1135. padding: 0 30upx;
  1136. box-sizing: border-box;
  1137. .order-info-item {
  1138. display: flex;
  1139. flex-direction: row;
  1140. padding: 20upx 0;
  1141. .product-img {
  1142. width: 180upx;
  1143. height: 180upx;
  1144. border-radius: 10upx;
  1145. margin-right: 30upx;
  1146. }
  1147. .info-box {
  1148. .product-name {
  1149. font-size: 26upx;
  1150. color: #333;
  1151. height: 68upx;
  1152. line-height: 34upx;
  1153. display: -webkit-box;
  1154. overflow: hidden;
  1155. text-overflow: ellipsis;
  1156. word-break: break-all;
  1157. -webkit-box-orient: vertical;
  1158. -webkit-line-clamp: 2;
  1159. }
  1160. .product-sku {
  1161. font-size: 24upx;
  1162. font-weight: 500;
  1163. color: #999;
  1164. margin-left: -20upx;
  1165. width: 100%;
  1166. display: flex;
  1167. flex-direction: row;
  1168. }
  1169. .price-sku-box {
  1170. width: 100%;
  1171. display: flex;
  1172. flex-direction: row;
  1173. justify-content: space-between;
  1174. .product-price {
  1175. font-size: 32upx;
  1176. color: #C83732;
  1177. font-weight: 400;
  1178. .fuhao {
  1179. font-size: 28upx;
  1180. }
  1181. }
  1182. .product-num {
  1183. font-size: 28upx;
  1184. color: #999;
  1185. font-weight: 400;
  1186. }
  1187. }
  1188. }
  1189. }
  1190. .adressTips {
  1191. margin-bottom: 19rpx;
  1192. color: #D53912;
  1193. }
  1194. .delivery-way-box {
  1195. display: flex;
  1196. flex-direction: column;
  1197. border: 2rpx solid #E4E5E6;
  1198. padding: 20rpx;
  1199. margin-bottom: 20rpx;
  1200. box-sizing: content-box;
  1201. .item {
  1202. display: flex;
  1203. flex-direction: row;
  1204. align-items: center;
  1205. justify-content: space-between;
  1206. font-size: 26upx;
  1207. color: #333;
  1208. }
  1209. }
  1210. .discount-item1 {
  1211. width: 100%;
  1212. box-sizing: border-box;
  1213. display: flex;
  1214. flex-direction: row;
  1215. align-items: center;
  1216. justify-content: space-between;
  1217. background: white;
  1218. padding: 20rpx;
  1219. border: 2rpx solid #E4E5E6;
  1220. }
  1221. .order-total-box {
  1222. padding: 20upx 0;
  1223. text-align: right;
  1224. .total-num {
  1225. font-size: 26upx;
  1226. color: #333;
  1227. }
  1228. .total-price {
  1229. font-size: 46rpx;
  1230. color: #333333;
  1231. }
  1232. .ml10 {
  1233. margin-left: 10upx;
  1234. }
  1235. }
  1236. }
  1237. }
  1238. }
  1239. .discount-item {
  1240. width: 100%;
  1241. height: 98upx;
  1242. box-sizing: border-box;
  1243. margin: 20upx 0 0;
  1244. display: flex;
  1245. flex-direction: row;
  1246. align-items: center;
  1247. justify-content: space-between;
  1248. padding: 0 20upx;
  1249. background: white;
  1250. }
  1251. .integralPayBox {
  1252. margin: 20rpx 0 0;
  1253. .integralBg {
  1254. height: 98rpx;
  1255. display: flex;
  1256. justify-content: space-between;
  1257. align-items: center;
  1258. background: #FFFFFF;
  1259. padding: 0 20rpx;
  1260. .maxIntegral /deep/ .uni-checkbox-input {
  1261. width: 30rpx;
  1262. height: 30rpx;
  1263. }
  1264. .maxIntegral /deep/ .uni-checkbox-input-checked:before {
  1265. font-size: 30rpx;
  1266. }
  1267. .maxIntegral /deep/ .uni-checkbox-input-checked {
  1268. border: 2rpx solid #C5AA7B !important;
  1269. }
  1270. }
  1271. }
  1272. .order-flow-box {
  1273. margin-top: 20upx;
  1274. display: flex;
  1275. flex-direction: column;
  1276. .flow-word {
  1277. font-size: 24upx;
  1278. color: #999;
  1279. display: flex;
  1280. flex-direction: column;
  1281. }
  1282. .mt25 {
  1283. margin-top: 20upx;
  1284. }
  1285. .mt50 {
  1286. margin-top: 30upx;
  1287. margin-bottom: 20upx;
  1288. }
  1289. }
  1290. }
  1291. .order-confirm-box {
  1292. width: 100%;
  1293. position: fixed;
  1294. bottom: 0;
  1295. left: 0;
  1296. width: 100%;
  1297. background: #fff;
  1298. padding: 30upx;
  1299. box-sizing: border-box;
  1300. .num-box {
  1301. font-size: 30upx;
  1302. color: #999;
  1303. }
  1304. .total {
  1305. color: #333;
  1306. }
  1307. .price {
  1308. color: #ff7911;
  1309. font-weight: bold;
  1310. }
  1311. .btn {
  1312. width: 100%;
  1313. height: 80rpx;
  1314. line-height: 80rpx;
  1315. background: #eee;
  1316. font-size: 28rpx;
  1317. color: #FFEBC4;
  1318. text-align: center;
  1319. margin-top: 20rpx;
  1320. }
  1321. .btn.active {
  1322. background: #333333;
  1323. color: #FFEBC4;
  1324. }
  1325. .btn.unActive {
  1326. background: #333333;
  1327. color: #FFEBC4;
  1328. opacity: 0.7;
  1329. }
  1330. }
  1331. .activity-con {
  1332. .activity-box {
  1333. display: flex;
  1334. flex-direction: column;
  1335. width: 100%;
  1336. height: 1000upx;
  1337. .title-box {
  1338. width: 100%;
  1339. height: 100upx;
  1340. display: flex;
  1341. flex-direction: row;
  1342. align-items: center;
  1343. justify-content: center;
  1344. position: relative;
  1345. border-bottom: solid 1px #EEEEEE;
  1346. }
  1347. .activity-coupon-box {
  1348. display: flex;
  1349. flex-direction: column;
  1350. width: 100%;
  1351. overflow: auto;
  1352. flex: 1;
  1353. .content-box {
  1354. width: 100%;
  1355. box-sizing: border-box;
  1356. display: flex;
  1357. flex-direction: column;
  1358. padding: 30upx;
  1359. .label-lingqu {
  1360. width: 100%;
  1361. font-size: 28upx;
  1362. font-weight: 500;
  1363. color: rgba(51, 51, 51, 1);
  1364. }
  1365. .couponBox {
  1366. display: flex;
  1367. flex-flow: wrap;
  1368. margin-top: 30rpx;
  1369. justify-content: space-between;
  1370. .coupon-item {
  1371. width: 48%;
  1372. height: 291rpx;
  1373. background: url("../../../static/images/new-business/shop/couponsIcon.png") no-repeat center top;
  1374. margin-top: 20upx;
  1375. color: #C5AA7B;
  1376. flex-shrink: 0;
  1377. text-align: center;
  1378. padding-top: 1rpx;
  1379. background-size: contain;
  1380. .money-box {
  1381. font-size: 40upx;
  1382. font-weight: 500;
  1383. margin-top: 30rpx;
  1384. }
  1385. }
  1386. }
  1387. }
  1388. }
  1389. }
  1390. }
  1391. }
  1392. </style>