create-order.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  1. <template>
  2. <view class="container order clearfix">
  3. <!-- 透明模态层 -->
  4. <modal-layer v-if='modallayer'></modal-layer>
  5. <!-- 地址选择 -->
  6. <choice-address ref="choiceAddress" v-if="isAddress" :addressData="addressData"></choice-address>
  7. <!-- 商品 -->
  8. <goods-list ref='goods' v-if="isRequest" :goodsData="goodsData" @handleGoodList="handChangeInputGoodsList"></goods-list>
  9. <!-- 发票信息 -->
  10. <invoice-tent ref="invoice" v-if="isRequest" :invoiceData="invoiceData"></invoice-tent>
  11. <!-- 运费 -->
  12. <freight ref="freight" v-if="isRequest" :freightData="freightData" @showFreightAlert="handFreightAlertShow"></freight>
  13. <freight-alert v-if="isfreightTip" ref="csPhone" :cellPhone ="cellPhone"></freight-alert>
  14. <!-- 余额抵扣 -->
  15. <view class="invoice-balance">
  16. <view class="balabce-t">
  17. <view class="balabce-t-le">余额抵扣</view>
  18. <view class="balabce-t-ri">
  19. <view class="money">
  20. <text>可用余额:</text>
  21. <text>¥{{userMoney.toFixed(2)}}</text>
  22. </view>
  23. <view class="checkbox-box">
  24. <button class="checkbox iconfont"
  25. hover-class="btn-hover"
  26. v-if="userMoney!=0"
  27. @click.stop="checkedBalabce"
  28. :class="[ischecked ?'icon-gouxuanl':'icon-weigouxuan']"
  29. >
  30. </button>
  31. </view>
  32. </view>
  33. </view>
  34. <view class="balabce-b" :class="{'balabce-b--hide':!ischecked}">
  35. <view class="balabce-b-text animation" :style="{'transform':ischecked?'translateY(0)':'translateY(-50%)','-webkit-transform':ischecked?'translateY(0)':'translateY(-50%)'}">
  36. <text>当前使用:¥{{deductMoney.toFixed(2)}},剩余:¥{{surplusMoney.toFixed(2)}}</text>
  37. </view>
  38. </view>
  39. </view>
  40. <!-- 底部 -->
  41. <view class="footer">
  42. <view class="footer-le">
  43. <view class="footer-count">
  44. <text>共{{allCount}}件商品</text>
  45. </view>
  46. <view class="footer-price">
  47. <text>总价:<text class="price">¥{{payAllPrice.toFixed(2)}}</text></text>
  48. </view>
  49. </view>
  50. <view class="footer-submit" @click.stop="submit">提交订单</view>
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. import choiceAddress from '@/components/module/creatOrder/choiceAddress'
  56. import goodsList from '@/components/module/creatOrder/goodsList'
  57. import invoiceTent from '@/components/module/creatOrder/invoiceTent'
  58. import freight from '@/components/module/creatOrder/freight'
  59. import freightAlert from '@/components/module/modelAlert/freightAlert'
  60. import modalLayer from "@/components/modal-layer"
  61. export default {
  62. components:{
  63. choiceAddress,
  64. goodsList,
  65. invoiceTent,
  66. freight,
  67. freightAlert,
  68. modalLayer
  69. },
  70. data() {
  71. return {
  72. modallayer:false,
  73. orderID:0,
  74. productIDs:'', //获取上一级页面商品信息
  75. productCount:'', //获取上一级页面商品数量
  76. classifyIDS:'', //获取上一级页面商品分类
  77. cellPhone:'0755-88888888',//默认客服电话
  78. userID:'', //用户ID
  79. cartType:'', //购买类型(1购物车提交,2直接购买提交)
  80. submitState:'', //提交状态
  81. balanceDeductionFlag:2, //勾选余额的状态(1使用,2不使用)
  82. allCount:1, //订单提交总数量
  83. payAllPrice:0.00, //订单提交总金额
  84. allPrice:0.00, //订单总金额
  85. surplusMoney:0.00, //显示勾选后的剩余抵扣
  86. userMoney:0.00, //显示可使用余额
  87. deductMoney:0.00, //显示已使用的余额
  88. addressID:'', //地址ID
  89. isRequest:false, //是否加载完成渲染子组件
  90. isAddress:false, //是否加载完成地址
  91. isfreightTip:false, //控制邮费弹窗
  92. ischecked:false, //是否勾选余额
  93. addressData:{}, //初始化地址信息
  94. goodsData:[], //初始化商品信息
  95. invoiceData:{}, //初始化发票信息
  96. freightData:{}, //邮费数据
  97. orderInfo:[], //提交的商品信息
  98. }
  99. },
  100. onLoad(option){//商品数据
  101. let data = JSON.parse(option.data);
  102. this.allPrice = data.data.allPrice;
  103. this.allCount = data.data.allCount;
  104. this.payAllPrice = this.allPrice;
  105. // console.log(data)
  106. if(option.type =='prodcut'){
  107. this.cartType = 2
  108. this.productCount = data.data.productCount
  109. this.productIDs = data.data.id
  110. this.classifyIDS = data.data.classifyID
  111. }else{
  112. this.cartType = 1
  113. this.productCount = data.data.productCount
  114. this.productIDs = data.data.id
  115. this.classifyIDS = data.data.classifyID
  116. }
  117. this.getInitCrearOrder(option);
  118. this.getAddressData()
  119. },
  120. methods: {
  121. getInitCrearOrder(option){//获取订单商品信息&&邮费信息&&发票信息
  122. this.$api.getStorage().then((resolve) =>{
  123. this.userID = resolve.userID
  124. let params ={
  125. userId:this.userID,
  126. count:this.productCount,
  127. organizeID:this.userOrganizeID,
  128. classifyIDS:this.classifyIDS,
  129. productIDs:this.productIDs
  130. }
  131. this.$api.lodingGet('/order/confirm',params,
  132. response => {
  133. // console.log(response)
  134. let resData = response.data;
  135. this.isRequest = true
  136. this.goodsData = resData.shopList;
  137. this.userMoney = resData.userMoney
  138. this.freightData = {freePostFlag:resData.freight,cellPhone:resData.cellPhone}
  139. this.invoiceData = resData.invoice
  140. this.goodsData = resData.shopList
  141. }
  142. )
  143. })
  144. },
  145. getAddressData(){//获取地址信息
  146. this.$api.getStorage().then((resolve) =>{
  147. this.userID = resolve.userID
  148. this.$api.lodingGet('/personal/findAddress',{index:1,pageSize:1,userID:this.userID},
  149. response => {
  150. this.isAddress = true
  151. this.addressData = {}
  152. if(response.results != ''){
  153. this.addressID = response.results[0].addressID;
  154. this.addressData = response.results[0];
  155. }else{
  156. this.addressData = this.addressData;
  157. }
  158. }
  159. )
  160. })
  161. },
  162. handChangeInputGoodsList(data){//对应供应商的留言信息
  163. this.goodsData = data;
  164. // console.log(this.goodsData)
  165. },
  166. submit(){//提交订单
  167. if(this.addressID == ''){
  168. this.$util.msg('请先添加收货地址~',3000);
  169. return
  170. }
  171. this.orderInfo = this.goodsData.map(el => {
  172. let productInfo = [];
  173. el.productsList.forEach(item => {
  174. productInfo.push({
  175. productId:item.id,
  176. productNum:item.productCount
  177. })
  178. })
  179. if(el.note == null){
  180. el.note = ''
  181. }else{
  182. el.note = el.note
  183. }
  184. return {shopId:el.shopID,note:el.note,productInfo:productInfo}
  185. })
  186. let param = {
  187. userId:this.userID,
  188. organizeID:this.userOrganizeID,
  189. cartType:this.cartType,
  190. addressID:this.addressID,
  191. orderInfo:this.orderInfo,
  192. balanceDeductionFlag:this.balanceDeductionFlag,
  193. orderShouldPayFee:this.payAllPrice,
  194. }
  195. this.modalLayer = true;
  196. // console.log(JSON.stringify(param))
  197. this.$api.lodingGet('/order/submitOrder',{'params':JSON.stringify(param)},
  198. response => {
  199. if(response.code === '1'){
  200. this.submitState ='success'
  201. let data = {orderID:response.data.orderID}
  202. this.$api.navigateTo(`/pages/user/order/order-cashier?type=${this.submitState}&data=${JSON.stringify({data:data})}`)
  203. }else if(response.code === '2'){
  204. this.submitState ='nosuccess'
  205. let data = {
  206. orderID:response.data.orderID,
  207. orderNo:response.data.orderNo,
  208. orderMark:response.data.orderMark,
  209. payableAmount:response.data.payableAmount
  210. }
  211. this.$api.navigateTo(`/pages/user/order/order-cashier?type=${this.submitState}&data=${JSON.stringify({data:data})}`)
  212. }else{
  213. this.$util.msg(response.msg,3000);
  214. }
  215. }
  216. )
  217. },
  218. handFreightAlertShow(){//显示邮费弹窗
  219. this.isfreightTip = true;
  220. this.cellPhone = this.freightData.cellPhone;
  221. },
  222. hideFreight(){//关闭邮费弹窗
  223. this.isfreightTip = false;
  224. },
  225. checkedBalabce(){//勾选使用余额
  226. if(this.userMoney == 0){
  227. return
  228. }else{
  229. this.ischecked = !this.ischecked
  230. if(this.ischecked){
  231. this.balanceDeductionFlag =1
  232. if(this.userMoney>this.payAllPrice){
  233. this.payAllPrice =0.00
  234. this.deductMoney = this.allPrice //勾选后使用抵余额
  235. this.surplusMoney = this.userMoney - this.deductMoney //勾选后的剩余抵扣
  236. }else{
  237. this.payAllPrice = this.allPrice - this.userMoney //勾选后的总价
  238. this.deductMoney = this.userMoney //勾选后使用抵余额
  239. this.surplusMoney = this.userMoney - this.deductMoney //勾选后的剩余抵扣
  240. }
  241. }else{
  242. this.payAllPrice = this.allPrice
  243. this.balanceDeductionFlag = 2
  244. }
  245. }
  246. }
  247. },
  248. onShow() {
  249. // this.addressID = ''
  250. let pages = getCurrentPages();
  251. let currPage = pages[pages.length-1];
  252. if(currPage.data.select =='select'){
  253. this.isAddress = true
  254. let SelectData = uni.getStorageSync('selectAddress');
  255. this.addressID = SelectData.addressID;
  256. this.addressData = SelectData
  257. }else{
  258. this.getAddressData()
  259. }
  260. }
  261. }
  262. </script>
  263. <style lang="scss">
  264. page {
  265. height: auto;
  266. background:#F7F7F7;
  267. }
  268. .btn-hover{
  269. background: #FFFFFF;
  270. }
  271. .animation{
  272. /* transition: transform 0.3s ease;*/
  273. transition-property: transform;
  274. transition-duration: 0.3s;
  275. transition-timing-function: ease;
  276. }
  277. .order{
  278. padding-bottom: 134rpx;
  279. }
  280. .invoice-freight{
  281. width: 702rpx;
  282. padding: 0 24rpx;
  283. height: 86rpx;
  284. line-height: 86rpx;
  285. font-size: $font-size-base;
  286. color: $text-color;
  287. background: #FFFFFF;
  288. float: left;
  289. font-weight: bold;
  290. .freight-left{
  291. float: left;
  292. .icon-yunfeishuoming{
  293. height: 100%;
  294. padding: 0 15rpx;
  295. color: $color-system;
  296. font-weight: normal;
  297. }
  298. }
  299. .freight-right{
  300. float: right;
  301. color: #2A81FF;
  302. }
  303. }
  304. .freight-alert{
  305. width: 100%;
  306. height: 100%;
  307. background: rgba(0,0,0,.5);
  308. position: fixed;
  309. top: 0;
  310. left: 0;
  311. z-index: 8888;
  312. transition: all 0.4s;
  313. &.none{
  314. display: none;
  315. }
  316. &.show{
  317. display: block;
  318. }
  319. .content{
  320. width: 518rpx;
  321. height: 420rpx;
  322. position: absolute;
  323. background: $bg-color;
  324. left: 0;
  325. right: 0;
  326. bottom: 0;
  327. top: 0;
  328. margin: auto;
  329. .text-content{
  330. width: 448rpx;
  331. height: 264rpx;
  332. padding: 35rpx;
  333. float: left;
  334. .title{
  335. line-height: 40rpx;
  336. font-size: $font-size-base;
  337. color: $text-color;
  338. text-align: center;
  339. font-weight: bold;
  340. margin-bottom: 32rpx;
  341. }
  342. .text{
  343. line-height: 36rpx;
  344. font-size: $font-size-sb;
  345. color: $text-color;
  346. text-align: justify;
  347. margin-top: 22rpx;
  348. }
  349. .tel{
  350. line-height: 36rpx;
  351. font-size: $font-size-sb;
  352. color: $text-color;
  353. text-align: justify;
  354. margin-top: 22rpx;
  355. font-weight: bold;
  356. .txt{
  357. margin-left: 10rpx;
  358. }
  359. }
  360. }
  361. .btn{
  362. width: 100%;
  363. height: 88rpx;
  364. float: left;
  365. background: #000000;
  366. line-height: 88rpx;
  367. font-size: $font-size-base;
  368. text-align: center;
  369. color: #FFFFFF;
  370. border-radius: 0;
  371. padding: 0;
  372. }
  373. }
  374. }
  375. .invoice-balance{
  376. width: 702rpx;
  377. height: auto;
  378. padding:0 24rpx;
  379. background: #FFFFFF;
  380. float: left;
  381. margin-top: 24rpx;
  382. margin-bottom: 24rpx;
  383. .balabce-t{
  384. width: 100%;
  385. height: 86rpx;
  386. line-height: 86rpx;
  387. font-size: $font-size-base;
  388. color: $text-color;
  389. float: left;
  390. .balabce-t-le{
  391. float: left;
  392. font-weight: bold;
  393. }
  394. .balabce-t-ri{
  395. float: right;
  396. display: flex;
  397. align-items: center;
  398. .money{
  399. display: flex;
  400. float: left;
  401. }
  402. .checkbox-box{
  403. display: flex;
  404. width: 60rpx;
  405. float: left;
  406. height: 100%;
  407. font-size: $font-size-sm;
  408. .checkbox{
  409. width: 40rpx;
  410. text-align: right;
  411. box-sizing: border-box;
  412. text-align: center;
  413. text-decoration: none;
  414. border-radius: 0;
  415. -webkit-tap-highlight-color: transparent;
  416. overflow: hidden;
  417. }
  418. }
  419. }
  420. }
  421. .balabce-b{
  422. width: 100%;
  423. float: left;
  424. overflow: hidden;
  425. .balabce-b-text{
  426. width: 100%;
  427. line-height: 58rpx;
  428. font-size: $font-size-sm;
  429. color: #FF2A2A;
  430. text-align: right;
  431. float: right;
  432. }
  433. &.balabce-b--hide {
  434. padding: 0 0;
  435. height: 0px;
  436. line-height: 0px;
  437. }
  438. }
  439. }
  440. .footer{
  441. position: fixed;
  442. left: 0;
  443. bottom: 0;
  444. z-index: 995;
  445. display: flex;
  446. align-items: center;
  447. width: 100%;
  448. height: 110rpx;
  449. line-height: 110rpx;
  450. justify-content: space-between;
  451. font-size: $font-size-base;
  452. background-color: #FFFFFF;
  453. z-index: 998;
  454. color: $text-color;
  455. .footer-le{
  456. width:550rpx;
  457. height:100%;
  458. float: left;
  459. }
  460. .footer-count{
  461. float: left;
  462. padding-left: 24rpx;
  463. font-weight: bold;
  464. }
  465. .footer-price{
  466. float: right;
  467. text-align: right;
  468. color: $text-color;
  469. font-weight: bold;
  470. padding-right: 24rpx;
  471. .price{
  472. font-size: $font-size-lg;
  473. color: #FF2A2A;
  474. }
  475. }
  476. .footer-submit{
  477. display:flex;
  478. align-items:center;
  479. justify-content: center;
  480. width: 200rpx;
  481. height: 100%;
  482. color: #FFFFFF;
  483. background:linear-gradient(135deg,rgba(242,143,49,1) 0%,rgba(225,86,22,1) 100%);
  484. }
  485. }
  486. </style>