create-order.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904
  1. <template>
  2. <view class="container order clearfix" :style="{ paddingBottom: isIphoneX ? '250rpx' : '214rpx' }">
  3. <!-- 地址选择 -->
  4. <cm-address-temp ref="choiceAddress" v-if="isRequest" :addressData="addressData" />
  5. <!-- 商品 -->
  6. <cm-goods-temp
  7. ref="goods"
  8. v-if="isRequest"
  9. :goodsData.sync="goodsData"
  10. @handleGoodList="handChangeInputGoodsList"
  11. @changeChina="handleChangeChina"
  12. @changePostage="handleChangePostage"
  13. />
  14. <!-- 发票信息 -->
  15. <cm-invice-popup
  16. ref="invoice"
  17. v-if="isRequest"
  18. :invoiceDatas="invoiceData"
  19. @handleChoiceaInvoice="handleChoiceaInvoiceData"
  20. />
  21. <!-- 优惠券选择弹窗 -->
  22. <cm-coupon-popup
  23. ref="coupon"
  24. v-if="isCouponShow"
  25. :couponList="couponList"
  26. @handleChoiceaCoupon="handleChoiceaCouponData"
  27. />
  28. <!-- 兑换优惠券弹窗 -->
  29. <cm-coupon-chang v-if="isExchangePopup" />
  30. <!-- 优惠券 -->
  31. <cm-coupon-tips ref="coupon-tips" :coupon="ExchangeCouponData" v-if="isCouponModel" />
  32. <!-- 余额抵扣 -->
  33. <view class="invoice-balance" v-show="isRequest && !rechargeGoods">
  34. <view class="balabce-t">
  35. <view class="balabce-t-le">余额抵扣:</view>
  36. <view class="balabce-t-ri">
  37. <view class="money">
  38. <text>可用余额:</text> <text>¥{{ userMoney | NumFormat }}</text>
  39. </view>
  40. <view class="checkbox-box">
  41. <button
  42. class="checkbox iconfont"
  43. hover-class="btn-hover"
  44. v-if="userMoney != 0"
  45. @click.stop="checkedBalabce"
  46. :class="[ischecked ? 'icon-yixuanze' : 'icon-weixuanze']"
  47. ></button>
  48. </view>
  49. </view>
  50. </view>
  51. <view class="balabce-b" :class="{ 'balabce-b--hide': !ischecked }">
  52. <view
  53. class="balabce-b-text animation"
  54. :style="{
  55. transform: ischecked ? 'translateY(0)' : 'translateY(-50%)',
  56. '-webkit-transform': ischecked ? 'translateY(0)' : 'translateY(-50%)'
  57. }"
  58. >
  59. <text>当前使用:¥{{ deductMoney | NumFormat }},剩余:¥{{ surplusMoney | NumFormat }}</text>
  60. </view>
  61. </view>
  62. </view>
  63. <!-- 底部 -->
  64. <view class="footer-wrapper" :style="{ paddingBottom: isIphoneX ? '68rpx' : '0rpx' }">
  65. <cm-return-popup v-if="returnGoodsStutas" :content="helpContent" @change="onAgreementChange" />
  66. <view class="footer">
  67. <view class="footer-le">
  68. <view class="footer-count">
  69. <text>共{{ totalCount }}件商品</text>
  70. </view>
  71. <view class="footer-price">
  72. <view class="sum" :class="totalDiscountAmount == 0 ? 'none' : ''">
  73. 总价:<text class="price">¥{{ orderShouldPayFee | NumFormat }}</text>
  74. </view>
  75. <view class="sum-none" v-if="totalDiscountAmount > 0">
  76. <text class="money-reduced"
  77. >共减<text>¥{{ totalDiscountAmount | NumFormat }}</text></text
  78. >
  79. </view>
  80. </view>
  81. </view>
  82. <view class="footer-submit" @click.stop="orderSubmitMit">
  83. <view class="btn" :class="isSubLoading ? 'disabled' : ''">提交订单</view>
  84. </view>
  85. </view>
  86. </view>
  87. <!-- 提示弹窗 -->
  88. <tui-modal
  89. :show="showModal"
  90. @click="handleClick"
  91. @cancel="hideMobel"
  92. :content="contentModalText"
  93. :button="modalButton"
  94. color="#333"
  95. :size="28"
  96. shape="circle"
  97. :maskClosable="false"
  98. />
  99. <tui-modal
  100. :show="agreementModel"
  101. title="提示"
  102. content="请先阅读《特殊商品退货须知》并勾选后再提交订单~"
  103. shape="circle"
  104. color="#333"
  105. :size="28"
  106. :button="agreementModelButtons"
  107. @click="agreementModel = false"
  108. />
  109. </view>
  110. </template>
  111. <script>
  112. import { mapState, mapMutations } from 'vuex'
  113. import cmAddressTemp from './components/cm-address-temp'
  114. import cmGoodsTemp from './components/cm-goods-temp'
  115. import cmInvicePopup from './components/cm-invice-popup'
  116. import cmCouponPopup from './components/cm-coupon-popup'
  117. import cmCouponChang from './components/cm-coupon-chang'
  118. import cmReturnPopup from './components/cm-return-popup'
  119. import cmCouponTips from './components/cm-coupon-tips'
  120. import conMixins from './mixins/conMixins.js'
  121. export default {
  122. mixins: [conMixins],
  123. components: {
  124. cmAddressTemp,
  125. cmGoodsTemp,
  126. cmInvicePopup,
  127. cmCouponPopup,
  128. cmCouponChang,
  129. cmReturnPopup,
  130. cmCouponTips
  131. },
  132. data() {
  133. return {
  134. isIphoneX: this.$store.state.isIphoneX,
  135. isSubLoading: false,
  136. confirmType: 1,
  137. confirmParam: {
  138. cartType: 1, // 购买类型:(1自主下单, 3协销下单)
  139. orderMiniType: 0, // 订单提交状态 0初始提交 1 继续提交
  140. orderSource: 6, // 订单来源 1WWW 6小程序[采美,星范]
  141. addressId: 0, // 收货地址Id
  142. clubCouponId: 0, // 关联优惠券Id
  143. clubId: 0, // 机构Id
  144. orderInfo: [], // 订单商品数据
  145. orderInvoice: { type: 0 }, // 订单发票信息
  146. payInfo: {
  147. // 订单金额数据
  148. orderShouldPayFee: 0, // 订单最终支付金额
  149. balancePayFlag: 0, // 勾选余额的状态(1使用,0不使用)
  150. clauseId: 0, // 条款Id
  151. postage: '0.00', // 运费金额
  152. postageFlag: 0, // 运费类型
  153. userBeans: 0, // 抵扣采美豆数量
  154. rebateFlag: 0 // 是否返佣订单
  155. },
  156. unionId: uni.getStorageSync('unionId') // 用户unionId
  157. }, // 提交订单参数
  158. productIds: '', // 获取上一级页面商品信息
  159. submitState: '', // 提交状态
  160. isRequest: false, // 是否加载完成渲染子组件
  161. isFreight: false, // 是否加载完成渲染子组件
  162. isExchangePopup: false, // 控制兑换优惠券弹窗
  163. ischecked: false, // 是否勾选余额
  164. addressData: {}, // 初始化地址信息
  165. goodsData: [], // 初始化商品信息
  166. couponList: [], // 初始化优惠券信息
  167. invoiceData: { type: 0 }, // 初始化发票信息
  168. freightData: {}, // 邮费数据
  169. orderInfo: [], // 提交的商品信息
  170. rechargeGoods: null, // 判断订单里有定金商品或者充值商品时,余额抵扣部分不显示
  171. freightBeansMoney: 0, // 存储采美豆抵扣金额
  172. isCouponShow: false, // 是否显示可选优惠券
  173. isCheckedBeans: false, // 是否抵扣采美豆
  174. isCouponModel: false, // 兑换优惠券成功提示
  175. ExchangeCouponData: {}, // 兑换优惠券信息
  176. contentModalText: '采购金额过小,将扣除500采美豆,建议您前往采美旗下“颜选美学”小程序购买小额商品。', //操作文字提示语句
  177. modalButton: [
  178. {
  179. text: '前往颜选美学',
  180. type: 'gray',
  181. plain: true //是否空心
  182. },
  183. {
  184. text: '继续提交',
  185. customStyle: {
  186. color: '#fff',
  187. bgColor: 'linear-gradient(90deg, #F28F31 0%, #FF5B00 100%)'
  188. },
  189. plain: false
  190. }
  191. ],
  192. showModal: false,
  193. showModalstauts: 0,
  194. returnGoodsStutas: false,
  195. helpContent: '',
  196. agreementActive: false,
  197. agreementModel: false,
  198. agreementModelButtons: [
  199. {
  200. text: '确定',
  201. customStyle: {
  202. color: '#fff',
  203. bgColor: 'linear-gradient(90deg, #F28F31 0%, #FF5B00 100%)'
  204. },
  205. plain: false
  206. }
  207. ]
  208. }
  209. },
  210. onLoad(option) {
  211. //商品数据
  212. this.initStorage(option)
  213. },
  214. filters: {
  215. NumFormat(value) {
  216. //处理金额
  217. return Number(value).toFixed(2)
  218. }
  219. },
  220. methods: {
  221. onAgreementChange(val) {
  222. this.agreementActive = val
  223. },
  224. async initStorage(option) {
  225. const data = JSON.parse(option.data)
  226. const userInfo = await this.$api.getStorage()
  227. this.handleComType = option.type * 1
  228. this.productParam.userId = this.cartParam.userId = userInfo.userId
  229. this.supportParm.userId = userInfo.userId
  230. this.confirmParam.clubId = userInfo.clubId
  231. switch (option.type) {
  232. case '1': // 商品详情立即购买
  233. this.confirmParam.cartType = 2
  234. this.productParam.productCount = data.data.productCount
  235. this.productParam.productId = data.data.productIds
  236. this.productParam.skuId = data.data.skuId
  237. this.productIds = data.data.productIds
  238. this.getAddressData(userInfo.userId, 1)
  239. break
  240. case '2': // 购物车结算
  241. this.confirmParam.cartType = 1
  242. this.confirmType = 2
  243. this.cartParam.skuIds = data.data.skuIds
  244. this.getAddressData(userInfo.userId, 2)
  245. break
  246. case '3': // 组合商品立即购买
  247. this.confirmParam.cartType = 2
  248. this.confirmType = 2
  249. this.supportParm.productInfo = JSON.stringify(data.data)
  250. this.getAddressData(userInfo.userId, 3)
  251. }
  252. },
  253. async getAddressData(userId, type) {
  254. //获取地址信息
  255. try {
  256. const params = { pageNum: 1, pageSize: 1, userId: userId }
  257. const res = await this.UserService.QueryAddressList(params)
  258. const data = res.data
  259. if (data.list && data.list.length > 0) {
  260. this.addressData = data.list[0]
  261. this.confirmParam.addressId = this.addressData.addressId
  262. this.cartParam.cityId = this.addressData.cityId
  263. this.productParam.cityId = this.addressData.cityId
  264. this.supportParm.cityId = this.addressData.cityId
  265. }
  266. if (type === 1) {
  267. //立即都买提交
  268. this.GetProductCreateOrderInfo()
  269. }
  270. if (type === 2) {
  271. //购物车提交
  272. this.CartCreateOrderInfo()
  273. }
  274. if (type === 3) {
  275. //组合商品提交
  276. this.GetOrderClubProductSupporting()
  277. }
  278. } catch (error) {
  279. console.log('获取订单地址异常')
  280. }
  281. },
  282. // 商品立即购买确认订单数据初始化
  283. async GetProductCreateOrderInfo() {
  284. try {
  285. const res = await this.OrderService.ProductCreateOrderInfo(this.productParam)
  286. this.setCreatDataInfo(res.data)
  287. } catch (error) {
  288. this.$util.msg(error.msg, 2000)
  289. }
  290. },
  291. // 组合商品立即购买确认订单数据初始化
  292. async GetOrderClubProductSupporting() {
  293. try {
  294. const res = await this.OrderService.OrderClubProductSupporting(this.supportParm)
  295. this.setCreatDataInfo(res.data)
  296. } catch (error) {
  297. this.$util.msg(error.msg, 2000)
  298. }
  299. },
  300. // 购物车去结算确认订单数据初始化
  301. async CartCreateOrderInfo() {
  302. try {
  303. const res = await this.OrderService.CartCreateOrderInfo(this.cartParam)
  304. this.setCreatDataInfo(res.data)
  305. } catch (error) {
  306. this.$util.msg(error.msg, 2000)
  307. }
  308. },
  309. // 公共初始化数据
  310. setCreatDataInfo(data) {
  311. this.isRequest = true
  312. this.goodsData = data.list.map(el => {
  313. el.handlePostageFlag = el.postageFlag
  314. return el
  315. })
  316. this.couponList = data.couponList
  317. this.userMoney = data.userMoney
  318. this.reducedPrice = data.reducedPrice
  319. this.totalCount = data.totalCount
  320. this.allPrice = data.totalPrice
  321. this.rechargeGoods = data.rechargeGoods
  322. if (this.couponList.length > 0) {
  323. this.isCouponShow = true
  324. this.couponAmount = data.couponList[0].couponAmount
  325. this.confirmParam.clubCouponId = data.couponList[0].clubCouponId
  326. }
  327. this.orderShouldPayFee = this.allPrice - this.couponAmount
  328. // 特殊商品退货须知
  329. this.returnGoodsStutas = data.returnGoodsStutas && data.returnGoodsStutas === 2 // 1:可以 2:不可以
  330. this.helpContent = data.helpContent
  331. },
  332. async getFreightData() {
  333. // 获取邮费信息
  334. try {
  335. this.isFreight = false
  336. const res = await this.OrderService.GetOrderPostage(this.postageParam)
  337. const data = res.data
  338. this.isFreight = true
  339. this.isCheckedBeans = false
  340. this.freightData = data
  341. this.hanldFreePostFlag = data.postageFlag
  342. this.hanldFreight = data.postage
  343. if (this.hanldFreePostFlag == 1) {
  344. if (this.freightData.userBeans > 0) {
  345. this.freightBeansMoney = this.hanldFreight
  346. } else {
  347. this.freightBeansMoney = 0
  348. }
  349. this.orderShouldPayFee = this.allPrice + data.postage
  350. this.attributePallPrice()
  351. this.hanldFreightBeans(this.isCheckedBeans)
  352. } else {
  353. if (this.freightData.userBeans > 0) {
  354. this.freightBeansMoney = 30
  355. } else {
  356. this.freightBeansMoney = 0
  357. }
  358. this.orderShouldPayFee = this.allPrice
  359. this.attributePallPrice()
  360. this.hanldFreightBeans(this.isCheckedBeans)
  361. }
  362. } catch (error) {
  363. console.log('获取订单运费异常')
  364. }
  365. },
  366. handChangeInputGoodsList(data) {
  367. //对应供应商的留言信息
  368. this.goodsData = data
  369. },
  370. handleChoiceaInvoiceData(data) {
  371. //获取发票信息
  372. this.confirmParam.orderInvoice = data
  373. },
  374. hanldFreightBeans(data) {
  375. //是否勾选采美豆抵扣
  376. this.isCheckedBeans = data
  377. console.log(this.confirmParam.payInfo)
  378. if (this.isCheckedBeans) {
  379. // 判断如果采美豆大于等于运费*100
  380. if (this.freightData.userBeans > 0) {
  381. this.confirmParam.payInfo.userBeans = this.freightBeansMoney * 100
  382. } else {
  383. this.confirmParam.payInfo.userBeans = 0
  384. }
  385. // 计算抵扣后的总价
  386. if (this.hanldFreePostFlag == 1) {
  387. // 如果使用了余额 最终价格
  388. if (this.ischecked) {
  389. let totalAmount = this.allPrice - this.couponAmount
  390. if (this.userMoney >= totalAmount) {
  391. this.orderShouldPayFee = 0.0
  392. this.deductMoney = this.allPrice - this.couponAmount // 当前使用金额等于订单金额
  393. this.surplusMoney = this.userMoney - this.deductMoney // 剩余金额等于余额-当前使用金额
  394. } else {
  395. this.orderShouldPayFee = this.allPrice - this.userMoney - this.couponAmount // 订单最终支付金额等于订单金额-账户余额
  396. this.deductMoney = this.userMoney // 当前使用金额等于总余额
  397. this.surplusMoney = this.userMoney - this.deductMoney // 剩余余额等于总余额-当前使用金额
  398. }
  399. } else {
  400. this.orderShouldPayFee =
  401. this.allPrice + this.hanldFreight - this.freightBeansMoney - this.couponAmount
  402. }
  403. console.log('抵扣', this.orderShouldPayFee)
  404. }
  405. } else {
  406. // 采美豆不抵扣运费
  407. this.confirmParam.payInfo.userBeans = 0
  408. // 不抵扣时计算总价
  409. if (this.hanldFreePostFlag == 1) {
  410. this.attributeHashfreight(this.hanldFreight)
  411. }
  412. }
  413. },
  414. handleChoiceaCouponData(data) {
  415. // 勾选使用优惠券
  416. console.log('优惠券信息', data)
  417. this.couponAmount = data.couponAmount
  418. this.confirmParam.clubCouponId = data.clubCouponId
  419. this.attributePallPrice()
  420. // this.hanldFreightBeans(this.isCheckedBeans)
  421. },
  422. attributeHashfreight() {
  423. // 计算需要邮费的支付价格
  424. let totalAmount = this.allPrice - this.couponAmount //计算不包邮的价格 总价等于商品价格+邮费
  425. if (this.ischecked) {
  426. if (this.userMoney >= totalAmount) {
  427. // 全部抵扣
  428. this.orderShouldPayFee = 0.0
  429. if (this.isCheckedBeans) {
  430. // 抵扣运费了
  431. this.deductMoney = this.allPrice - this.couponAmount // 当前使用金额等于订单金额
  432. this.surplusMoney = this.userMoney - this.deductMoney // 剩余金额等于余额减去当前使用金额
  433. } else {
  434. this.deductMoney = this.allPrice - this.couponAmount // 当前使用金额等于订单金额+运费金额
  435. this.surplusMoney = this.userMoney - this.deductMoney // 剩余余额等于总余额-当前使用金额
  436. }
  437. } else {
  438. // 部分抵扣
  439. if (this.isCheckedBeans) {
  440. // 抵扣运费了
  441. this.orderShouldPayFee = this.allPrice - this.userMoney - this.couponAmount // 订单最终支付金额等于总订单金额-账户余额-优惠券金额
  442. this.deductMoney = this.userMoney // 当前使用金额等于账户余额
  443. this.surplusMoney = this.userMoney - this.deductMoney // 剩余余额等于账户余额-当前使用金额
  444. } else {
  445. this.orderShouldPayFee = this.allPrice - this.userMoney - this.couponAmount //订单支付金额等于订单金额+运费-账户余额-优惠券
  446. this.deductMoney = this.userMoney // 当前使用金额等于账户余额
  447. this.surplusMoney = this.userMoney - this.deductMoney // 剩余余额等于账户余额-当前使用金额
  448. }
  449. }
  450. } else {
  451. this.orderShouldPayFee = this.allPrice - this.couponAmount
  452. this.deductMoney = 0.0 // 当前使用金额
  453. this.surplusMoney = this.userMoney // 剩余余额
  454. }
  455. console.log('最终订单支付金额', this.orderShouldPayFee)
  456. console.log('优惠券金额', this.couponAmount)
  457. },
  458. orderSubmitMit() {
  459. // 提交订单按钮点击事件
  460. if (this.returnGoodsStutas && !this.agreementActive) {
  461. this.agreementModel = true
  462. } else {
  463. this.handleClickOrderSubmitMit()
  464. }
  465. },
  466. handleClickOrderSubmitMit() {
  467. // 提交订单
  468. if (this.isSubLoading) {
  469. return
  470. }
  471. if (this.confirmParam.addressId == '') {
  472. this.$util.msg('请先添加收货地址~', 2000)
  473. return
  474. }
  475. this.confirmParam.orderInfo = this.hanldeProcessing()
  476. this.confirmParam.payInfo.orderShouldPayFee = this.orderShouldPayFee.toFixed(2)
  477. this.confirmParam.payInfo = JSON.stringify(this.confirmParam.payInfo)
  478. this.confirmParam.orderInfo = JSON.stringify(this.confirmParam.orderInfo)
  479. this.confirmParam.orderInvoice = JSON.stringify(this.confirmParam.orderInvoice)
  480. console.log(this.confirmParam)
  481. this.isSubLoading = true
  482. this.hanldeOrderSubmit(this.confirmParam)
  483. },
  484. // 处理数据格式
  485. hanldeProcessing() {
  486. return this.goodsData.map(el => {
  487. let productInfo = []
  488. el.cartList.forEach(pros => {
  489. productInfo.push({
  490. skuId: pros.skuId,
  491. productNum: pros.number,
  492. presentNum: 0,
  493. productType: pros.giftType
  494. })
  495. })
  496. return {
  497. splitCode: el.splitCode,
  498. shopId: el.shopId,
  499. note: el.note ? el.note : '',
  500. postage: el.isColdChina
  501. ? parseInt(el.postage + el.coldChain).toFixed(2)
  502. : parseInt(el.postage).toFixed(2),
  503. postageFlag: parseInt(el.handlePostageFlag),
  504. isColdChina: el.isColdChina ? 1 : 0,
  505. productInfo: productInfo
  506. }
  507. })
  508. },
  509. // 提交订单
  510. async hanldeOrderSubmit(params) {
  511. try {
  512. const res = await this.OrderService.CreatedOrderSubmit(params)
  513. const data = res.data
  514. // 友盟埋点收集机构自主提交订单
  515. if (process.env.NODE_ENV != 'development') {
  516. this.$uma.trackEvent('Um_Event_ConfirmOrder', {
  517. Um_Key_PageName: '机构提交订单',
  518. Um_Key_SourcePage: '确认订单',
  519. Um_Key_OrderID: `${data.orderId}`
  520. })
  521. }
  522. if (data.code === 1) {
  523. this.submitState = 'success'
  524. setTimeout(() => {
  525. this.isSubLoading = false
  526. }, 2000)
  527. this.$api.redirectTo(
  528. `/pages/user/order/success?data=${JSON.stringify({ data: { orderId: data.orderId } })}`
  529. )
  530. } else {
  531. this.submitState = 'confirm'
  532. this.$util.msg('订单提交成功', 2000, true, 'success')
  533. setTimeout(() => {
  534. this.isSubLoading = false
  535. this.$api.redirectTo(`/pages/user/order/order-pay-list?orderId=${data.orderId}`)
  536. }, 2000)
  537. }
  538. } catch (error) {
  539. this.isSubLoading = false
  540. this.handleError(error)
  541. }
  542. },
  543. handleError(data) {
  544. // 提交订单异常处理
  545. const buttonMap = {
  546. 1: {
  547. contentModalText:
  548. '您已有2个采购金额过小的订单,本次不能再进行采购。建议您前往采美旗下“颜选美学”小程序购买小额商品。',
  549. modalButton: [
  550. { text: '了解', type: 'gray', plain: true },
  551. {
  552. text: '前往颜选美学',
  553. customStyle: { color: '#fff', bgColor: 'linear-gradient(90deg, #F28F31 0%, #FF5B00 100%)' },
  554. plain: false
  555. }
  556. ]
  557. },
  558. 2: {
  559. contentModalText: '采美豆不足,不能提交订单。建议您前往采美旗下“颜选美学”小程序购买小额商品。',
  560. modalButton: [
  561. { text: '了解', type: 'gray', plain: true },
  562. {
  563. text: '前往颜选美学',
  564. customStyle: { color: '#fff', bgColor: 'linear-gradient(90deg, #F28F31 0%, #FF5B00 100%)' },
  565. plain: false
  566. }
  567. ]
  568. },
  569. 3: {
  570. contentModalText: '采购金额过小,将扣除500采美豆,建议您前往采美旗下“颜选美学”小程序购买小额商品。',
  571. modalButton: [
  572. { text: '前往颜选美学', type: 'gray', plain: true },
  573. {
  574. text: '继续提交',
  575. customStyle: { color: '#fff', bgColor: 'linear-gradient(90deg, #F28F31 0%, #FF5B00 100%)' },
  576. plain: false
  577. }
  578. ]
  579. },
  580. 4: {
  581. contentModalText:
  582. '订单内存在械字号三类商品,需要拥有医疗执业许可证的医美机构才能购买。建议升级医美机构后再下单,否则会导致订单退款或影响发货。',
  583. modalButton: [
  584. { text: '继续提交', type: 'gray', plain: true },
  585. {
  586. text: '去升级',
  587. customStyle: { color: '#fff', bgColor: 'linear-gradient(90deg, #F28F31 0%, #FF5B00 100%)' },
  588. plain: false
  589. }
  590. ]
  591. }
  592. }
  593. if (data.code === -3) {
  594. // 已提交2个小于1000元的订单提示
  595. this.showModal = true
  596. this.showModalstauts = 3
  597. this.contentModalText = buttonMap[1].contentModalText
  598. this.modalButton = buttonMap[1].modalButton
  599. this.formatConfirmParam()
  600. } else if (data.code === -4) {
  601. // 采美豆为负数
  602. this.showModal = true
  603. this.showModalstauts = 3
  604. this.contentModalText = buttonMap[2].contentModalText
  605. this.modalButton = buttonMap[2].modalButton
  606. this.formatConfirmParam()
  607. } else if (data.code === -5) {
  608. // 订单总金额低于500
  609. this.showModal = true
  610. this.showModalstauts = 1
  611. this.contentModalText = buttonMap[3].contentModalText
  612. this.modalButton = buttonMap[3].modalButton
  613. this.formatConfirmParam()
  614. } else if (data.code === -6) {
  615. // 非医美机构下三类商品订单
  616. this.showModal = true
  617. this.showModalstauts = 2
  618. this.contentModalText = buttonMap[4].contentModalText
  619. this.modalButton = buttonMap[4].modalButton
  620. this.formatConfirmParam()
  621. } else {
  622. this.$util.msg(data.msg, 3000)
  623. }
  624. },
  625. formatConfirmParam() {
  626. // 还原提交订单参数格式
  627. this.confirmParam.payInfo = JSON.parse(this.confirmParam.payInfo)
  628. this.confirmParam.orderInfo = JSON.parse(this.confirmParam.orderInfo)
  629. this.confirmParam.orderInvoice = JSON.parse(this.confirmParam.orderInvoice)
  630. },
  631. handleClickCancel() {
  632. // 关闭优惠券弹窗
  633. this.isCouponModel = false
  634. if (this.confirmType == 1) {
  635. this.GetProductCreateOrderInfo()
  636. } else {
  637. this.CartCreateOrderInfo()
  638. }
  639. },
  640. handleClick(e) {
  641. // 采购量过小提示弹窗
  642. if (e.index === 1) {
  643. if (this.showModalstauts === 1) {
  644. this.showModal = false
  645. this.confirmParam.orderMiniType = 1
  646. this.handleClickOrderSubmitMit()
  647. } else if (this.showModalstauts === 2) {
  648. this.showModal = false
  649. this.isSubLoading = false
  650. this.$api.navigateTo('/pages/login/apply')
  651. } else {
  652. this.showModal = false
  653. this.handleClickHeHeMiniApplet()
  654. }
  655. } else {
  656. if (this.showModalstauts == 1) {
  657. this.showModal = false
  658. this.handleClickHeHeMiniApplet()
  659. } else if (this.showModalstauts === 2) {
  660. this.showModal = false
  661. this.confirmParam.orderMiniType = 2
  662. this.handleClickOrderSubmitMit()
  663. } else {
  664. this.showModal = false
  665. }
  666. }
  667. },
  668. handleClickHeHeMiniApplet() {
  669. // 跳转颜选美学小程序
  670. uni.navigateToMiniProgram({
  671. appId: 'wx2c3b0a7f343235b1',
  672. path: '/pages/tabBar/index/index',
  673. extraData: {
  674. data1: 'test'
  675. },
  676. envVersion: 'develop',
  677. success(res) {
  678. // 打开成功
  679. console.log(res)
  680. }
  681. })
  682. }
  683. },
  684. onShow() {
  685. let pages = getCurrentPages()
  686. let currPage = pages[pages.length - 1]
  687. if (currPage.data.select == 'select') {
  688. let address = uni.getStorageSync('selectAddress')
  689. this.confirmParam.addressId = address.addressId
  690. this.cartParam.cityId = address.cityId
  691. this.productParam.cityId = address.cityId
  692. this.supportParm.cityId = address.cityId
  693. this.addressData = address
  694. this.ischecked = false
  695. this.isRequest = false
  696. if (this.handleComType === 1) {
  697. //立即都买提交
  698. this.GetProductCreateOrderInfo()
  699. }
  700. if (this.handleComType === 2) {
  701. //购物车提交
  702. this.CartCreateOrderInfo()
  703. }
  704. if (this.handleComType === 3) {
  705. //组合商品提交
  706. this.GetOrderClubProductSupporting()
  707. }
  708. }
  709. }
  710. }
  711. </script>
  712. <style lang="scss">
  713. page {
  714. height: auto;
  715. background: #f7f7f7;
  716. }
  717. .btn-hover {
  718. background: #ffffff;
  719. }
  720. .animation {
  721. /* transition: transform 0.3s ease;*/
  722. transition-property: transform;
  723. transition-duration: 0.3s;
  724. transition-timing-function: ease;
  725. }
  726. .order {
  727. padding-bottom: 134rpx;
  728. }
  729. .invoice-freight {
  730. width: 702rpx;
  731. padding: 0 24rpx;
  732. height: auto;
  733. font-size: $font-size-28;
  734. color: $text-color;
  735. background: #ffffff;
  736. float: left;
  737. font-weight: bold;
  738. }
  739. .invoice-balance {
  740. width: 702rpx;
  741. height: auto;
  742. padding: 0 24rpx;
  743. background: #ffffff;
  744. float: left;
  745. margin-top: 24rpx;
  746. margin-bottom: 24rpx;
  747. .balabce-t {
  748. width: 100%;
  749. height: 86rpx;
  750. line-height: 86rpx;
  751. font-size: $font-size-28;
  752. color: $text-color;
  753. float: left;
  754. .balabce-t-le {
  755. float: left;
  756. font-weight: bold;
  757. }
  758. .balabce-t-ri {
  759. float: right;
  760. display: flex;
  761. align-items: center;
  762. .money {
  763. display: flex;
  764. float: left;
  765. }
  766. .checkbox-box {
  767. display: flex;
  768. width: 60rpx;
  769. float: left;
  770. height: 100%;
  771. font-size: $font-size-24;
  772. .checkbox {
  773. width: 40rpx;
  774. text-align: right;
  775. box-sizing: border-box;
  776. text-align: center;
  777. text-decoration: none;
  778. border-radius: 0;
  779. -webkit-tap-highlight-color: transparent;
  780. overflow: hidden;
  781. color: $color-system;
  782. }
  783. }
  784. }
  785. }
  786. .balabce-b {
  787. width: 100%;
  788. float: left;
  789. overflow: hidden;
  790. .balabce-b-text {
  791. width: 100%;
  792. line-height: 58rpx;
  793. font-size: $font-size-24;
  794. color: #ff2a2a;
  795. text-align: right;
  796. float: right;
  797. }
  798. &.balabce-b--hide {
  799. padding: 0 0;
  800. height: 0px;
  801. line-height: 0px;
  802. }
  803. }
  804. }
  805. .footer-wrapper {
  806. position: fixed;
  807. left: 0;
  808. bottom: 0;
  809. background-color: #ffffff;
  810. z-index: 990;
  811. .footer {
  812. display: flex;
  813. align-items: center;
  814. width: 100%;
  815. height: 110rpx;
  816. line-height: 110rpx;
  817. justify-content: space-between;
  818. font-size: $font-size-28;
  819. color: $text-color;
  820. }
  821. .footer-le {
  822. width: 570rpx;
  823. height: 100%;
  824. float: left;
  825. }
  826. .footer-count {
  827. float: left;
  828. padding-left: 24rpx;
  829. width: 180rpx;
  830. box-sizing: border-box;
  831. }
  832. .footer-price {
  833. width: 370rpx;
  834. float: right;
  835. text-align: right;
  836. color: $text-color;
  837. padding: 10rpx 20rpx 10rpx 0;
  838. box-sizing: border-box;
  839. .sum-none {
  840. width: 100%;
  841. height: 45rpx;
  842. line-height: 45rpx;
  843. color: $text-color;
  844. float: left;
  845. text-align: right;
  846. .money {
  847. font-size: $font-size-26;
  848. color: #999999;
  849. text-decoration: line-through;
  850. }
  851. .money-sign {
  852. font-size: $font-size-26;
  853. color: #999999;
  854. text-decoration: line-through;
  855. }
  856. .money-reduced {
  857. margin-left: 10rpx;
  858. font-size: $font-size-26;
  859. color: #ff2a2a;
  860. }
  861. }
  862. .sum {
  863. width: 100%;
  864. height: 45rpx;
  865. line-height: 45rpx;
  866. float: left;
  867. &.none {
  868. height: 90rpx;
  869. line-height: 90rpx;
  870. }
  871. .price {
  872. font-size: $font-size-32;
  873. color: #ff2a2a;
  874. }
  875. }
  876. }
  877. .footer-submit {
  878. display: flex;
  879. align-items: center;
  880. justify-content: center;
  881. width: 180rpx;
  882. height: 100%;
  883. box-sizing: border-box;
  884. padding: 15rpx 5rpx;
  885. .btn {
  886. width: 100%;
  887. height: 100%;
  888. color: #ffffff;
  889. background: linear-gradient(135deg, rgba(242, 143, 49, 1) 0%, rgba(225, 86, 22, 1) 100%);
  890. font-size: $font-size-26;
  891. text-align: center;
  892. line-height: 80rpx;
  893. border-radius: 40rpx;
  894. &.disabled {
  895. background: #e4e8eb;
  896. color: #999999;
  897. }
  898. }
  899. }
  900. }
  901. </style>