create-order.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047
  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. if(data.onlinePayFlag === 1){
  609. this.$api.redirectTo(`/pages/user/order/order-payunder?orderId=${data.orderId}`)
  610. }else{
  611. this.$api.redirectTo(`/pages/user/order/order-pay-list?orderId=${data.orderId}`)
  612. }
  613. },3000)
  614. }
  615. }).catch(error =>{
  616. this.isSubLoading = false
  617. this.confirmParam.payInfo = JSON.parse(this.confirmParam.payInfo)
  618. this.confirmParam.orderInfo = JSON.parse(this.confirmParam.orderInfo)
  619. this.confirmParam.orderInvoice = JSON.parse(this.confirmParam.orderInvoice)
  620. if(error.code == -3){// 已提交2个小于1000元的订单提示
  621. this.showModal = true
  622. this.contentModalText = '您已有2个采购金额过小的订单,本次不能再进行采购。建议您前往采美旗下“呵呵商城”小程序购买小额商品。' //操作文字提示语句
  623. this.showModalstauts = 3
  624. this.modalButton=[
  625. {
  626. text: '了解',
  627. type: 'gray',
  628. plain: true //是否空心
  629. },
  630. {
  631. text: '前往呵呵商城',
  632. customStyle: {
  633. color: '#fff',
  634. bgColor: 'linear-gradient(90deg, #F28F31 0%, #E15616 100%)'
  635. },
  636. plain: false
  637. }
  638. ]
  639. }else if(error.code == -4){// 采美豆为负数
  640. this.showModal = true
  641. this.contentModalText = '采美豆不足,不能提交订单。建议您前往采美旗下“呵呵商城”小程序购买小额商品。' //操作文字提示语句
  642. this.showModalstauts = 3
  643. this.modalButton=[
  644. {
  645. text: '了解',
  646. type: 'gray',
  647. plain: true //是否空心
  648. },
  649. {
  650. text: '前往呵呵商城',
  651. customStyle: {
  652. color: '#fff',
  653. bgColor: 'linear-gradient(90deg, #F28F31 0%, #E15616 100%)'
  654. },
  655. plain: false
  656. }
  657. ]
  658. }else{
  659. this.$util.msg(error.msg,3000)
  660. }
  661. })
  662. },
  663. handFreightAlertShow(){//显示邮费弹窗
  664. this.isfreightTip = true
  665. },
  666. handleClickCancel(){// 关闭优惠券弹窗
  667. this.isCouponModel = false
  668. if(this.confirmType == 1){
  669. this.GetProductCreateOrderInfo()
  670. }else{
  671. this.CartCreateOrderInfo()
  672. }
  673. },
  674. handleClick(e){// 采购量过小提示弹窗
  675. if (e.index == 1) {
  676. if( this.showModalstauts == 1){
  677. this.showModal = false
  678. this.handleClickOrderSubmitMit()
  679. }else{
  680. this.showModal = false
  681. this.handleClickHeHeMiniApplet()
  682. }
  683. }else{
  684. if( this.showModalstauts == 1 ){
  685. this.showModal = false
  686. this.handleClickHeHeMiniApplet()
  687. }else{
  688. this.showModal = false
  689. }
  690. }
  691. },
  692. handleClickHeHeMiniApplet(){ // 跳转呵呵商城小程序
  693. uni.navigateToMiniProgram({
  694. appId: 'wx2c3b0a7f343235b1',
  695. path: '/pages/tabBar/index/index',
  696. extraData: {
  697. 'data1': 'test'
  698. },
  699. envVersion: 'develop',
  700. success(res) {
  701. // 打开成功
  702. console.log(res)
  703. }
  704. })
  705. },
  706. hideFreight(){//关闭邮费弹窗
  707. this.isfreightTip = false
  708. },
  709. },
  710. onShow() {
  711. let pages = getCurrentPages()
  712. let currPage = pages[pages.length-1]
  713. if(currPage.data.select =='select'){
  714. this.isAddress = true
  715. let SelectData = uni.getStorageSync('selectAddress')
  716. this.confirmParam.addressId = SelectData.addressId
  717. this.postageParam.townId = SelectData.townId
  718. this.addressData = SelectData
  719. this.getFreightData()
  720. }else{
  721. this.getAddressData()
  722. }
  723. }
  724. }
  725. </script>
  726. <style lang="scss">
  727. page {
  728. height: auto;
  729. background:#F7F7F7;
  730. }
  731. .btn-hover{
  732. background: #FFFFFF;
  733. }
  734. .animation{
  735. /* transition: transform 0.3s ease;*/
  736. transition-property: transform;
  737. transition-duration: 0.3s;
  738. transition-timing-function: ease;
  739. }
  740. .order{
  741. padding-bottom: 134rpx;
  742. }
  743. .invoice-freight{
  744. width: 702rpx;
  745. padding: 0 24rpx;
  746. height: auto;
  747. font-size: $font-size-28;
  748. color: $text-color;
  749. background: #FFFFFF;
  750. float: left;
  751. font-weight: bold;
  752. }
  753. .invoice-balance{
  754. width: 702rpx;
  755. height: auto;
  756. padding:0 24rpx;
  757. background: #FFFFFF;
  758. float: left;
  759. margin-top: 24rpx;
  760. margin-bottom: 24rpx;
  761. .balabce-t{
  762. width: 100%;
  763. height: 86rpx;
  764. line-height: 86rpx;
  765. font-size: $font-size-28;
  766. color: $text-color;
  767. float: left;
  768. .balabce-t-le{
  769. float: left;
  770. font-weight: bold;
  771. }
  772. .balabce-t-ri{
  773. float: right;
  774. display: flex;
  775. align-items: center;
  776. .money{
  777. display: flex;
  778. float: left;
  779. }
  780. .checkbox-box{
  781. display: flex;
  782. width: 60rpx;
  783. float: left;
  784. height: 100%;
  785. font-size: $font-size-24;
  786. .checkbox{
  787. width: 40rpx;
  788. text-align: right;
  789. box-sizing: border-box;
  790. text-align: center;
  791. text-decoration: none;
  792. border-radius: 0;
  793. -webkit-tap-highlight-color: transparent;
  794. overflow: hidden;
  795. color: $color-system;
  796. }
  797. }
  798. }
  799. }
  800. .balabce-b{
  801. width: 100%;
  802. float: left;
  803. overflow: hidden;
  804. .balabce-b-text{
  805. width: 100%;
  806. line-height: 58rpx;
  807. font-size: $font-size-24;
  808. color: #FF2A2A;
  809. text-align: right;
  810. float: right;
  811. }
  812. &.balabce-b--hide {
  813. padding: 0 0;
  814. height: 0px;
  815. line-height: 0px;
  816. }
  817. }
  818. }
  819. .footer{
  820. position: fixed;
  821. left: 0;
  822. bottom: 0;
  823. display: flex;
  824. align-items: center;
  825. width: 100%;
  826. height: 110rpx;
  827. line-height: 110rpx;
  828. justify-content: space-between;
  829. font-size: $font-size-28;
  830. background-color: #FFFFFF;
  831. z-index: 990;
  832. color: $text-color;
  833. .footer-le{
  834. width:570rpx;
  835. height:100%;
  836. float: left;
  837. }
  838. .footer-count{
  839. float: left;
  840. padding-left: 24rpx;
  841. width:180rpx;
  842. box-sizing: border-box;
  843. }
  844. .footer-price{
  845. width:370rpx;
  846. float: right;
  847. text-align: right;
  848. color: $text-color;
  849. padding: 10rpx 20rpx 10rpx 0;
  850. box-sizing: border-box;
  851. .sum-none{
  852. width: 100%;
  853. height: 45rpx;
  854. line-height: 45rpx;
  855. color: $text-color;
  856. float: left;
  857. text-align: right;
  858. .money{
  859. font-size: $font-size-26;
  860. color: #999999;
  861. text-decoration: line-through;
  862. }
  863. .money-sign{
  864. font-size: $font-size-26;
  865. color: #999999;
  866. text-decoration: line-through;
  867. }
  868. .money-reduced{
  869. margin-left: 10rpx;
  870. font-size: $font-size-26;
  871. color:#FF2A2A;
  872. }
  873. }
  874. .sum{
  875. width: 100%;
  876. height: 45rpx;
  877. line-height: 45rpx;
  878. float: left;
  879. &.none{
  880. height: 90rpx;
  881. line-height: 90rpx;
  882. }
  883. .price{
  884. font-size: $font-size-32;
  885. color: #FF2A2A;
  886. }
  887. }
  888. }
  889. .footer-submit{
  890. display:flex;
  891. align-items:center;
  892. justify-content: center;
  893. width: 180rpx;
  894. height: 100%;
  895. box-sizing: border-box;
  896. padding: 15rpx 5rpx;
  897. .btn{
  898. width: 100%;
  899. height: 100%;
  900. color: #FFFFFF;
  901. background:linear-gradient(135deg,rgba(242,143,49,1) 0%,rgba(225,86,22,1) 100%);
  902. font-size: $font-size-26;
  903. text-align: center;
  904. line-height: 80rpx;
  905. border-radius: 40rpx;
  906. &.disabled{
  907. background: #e4e8eb;
  908. color: #999999;
  909. }
  910. }
  911. }
  912. }
  913. .coupon-content-model{
  914. width: 100%;
  915. height: 100%;
  916. background: rgba(0,0,0,.5);
  917. position: fixed;
  918. top: 0;
  919. left: 0;
  920. z-index: 8888;
  921. transition: all 0.4s;
  922. .coupon-alert-content{
  923. width: 600rpx;
  924. height: 612rpx;
  925. position: absolute;
  926. top: 0;
  927. left: 0;
  928. bottom: 0;
  929. right: 0;
  930. margin: auto;
  931. box-sizing: border-box;
  932. padding-top: 92rpx;
  933. .coupon{
  934. width: 600rpx;
  935. height: 522rpx;
  936. background: url(https://static.caimei365.com/app/img/icon/icon-coupon-alertbg@2x.png);
  937. background-size: cover;
  938. box-sizing: border-box;
  939. padding: 230rpx 40rpx 0 40rpx;
  940. .coupon-list{
  941. width: 100%;
  942. height: 147rpx;
  943. margin-bottom: 32rpx;
  944. box-sizing: border-box;
  945. background: url(https://static.caimei365.com/app/img/icon/icon-coupon-bg@2x.png);
  946. background-size: cover;
  947. position: relative;
  948. .list-cell-tags{
  949. display: inline-block;
  950. padding: 0 10rpx;
  951. height: 32rpx;
  952. line-height: 32rpx;
  953. background-color: #f94b4b;
  954. color: #FFFFFF;
  955. font-size: 18rpx;
  956. border-radius: 16rpx 0 16rpx 0;
  957. text-align: center;
  958. position: absolute;
  959. top: 0;
  960. left: 0;
  961. }
  962. .list-cell-le{
  963. width: 154rpx;
  964. height: 100%;
  965. box-sizing: border-box;
  966. padding: 30rpx 0;
  967. float: left;
  968. .coupon-maxMoney{
  969. width: 100%;
  970. height: 54rpx;
  971. line-height: 54rpx;
  972. font-size: 42rpx;
  973. color: #f94b4b;
  974. text-align: center;
  975. margin-top: 10rpx;
  976. .small{
  977. font-size: $font-size-20;
  978. }
  979. }
  980. .coupon-minMoney{
  981. width: 100%;
  982. height: 28rpx;
  983. float: left;
  984. box-sizing: border-box;
  985. padding-left: 24rpx;
  986. .txt{
  987. display: block;
  988. height: 28rpx;
  989. line-height: 28rpx;
  990. font-size: 16rpx;
  991. color: #f94b4b;
  992. text-align: center;
  993. padding: 0 5rpx;
  994. background-color: #fff1eb;
  995. border-radius: 4rpx;
  996. float: left;
  997. }
  998. }
  999. }
  1000. .list-cell-ri{
  1001. width: 366rpx;
  1002. height: 100%;
  1003. box-sizing: border-box;
  1004. padding:30rpx 20rpx;
  1005. float: left;
  1006. .list-cell-top{
  1007. width: 100%;
  1008. height: 64rpx;
  1009. line-height: 64rpx;
  1010. font-size: $font-size-26;
  1011. color: #333333;
  1012. float: left;
  1013. text-overflow:ellipsis;
  1014. display: -webkit-box;
  1015. word-break: break-all;
  1016. -webkit-box-orient: vertical;
  1017. -webkit-line-clamp: 1;
  1018. overflow: hidden;
  1019. }
  1020. .list-cell-time{
  1021. width: 100%;
  1022. height: 28rpx;
  1023. line-height: 28rpx;
  1024. text-align: left;
  1025. font-size: $font-size-20;
  1026. color: #999999;
  1027. }
  1028. }
  1029. }
  1030. .coupon-btn{
  1031. width: 100%;
  1032. height: 78rpx;
  1033. background: url(https://static.caimei365.com/app/img/icon/icon-coupon-alertbtnbg@2x.png);
  1034. background-size: cover;
  1035. line-height: 78rpx;
  1036. text-align: center;
  1037. color: #FFFFFF;
  1038. font-size: $font-size-36;
  1039. }
  1040. }
  1041. }
  1042. }
  1043. </style>