create-order.vue 26 KB

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