create-order.vue 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027
  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" :style="{paddingBottom :isIphoneX ? '68rpx' : '0rpx'}">
  58. <view class="footer-le">
  59. <view class="footer-count">
  60. <text>共{{ totalCount }}件商品</text>
  61. </view>
  62. <view class="footer-price">
  63. <view class="sum" :class="totalDiscountAmount == 0 ? 'none' : ''">
  64. 总价:<text class="price">¥{{ orderShouldPayFee | NumFormat }}</text>
  65. </view>
  66. <view class="sum-none" v-if="totalDiscountAmount > 0">
  67. <text class="money-reduced">共减<text>¥{{ totalDiscountAmount | NumFormat}}</text></text>
  68. </view>
  69. </view>
  70. </view>
  71. <view class="footer-submit" @click.stop="orderSubmitMit">
  72. <view class="btn" :class="isSubLoading ? 'disabled' : ''" >提交订单</view>
  73. </view>
  74. </view>
  75. <!-- 优惠券 -->
  76. <view class="coupon-content-model" v-if="isCouponModel">
  77. <view class="coupon-alert-content">
  78. <view class="coupon">
  79. <view class="coupon-list">
  80. <view class="list-cell-tags">{{ ExchangeCouponData.couponType | TypeFormat }}</text></view>
  81. <view class="list-cell-le">
  82. <view class="coupon-maxMoney">
  83. <text class="small">¥</text>
  84. {{ ExchangeCouponData.couponAmount }}
  85. </view>
  86. <view class="coupon-minMoney">
  87. <text class="txt">满{{ ExchangeCouponData.touchPrice }}可用</text>
  88. </view>
  89. </view>
  90. <view class="list-cell-ri">
  91. <view class="list-cell-top">
  92. <text v-if="ExchangeCouponData.couponType == 0">
  93. {{ ExchangeCouponData.productType && ExchangeCouponData.productType == 1 ? '全商城商品通用' : '仅可购买指定商品' }}
  94. </text>
  95. <text v-if="ExchangeCouponData.couponType == 1">
  96. {{ ExchangeCouponData.categoryType == 1 ? '仅限购买产品类商品' : '仅限购买仪器类商品' }}
  97. </text>
  98. <text v-if="ExchangeCouponData.couponType == 3">仅限购买店铺【{{ ExchangeCouponData.shopName }}】的商品</text>
  99. <text v-if="ExchangeCouponData.couponType == 4 || ExchangeCouponData.couponType == 2">全商城商品通用</text>
  100. </view>
  101. <view class="list-cell-time">{{ ExchangeCouponData.startDate }} - {{ ExchangeCouponData.endDate }}</view>
  102. </view>
  103. </view>
  104. <view class="coupon-btn" @click.stop="handleClickCancel">立即收下</view>
  105. </view>
  106. </view>
  107. </view>
  108. <!-- 提示弹窗 -->
  109. <tui-modal
  110. :show="showModal"
  111. @click="handleClick"
  112. @cancel="hideMobel"
  113. :content="contentModalText"
  114. :button="modalButton"
  115. color="#333"
  116. :size="28"
  117. shape="circle"
  118. :maskClosable="false"
  119. ></tui-modal>
  120. </view>
  121. </template>
  122. <script>
  123. import choiceAddress from '@/components/cm-module/creatOrder/choiceAddress'
  124. import goodsList from '@/components/cm-module/creatOrder/goodsList'
  125. import invoiceTent from '@/components/cm-module/creatOrder/invoiceTent'
  126. import coupon from '@/components/cm-module/creatOrder/coupon'
  127. import exchangeCoupon from '@/components/cm-module/creatOrder/exchangeCoupon'
  128. import freight from '@/components/cm-module/creatOrder/freight'
  129. import freightAlert from '@/components/cm-module/modelAlert/freightAlert'
  130. export default {
  131. components:{
  132. choiceAddress,
  133. goodsList,
  134. invoiceTent,
  135. coupon,
  136. exchangeCoupon,
  137. freight,
  138. freightAlert
  139. },
  140. data() {
  141. return {
  142. isIphoneX:this.$store.state.isIphoneX,
  143. isSubLoading:false,
  144. confirmType:1,
  145. orderID:0,
  146. cartParam: {// 购物车立即结算确认订单参数
  147. productIds:0, // 商品Id(逗号隔开)
  148. source:2, // 来源:1WWW 2小程序
  149. userId:0 // 用户Id
  150. },
  151. productParam: {// 商品立即购买确认订单参数
  152. productCount:0, // 商品数量
  153. productId:0, // 商品Id
  154. source:2, // 来源:1WWW 2小程序
  155. userId:0 // 用户Id
  156. },
  157. supportParm:{// 组合商品立即购买确认订单参数
  158. productInfo:'',
  159. source:2, // 来源:1WWW 2小程序
  160. userId:0 // 用户Id
  161. },
  162. postageParam: {// 邮费计算参数
  163. productIds:0, // 商品Id(逗号隔开)
  164. userId:0, // 用户Id
  165. townId:0 // 地区Id
  166. },
  167. confirmParam: {
  168. cartType:1, // 购买类型:(1自主下单, 3协销下单)
  169. orderSource:6, // 订单来源 1WWW 6小程序[采美,星范]
  170. addressId:0, // 收货地址Id
  171. clubCouponId:0, // 关联优惠券Id
  172. clubId:0, // 机构Id
  173. orderInfo:[], // 订单商品数据
  174. orderInvoice:{type:0}, // 订单发票信息
  175. payInfo:{ // 订单金额数据
  176. orderShouldPayFee: 0, // 订单最终支付金额
  177. balancePayFlag: 0, // 勾选余额的状态(1使用,0不使用)
  178. clauseId:0, // 条款Id
  179. postage: 0, // 运费金额
  180. postageFlag: 0, // 运费类型
  181. userBeans: 0, // 抵扣采美豆数量
  182. rebateFlag:0 // 是否返佣订单
  183. },
  184. unionId:uni.getStorageSync('unionId'),// 用户unionId
  185. }, // 提交订单参数
  186. productIds:'', // 获取上一级页面商品信息
  187. submitState:'', // 提交状态
  188. totalCount:1, // 订单提交总数量
  189. reducedPrice:0, // 满减金额
  190. couponAmount:0, // 优惠券金额
  191. totalDiscountAmount:0, // 共减金额
  192. allPrice:0.00, // 订单总金额
  193. orderShouldPayFee:0, // 订单最终支付金额
  194. surplusMoney:0.00, // 显示勾选后的剩余抵扣
  195. userMoney:0.00, // 显示可使用余额
  196. deductMoney:0.00, // 显示已使用的余额
  197. isRequest:false, // 是否加载完成渲染子组件
  198. isFreight:false, // 是否加载完成渲染子组件
  199. isAddress:false, // 是否加载完成地址
  200. isExchangePopup:false, // 控制兑换优惠券弹窗
  201. isfreightTip:false, // 控制邮费弹窗
  202. ischecked:false, // 是否勾选余额
  203. hanldFreePostFlag:'', // 邮费状态
  204. hanldFreight:'', // 邮费
  205. addressData:{}, // 初始化地址信息
  206. goodsData:[], // 初始化商品信息
  207. couponList:[], // 初始化优惠券信息
  208. invoiceData:{type:0}, // 初始化发票信息
  209. freightData:{}, // 邮费数据
  210. orderInfo:[], // 提交的商品信息
  211. rechargeGoods:null, // 判断订单里有定金商品或者充值商品时,余额抵扣部分不显示
  212. freightBeansMoney:0, // 存储采美豆抵扣金额
  213. isCouponShow:false, // 是否显示可选优惠券
  214. isCheckedBeans:false, // 是否抵扣采美豆
  215. isCouponModel:false, // 兑换优惠券成功提示
  216. ExchangeCouponData:{}, // 兑换优惠券信息
  217. contentModalText: '采购金额过小,将扣除500采美豆,建议您前往采美旗下“呵呵商城”小程序购买小额商品。', //操作文字提示语句
  218. modalButton: [
  219. {
  220. text: '前往呵呵商城',
  221. type: 'gray',
  222. plain: true //是否空心
  223. },
  224. {
  225. text: '继续提交',
  226. customStyle: {
  227. color: '#fff',
  228. bgColor: 'linear-gradient(90deg, #F28F31 0%, #E15616 100%)'
  229. },
  230. plain: false
  231. }
  232. ],
  233. showModal: false,
  234. showModalType:1,
  235. showModalstauts:0
  236. }
  237. },
  238. onLoad(option){//商品数据
  239. this.initStorage(option)
  240. },
  241. filters:{
  242. NumFormat(value) {//处理金额
  243. return Number(value).toFixed(2)
  244. },
  245. },
  246. methods: {
  247. async initStorage(option){
  248. console.log(option)
  249. const data = JSON.parse(option.data)
  250. const userInfo = await this.$api.getStorage()
  251. console.log('infodata',data)
  252. this.productParam.userId =
  253. this.cartParam.userId =
  254. this.supportParm.userId =
  255. this.postageParam.userId = userInfo.userId ? userInfo.userId : 0
  256. this.confirmParam.clubId = userInfo.clubId ? userInfo.clubId : 0
  257. switch(option.type){
  258. case '1':
  259. console.log('商品详情立即购买')
  260. this.confirmParam.cartType = 2
  261. this.productParam.productCount = data.data.productCount
  262. this.productParam.productId = data.data.productIds
  263. // this.productIds = this.postageParam.productIds = data.data.productIds
  264. this.productIds = data.data.productIds
  265. this.GetProductCreateOrderInfo()
  266. break;
  267. case '2':
  268. console.log('购物车结算')
  269. this.confirmParam.cartType = 1
  270. this.confirmType = 2
  271. // this.productIds = this.cartParam.productIds = this.postageParam.productIds = data.data.productIds
  272. this.productIds = this.cartParam.productIds = data.data.productIds
  273. this.CartCreateOrderInfo()
  274. break;
  275. case '3':
  276. console.log('组合商品立即购买')
  277. this.confirmParam.cartType = 1
  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.productIds = this.getProductIds(data.list)
  324. this.getAddressData()
  325. },
  326. // 获取订单商品id列表
  327. getProductIds(list){
  328. const productIds = []
  329. list.forEach(function(supplier){
  330. supplier.cartList.forEach(function(product){
  331. productIds.push(product.productId)
  332. })
  333. })
  334. // console.log(list);
  335. return productIds.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.orderShouldPayFee <1000){
  546. this.showModal = true
  547. this.contentModalText = '采购金额过小,将扣除500采美豆,建议您前往采美旗下“呵呵商城”小程序购买小额商品。' //操作文字提示语句
  548. this.modalButton= [
  549. {
  550. text: '前往呵呵商城',
  551. type: 'gray',
  552. plain: true //是否空心
  553. },
  554. {
  555. text: '继续提交',
  556. customStyle: {
  557. color: '#fff',
  558. bgColor: 'linear-gradient(90deg, #F28F31 0%, #E15616 100%)'
  559. },
  560. plain: false
  561. }
  562. ]
  563. }else if(this.orderShouldPayFee <1000 && this.freightData.userBeans <0){
  564. this.showModal = true
  565. this.contentModalText = '您已有采美豆不足,不能提交订单。建议您前往采美旗下“呵呵商城”小程序购买小额商品。' //操作文字提示语句
  566. this.modalButton=[
  567. {
  568. text: '了解',
  569. type: 'gray',
  570. plain: true //是否空心
  571. },
  572. {
  573. text: '前往呵呵商城',
  574. customStyle: {
  575. color: '#fff',
  576. bgColor: 'linear-gradient(90deg, #F28F31 0%, #E15616 100%)'
  577. },
  578. plain: false
  579. }
  580. ]
  581. }else{
  582. this.handleClickOrderSubmitMit()
  583. }
  584. },
  585. handleClickOrderSubmitMit(){// 提交订单
  586. if(this.isSubLoading){ return }
  587. if(this.confirmParam.addressId == ''){
  588. this.$util.msg('请先添加收货地址~',2000)
  589. return
  590. }
  591. this.confirmParam.orderInfo = this.goodsData.map(el => {
  592. let productInfo = []
  593. el.cartList.forEach(item => {
  594. productInfo.push({
  595. productId:item.productId,
  596. productNum:item.number,
  597. presentNum:0,
  598. productType:item.productType
  599. })
  600. })
  601. return {shopId:el.shopId,note:el.note?el.note:'',productInfo:productInfo}
  602. })
  603. this.confirmParam.payInfo.postage = parseInt(this.hanldFreight).toFixed(2)
  604. this.confirmParam.payInfo.postageFlag = parseInt(this.hanldFreePostFlag)
  605. this.confirmParam.payInfo.orderShouldPayFee = this.orderShouldPayFee.toFixed(2)
  606. this.confirmParam.payInfo = JSON.stringify(this.confirmParam.payInfo)
  607. this.confirmParam.orderInfo = JSON.stringify(this.confirmParam.orderInfo)
  608. this.confirmParam.orderInvoice = JSON.stringify(this.confirmParam.orderInvoice)
  609. console.log(this.confirmParam)
  610. this.isSubLoading = true
  611. this.OrderService.CreatedOrderSubmit(this.confirmParam).then(response =>{
  612. let data = response.data
  613. // 友盟埋点收集机构自主提交订单
  614. if(process.env.NODE_ENV != 'development'){
  615. this.$uma.trackEvent('Um_Event_ConfirmOrder', {
  616. Um_Key_PageName: '机构提交订单',
  617. Um_Key_SourcePage: '确认订单',
  618. Um_Key_OrderID:`${data.orderId}`
  619. })
  620. }
  621. if(data.code === 1){
  622. this.submitState ='success'
  623. setTimeout(()=>{
  624. this.isSubLoading = false
  625. },2000)
  626. this.$api.redirectTo(`/pages/user/order/success?data=${JSON.stringify({data:{orderId:data.orderId}})}`)
  627. }else{
  628. this.submitState ='confirm'
  629. this.$util.msg('订单提交成功',3000,true,'success')
  630. setTimeout(()=>{
  631. this.isSubLoading = false
  632. this.$api.redirectTo(`/pages/user/order/order-payment?type=${this.submitState}&orderId=${data.orderId}`)
  633. },3000)
  634. }
  635. }).catch(error =>{
  636. this.isSubLoading = false
  637. this.confirmParam.payInfo = JSON.parse(this.confirmParam.payInfo)
  638. this.confirmParam.orderInfo = JSON.parse(this.confirmParam.orderInfo)
  639. this.confirmParam.orderInvoice = JSON.parse(this.confirmParam.orderInvoice)
  640. this.$util.msg(error.msg,3000)
  641. })
  642. },
  643. handFreightAlertShow(){//显示邮费弹窗
  644. this.isfreightTip = true
  645. },
  646. handleClickCancel(){// 关闭优惠券弹窗
  647. this.isCouponModel = false
  648. if(this.confirmType == 1){
  649. this.GetProductCreateOrderInfo()
  650. }else{
  651. this.CartCreateOrderInfo()
  652. }
  653. },
  654. handleClick(e){// 采购量过小提示弹窗
  655. if (e.index == 1) {
  656. if( this.orderShouldPayFee <1000 ){
  657. this.showModal = false
  658. this.handleClickOrderSubmitMit()
  659. }else{
  660. this.showModal = false
  661. this.handleClickHeHeMiniApplet()
  662. }
  663. }else{
  664. if( this.orderShouldPayFee <1000 ){
  665. this.showModal = false
  666. this.handleClickHeHeMiniApplet()
  667. }else{
  668. this.showModal = false
  669. }
  670. }
  671. },
  672. handleClickHeHeMiniApplet(){ // 跳转呵呵商城小程序
  673. uni.navigateToMiniProgram({
  674. appId: 'wx2c3b0a7f343235b1',
  675. path: '/pages/tabBar/index/index',
  676. extraData: {
  677. 'data1': 'test'
  678. },
  679. envVersion: 'develop',
  680. success(res) {
  681. // 打开成功
  682. console.log(res)
  683. }
  684. })
  685. },
  686. hideFreight(){//关闭邮费弹窗
  687. this.isfreightTip = false
  688. },
  689. },
  690. onShow() {
  691. let pages = getCurrentPages()
  692. let currPage = pages[pages.length-1]
  693. if(currPage.data.select =='select'){
  694. this.isAddress = true
  695. let SelectData = uni.getStorageSync('selectAddress')
  696. this.confirmParam.addressId = SelectData.addressId
  697. this.postageParam.townId = SelectData.townId
  698. this.addressData = SelectData
  699. this.getFreightData()
  700. }else{
  701. this.getAddressData()
  702. }
  703. }
  704. }
  705. </script>
  706. <style lang="scss">
  707. page {
  708. height: auto;
  709. background:#F7F7F7;
  710. }
  711. .btn-hover{
  712. background: #FFFFFF;
  713. }
  714. .animation{
  715. /* transition: transform 0.3s ease;*/
  716. transition-property: transform;
  717. transition-duration: 0.3s;
  718. transition-timing-function: ease;
  719. }
  720. .order{
  721. padding-bottom: 134rpx;
  722. }
  723. .invoice-freight{
  724. width: 702rpx;
  725. padding: 0 24rpx;
  726. height: auto;
  727. font-size: $font-size-28;
  728. color: $text-color;
  729. background: #FFFFFF;
  730. float: left;
  731. font-weight: bold;
  732. }
  733. .invoice-balance{
  734. width: 702rpx;
  735. height: auto;
  736. padding:0 24rpx;
  737. background: #FFFFFF;
  738. float: left;
  739. margin-top: 24rpx;
  740. margin-bottom: 24rpx;
  741. .balabce-t{
  742. width: 100%;
  743. height: 86rpx;
  744. line-height: 86rpx;
  745. font-size: $font-size-28;
  746. color: $text-color;
  747. float: left;
  748. .balabce-t-le{
  749. float: left;
  750. font-weight: bold;
  751. }
  752. .balabce-t-ri{
  753. float: right;
  754. display: flex;
  755. align-items: center;
  756. .money{
  757. display: flex;
  758. float: left;
  759. }
  760. .checkbox-box{
  761. display: flex;
  762. width: 60rpx;
  763. float: left;
  764. height: 100%;
  765. font-size: $font-size-24;
  766. .checkbox{
  767. width: 40rpx;
  768. text-align: right;
  769. box-sizing: border-box;
  770. text-align: center;
  771. text-decoration: none;
  772. border-radius: 0;
  773. -webkit-tap-highlight-color: transparent;
  774. overflow: hidden;
  775. color: $color-system;
  776. }
  777. }
  778. }
  779. }
  780. .balabce-b{
  781. width: 100%;
  782. float: left;
  783. overflow: hidden;
  784. .balabce-b-text{
  785. width: 100%;
  786. line-height: 58rpx;
  787. font-size: $font-size-24;
  788. color: #FF2A2A;
  789. text-align: right;
  790. float: right;
  791. }
  792. &.balabce-b--hide {
  793. padding: 0 0;
  794. height: 0px;
  795. line-height: 0px;
  796. }
  797. }
  798. }
  799. .footer{
  800. position: fixed;
  801. left: 0;
  802. bottom: 0;
  803. display: flex;
  804. align-items: center;
  805. width: 100%;
  806. height: 110rpx;
  807. line-height: 110rpx;
  808. justify-content: space-between;
  809. font-size: $font-size-28;
  810. background-color: #FFFFFF;
  811. z-index: 990;
  812. color: $text-color;
  813. .footer-le{
  814. width:570rpx;
  815. height:100%;
  816. float: left;
  817. }
  818. .footer-count{
  819. float: left;
  820. padding-left: 24rpx;
  821. width:180rpx;
  822. box-sizing: border-box;
  823. }
  824. .footer-price{
  825. width:370rpx;
  826. float: right;
  827. text-align: right;
  828. color: $text-color;
  829. padding: 10rpx 20rpx 10rpx 0;
  830. box-sizing: border-box;
  831. .sum-none{
  832. width: 100%;
  833. height: 45rpx;
  834. line-height: 45rpx;
  835. color: $text-color;
  836. float: left;
  837. text-align: right;
  838. .money{
  839. font-size: $font-size-26;
  840. color: #999999;
  841. text-decoration: line-through;
  842. }
  843. .money-sign{
  844. font-size: $font-size-26;
  845. color: #999999;
  846. text-decoration: line-through;
  847. }
  848. .money-reduced{
  849. margin-left: 10rpx;
  850. font-size: $font-size-26;
  851. color:#FF2A2A;
  852. }
  853. }
  854. .sum{
  855. width: 100%;
  856. height: 45rpx;
  857. line-height: 45rpx;
  858. float: left;
  859. &.none{
  860. height: 90rpx;
  861. line-height: 90rpx;
  862. }
  863. .price{
  864. font-size: $font-size-32;
  865. color: #FF2A2A;
  866. }
  867. }
  868. }
  869. .footer-submit{
  870. display:flex;
  871. align-items:center;
  872. justify-content: center;
  873. width: 180rpx;
  874. height: 100%;
  875. box-sizing: border-box;
  876. padding: 15rpx 5rpx;
  877. .btn{
  878. width: 100%;
  879. height: 100%;
  880. color: #FFFFFF;
  881. background:linear-gradient(135deg,rgba(242,143,49,1) 0%,rgba(225,86,22,1) 100%);
  882. font-size: $font-size-26;
  883. text-align: center;
  884. line-height: 80rpx;
  885. border-radius: 40rpx;
  886. &.disabled{
  887. background: #e4e8eb;
  888. color: #999999;
  889. }
  890. }
  891. }
  892. }
  893. .coupon-content-model{
  894. width: 100%;
  895. height: 100%;
  896. background: rgba(0,0,0,.5);
  897. position: fixed;
  898. top: 0;
  899. left: 0;
  900. z-index: 8888;
  901. transition: all 0.4s;
  902. .coupon-alert-content{
  903. width: 600rpx;
  904. height: 612rpx;
  905. position: absolute;
  906. top: 0;
  907. left: 0;
  908. bottom: 0;
  909. right: 0;
  910. margin: auto;
  911. box-sizing: border-box;
  912. padding-top: 92rpx;
  913. .coupon{
  914. width: 600rpx;
  915. height: 522rpx;
  916. background: url(https://static.caimei365.com/app/img/icon/icon-coupon-alertbg@2x.png);
  917. background-size: cover;
  918. box-sizing: border-box;
  919. padding: 230rpx 40rpx 0 40rpx;
  920. .coupon-list{
  921. width: 100%;
  922. height: 147rpx;
  923. margin-bottom: 32rpx;
  924. box-sizing: border-box;
  925. background: url(https://static.caimei365.com/app/img/icon/icon-coupon-bg@2x.png);
  926. background-size: cover;
  927. position: relative;
  928. .list-cell-tags{
  929. display: inline-block;
  930. padding: 0 10rpx;
  931. height: 32rpx;
  932. line-height: 32rpx;
  933. background-color: #f94b4b;
  934. color: #FFFFFF;
  935. font-size: 18rpx;
  936. border-radius: 16rpx 0 16rpx 0;
  937. text-align: center;
  938. position: absolute;
  939. top: 0;
  940. left: 0;
  941. }
  942. .list-cell-le{
  943. width: 154rpx;
  944. height: 100%;
  945. box-sizing: border-box;
  946. padding: 30rpx 0;
  947. float: left;
  948. .coupon-maxMoney{
  949. width: 100%;
  950. height: 54rpx;
  951. line-height: 54rpx;
  952. font-size: 42rpx;
  953. color: #f94b4b;
  954. text-align: center;
  955. margin-top: 10rpx;
  956. .small{
  957. font-size: $font-size-20;
  958. }
  959. }
  960. .coupon-minMoney{
  961. width: 100%;
  962. height: 28rpx;
  963. float: left;
  964. box-sizing: border-box;
  965. padding-left: 24rpx;
  966. .txt{
  967. display: block;
  968. height: 28rpx;
  969. line-height: 28rpx;
  970. font-size: 16rpx;
  971. color: #f94b4b;
  972. text-align: center;
  973. padding: 0 5rpx;
  974. background-color: #fff1eb;
  975. border-radius: 4rpx;
  976. float: left;
  977. }
  978. }
  979. }
  980. .list-cell-ri{
  981. width: 366rpx;
  982. height: 100%;
  983. box-sizing: border-box;
  984. padding:30rpx 20rpx;
  985. float: left;
  986. .list-cell-top{
  987. width: 100%;
  988. height: 64rpx;
  989. line-height: 64rpx;
  990. font-size: $font-size-26;
  991. color: #333333;
  992. float: left;
  993. text-overflow:ellipsis;
  994. display: -webkit-box;
  995. word-break: break-all;
  996. -webkit-box-orient: vertical;
  997. -webkit-line-clamp: 1;
  998. overflow: hidden;
  999. }
  1000. .list-cell-time{
  1001. width: 100%;
  1002. height: 28rpx;
  1003. line-height: 28rpx;
  1004. text-align: left;
  1005. font-size: $font-size-20;
  1006. color: #999999;
  1007. }
  1008. }
  1009. }
  1010. .coupon-btn{
  1011. width: 100%;
  1012. height: 78rpx;
  1013. background: url(https://static.caimei365.com/app/img/icon/icon-coupon-alertbtnbg@2x.png);
  1014. background-size: cover;
  1015. line-height: 78rpx;
  1016. text-align: center;
  1017. color: #FFFFFF;
  1018. font-size: $font-size-36;
  1019. }
  1020. }
  1021. }
  1022. }
  1023. </style>