create-order.vue 35 KB

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