create-order.vue 29 KB

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