create-order.vue 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043
  1. <template>
  2. <view class="container order clearfix" :style="{paddingBottom :isIphoneX ? '170rpx' : '134rpx'}">
  3. <!-- 地址选择 -->
  4. <choice-address ref="choiceAddress" v-if="isAddress" :addressData="addressData"></choice-address>
  5. <!-- 商品 -->
  6. <goods-list ref='goods' v-if="isRequest" :goodsData="goodsData" @handleGoodList="handChangeInputGoodsList"></goods-list>
  7. <!-- 发票信息 -->
  8. <invoice-tent ref="invoice"
  9. v-if="isRequest"
  10. :invoiceDatas="invoiceData"
  11. @handleChoiceaInvoice="handleChoiceaInvoiceData">
  12. </invoice-tent>
  13. <!-- 优惠券选择弹窗 -->
  14. <coupon ref="coupon"
  15. v-if="isCouponShow"
  16. :couponList="couponList"
  17. @handleChoiceaCoupon="handleChoiceaCouponData">
  18. </coupon>
  19. <!-- 兑换优惠券弹窗 -->
  20. <exchangeCoupon v-if="isExchangePopup"></exchangeCoupon>
  21. <!-- 运费 -->
  22. <freight ref="freight"
  23. v-if="isFreight"
  24. :freightData="freightData"
  25. @confirmFreight="hanldFreightFn"
  26. @confirmFreightBeans = "hanldFreightBeans"
  27. >
  28. </freight>
  29. <freight-alert v-if="isfreightTip" ref="csPhone"></freight-alert>
  30. <!-- 余额抵扣 -->
  31. <view class="invoice-balance" v-show="!rechargeGoods">
  32. <view class="balabce-t">
  33. <view class="balabce-t-le">余额抵扣</view>
  34. <view class="balabce-t-ri">
  35. <view class="money">
  36. <text>可用余额:</text>
  37. <text>¥{{userMoney | NumFormat}}</text>
  38. </view>
  39. <view class="checkbox-box">
  40. <button class="checkbox iconfont"
  41. hover-class="btn-hover"
  42. v-if="userMoney!=0"
  43. @click.stop="checkedBalabce"
  44. :class="[ischecked ?'icon-yixuanze':'icon-weixuanze']"
  45. >
  46. </button>
  47. </view>
  48. </view>
  49. </view>
  50. <view class="balabce-b" :class="{'balabce-b--hide':!ischecked}">
  51. <view class="balabce-b-text animation" :style="{'transform':ischecked?'translateY(0)':'translateY(-50%)','-webkit-transform':ischecked?'translateY(0)':'translateY(-50%)'}">
  52. <text>当前使用:¥{{deductMoney | NumFormat}},剩余:¥{{surplusMoney | NumFormat}}</text>
  53. </view>
  54. </view>
  55. </view>
  56. <!-- 底部 -->
  57. <view class="footer" :style="{paddingBottom :isIphoneX ? '68rpx' : '0rpx'}">
  58. <view class="footer-le">
  59. <view class="footer-count">
  60. <text>共{{ totalCount }}件商品</text>
  61. </view>
  62. <view class="footer-price">
  63. <view class="sum" :class="totalDiscountAmount == 0 ? 'none' : ''">
  64. 总价:<text class="price">¥{{ orderShouldPayFee | NumFormat }}</text>
  65. </view>
  66. <view class="sum-none" v-if="totalDiscountAmount > 0">
  67. <text class="money-reduced">共减<text>¥{{ totalDiscountAmount | NumFormat}}</text></text>
  68. </view>
  69. </view>
  70. </view>
  71. <view class="footer-submit" @click.stop="orderSubmitMit">
  72. <view class="btn" :class="isSubLoading ? 'disabled' : ''" >提交订单</view>
  73. </view>
  74. </view>
  75. <!-- 优惠券 -->
  76. <view class="coupon-content-model" v-if="isCouponModel">
  77. <view class="coupon-alert-content">
  78. <view class="coupon">
  79. <view class="coupon-list">
  80. <view class="list-cell-tags">{{ ExchangeCouponData.couponType | TypeFormat }}</text></view>
  81. <view class="list-cell-le">
  82. <view class="coupon-maxMoney">
  83. <text class="small">¥</text>
  84. {{ ExchangeCouponData.couponAmount }}
  85. </view>
  86. <view class="coupon-minMoney">
  87. <text class="txt">满{{ ExchangeCouponData.touchPrice }}可用</text>
  88. </view>
  89. </view>
  90. <view class="list-cell-ri">
  91. <view class="list-cell-top">
  92. <text v-if="ExchangeCouponData.couponType == 0">
  93. {{ ExchangeCouponData.productType && ExchangeCouponData.productType == 1 ? '全商城商品通用' : '仅可购买指定商品' }}
  94. </text>
  95. <text v-if="ExchangeCouponData.couponType == 1">
  96. {{ ExchangeCouponData.categoryType == 1 ? '仅限购买产品类商品' : '仅限购买仪器类商品' }}
  97. </text>
  98. <text v-if="ExchangeCouponData.couponType == 3">仅限购买店铺【{{ ExchangeCouponData.shopName }}】的商品</text>
  99. <text v-if="ExchangeCouponData.couponType == 4 || ExchangeCouponData.couponType == 2">全商城商品通用</text>
  100. </view>
  101. <view class="list-cell-time">{{ ExchangeCouponData.startDate }} - {{ ExchangeCouponData.endDate }}</view>
  102. </view>
  103. </view>
  104. <view class="coupon-btn" @click.stop="handleClickCancel">立即收下</view>
  105. </view>
  106. </view>
  107. </view>
  108. <!-- 提示弹窗 -->
  109. <tui-modal
  110. :show="showModal"
  111. @click="handleClick"
  112. @cancel="hideMobel"
  113. :content="contentModalText"
  114. :button="modalButton"
  115. color="#333"
  116. :size="28"
  117. shape="circle"
  118. :maskClosable="false"
  119. ></tui-modal>
  120. </view>
  121. </template>
  122. <script>
  123. import choiceAddress from '@/components/cm-module/creatOrder/choiceAddress'
  124. import goodsList from '@/components/cm-module/creatOrder/goodsList'
  125. import invoiceTent from '@/components/cm-module/creatOrder/invoiceTent'
  126. import coupon from '@/components/cm-module/creatOrder/coupon'
  127. import exchangeCoupon from '@/components/cm-module/creatOrder/exchangeCoupon'
  128. import freight from '@/components/cm-module/creatOrder/freight'
  129. import freightAlert from '@/components/cm-module/modelAlert/freightAlert'
  130. export default {
  131. components:{
  132. choiceAddress,
  133. goodsList,
  134. invoiceTent,
  135. coupon,
  136. exchangeCoupon,
  137. freight,
  138. freightAlert
  139. },
  140. data() {
  141. return {
  142. isIphoneX:this.$store.state.isIphoneX,
  143. isSubLoading:false,
  144. confirmType:1,
  145. orderID:0,
  146. cartParam: {// 购物车立即结算确认订单参数
  147. productIds:0, // 商品Id(逗号隔开)
  148. source:2, // 来源:1WWW 2小程序
  149. userId:0 // 用户Id
  150. },
  151. productParam: {// 商品立即购买确认订单参数
  152. productCount:0, // 商品数量
  153. productId:0, // 商品Id
  154. source:2, // 来源:1WWW 2小程序
  155. userId:0 // 用户Id
  156. },
  157. supportParm:{// 组合商品立即购买确认订单参数
  158. productInfo:'',
  159. source:2, // 来源:1WWW 2小程序
  160. userId:0 // 用户Id
  161. },
  162. postageParam: {// 邮费计算参数
  163. productIds:0, // 商品Id(逗号隔开)
  164. userId:0, // 用户Id
  165. townId:0 // 地区Id
  166. },
  167. confirmParam: {
  168. cartType:1, // 购买类型:(1自主下单, 3协销下单)
  169. orderSource:6, // 订单来源 1WWW 6小程序[采美,星范]
  170. addressId:0, // 收货地址Id
  171. clubCouponId:0, // 关联优惠券Id
  172. clubId:0, // 机构Id
  173. orderInfo:[], // 订单商品数据
  174. orderInvoice:{type:0}, // 订单发票信息
  175. payInfo:{ // 订单金额数据
  176. orderShouldPayFee: 0, // 订单最终支付金额
  177. balancePayFlag: 0, // 勾选余额的状态(1使用,0不使用)
  178. clauseId:0, // 条款Id
  179. postage: 0, // 运费金额
  180. postageFlag: 0, // 运费类型
  181. userBeans: 0, // 抵扣采美豆数量
  182. rebateFlag:0 // 是否返佣订单
  183. },
  184. unionId:uni.getStorageSync('unionId'),// 用户unionId
  185. }, // 提交订单参数
  186. productIds:'', // 获取上一级页面商品信息
  187. submitState:'', // 提交状态
  188. totalCount:1, // 订单提交总数量
  189. reducedPrice:0, // 满减金额
  190. couponAmount:0, // 优惠券金额
  191. totalDiscountAmount:0, // 共减金额
  192. allPrice:0.00, // 订单总金额
  193. orderShouldPayFee:0, // 订单最终支付金额
  194. surplusMoney:0.00, // 显示勾选后的剩余抵扣
  195. userMoney:0.00, // 显示可使用余额
  196. deductMoney:0.00, // 显示已使用的余额
  197. isRequest:false, // 是否加载完成渲染子组件
  198. isFreight:false, // 是否加载完成渲染子组件
  199. isAddress:false, // 是否加载完成地址
  200. isExchangePopup:false, // 控制兑换优惠券弹窗
  201. isfreightTip:false, // 控制邮费弹窗
  202. ischecked:false, // 是否勾选余额
  203. hanldFreePostFlag:'', // 邮费状态
  204. hanldFreight:'', // 邮费
  205. addressData:{}, // 初始化地址信息
  206. goodsData:[], // 初始化商品信息
  207. couponList:[], // 初始化优惠券信息
  208. invoiceData:{type:0}, // 初始化发票信息
  209. freightData:{}, // 邮费数据
  210. orderInfo:[], // 提交的商品信息
  211. rechargeGoods:null, // 判断订单里有定金商品或者充值商品时,余额抵扣部分不显示
  212. freightBeansMoney:0, // 存储采美豆抵扣金额
  213. isCouponShow:false, // 是否显示可选优惠券
  214. isCheckedBeans:false, // 是否抵扣采美豆
  215. isCouponModel:false, // 兑换优惠券成功提示
  216. ExchangeCouponData:{}, // 兑换优惠券信息
  217. contentModalText: '采购金额过小,将扣除500采美豆,建议您前往采美旗下“呵呵商城”小程序购买小额商品。', //操作文字提示语句
  218. modalButton: [
  219. {
  220. text: '前往呵呵商城',
  221. type: 'gray',
  222. plain: true //是否空心
  223. },
  224. {
  225. text: '继续提交',
  226. customStyle: {
  227. color: '#fff',
  228. bgColor: 'linear-gradient(90deg, #F28F31 0%, #E15616 100%)'
  229. },
  230. plain: false
  231. }
  232. ],
  233. showModal: false,
  234. showModalstauts:0
  235. }
  236. },
  237. onLoad(option){//商品数据
  238. this.initStorage(option)
  239. },
  240. filters:{
  241. NumFormat(value) {//处理金额
  242. return Number(value).toFixed(2)
  243. },
  244. },
  245. methods: {
  246. async initStorage(option){
  247. const data = JSON.parse(option.data)
  248. const userInfo = await this.$api.getStorage()
  249. console.log('data',data)
  250. this.productParam.userId =
  251. this.cartParam.userId =
  252. this.supportParm.userId =
  253. this.postageParam.userId = userInfo.userId ? userInfo.userId : 0
  254. this.confirmParam.clubId = userInfo.clubId ? userInfo.clubId : 0
  255. switch(option.type){
  256. case '1':// 商品详情立即购买
  257. this.confirmParam.cartType = 2
  258. this.productParam.productCount = data.data.productCount
  259. this.productParam.productId = data.data.productIds
  260. this.productIds = data.data.productIds
  261. this.GetProductCreateOrderInfo()
  262. break
  263. case '2':// 购物车结算
  264. this.confirmParam.cartType = 1
  265. this.confirmType = 2
  266. this.productIds = this.cartParam.productIds = data.data.productIds
  267. this.CartCreateOrderInfo()
  268. break
  269. case '3':// 组合商品立即购买
  270. this.confirmParam.cartType = 2
  271. this.confirmType = 2
  272. this.supportParm.productInfo = JSON.stringify(data.data)
  273. this.GetOrderClubProductSupporting()
  274. }
  275. },
  276. GetProductCreateOrderInfo(){// 商品立即购买确认订单数据初始化
  277. this.OrderService.ProductCreateOrderInfo(this.productParam).then(response =>{
  278. this.setCreatDataInfo(response.data)
  279. })
  280. .catch(error =>{
  281. this.$util.msg(error.msg,2000)
  282. })
  283. },
  284. GetOrderClubProductSupporting(){// 组合商品立即购买确认订单数据初始化
  285. this.OrderService.OrderClubProductSupporting(this.supportParm).then(response =>{
  286. this.setCreatDataInfo(response.data)
  287. })
  288. .catch(error =>{
  289. this.$util.msg(error.msg,2000)
  290. })
  291. },
  292. CartCreateOrderInfo(){// 购物车去结算确认订单数据初始化
  293. this.OrderService.CartCreateOrderInfo(this.cartParam).then(response =>{
  294. this.setCreatDataInfo(response.data)
  295. })
  296. .catch(error =>{
  297. this.$util.msg(error.msg,2000)
  298. })
  299. },
  300. setCreatDataInfo(data){// 公共初始化数据
  301. this.isRequest = true
  302. this.goodsData = data.list
  303. this.couponList = data.couponList
  304. this.userMoney = data.userMoney
  305. this.reducedPrice = data.reducedPrice
  306. this.totalCount = data.totalCount
  307. this.allPrice = data.totalPrice
  308. this.rechargeGoods = data.rechargeGoods
  309. if(this.couponList.length>0){
  310. this.isCouponShow = true
  311. this.couponAmount = data.couponList[0].couponAmount
  312. this.confirmParam.clubCouponId = data.couponList[0].clubCouponId
  313. }
  314. this.orderShouldPayFee = this.allPrice - this.couponAmount
  315. this.totalDiscountAmount = this.reducedPrice + this.couponAmount
  316. this.postageParam.productIds = this.getProductIds(data.list)
  317. this.getAddressData()
  318. },
  319. // 获取订单商品id列表
  320. getProductIds(list){
  321. const productIds = []
  322. list.forEach(function(supplier){
  323. supplier.cartList.forEach(function(product){
  324. productIds.push(product.productId)
  325. })
  326. })
  327. // console.log(list);
  328. return productIds.join(',')
  329. },
  330. getFreightData(){// 获取邮费信息
  331. this.isFreight = false
  332. this.OrderService.GetOrderPostage(this.postageParam).then(response =>{
  333. const data = response.data
  334. this.isFreight = true
  335. this.isCheckedBeans = false
  336. this.freightData = data
  337. this.hanldFreePostFlag = data.postageFlag
  338. this.hanldFreight = data.postage
  339. if(this.hanldFreePostFlag == 1){
  340. if( this.freightData.userBeans > 0 ){
  341. this.freightBeansMoney = this.hanldFreight
  342. }else{
  343. this.freightBeansMoney = 0
  344. }
  345. this.orderShouldPayFee = this.allPrice + data.postage
  346. this.attributePallPrice()
  347. this.hanldFreightBeans(this.isCheckedBeans)
  348. }else{
  349. if( this.freightData.userBeans > 0 ){
  350. this.freightBeansMoney = 30
  351. }else{
  352. this.freightBeansMoney = 0
  353. }
  354. this.orderShouldPayFee = this.allPrice
  355. this.attributePallPrice()
  356. this.hanldFreightBeans(this.isCheckedBeans)
  357. }
  358. })
  359. },
  360. async getAddressData(){//获取地址信息
  361. const userInfo = await this.$api.getStorage()
  362. this.UserService.QueryAddressList(
  363. {
  364. pageNum:1,
  365. pageSize:1,
  366. userId:userInfo.userId,
  367. }
  368. ).then(response =>{
  369. let data = response.data
  370. this.isAddress = true
  371. this.addressData = {}
  372. if( data.list && data.list.length > 0 ){
  373. this.confirmParam.addressId = data.list[0].addressId
  374. this.postageParam.townId = data.list[0].townId
  375. this.addressData = data.list[0]
  376. this.getFreightData()
  377. }else{
  378. this.addressData = this.addressData
  379. }
  380. })
  381. },
  382. handChangeInputGoodsList(data){//对应供应商的留言信息
  383. this.goodsData = data
  384. },
  385. handleChoiceaInvoiceData(data){//获取发票信息
  386. this.confirmParam.orderInvoice = data
  387. },
  388. hanldFreightFn(data){//显示邮费弹窗
  389. console.log('邮费信息',data)
  390. switch(data.postageFlag){
  391. case 1:
  392. this.hanldFreight = this.freightData.postage
  393. this.hanldFreePostFlag = data.postageFlag
  394. this.freightBeansMoney = data.freightBeansMoney
  395. this.orderShouldPayFee =this.allPrice + this.hanldFreight
  396. this.attributePallPrice()
  397. this.hanldFreightBeans(this.isCheckedBeans)
  398. break
  399. case -1:
  400. this.hanldFreight = 0
  401. this.hanldFreePostFlag = data.postageFlag
  402. this.freightBeansMoney = data.freightBeansMoney
  403. this.orderShouldPayFee = this.allPrice
  404. this.attributePallPrice()
  405. this.hanldFreightBeans(this.isCheckedBeans)
  406. break
  407. }
  408. },
  409. hanldFreightBeans(data){//是否勾选采美豆抵扣
  410. this.isCheckedBeans = data
  411. console.log(this.confirmParam.payInfo)
  412. if(this.isCheckedBeans){
  413. // 判断如果采美豆大于等于运费*100
  414. if( this.freightData.userBeans > 0 ){
  415. this.confirmParam.payInfo.userBeans = this.freightBeansMoney*100
  416. }else{
  417. this.confirmParam.payInfo.userBeans = 0
  418. }
  419. // 计算抵扣后的总价
  420. if(this.hanldFreePostFlag == 1){
  421. // 如果使用了余额 最终价格
  422. if(this.ischecked){
  423. let totalAmount = this.allPrice - this.couponAmount
  424. if(this.userMoney >= totalAmount){
  425. this.orderShouldPayFee = 0.00
  426. this.deductMoney = this.allPrice - this.couponAmount // 当前使用金额等于订单金额
  427. this.surplusMoney = this.userMoney - this.deductMoney // 剩余金额等于余额-当前使用金额
  428. }else{
  429. this.orderShouldPayFee = this.allPrice - this.userMoney - this.couponAmount // 订单最终支付金额等于订单金额-账户余额
  430. this.deductMoney = this.userMoney // 当前使用金额等于总余额
  431. this.surplusMoney = this.userMoney - this.deductMoney // 剩余余额等于总余额-当前使用金额
  432. }
  433. }else{
  434. this.orderShouldPayFee = this.allPrice + this.hanldFreight - this.freightBeansMoney - this.couponAmount
  435. }
  436. console.log('抵扣',this.orderShouldPayFee)
  437. }
  438. }else{// 采美豆不抵扣运费
  439. this.confirmParam.payInfo.userBeans = 0
  440. // 不抵扣时计算总价
  441. if(this.hanldFreePostFlag == 1){
  442. this.attributeHashfreight(this.hanldFreight)
  443. }
  444. }
  445. },
  446. handleChoiceaCouponData(data){// 勾选使用优惠券
  447. console.log('优惠券信息',data)
  448. this.couponAmount = data.couponAmount
  449. this.totalDiscountAmount = this.reducedPrice + this.couponAmount
  450. this.confirmParam.clubCouponId = data.clubCouponId
  451. this.attributePallPrice()
  452. this.hanldFreightBeans(this.isCheckedBeans)
  453. },
  454. checkedBalabce(){//勾选使用余额
  455. if(this.userMoney > 0){
  456. this.ischecked = !this.ischecked
  457. if(this.ischecked){
  458. this.confirmParam.payInfo.balancePayFlag = 1
  459. this.attributePallPrice()
  460. }else{
  461. this.confirmParam.payInfo.balancePayFlag = 0
  462. if(this.hanldFreePostFlag == 1 || this.hanldFreePostFlag == '1'){ //如果是有运费时
  463. if(this.isCheckedBeans){
  464. this.orderShouldPayFee = this.allPrice - this.couponAmount
  465. }else{
  466. this.orderShouldPayFee = this.allPrice+parseInt(this.freightData.postage) - this.couponAmount
  467. }
  468. }else{
  469. this.orderShouldPayFee = this.allPrice - this.couponAmount
  470. }
  471. }
  472. console.log('最终订单支付金额',this.orderShouldPayFee)
  473. console.log('优惠券金额',this.couponAmount)
  474. }else{
  475. return
  476. }
  477. },
  478. attributePallPrice(){// 计算价格
  479. if(this.hanldFreePostFlag == 1 || this.hanldFreePostFlag == '1'){
  480. this.attributeHashfreight(this.freightData.postage)
  481. }else{
  482. this.attributeNofreight()
  483. }
  484. },
  485. attributeNofreight(){// 计算没有邮费的支付价格
  486. if(this.ischecked){
  487. let totalAmount = this.allPrice - this.couponAmount
  488. if(this.userMoney >= totalAmount){
  489. this.orderShouldPayFee = 0.00
  490. this.deductMoney = this.allPrice - this.couponAmount // 当前使用金额等于订单金额
  491. this.surplusMoney = this.userMoney - this.deductMoney // 剩余金额等于余额-当前使用金额
  492. }else{
  493. this.orderShouldPayFee = this.allPrice - this.userMoney - this.couponAmount // 订单最终支付金额等于订单金额-账户余额
  494. this.deductMoney = this.userMoney // 当前使用金额等于总余额
  495. this.surplusMoney = this.userMoney - this.deductMoney // 剩余余额等于总余额-当前使用金额
  496. }
  497. }else{
  498. this.orderShouldPayFee = this.allPrice - this.couponAmount
  499. this.deductMoney = 0.00 // 当前使用
  500. this.surplusMoney = this.userMoney // 剩余余额
  501. }
  502. console.log('最终订单支付金额',this.orderShouldPayFee)
  503. console.log('优惠券金额',this.couponAmount)
  504. },
  505. attributeHashfreight(postage){// 计算需要邮费的支付价格
  506. console.log()
  507. let totalAmount = this.allPrice + parseInt(postage) - this.couponAmount//计算不包邮的价格 总价等于商品价格+邮费
  508. if(this.ischecked){
  509. if(this.userMoney >= totalAmount){// 全部抵扣
  510. this.orderShouldPayFee =0.00
  511. if(this.isCheckedBeans){// 抵扣运费了
  512. this.deductMoney = this.allPrice - this.couponAmount // 当前使用金额等于订单金额
  513. this.surplusMoney = this.userMoney - this.deductMoney // 剩余金额等于余额减去当前使用金额
  514. }else{
  515. this.deductMoney = this.allPrice + parseInt(postage)- this.couponAmount // 当前使用金额等于订单金额+运费金额
  516. this.surplusMoney = this.userMoney - this.deductMoney // 剩余余额等于总余额-当前使用金额
  517. }
  518. }else{// 部分抵扣
  519. if(this.isCheckedBeans){// 抵扣运费了
  520. this.orderShouldPayFee = this.allPrice - this.userMoney - this.couponAmount // 订单最终支付金额等于总订单金额-账户余额-优惠券金额
  521. this.deductMoney = this.userMoney // 当前使用金额等于账户余额
  522. this.surplusMoney = this.userMoney - this.deductMoney // 剩余余额等于账户余额-当前使用金额
  523. }else{
  524. this.orderShouldPayFee = this.allPrice + parseInt(postage) - this.userMoney - this.couponAmount//订单支付金额等于订单金额+运费-账户余额-优惠券
  525. this.deductMoney = this.userMoney // 当前使用金额等于账户余额
  526. this.surplusMoney = this.userMoney - this.deductMoney // 剩余余额等于账户余额-当前使用金额
  527. }
  528. }
  529. }else{
  530. this.orderShouldPayFee = this.allPrice + parseInt(postage) - this.couponAmount
  531. this.deductMoney = 0.00 // 当前使用金额
  532. this.surplusMoney = this.userMoney // 剩余余额
  533. }
  534. console.log('最终订单支付金额',this.orderShouldPayFee)
  535. console.log('优惠券金额',this.couponAmount)
  536. },
  537. orderSubmitMit(){// 提交订单按钮点击事件
  538. if(this.allPrice <1000){
  539. this.showModal = true
  540. this.contentModalText = '采购金额过小,将扣除500采美豆,建议您前往采美旗下“呵呵商城”小程序购买小额商品。' //操作文字提示语句
  541. this.showModalstauts = 1
  542. this.modalButton= [
  543. {
  544. text: '前往呵呵商城',
  545. type: 'gray',
  546. plain: true //是否空心
  547. },
  548. {
  549. text: '继续提交',
  550. customStyle: {
  551. color: '#fff',
  552. bgColor: 'linear-gradient(90deg, #F28F31 0%, #E15616 100%)'
  553. },
  554. plain: false
  555. }
  556. ]
  557. }else{
  558. this.handleClickOrderSubmitMit()
  559. }
  560. },
  561. handleClickOrderSubmitMit(){// 提交订单
  562. if(this.isSubLoading){ return }
  563. if(this.confirmParam.addressId == ''){
  564. this.$util.msg('请先添加收货地址~',2000)
  565. return
  566. }
  567. this.confirmParam.orderInfo = this.goodsData.map(el => {
  568. let productInfo = []
  569. el.cartList.forEach(item => {
  570. productInfo.push({
  571. productId:item.productId,
  572. productNum:item.number,
  573. presentNum:0,
  574. productType:item.giftType
  575. })
  576. })
  577. return {splitCode:el.splitCode,shopId:el.shopId,note:el.note?el.note:'',productInfo:productInfo}
  578. })
  579. this.confirmParam.payInfo.postage = parseInt(this.hanldFreight).toFixed(2)
  580. this.confirmParam.payInfo.postageFlag = parseInt(this.hanldFreePostFlag)
  581. this.confirmParam.payInfo.orderShouldPayFee = this.orderShouldPayFee.toFixed(2)
  582. this.confirmParam.payInfo = JSON.stringify(this.confirmParam.payInfo)
  583. this.confirmParam.orderInfo = JSON.stringify(this.confirmParam.orderInfo)
  584. this.confirmParam.orderInvoice = JSON.stringify(this.confirmParam.orderInvoice)
  585. console.log(this.confirmParam)
  586. this.isSubLoading = true
  587. this.OrderService.CreatedOrderSubmit(this.confirmParam).then(response =>{
  588. let data = response.data
  589. // 友盟埋点收集机构自主提交订单
  590. if(process.env.NODE_ENV != 'development'){
  591. this.$uma.trackEvent('Um_Event_ConfirmOrder', {
  592. Um_Key_PageName: '机构提交订单',
  593. Um_Key_SourcePage: '确认订单',
  594. Um_Key_OrderID:`${data.orderId}`
  595. })
  596. }
  597. if(data.code === 1){
  598. this.submitState ='success'
  599. setTimeout(()=>{
  600. this.isSubLoading = false
  601. },2000)
  602. this.$api.redirectTo(`/pages/user/order/success?data=${JSON.stringify({data:{orderId:data.orderId}})}`)
  603. }else{
  604. this.submitState ='confirm'
  605. this.$util.msg('订单提交成功',3000,true,'success')
  606. setTimeout(()=>{
  607. this.isSubLoading = false
  608. this.$api.redirectTo(`/pages/user/order/order-payment?type=${this.submitState}&orderId=${data.orderId}`)
  609. },3000)
  610. }
  611. }).catch(error =>{
  612. this.isSubLoading = false
  613. this.confirmParam.payInfo = JSON.parse(this.confirmParam.payInfo)
  614. this.confirmParam.orderInfo = JSON.parse(this.confirmParam.orderInfo)
  615. this.confirmParam.orderInvoice = JSON.parse(this.confirmParam.orderInvoice)
  616. if(error.code == -3){// 已提交2个小于1000元的订单提示
  617. this.showModal = true
  618. this.contentModalText = '您已有2个采购金额过小的订单,本次不能再进行采购。建议您前往采美旗下“呵呵商城”小程序购买小额商品。' //操作文字提示语句
  619. this.showModalstauts = 3
  620. this.modalButton=[
  621. {
  622. text: '了解',
  623. type: 'gray',
  624. plain: true //是否空心
  625. },
  626. {
  627. text: '前往呵呵商城',
  628. customStyle: {
  629. color: '#fff',
  630. bgColor: 'linear-gradient(90deg, #F28F31 0%, #E15616 100%)'
  631. },
  632. plain: false
  633. }
  634. ]
  635. }else if(error.code == -4){// 采美豆为负数
  636. this.showModal = true
  637. this.contentModalText = '采美豆不足,不能提交订单。建议您前往采美旗下“呵呵商城”小程序购买小额商品。' //操作文字提示语句
  638. this.showModalstauts = 3
  639. this.modalButton=[
  640. {
  641. text: '了解',
  642. type: 'gray',
  643. plain: true //是否空心
  644. },
  645. {
  646. text: '前往呵呵商城',
  647. customStyle: {
  648. color: '#fff',
  649. bgColor: 'linear-gradient(90deg, #F28F31 0%, #E15616 100%)'
  650. },
  651. plain: false
  652. }
  653. ]
  654. }else{
  655. this.$util.msg(error.msg,3000)
  656. }
  657. })
  658. },
  659. handFreightAlertShow(){//显示邮费弹窗
  660. this.isfreightTip = true
  661. },
  662. handleClickCancel(){// 关闭优惠券弹窗
  663. this.isCouponModel = false
  664. if(this.confirmType == 1){
  665. this.GetProductCreateOrderInfo()
  666. }else{
  667. this.CartCreateOrderInfo()
  668. }
  669. },
  670. handleClick(e){// 采购量过小提示弹窗
  671. if (e.index == 1) {
  672. if( this.showModalstauts == 1){
  673. this.showModal = false
  674. this.handleClickOrderSubmitMit()
  675. }else{
  676. this.showModal = false
  677. this.handleClickHeHeMiniApplet()
  678. }
  679. }else{
  680. if( this.showModalstauts == 1 ){
  681. this.showModal = false
  682. this.handleClickHeHeMiniApplet()
  683. }else{
  684. this.showModal = false
  685. }
  686. }
  687. },
  688. handleClickHeHeMiniApplet(){ // 跳转呵呵商城小程序
  689. uni.navigateToMiniProgram({
  690. appId: 'wx2c3b0a7f343235b1',
  691. path: '/pages/tabBar/index/index',
  692. extraData: {
  693. 'data1': 'test'
  694. },
  695. envVersion: 'develop',
  696. success(res) {
  697. // 打开成功
  698. console.log(res)
  699. }
  700. })
  701. },
  702. hideFreight(){//关闭邮费弹窗
  703. this.isfreightTip = false
  704. },
  705. },
  706. onShow() {
  707. let pages = getCurrentPages()
  708. let currPage = pages[pages.length-1]
  709. if(currPage.data.select =='select'){
  710. this.isAddress = true
  711. let SelectData = uni.getStorageSync('selectAddress')
  712. this.confirmParam.addressId = SelectData.addressId
  713. this.postageParam.townId = SelectData.townId
  714. this.addressData = SelectData
  715. this.getFreightData()
  716. }else{
  717. this.getAddressData()
  718. }
  719. }
  720. }
  721. </script>
  722. <style lang="scss">
  723. page {
  724. height: auto;
  725. background:#F7F7F7;
  726. }
  727. .btn-hover{
  728. background: #FFFFFF;
  729. }
  730. .animation{
  731. /* transition: transform 0.3s ease;*/
  732. transition-property: transform;
  733. transition-duration: 0.3s;
  734. transition-timing-function: ease;
  735. }
  736. .order{
  737. padding-bottom: 134rpx;
  738. }
  739. .invoice-freight{
  740. width: 702rpx;
  741. padding: 0 24rpx;
  742. height: auto;
  743. font-size: $font-size-28;
  744. color: $text-color;
  745. background: #FFFFFF;
  746. float: left;
  747. font-weight: bold;
  748. }
  749. .invoice-balance{
  750. width: 702rpx;
  751. height: auto;
  752. padding:0 24rpx;
  753. background: #FFFFFF;
  754. float: left;
  755. margin-top: 24rpx;
  756. margin-bottom: 24rpx;
  757. .balabce-t{
  758. width: 100%;
  759. height: 86rpx;
  760. line-height: 86rpx;
  761. font-size: $font-size-28;
  762. color: $text-color;
  763. float: left;
  764. .balabce-t-le{
  765. float: left;
  766. font-weight: bold;
  767. }
  768. .balabce-t-ri{
  769. float: right;
  770. display: flex;
  771. align-items: center;
  772. .money{
  773. display: flex;
  774. float: left;
  775. }
  776. .checkbox-box{
  777. display: flex;
  778. width: 60rpx;
  779. float: left;
  780. height: 100%;
  781. font-size: $font-size-24;
  782. .checkbox{
  783. width: 40rpx;
  784. text-align: right;
  785. box-sizing: border-box;
  786. text-align: center;
  787. text-decoration: none;
  788. border-radius: 0;
  789. -webkit-tap-highlight-color: transparent;
  790. overflow: hidden;
  791. color: $color-system;
  792. }
  793. }
  794. }
  795. }
  796. .balabce-b{
  797. width: 100%;
  798. float: left;
  799. overflow: hidden;
  800. .balabce-b-text{
  801. width: 100%;
  802. line-height: 58rpx;
  803. font-size: $font-size-24;
  804. color: #FF2A2A;
  805. text-align: right;
  806. float: right;
  807. }
  808. &.balabce-b--hide {
  809. padding: 0 0;
  810. height: 0px;
  811. line-height: 0px;
  812. }
  813. }
  814. }
  815. .footer{
  816. position: fixed;
  817. left: 0;
  818. bottom: 0;
  819. display: flex;
  820. align-items: center;
  821. width: 100%;
  822. height: 110rpx;
  823. line-height: 110rpx;
  824. justify-content: space-between;
  825. font-size: $font-size-28;
  826. background-color: #FFFFFF;
  827. z-index: 990;
  828. color: $text-color;
  829. .footer-le{
  830. width:570rpx;
  831. height:100%;
  832. float: left;
  833. }
  834. .footer-count{
  835. float: left;
  836. padding-left: 24rpx;
  837. width:180rpx;
  838. box-sizing: border-box;
  839. }
  840. .footer-price{
  841. width:370rpx;
  842. float: right;
  843. text-align: right;
  844. color: $text-color;
  845. padding: 10rpx 20rpx 10rpx 0;
  846. box-sizing: border-box;
  847. .sum-none{
  848. width: 100%;
  849. height: 45rpx;
  850. line-height: 45rpx;
  851. color: $text-color;
  852. float: left;
  853. text-align: right;
  854. .money{
  855. font-size: $font-size-26;
  856. color: #999999;
  857. text-decoration: line-through;
  858. }
  859. .money-sign{
  860. font-size: $font-size-26;
  861. color: #999999;
  862. text-decoration: line-through;
  863. }
  864. .money-reduced{
  865. margin-left: 10rpx;
  866. font-size: $font-size-26;
  867. color:#FF2A2A;
  868. }
  869. }
  870. .sum{
  871. width: 100%;
  872. height: 45rpx;
  873. line-height: 45rpx;
  874. float: left;
  875. &.none{
  876. height: 90rpx;
  877. line-height: 90rpx;
  878. }
  879. .price{
  880. font-size: $font-size-32;
  881. color: #FF2A2A;
  882. }
  883. }
  884. }
  885. .footer-submit{
  886. display:flex;
  887. align-items:center;
  888. justify-content: center;
  889. width: 180rpx;
  890. height: 100%;
  891. box-sizing: border-box;
  892. padding: 15rpx 5rpx;
  893. .btn{
  894. width: 100%;
  895. height: 100%;
  896. color: #FFFFFF;
  897. background:linear-gradient(135deg,rgba(242,143,49,1) 0%,rgba(225,86,22,1) 100%);
  898. font-size: $font-size-26;
  899. text-align: center;
  900. line-height: 80rpx;
  901. border-radius: 40rpx;
  902. &.disabled{
  903. background: #e4e8eb;
  904. color: #999999;
  905. }
  906. }
  907. }
  908. }
  909. .coupon-content-model{
  910. width: 100%;
  911. height: 100%;
  912. background: rgba(0,0,0,.5);
  913. position: fixed;
  914. top: 0;
  915. left: 0;
  916. z-index: 8888;
  917. transition: all 0.4s;
  918. .coupon-alert-content{
  919. width: 600rpx;
  920. height: 612rpx;
  921. position: absolute;
  922. top: 0;
  923. left: 0;
  924. bottom: 0;
  925. right: 0;
  926. margin: auto;
  927. box-sizing: border-box;
  928. padding-top: 92rpx;
  929. .coupon{
  930. width: 600rpx;
  931. height: 522rpx;
  932. background: url(https://static.caimei365.com/app/img/icon/icon-coupon-alertbg@2x.png);
  933. background-size: cover;
  934. box-sizing: border-box;
  935. padding: 230rpx 40rpx 0 40rpx;
  936. .coupon-list{
  937. width: 100%;
  938. height: 147rpx;
  939. margin-bottom: 32rpx;
  940. box-sizing: border-box;
  941. background: url(https://static.caimei365.com/app/img/icon/icon-coupon-bg@2x.png);
  942. background-size: cover;
  943. position: relative;
  944. .list-cell-tags{
  945. display: inline-block;
  946. padding: 0 10rpx;
  947. height: 32rpx;
  948. line-height: 32rpx;
  949. background-color: #f94b4b;
  950. color: #FFFFFF;
  951. font-size: 18rpx;
  952. border-radius: 16rpx 0 16rpx 0;
  953. text-align: center;
  954. position: absolute;
  955. top: 0;
  956. left: 0;
  957. }
  958. .list-cell-le{
  959. width: 154rpx;
  960. height: 100%;
  961. box-sizing: border-box;
  962. padding: 30rpx 0;
  963. float: left;
  964. .coupon-maxMoney{
  965. width: 100%;
  966. height: 54rpx;
  967. line-height: 54rpx;
  968. font-size: 42rpx;
  969. color: #f94b4b;
  970. text-align: center;
  971. margin-top: 10rpx;
  972. .small{
  973. font-size: $font-size-20;
  974. }
  975. }
  976. .coupon-minMoney{
  977. width: 100%;
  978. height: 28rpx;
  979. float: left;
  980. box-sizing: border-box;
  981. padding-left: 24rpx;
  982. .txt{
  983. display: block;
  984. height: 28rpx;
  985. line-height: 28rpx;
  986. font-size: 16rpx;
  987. color: #f94b4b;
  988. text-align: center;
  989. padding: 0 5rpx;
  990. background-color: #fff1eb;
  991. border-radius: 4rpx;
  992. float: left;
  993. }
  994. }
  995. }
  996. .list-cell-ri{
  997. width: 366rpx;
  998. height: 100%;
  999. box-sizing: border-box;
  1000. padding:30rpx 20rpx;
  1001. float: left;
  1002. .list-cell-top{
  1003. width: 100%;
  1004. height: 64rpx;
  1005. line-height: 64rpx;
  1006. font-size: $font-size-26;
  1007. color: #333333;
  1008. float: left;
  1009. text-overflow:ellipsis;
  1010. display: -webkit-box;
  1011. word-break: break-all;
  1012. -webkit-box-orient: vertical;
  1013. -webkit-line-clamp: 1;
  1014. overflow: hidden;
  1015. }
  1016. .list-cell-time{
  1017. width: 100%;
  1018. height: 28rpx;
  1019. line-height: 28rpx;
  1020. text-align: left;
  1021. font-size: $font-size-20;
  1022. color: #999999;
  1023. }
  1024. }
  1025. }
  1026. .coupon-btn{
  1027. width: 100%;
  1028. height: 78rpx;
  1029. background: url(https://static.caimei365.com/app/img/icon/icon-coupon-alertbtnbg@2x.png);
  1030. background-size: cover;
  1031. line-height: 78rpx;
  1032. text-align: center;
  1033. color: #FFFFFF;
  1034. font-size: $font-size-36;
  1035. }
  1036. }
  1037. }
  1038. }
  1039. </style>