create-order.vue 34 KB

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