create-order.vue 40 KB

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