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.confirmParam.cartType = 2
  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.confirmParam.cartType = 1
  230. this.confirmType = 2
  231. this.productIds = this.cartParam.productIds = this.postageParam.productIds = data.data.productIds
  232. this.CartCreateOrderInfo()
  233. }
  234. },
  235. GetProductCreateOrderInfo(){// 商品立即购买确认订单数据初始化
  236. this.OrderService.ProductCreateOrderInfo(this.productParam).then(response =>{
  237. let data = response.data
  238. this.isRequest = true
  239. this.goodsData = data.list
  240. this.couponList = data.couponList
  241. this.userMoney = data.userMoney
  242. this.reducedPrice = data.reducedPrice
  243. this.totalCount = data.totalCount
  244. this.allPrice = data.totalPrice
  245. this.rechargeGoods = data.rechargeGoods
  246. this.isCouponShow = true
  247. if(this.couponList.length>0){
  248. this.couponAmount = data.couponList[0].couponAmount
  249. this.confirmParam.clubCouponId = data.couponList[0].clubCouponId
  250. }
  251. this.orderShouldPayFee = this.allPrice - this.couponAmount
  252. this.totalDiscountAmount = this.reducedPrice + this.couponAmount
  253. })
  254. .catch(error =>{
  255. this.$util.msg(error.msg,2000)
  256. })
  257. },
  258. CartCreateOrderInfo(){// 购物车去结算确认订单数据初始化
  259. this.OrderService.CartCreateOrderInfo(this.cartParam).then(response =>{
  260. let data = response.data
  261. this.isRequest = true
  262. this.goodsData = data.list
  263. this.couponList = data.couponList
  264. this.userMoney = data.userMoney
  265. this.reducedPrice = data.reducedPrice
  266. this.totalCount = data.totalCount
  267. this.allPrice = data.totalPrice
  268. this.rechargeGoods = data.rechargeGoods
  269. if(this.couponList.length>0){
  270. this.isCouponShow = true
  271. this.couponAmount = data.couponList[0].couponAmount
  272. this.confirmParam.clubCouponId = data.couponList[0].clubCouponId
  273. }
  274. this.orderShouldPayFee = this.allPrice - this.couponAmount
  275. this.totalDiscountAmount = this.reducedPrice + this.couponAmount
  276. })
  277. .catch(error =>{
  278. this.$util.msg(error.msg,2000)
  279. })
  280. },
  281. getFreightData(){// 获取邮费信息
  282. this.isFreight = false
  283. this.OrderService.GetOrderPostage(this.postageParam).then(response =>{
  284. const data = response.data
  285. this.isFreight = true
  286. this.isCheckedBeans = false
  287. this.freightData = data
  288. this.hanldFreePostFlag = data.postageFlag
  289. this.hanldFreight = data.postage
  290. if(this.hanldFreePostFlag == 1){
  291. if( this.freightData.userBeans > 0 ){
  292. this.freightBeansMoney = this.hanldFreight
  293. }else{
  294. this.freightBeansMoney = 0
  295. }
  296. this.orderShouldPayFee = this.allPrice + data.postage
  297. this.attributePallPrice()
  298. this.hanldFreightBeans(this.isCheckedBeans)
  299. }else{
  300. if( this.freightData.userBeans > 0 ){
  301. this.freightBeansMoney = 30
  302. }else{
  303. this.freightBeansMoney = 0
  304. }
  305. this.orderShouldPayFee = this.allPrice
  306. this.attributePallPrice()
  307. this.hanldFreightBeans(this.isCheckedBeans)
  308. }
  309. })
  310. },
  311. async getAddressData(){//获取地址信息
  312. const userInfo = await this.$api.getStorage()
  313. this.UserService.QueryAddressList(
  314. {
  315. pageNum:1,
  316. pageSize:1,
  317. userId:userInfo.userId,
  318. }
  319. ).then(response =>{
  320. let data = response.data
  321. this.isAddress = true
  322. this.addressData = {}
  323. if( data.list && data.list.length > 0 ){
  324. this.confirmParam.addressId = data.list[0].addressId
  325. this.postageParam.townId = data.list[0].townId
  326. this.addressData = data.list[0]
  327. this.getFreightData()
  328. }else{
  329. this.addressData = this.addressData
  330. }
  331. })
  332. },
  333. handChangeInputGoodsList(data){//对应供应商的留言信息
  334. this.goodsData = data
  335. },
  336. handleChoiceaInvoiceData(data){//获取发票信息
  337. this.confirmParam.orderInvoice = data
  338. },
  339. hanldFreightFn(data){//显示邮费弹窗
  340. console.log('邮费信息',data)
  341. switch(data.postageFlag){
  342. case 1:
  343. this.hanldFreight = this.freightData.postage
  344. this.hanldFreePostFlag = data.postageFlag
  345. this.freightBeansMoney = data.freightBeansMoney
  346. this.orderShouldPayFee =this.allPrice + this.hanldFreight
  347. this.attributePallPrice()
  348. this.hanldFreightBeans(this.isCheckedBeans)
  349. break
  350. case -1:
  351. this.hanldFreight = 0
  352. this.hanldFreePostFlag = data.postageFlag
  353. this.freightBeansMoney = data.freightBeansMoney
  354. this.orderShouldPayFee = this.allPrice
  355. this.attributePallPrice()
  356. this.hanldFreightBeans(this.isCheckedBeans)
  357. break
  358. }
  359. },
  360. hanldFreightBeans(data){//是否勾选采美豆抵扣
  361. this.isCheckedBeans = data
  362. if(this.isCheckedBeans){
  363. // 判断如果采美豆大于等于运费*100
  364. if( this.freightData.userBeans > 0 ){
  365. this.confirmParam.payInfo.userBeans = this.freightBeansMoney*100
  366. }else{
  367. this.confirmParam.payInfo.userBeans = 0
  368. }
  369. // 计算抵扣后的总价
  370. if(this.hanldFreePostFlag == 1){
  371. // 如果使用了余额 最终价格
  372. if(this.ischecked){
  373. let totalAmount = this.allPrice - this.couponAmount
  374. if(this.userMoney >= totalAmount){
  375. this.orderShouldPayFee = 0.00
  376. this.deductMoney = this.allPrice - this.couponAmount // 当前使用金额等于订单金额
  377. this.surplusMoney = this.userMoney - this.deductMoney // 剩余金额等于余额-当前使用金额
  378. }else{
  379. this.orderShouldPayFee = this.allPrice - this.userMoney - this.couponAmount // 订单最终支付金额等于订单金额-账户余额
  380. this.deductMoney = this.userMoney // 当前使用金额等于总余额
  381. this.surplusMoney = this.userMoney - this.deductMoney // 剩余余额等于总余额-当前使用金额
  382. }
  383. }else{
  384. this.orderShouldPayFee = this.allPrice + this.hanldFreight - this.freightBeansMoney - this.couponAmount
  385. }
  386. console.log('抵扣',this.orderShouldPayFee)
  387. }
  388. }else{// 采美豆不抵扣运费
  389. this.confirmParam.payInfo.userBeans = 0
  390. // 不抵扣时计算总价
  391. if(this.hanldFreePostFlag == 1){
  392. this.attributeHashfreight(this.hanldFreight)
  393. }
  394. }
  395. },
  396. handleChoiceaCouponData(data){// 勾选使用优惠券
  397. console.log('优惠券信息',data)
  398. this.couponAmount = data.couponAmount
  399. this.totalDiscountAmount = this.reducedPrice + this.couponAmount
  400. this.confirmParam.clubCouponId = data.clubCouponId
  401. this.attributePallPrice()
  402. this.hanldFreightBeans(this.isCheckedBeans)
  403. },
  404. checkedBalabce(){//勾选使用余额
  405. if(this.userMoney > 0){
  406. this.ischecked = !this.ischecked
  407. if(this.ischecked){
  408. this.confirmParam.payInfo.balancePayFlag = 1
  409. this.attributePallPrice()
  410. }else{
  411. if(this.hanldFreePostFlag == 1 || this.hanldFreePostFlag == '1'){ //如果是有运费时
  412. if(this.isCheckedBeans){
  413. this.orderShouldPayFee = this.allPrice - this.couponAmount
  414. }else{
  415. this.orderShouldPayFee = this.allPrice+parseInt(this.freightData.postage) - this.couponAmount
  416. }
  417. }else{
  418. this.orderShouldPayFee = this.allPrice - this.couponAmount
  419. }
  420. this.confirmParam.payInfo.balancePayFlag = 0
  421. }
  422. console.log('最终订单支付金额',this.orderShouldPayFee)
  423. console.log('优惠券金额',this.couponAmount)
  424. }else{
  425. return
  426. }
  427. },
  428. attributePallPrice(){// 计算价格
  429. if(this.hanldFreePostFlag == 1 || this.hanldFreePostFlag == '1'){
  430. this.attributeHashfreight(this.freightData.postage)
  431. }else{
  432. this.attributeNofreight()
  433. }
  434. },
  435. attributeNofreight(){// 计算没有邮费的支付价格
  436. if(this.ischecked){
  437. let totalAmount = this.allPrice - this.couponAmount
  438. if(this.userMoney >= totalAmount){
  439. this.orderShouldPayFee = 0.00
  440. this.deductMoney = this.allPrice - this.couponAmount // 当前使用金额等于订单金额
  441. this.surplusMoney = this.userMoney - this.deductMoney // 剩余金额等于余额-当前使用金额
  442. }else{
  443. this.orderShouldPayFee = this.allPrice - this.userMoney - this.couponAmount // 订单最终支付金额等于订单金额-账户余额
  444. this.deductMoney = this.userMoney // 当前使用金额等于总余额
  445. this.surplusMoney = this.userMoney - this.deductMoney // 剩余余额等于总余额-当前使用金额
  446. }
  447. }else{
  448. this.orderShouldPayFee = this.allPrice - this.couponAmount
  449. this.deductMoney = 0.00 // 当前使用
  450. this.surplusMoney = this.userMoney // 剩余余额
  451. }
  452. console.log('最终订单支付金额',this.orderShouldPayFee)
  453. console.log('优惠券金额',this.couponAmount)
  454. },
  455. attributeHashfreight(postage){// 计算需要邮费的支付价格
  456. console.log()
  457. let totalAmount = this.allPrice + parseInt(postage) - this.couponAmount//计算不包邮的价格 总价等于商品价格+邮费
  458. if(this.ischecked){
  459. if(this.userMoney >= totalAmount){// 全部抵扣
  460. this.orderShouldPayFee =0.00
  461. if(this.isCheckedBeans){// 抵扣运费了
  462. this.deductMoney = this.allPrice - this.couponAmount // 当前使用金额等于订单金额
  463. this.surplusMoney = this.userMoney - this.deductMoney // 剩余金额等于余额减去当前使用金额
  464. }else{
  465. this.deductMoney = this.allPrice + parseInt(postage)- this.couponAmount // 当前使用金额等于订单金额+运费金额
  466. this.surplusMoney = this.userMoney - this.deductMoney // 剩余余额等于总余额-当前使用金额
  467. }
  468. }else{// 部分抵扣
  469. if(this.isCheckedBeans){// 抵扣运费了
  470. this.orderShouldPayFee = this.allPrice - this.userMoney - this.couponAmount // 订单最终支付金额等于总订单金额-账户余额-优惠券金额
  471. this.deductMoney = this.userMoney // 当前使用金额等于账户余额
  472. this.surplusMoney = this.userMoney - this.deductMoney // 剩余余额等于账户余额-当前使用金额
  473. }else{
  474. this.orderShouldPayFee = this.allPrice + parseInt(postage) - this.userMoney - this.couponAmount//订单支付金额等于订单金额+运费-账户余额-优惠券
  475. this.deductMoney = this.userMoney // 当前使用金额等于账户余额
  476. this.surplusMoney = this.userMoney - this.deductMoney // 剩余余额等于账户余额-当前使用金额
  477. }
  478. }
  479. }else{
  480. this.orderShouldPayFee = this.allPrice + parseInt(postage) - this.couponAmount
  481. this.deductMoney = 0.00 // 当前使用金额
  482. this.surplusMoney = this.userMoney // 剩余余额
  483. }
  484. console.log('最终订单支付金额',this.orderShouldPayFee)
  485. console.log('优惠券金额',this.couponAmount)
  486. },
  487. orderSubmitMit(){// 提交订单
  488. if(this.isSubLoading){ return }
  489. if(this.confirmParam.addressId == ''){
  490. this.$util.msg('请先添加收货地址~',2000)
  491. return
  492. }
  493. this.confirmParam.orderInfo = this.goodsData.map(el => {
  494. let productInfo = []
  495. el.cartList.forEach(item => {
  496. productInfo.push({
  497. productId:item.productId,
  498. productNum:item.number,
  499. presentNum:0,
  500. productType:item.productType
  501. })
  502. })
  503. return {shopId:el.shopId,note:el.note?el.note:'',productInfo:productInfo}
  504. })
  505. this.confirmParam.payInfo.postage = parseInt(this.hanldFreight).toFixed(2)
  506. this.confirmParam.payInfo.postageFlag = parseInt(this.hanldFreePostFlag)
  507. this.confirmParam.payInfo.orderShouldPayFee = this.orderShouldPayFee.toFixed(2)
  508. this.confirmParam.payInfo = JSON.stringify(this.confirmParam.payInfo)
  509. this.confirmParam.orderInfo = JSON.stringify(this.confirmParam.orderInfo)
  510. this.confirmParam.orderInvoice = JSON.stringify(this.confirmParam.orderInvoice)
  511. console.log(this.confirmParam)
  512. this.isSubLoading = true
  513. this.OrderService.CreatedOrderSubmit(this.confirmParam).then(response =>{
  514. let data = response.data
  515. // 友盟埋点收集机构自主提交订单
  516. if(process.env.NODE_ENV != 'development'){
  517. this.$uma.trackEvent('Um_Event_ConfirmOrder', {
  518. Um_Key_PageName: '机构提交订单',
  519. Um_Key_SourcePage: '确认订单',
  520. Um_Key_OrderID:`${data.orderId}`
  521. })
  522. }
  523. console.log('机构提交订单机构提交订单机构提交订单机构提交订单')
  524. if(data.code === 1){
  525. this.submitState ='success'
  526. setTimeout(()=>{
  527. this.isSubLoading = false
  528. },2000)
  529. this.$api.navigateTo(`/pages/user/order/success?data=${JSON.stringify({data:{orderId:data.orderId}})}`)
  530. }else{
  531. this.submitState ='confirm'
  532. this.$util.msg('订单提交成功',3000,true,'success')
  533. setTimeout(()=>{
  534. this.isSubLoading = false
  535. this.$api.redirectTo(`/pages/user/order/order-payment?type=${this.submitState}&orderId=${data.orderId}`)
  536. },3000)
  537. }
  538. }).catch(error =>{
  539. this.isSubLoading = false
  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>