create-order.vue 30 KB

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