create-order.vue 32 KB

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