create-order.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913
  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. </view>
  109. </template>
  110. <script>
  111. import choiceAddress from '@/components/cm-module/creatOrder/choiceAddress'
  112. import goodsList from '@/components/cm-module/creatOrder/goodsList'
  113. import invoiceTent from '@/components/cm-module/creatOrder/invoiceTent'
  114. import coupon from '@/components/cm-module/creatOrder/coupon'
  115. import exchangeCoupon from '@/components/cm-module/creatOrder/exchangeCoupon'
  116. import freight from '@/components/cm-module/creatOrder/freight'
  117. import freightAlert from '@/components/cm-module/modelAlert/freightAlert'
  118. export default {
  119. components:{
  120. choiceAddress,
  121. goodsList,
  122. invoiceTent,
  123. coupon,
  124. exchangeCoupon,
  125. freight,
  126. freightAlert
  127. },
  128. data() {
  129. return {
  130. isIphoneX:this.$store.state.isIphoneX,
  131. isSubLoading:false,
  132. confirmType:1,
  133. orderID:0,
  134. cartParam: {// 购物车立即结算确认订单参数
  135. productIds:0, // 商品Id(逗号隔开)
  136. source:2, // 来源:1WWW 2小程序
  137. userId:0 // 用户Id
  138. },
  139. productParam: {// 商品立即购买确认订单参数
  140. productCount:0, // 商品数量
  141. productId:0, // 商品Id
  142. source:2, // 来源:1WWW 2小程序
  143. userId:0 // 用户Id
  144. },
  145. postageParam: {// 邮费计算参数
  146. productIds:0, // 商品Id(逗号隔开)
  147. userId:0, // 用户Id
  148. townId:0 // 地区Id
  149. },
  150. confirmParam: {
  151. cartType:1, // 购买类型:(1自主下单, 3协销下单)
  152. orderSource:6, // 订单来源 1WWW 6小程序[采美,星范]
  153. addressId:0, // 收货地址Id
  154. clubCouponId:0, // 关联优惠券Id
  155. clubId:0, // 机构Id
  156. orderInfo:[], // 订单商品数据
  157. orderInvoice:{type:0}, // 订单发票信息
  158. payInfo:{ // 订单金额数据
  159. orderShouldPayFee: 0, // 订单最终支付金额
  160. balancePayFlag: 0, // 勾选余额的状态(1使用,0不使用)
  161. clauseId:0, // 条款Id
  162. postage: 0, // 运费金额
  163. postageFlag: 0, // 运费类型
  164. userBeans: 0, // 抵扣采美豆数量
  165. rebateFlag:0 // 是否返佣订单
  166. },
  167. unionId:uni.getStorageSync('unionId'),// 用户unionId
  168. }, // 提交订单参数
  169. productIds:'', // 获取上一级页面商品信息
  170. submitState:'', // 提交状态
  171. totalCount:1, // 订单提交总数量
  172. reducedPrice:0, // 满减金额
  173. couponAmount:0, // 优惠券金额
  174. totalDiscountAmount:0, // 共减金额
  175. allPrice:0.00, // 订单总金额
  176. orderShouldPayFee:0, // 订单最终支付金额
  177. surplusMoney:0.00, // 显示勾选后的剩余抵扣
  178. userMoney:0.00, // 显示可使用余额
  179. deductMoney:0.00, // 显示已使用的余额
  180. isRequest:false, // 是否加载完成渲染子组件
  181. isFreight:false, // 是否加载完成渲染子组件
  182. isAddress:false, // 是否加载完成地址
  183. isExchangePopup:false, // 控制兑换优惠券弹窗
  184. isfreightTip:false, // 控制邮费弹窗
  185. ischecked:false, // 是否勾选余额
  186. hanldFreePostFlag:'', // 邮费状态
  187. hanldFreight:'', // 邮费
  188. addressData:{}, // 初始化地址信息
  189. goodsData:[], // 初始化商品信息
  190. couponList:[], // 初始化优惠券信息
  191. invoiceData:{type:0}, // 初始化发票信息
  192. freightData:{}, // 邮费数据
  193. orderInfo:[], // 提交的商品信息
  194. rechargeGoods:null, // 判断订单里有定金商品或者充值商品时,余额抵扣部分不显示
  195. freightBeansMoney:0, // 存储采美豆抵扣金额
  196. isCouponShow:false, // 是否显示可选优惠券
  197. isCheckedBeans:false, // 是否抵扣采美豆
  198. isCouponModel:false, // 兑换优惠券成功提示
  199. ExchangeCouponData:{} // 兑换优惠券信息
  200. }
  201. },
  202. onLoad(option){//商品数据
  203. this.initStorage(option)
  204. },
  205. filters:{
  206. NumFormat(value) {//处理金额
  207. return Number(value).toFixed(2)
  208. },
  209. },
  210. methods: {
  211. async initStorage(option){
  212. console.log(option)
  213. const data = JSON.parse(option.data)
  214. const userInfo = await this.$api.getStorage()
  215. console.log('infodata',data)
  216. this.productParam.userId = this.cartParam.userId = this.postageParam.userId = userInfo.userId ? userInfo.userId : 0
  217. this.confirmParam.clubId = userInfo.clubId ? userInfo.clubId : 0
  218. console.log('userInfo',this.productParam.userId)
  219. if(option.type =='prodcut'){
  220. this.confirmParam.cartType = 2
  221. this.productParam.productCount = data.data.productCount
  222. this.productParam.productId = data.data.productIds
  223. // this.productIds = this.postageParam.productIds = data.data.productIds
  224. this.productIds = data.data.productIds
  225. this.GetProductCreateOrderInfo()
  226. }else{
  227. this.confirmParam.cartType = 1
  228. this.confirmType = 2
  229. // this.productIds = this.cartParam.productIds = this.postageParam.productIds = data.data.productIds
  230. this.productIds = this.cartParam.productIds = data.data.productIds
  231. this.CartCreateOrderInfo()
  232. }
  233. },
  234. GetProductCreateOrderInfo(){// 商品立即购买确认订单数据初始化
  235. this.OrderService.ProductCreateOrderInfo(this.productParam).then(response =>{
  236. let data = response.data
  237. this.isRequest = true
  238. this.goodsData = data.list
  239. this.couponList = data.couponList
  240. this.userMoney = data.userMoney
  241. this.reducedPrice = data.reducedPrice
  242. this.totalCount = data.totalCount
  243. this.allPrice = data.totalPrice
  244. this.rechargeGoods = data.rechargeGoods
  245. this.isCouponShow = true
  246. if(this.couponList.length>0){
  247. this.couponAmount = data.couponList[0].couponAmount
  248. this.confirmParam.clubCouponId = data.couponList[0].clubCouponId
  249. }
  250. this.orderShouldPayFee = this.allPrice - this.couponAmount
  251. this.totalDiscountAmount = this.reducedPrice + this.couponAmount
  252. this.postageParam.productIds = this.getProductIds(data.list)
  253. this.getAddressData()
  254. })
  255. .catch(error =>{
  256. this.$util.msg(error.msg,2000)
  257. })
  258. },
  259. CartCreateOrderInfo(){// 购物车去结算确认订单数据初始化
  260. this.OrderService.CartCreateOrderInfo(this.cartParam).then(response =>{
  261. let data = response.data
  262. this.isRequest = true
  263. debugger
  264. this.goodsData = data.list
  265. this.couponList = data.couponList
  266. this.userMoney = data.userMoney
  267. this.reducedPrice = data.reducedPrice
  268. this.totalCount = data.totalCount
  269. this.allPrice = data.totalPrice
  270. this.rechargeGoods = data.rechargeGoods
  271. if(this.couponList.length>0){
  272. this.isCouponShow = true
  273. this.couponAmount = data.couponList[0].couponAmount
  274. this.confirmParam.clubCouponId = data.couponList[0].clubCouponId
  275. }
  276. this.orderShouldPayFee = this.allPrice - this.couponAmount
  277. this.totalDiscountAmount = this.reducedPrice + this.couponAmount
  278. this.postageParam.productIds = this.getProductIds(data.list)
  279. this.getAddressData()
  280. })
  281. .catch(error =>{
  282. this.$util.msg(error.msg,2000)
  283. })
  284. },
  285. // 获取订单商品id列表
  286. getProductIds(list){
  287. const productIds = []
  288. list.forEach(function(supplier){
  289. supplier.cartList.forEach(function(product){
  290. productIds.push(product.productId)
  291. })
  292. })
  293. // console.log(list);
  294. return productIds.join(',')
  295. },
  296. getFreightData(){// 获取邮费信息
  297. this.isFreight = false
  298. this.OrderService.GetOrderPostage(this.postageParam).then(response =>{
  299. const data = response.data
  300. this.isFreight = true
  301. this.isCheckedBeans = false
  302. this.freightData = data
  303. this.hanldFreePostFlag = data.postageFlag
  304. this.hanldFreight = data.postage
  305. if(this.hanldFreePostFlag == 1){
  306. if( this.freightData.userBeans > 0 ){
  307. this.freightBeansMoney = this.hanldFreight
  308. }else{
  309. this.freightBeansMoney = 0
  310. }
  311. this.orderShouldPayFee = this.allPrice + data.postage
  312. this.attributePallPrice()
  313. this.hanldFreightBeans(this.isCheckedBeans)
  314. }else{
  315. if( this.freightData.userBeans > 0 ){
  316. this.freightBeansMoney = 30
  317. }else{
  318. this.freightBeansMoney = 0
  319. }
  320. this.orderShouldPayFee = this.allPrice
  321. this.attributePallPrice()
  322. this.hanldFreightBeans(this.isCheckedBeans)
  323. }
  324. })
  325. },
  326. async getAddressData(){//获取地址信息
  327. const userInfo = await this.$api.getStorage()
  328. this.UserService.QueryAddressList(
  329. {
  330. pageNum:1,
  331. pageSize:1,
  332. userId:userInfo.userId,
  333. }
  334. ).then(response =>{
  335. let data = response.data
  336. this.isAddress = true
  337. this.addressData = {}
  338. if( data.list && data.list.length > 0 ){
  339. this.confirmParam.addressId = data.list[0].addressId
  340. this.postageParam.townId = data.list[0].townId
  341. this.addressData = data.list[0]
  342. this.getFreightData()
  343. }else{
  344. this.addressData = this.addressData
  345. }
  346. })
  347. },
  348. handChangeInputGoodsList(data){//对应供应商的留言信息
  349. this.goodsData = data
  350. },
  351. handleChoiceaInvoiceData(data){//获取发票信息
  352. this.confirmParam.orderInvoice = data
  353. },
  354. hanldFreightFn(data){//显示邮费弹窗
  355. console.log('邮费信息',data)
  356. switch(data.postageFlag){
  357. case 1:
  358. this.hanldFreight = this.freightData.postage
  359. this.hanldFreePostFlag = data.postageFlag
  360. this.freightBeansMoney = data.freightBeansMoney
  361. this.orderShouldPayFee =this.allPrice + this.hanldFreight
  362. this.attributePallPrice()
  363. this.hanldFreightBeans(this.isCheckedBeans)
  364. break
  365. case -1:
  366. this.hanldFreight = 0
  367. this.hanldFreePostFlag = data.postageFlag
  368. this.freightBeansMoney = data.freightBeansMoney
  369. this.orderShouldPayFee = this.allPrice
  370. this.attributePallPrice()
  371. this.hanldFreightBeans(this.isCheckedBeans)
  372. break
  373. }
  374. },
  375. hanldFreightBeans(data){//是否勾选采美豆抵扣
  376. this.isCheckedBeans = data
  377. console.log(this.confirmParam.payInfo)
  378. if(this.isCheckedBeans){
  379. // 判断如果采美豆大于等于运费*100
  380. if( this.freightData.userBeans > 0 ){
  381. this.confirmParam.payInfo.userBeans = this.freightBeansMoney*100
  382. }else{
  383. this.confirmParam.payInfo.userBeans = 0
  384. }
  385. // 计算抵扣后的总价
  386. if(this.hanldFreePostFlag == 1){
  387. // 如果使用了余额 最终价格
  388. if(this.ischecked){
  389. let totalAmount = this.allPrice - this.couponAmount
  390. if(this.userMoney >= totalAmount){
  391. this.orderShouldPayFee = 0.00
  392. this.deductMoney = this.allPrice - this.couponAmount // 当前使用金额等于订单金额
  393. this.surplusMoney = this.userMoney - this.deductMoney // 剩余金额等于余额-当前使用金额
  394. }else{
  395. this.orderShouldPayFee = this.allPrice - this.userMoney - this.couponAmount // 订单最终支付金额等于订单金额-账户余额
  396. this.deductMoney = this.userMoney // 当前使用金额等于总余额
  397. this.surplusMoney = this.userMoney - this.deductMoney // 剩余余额等于总余额-当前使用金额
  398. }
  399. }else{
  400. this.orderShouldPayFee = this.allPrice + this.hanldFreight - this.freightBeansMoney - this.couponAmount
  401. }
  402. console.log('抵扣',this.orderShouldPayFee)
  403. }
  404. }else{// 采美豆不抵扣运费
  405. this.confirmParam.payInfo.userBeans = 0
  406. // 不抵扣时计算总价
  407. if(this.hanldFreePostFlag == 1){
  408. this.attributeHashfreight(this.hanldFreight)
  409. }
  410. }
  411. },
  412. handleChoiceaCouponData(data){// 勾选使用优惠券
  413. console.log('优惠券信息',data)
  414. this.couponAmount = data.couponAmount
  415. this.totalDiscountAmount = this.reducedPrice + this.couponAmount
  416. this.confirmParam.clubCouponId = data.clubCouponId
  417. this.attributePallPrice()
  418. this.hanldFreightBeans(this.isCheckedBeans)
  419. },
  420. checkedBalabce(){//勾选使用余额
  421. if(this.userMoney > 0){
  422. this.ischecked = !this.ischecked
  423. if(this.ischecked){
  424. this.confirmParam.payInfo.balancePayFlag = 1
  425. this.attributePallPrice()
  426. }else{
  427. this.confirmParam.payInfo.balancePayFlag = 0
  428. if(this.hanldFreePostFlag == 1 || this.hanldFreePostFlag == '1'){ //如果是有运费时
  429. if(this.isCheckedBeans){
  430. this.orderShouldPayFee = this.allPrice - this.couponAmount
  431. }else{
  432. this.orderShouldPayFee = this.allPrice+parseInt(this.freightData.postage) - this.couponAmount
  433. }
  434. }else{
  435. this.orderShouldPayFee = this.allPrice - this.couponAmount
  436. }
  437. }
  438. console.log('最终订单支付金额',this.orderShouldPayFee)
  439. console.log('优惠券金额',this.couponAmount)
  440. }else{
  441. return
  442. }
  443. },
  444. attributePallPrice(){// 计算价格
  445. if(this.hanldFreePostFlag == 1 || this.hanldFreePostFlag == '1'){
  446. this.attributeHashfreight(this.freightData.postage)
  447. }else{
  448. this.attributeNofreight()
  449. }
  450. },
  451. attributeNofreight(){// 计算没有邮费的支付价格
  452. if(this.ischecked){
  453. let totalAmount = this.allPrice - this.couponAmount
  454. if(this.userMoney >= totalAmount){
  455. this.orderShouldPayFee = 0.00
  456. this.deductMoney = this.allPrice - this.couponAmount // 当前使用金额等于订单金额
  457. this.surplusMoney = this.userMoney - this.deductMoney // 剩余金额等于余额-当前使用金额
  458. }else{
  459. this.orderShouldPayFee = this.allPrice - this.userMoney - this.couponAmount // 订单最终支付金额等于订单金额-账户余额
  460. this.deductMoney = this.userMoney // 当前使用金额等于总余额
  461. this.surplusMoney = this.userMoney - this.deductMoney // 剩余余额等于总余额-当前使用金额
  462. }
  463. }else{
  464. this.orderShouldPayFee = this.allPrice - this.couponAmount
  465. this.deductMoney = 0.00 // 当前使用
  466. this.surplusMoney = this.userMoney // 剩余余额
  467. }
  468. console.log('最终订单支付金额',this.orderShouldPayFee)
  469. console.log('优惠券金额',this.couponAmount)
  470. },
  471. attributeHashfreight(postage){// 计算需要邮费的支付价格
  472. console.log()
  473. let totalAmount = this.allPrice + parseInt(postage) - this.couponAmount//计算不包邮的价格 总价等于商品价格+邮费
  474. if(this.ischecked){
  475. if(this.userMoney >= totalAmount){// 全部抵扣
  476. this.orderShouldPayFee =0.00
  477. if(this.isCheckedBeans){// 抵扣运费了
  478. this.deductMoney = this.allPrice - this.couponAmount // 当前使用金额等于订单金额
  479. this.surplusMoney = this.userMoney - this.deductMoney // 剩余金额等于余额减去当前使用金额
  480. }else{
  481. this.deductMoney = this.allPrice + parseInt(postage)- this.couponAmount // 当前使用金额等于订单金额+运费金额
  482. this.surplusMoney = this.userMoney - this.deductMoney // 剩余余额等于总余额-当前使用金额
  483. }
  484. }else{// 部分抵扣
  485. if(this.isCheckedBeans){// 抵扣运费了
  486. this.orderShouldPayFee = this.allPrice - this.userMoney - this.couponAmount // 订单最终支付金额等于总订单金额-账户余额-优惠券金额
  487. this.deductMoney = this.userMoney // 当前使用金额等于账户余额
  488. this.surplusMoney = this.userMoney - this.deductMoney // 剩余余额等于账户余额-当前使用金额
  489. }else{
  490. this.orderShouldPayFee = this.allPrice + parseInt(postage) - this.userMoney - this.couponAmount//订单支付金额等于订单金额+运费-账户余额-优惠券
  491. this.deductMoney = this.userMoney // 当前使用金额等于账户余额
  492. this.surplusMoney = this.userMoney - this.deductMoney // 剩余余额等于账户余额-当前使用金额
  493. }
  494. }
  495. }else{
  496. this.orderShouldPayFee = this.allPrice + parseInt(postage) - this.couponAmount
  497. this.deductMoney = 0.00 // 当前使用金额
  498. this.surplusMoney = this.userMoney // 剩余余额
  499. }
  500. console.log('最终订单支付金额',this.orderShouldPayFee)
  501. console.log('优惠券金额',this.couponAmount)
  502. },
  503. orderSubmitMit(){// 提交订单
  504. if(this.isSubLoading){ return }
  505. if(this.confirmParam.addressId == ''){
  506. this.$util.msg('请先添加收货地址~',2000)
  507. return
  508. }
  509. this.confirmParam.orderInfo = this.goodsData.map(el => {
  510. let productInfo = []
  511. el.cartList.forEach(item => {
  512. productInfo.push({
  513. productId:item.productId,
  514. productNum:item.number,
  515. presentNum:0,
  516. productType:item.productType
  517. })
  518. })
  519. return {shopId:el.shopId,note:el.note?el.note:'',productInfo:productInfo}
  520. })
  521. this.confirmParam.payInfo.postage = parseInt(this.hanldFreight).toFixed(2)
  522. this.confirmParam.payInfo.postageFlag = parseInt(this.hanldFreePostFlag)
  523. this.confirmParam.payInfo.orderShouldPayFee = this.orderShouldPayFee.toFixed(2)
  524. this.confirmParam.payInfo = JSON.stringify(this.confirmParam.payInfo)
  525. this.confirmParam.orderInfo = JSON.stringify(this.confirmParam.orderInfo)
  526. this.confirmParam.orderInvoice = JSON.stringify(this.confirmParam.orderInvoice)
  527. console.log(this.confirmParam)
  528. this.isSubLoading = true
  529. this.OrderService.CreatedOrderSubmit(this.confirmParam).then(response =>{
  530. let data = response.data
  531. // 友盟埋点收集机构自主提交订单
  532. if(process.env.NODE_ENV != 'development'){
  533. this.$uma.trackEvent('Um_Event_ConfirmOrder', {
  534. Um_Key_PageName: '机构提交订单',
  535. Um_Key_SourcePage: '确认订单',
  536. Um_Key_OrderID:`${data.orderId}`
  537. })
  538. }
  539. if(data.code === 1){
  540. this.submitState ='success'
  541. setTimeout(()=>{
  542. this.isSubLoading = false
  543. },2000)
  544. this.$api.redirectTo(`/pages/user/order/success?data=${JSON.stringify({data:{orderId:data.orderId}})}`)
  545. }else{
  546. this.submitState ='confirm'
  547. this.$util.msg('订单提交成功',3000,true,'success')
  548. setTimeout(()=>{
  549. this.isSubLoading = false
  550. this.$api.redirectTo(`/pages/user/order/order-payment?type=${this.submitState}&orderId=${data.orderId}`)
  551. },3000)
  552. }
  553. }).catch(error =>{
  554. this.isSubLoading = false
  555. this.confirmParam.payInfo = JSON.parse(this.confirmParam.payInfo)
  556. this.confirmParam.orderInfo = JSON.parse(this.confirmParam.orderInfo)
  557. this.confirmParam.orderInvoice = JSON.parse(this.confirmParam.orderInvoice)
  558. this.$util.msg(error.msg,3000)
  559. })
  560. },
  561. handFreightAlertShow(){//显示邮费弹窗
  562. this.isfreightTip = true
  563. },
  564. handleClickCancel(){// 关闭优惠券弹窗
  565. this.isCouponModel = false
  566. if(this.confirmType == 1){
  567. this.GetProductCreateOrderInfo()
  568. }else{
  569. this.CartCreateOrderInfo()
  570. }
  571. },
  572. hideFreight(){//关闭邮费弹窗
  573. this.isfreightTip = false
  574. },
  575. },
  576. onShow() {
  577. let pages = getCurrentPages()
  578. let currPage = pages[pages.length-1]
  579. if(currPage.data.select =='select'){
  580. this.isAddress = true
  581. let SelectData = uni.getStorageSync('selectAddress')
  582. this.confirmParam.addressId = SelectData.addressId
  583. this.postageParam.townId = SelectData.townId
  584. this.addressData = SelectData
  585. this.getFreightData()
  586. }else{
  587. this.getAddressData()
  588. }
  589. }
  590. }
  591. </script>
  592. <style lang="scss">
  593. page {
  594. height: auto;
  595. background:#F7F7F7;
  596. }
  597. .btn-hover{
  598. background: #FFFFFF;
  599. }
  600. .animation{
  601. /* transition: transform 0.3s ease;*/
  602. transition-property: transform;
  603. transition-duration: 0.3s;
  604. transition-timing-function: ease;
  605. }
  606. .order{
  607. padding-bottom: 134rpx;
  608. }
  609. .invoice-freight{
  610. width: 702rpx;
  611. padding: 0 24rpx;
  612. height: auto;
  613. font-size: $font-size-28;
  614. color: $text-color;
  615. background: #FFFFFF;
  616. float: left;
  617. font-weight: bold;
  618. }
  619. .invoice-balance{
  620. width: 702rpx;
  621. height: auto;
  622. padding:0 24rpx;
  623. background: #FFFFFF;
  624. float: left;
  625. margin-top: 24rpx;
  626. margin-bottom: 24rpx;
  627. .balabce-t{
  628. width: 100%;
  629. height: 86rpx;
  630. line-height: 86rpx;
  631. font-size: $font-size-28;
  632. color: $text-color;
  633. float: left;
  634. .balabce-t-le{
  635. float: left;
  636. font-weight: bold;
  637. }
  638. .balabce-t-ri{
  639. float: right;
  640. display: flex;
  641. align-items: center;
  642. .money{
  643. display: flex;
  644. float: left;
  645. }
  646. .checkbox-box{
  647. display: flex;
  648. width: 60rpx;
  649. float: left;
  650. height: 100%;
  651. font-size: $font-size-24;
  652. .checkbox{
  653. width: 40rpx;
  654. text-align: right;
  655. box-sizing: border-box;
  656. text-align: center;
  657. text-decoration: none;
  658. border-radius: 0;
  659. -webkit-tap-highlight-color: transparent;
  660. overflow: hidden;
  661. color: $color-system;
  662. }
  663. }
  664. }
  665. }
  666. .balabce-b{
  667. width: 100%;
  668. float: left;
  669. overflow: hidden;
  670. .balabce-b-text{
  671. width: 100%;
  672. line-height: 58rpx;
  673. font-size: $font-size-24;
  674. color: #FF2A2A;
  675. text-align: right;
  676. float: right;
  677. }
  678. &.balabce-b--hide {
  679. padding: 0 0;
  680. height: 0px;
  681. line-height: 0px;
  682. }
  683. }
  684. }
  685. .footer{
  686. position: fixed;
  687. left: 0;
  688. bottom: 0;
  689. display: flex;
  690. align-items: center;
  691. width: 100%;
  692. height: 110rpx;
  693. line-height: 110rpx;
  694. justify-content: space-between;
  695. font-size: $font-size-28;
  696. background-color: #FFFFFF;
  697. z-index: 990;
  698. color: $text-color;
  699. .footer-le{
  700. width:570rpx;
  701. height:100%;
  702. float: left;
  703. }
  704. .footer-count{
  705. float: left;
  706. padding-left: 24rpx;
  707. width:180rpx;
  708. box-sizing: border-box;
  709. }
  710. .footer-price{
  711. width:370rpx;
  712. float: right;
  713. text-align: right;
  714. color: $text-color;
  715. padding: 10rpx 20rpx 10rpx 0;
  716. box-sizing: border-box;
  717. .sum-none{
  718. width: 100%;
  719. height: 45rpx;
  720. line-height: 45rpx;
  721. color: $text-color;
  722. float: left;
  723. text-align: right;
  724. .money{
  725. font-size: $font-size-26;
  726. color: #999999;
  727. text-decoration: line-through;
  728. }
  729. .money-sign{
  730. font-size: $font-size-26;
  731. color: #999999;
  732. text-decoration: line-through;
  733. }
  734. .money-reduced{
  735. margin-left: 10rpx;
  736. font-size: $font-size-26;
  737. color:#FF2A2A;
  738. }
  739. }
  740. .sum{
  741. width: 100%;
  742. height: 45rpx;
  743. line-height: 45rpx;
  744. float: left;
  745. &.none{
  746. height: 90rpx;
  747. line-height: 90rpx;
  748. }
  749. .price{
  750. font-size: $font-size-32;
  751. color: #FF2A2A;
  752. }
  753. }
  754. }
  755. .footer-submit{
  756. display:flex;
  757. align-items:center;
  758. justify-content: center;
  759. width: 180rpx;
  760. height: 100%;
  761. box-sizing: border-box;
  762. padding: 15rpx 5rpx;
  763. .btn{
  764. width: 100%;
  765. height: 100%;
  766. color: #FFFFFF;
  767. background:linear-gradient(135deg,rgba(242,143,49,1) 0%,rgba(225,86,22,1) 100%);
  768. font-size: $font-size-26;
  769. text-align: center;
  770. line-height: 80rpx;
  771. border-radius: 40rpx;
  772. &.disabled{
  773. background: #e4e8eb;
  774. color: #999999;
  775. }
  776. }
  777. }
  778. }
  779. .coupon-content-model{
  780. width: 100%;
  781. height: 100%;
  782. background: rgba(0,0,0,.5);
  783. position: fixed;
  784. top: 0;
  785. left: 0;
  786. z-index: 8888;
  787. transition: all 0.4s;
  788. .coupon-alert-content{
  789. width: 600rpx;
  790. height: 612rpx;
  791. position: absolute;
  792. top: 0;
  793. left: 0;
  794. bottom: 0;
  795. right: 0;
  796. margin: auto;
  797. box-sizing: border-box;
  798. padding-top: 92rpx;
  799. .coupon{
  800. width: 600rpx;
  801. height: 522rpx;
  802. background: url(https://static.caimei365.com/app/img/icon/icon-coupon-alertbg@2x.png);
  803. background-size: cover;
  804. box-sizing: border-box;
  805. padding: 230rpx 40rpx 0 40rpx;
  806. .coupon-list{
  807. width: 100%;
  808. height: 147rpx;
  809. margin-bottom: 32rpx;
  810. box-sizing: border-box;
  811. background: url(https://static.caimei365.com/app/img/icon/icon-coupon-bg@2x.png);
  812. background-size: cover;
  813. position: relative;
  814. .list-cell-tags{
  815. display: inline-block;
  816. padding: 0 10rpx;
  817. height: 32rpx;
  818. line-height: 32rpx;
  819. background-color: #f94b4b;
  820. color: #FFFFFF;
  821. font-size: 18rpx;
  822. border-radius: 16rpx 0 16rpx 0;
  823. text-align: center;
  824. position: absolute;
  825. top: 0;
  826. left: 0;
  827. }
  828. .list-cell-le{
  829. width: 154rpx;
  830. height: 100%;
  831. box-sizing: border-box;
  832. padding: 30rpx 0;
  833. float: left;
  834. .coupon-maxMoney{
  835. width: 100%;
  836. height: 54rpx;
  837. line-height: 54rpx;
  838. font-size: 42rpx;
  839. color: #f94b4b;
  840. text-align: center;
  841. margin-top: 10rpx;
  842. .small{
  843. font-size: $font-size-20;
  844. }
  845. }
  846. .coupon-minMoney{
  847. width: 100%;
  848. height: 28rpx;
  849. float: left;
  850. box-sizing: border-box;
  851. padding-left: 24rpx;
  852. .txt{
  853. display: block;
  854. height: 28rpx;
  855. line-height: 28rpx;
  856. font-size: 16rpx;
  857. color: #f94b4b;
  858. text-align: center;
  859. padding: 0 5rpx;
  860. background-color: #fff1eb;
  861. border-radius: 4rpx;
  862. float: left;
  863. }
  864. }
  865. }
  866. .list-cell-ri{
  867. width: 366rpx;
  868. height: 100%;
  869. box-sizing: border-box;
  870. padding:30rpx 20rpx;
  871. float: left;
  872. .list-cell-top{
  873. width: 100%;
  874. height: 64rpx;
  875. line-height: 64rpx;
  876. font-size: $font-size-26;
  877. color: #333333;
  878. float: left;
  879. text-overflow:ellipsis;
  880. display: -webkit-box;
  881. word-break: break-all;
  882. -webkit-box-orient: vertical;
  883. -webkit-line-clamp: 1;
  884. overflow: hidden;
  885. }
  886. .list-cell-time{
  887. width: 100%;
  888. height: 28rpx;
  889. line-height: 28rpx;
  890. text-align: left;
  891. font-size: $font-size-20;
  892. color: #999999;
  893. }
  894. }
  895. }
  896. .coupon-btn{
  897. width: 100%;
  898. height: 78rpx;
  899. background: url(https://static.caimei365.com/app/img/icon/icon-coupon-alertbtnbg@2x.png);
  900. background-size: cover;
  901. line-height: 78rpx;
  902. text-align: center;
  903. color: #FFFFFF;
  904. font-size: $font-size-36;
  905. }
  906. }
  907. }
  908. }
  909. </style>