create-order.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  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" :style="{paddingBottom :isIphoneX ? '68rpx' : '0rpx'}">
  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. isIphoneX:this.$store.state.isIphoneX
  99. }
  100. },
  101. onLoad(option){//商品数据
  102. let data = JSON.parse(option.data);
  103. this.allPrice = data.data.allPrice;
  104. this.allCount = data.data.allCount;
  105. this.payAllPrice = this.allPrice;
  106. // console.log(data)
  107. if(option.type =='prodcut'){
  108. this.cartType = 2
  109. this.productCount = data.data.productCount
  110. this.productIDs = data.data.id
  111. this.classifyIDS = data.data.classifyID
  112. }else{
  113. this.cartType = 1
  114. this.productCount = data.data.productCount
  115. this.productIDs = data.data.id
  116. this.classifyIDS = data.data.classifyID
  117. }
  118. this.getInitCrearOrder(option);
  119. this.getAddressData()
  120. },
  121. methods: {
  122. getInitCrearOrder(option){//获取订单商品信息&&邮费信息&&发票信息
  123. this.$api.getStorage().then((resolve) =>{
  124. this.userID = resolve.userID
  125. let params ={
  126. userId:this.userID,
  127. count:this.productCount,
  128. organizeID:this.userOrganizeID,
  129. classifyIDS:this.classifyIDS,
  130. productIDs:this.productIDs
  131. }
  132. this.$api.lodingGet('/order/confirm',params,
  133. response => {
  134. // console.log(response)
  135. let resData = response.data;
  136. this.isRequest = true
  137. this.goodsData = resData.shopList;
  138. this.userMoney = resData.userMoney
  139. this.freightData = {freePostFlag:resData.freight,cellPhone:resData.cellPhone}
  140. this.invoiceData = resData.invoice
  141. this.goodsData = resData.shopList
  142. }
  143. )
  144. })
  145. },
  146. getAddressData(){//获取地址信息
  147. this.$api.getStorage().then((resolve) =>{
  148. this.userID = resolve.userID
  149. this.$api.lodingGet('/personal/findAddress',{index:1,pageSize:1,userID:this.userID},
  150. response => {
  151. this.isAddress = true
  152. this.addressData = {}
  153. if(response.results != ''){
  154. this.addressID = response.results[0].addressID;
  155. this.addressData = response.results[0];
  156. }else{
  157. this.addressData = this.addressData;
  158. }
  159. }
  160. )
  161. })
  162. },
  163. handChangeInputGoodsList(data){//对应供应商的留言信息
  164. this.goodsData = data;
  165. // console.log(this.goodsData)
  166. },
  167. submit(){//提交订单
  168. if(this.addressID == ''){
  169. this.$util.msg('请先添加收货地址~',3000);
  170. return
  171. }
  172. this.orderInfo = this.goodsData.map(el => {
  173. let productInfo = [];
  174. el.productsList.forEach(item => {
  175. productInfo.push({
  176. productId:item.id,
  177. productNum:item.productCount
  178. })
  179. })
  180. if(el.note == null){
  181. el.note = ''
  182. }else{
  183. el.note = el.note
  184. }
  185. return {shopId:el.shopID,note:el.note,productInfo:productInfo}
  186. })
  187. let param = {
  188. userId:this.userID,
  189. organizeID:this.userOrganizeID,
  190. cartType:this.cartType,
  191. addressID:this.addressID,
  192. orderInfo:this.orderInfo,
  193. balanceDeductionFlag:this.balanceDeductionFlag,
  194. orderShouldPayFee:this.payAllPrice,
  195. }
  196. this.modalLayer = true;
  197. // console.log(JSON.stringify(param))
  198. this.$api.lodingGet('/order/submitOrder',{'params':JSON.stringify(param)},
  199. response => {
  200. if(response.code === '1'){
  201. this.submitState ='success'
  202. let data = {orderID:response.data.orderID}
  203. this.$api.navigateTo(`/pages/user/order/order-cashier?type=${this.submitState}&data=${JSON.stringify({data:data})}`)
  204. }else if(response.code === '2'){
  205. this.submitState ='nosuccess'
  206. let data = {
  207. orderID:response.data.orderID,
  208. orderNo:response.data.orderNo,
  209. orderMark:response.data.orderMark,
  210. payableAmount:response.data.payableAmount
  211. }
  212. this.$api.navigateTo(`/pages/user/order/order-cashier?type=${this.submitState}&data=${JSON.stringify({data:data})}`)
  213. }else{
  214. this.$util.msg(response.msg,3000);
  215. }
  216. }
  217. )
  218. },
  219. handFreightAlertShow(){//显示邮费弹窗
  220. this.isfreightTip = true;
  221. this.cellPhone = this.freightData.cellPhone;
  222. },
  223. hideFreight(){//关闭邮费弹窗
  224. this.isfreightTip = false;
  225. },
  226. checkedBalabce(){//勾选使用余额
  227. if(this.userMoney == 0){
  228. return
  229. }else{
  230. this.ischecked = !this.ischecked
  231. if(this.ischecked){
  232. this.balanceDeductionFlag =1
  233. if(this.userMoney>this.payAllPrice){
  234. this.payAllPrice =0.00
  235. this.deductMoney = this.allPrice //勾选后使用抵余额
  236. this.surplusMoney = this.userMoney - this.deductMoney //勾选后的剩余抵扣
  237. }else{
  238. this.payAllPrice = this.allPrice - this.userMoney //勾选后的总价
  239. this.deductMoney = this.userMoney //勾选后使用抵余额
  240. this.surplusMoney = this.userMoney - this.deductMoney //勾选后的剩余抵扣
  241. }
  242. }else{
  243. this.payAllPrice = this.allPrice
  244. this.balanceDeductionFlag = 2
  245. }
  246. }
  247. }
  248. },
  249. onShow() {
  250. // this.addressID = ''
  251. let pages = getCurrentPages();
  252. let currPage = pages[pages.length-1];
  253. if(currPage.data.select =='select'){
  254. this.isAddress = true
  255. let SelectData = uni.getStorageSync('selectAddress');
  256. this.addressID = SelectData.addressID;
  257. this.addressData = SelectData
  258. }else{
  259. this.getAddressData()
  260. }
  261. }
  262. }
  263. </script>
  264. <style lang="scss">
  265. page {
  266. height: auto;
  267. background:#F7F7F7;
  268. }
  269. .btn-hover{
  270. background: #FFFFFF;
  271. }
  272. .animation{
  273. /* transition: transform 0.3s ease;*/
  274. transition-property: transform;
  275. transition-duration: 0.3s;
  276. transition-timing-function: ease;
  277. }
  278. .order{
  279. padding-bottom: 134rpx;
  280. }
  281. .invoice-freight{
  282. width: 702rpx;
  283. padding: 0 24rpx;
  284. height: 86rpx;
  285. line-height: 86rpx;
  286. font-size: $font-size-base;
  287. color: $text-color;
  288. background: #FFFFFF;
  289. float: left;
  290. font-weight: bold;
  291. .freight-left{
  292. float: left;
  293. .icon-yunfeishuoming{
  294. height: 100%;
  295. padding: 0 15rpx;
  296. color: $color-system;
  297. font-weight: normal;
  298. }
  299. }
  300. .freight-right{
  301. float: right;
  302. color: #2A81FF;
  303. }
  304. }
  305. .freight-alert{
  306. width: 100%;
  307. height: 100%;
  308. background: rgba(0,0,0,.5);
  309. position: fixed;
  310. top: 0;
  311. left: 0;
  312. z-index: 8888;
  313. transition: all 0.4s;
  314. &.none{
  315. display: none;
  316. }
  317. &.show{
  318. display: block;
  319. }
  320. .content{
  321. width: 518rpx;
  322. height: 420rpx;
  323. position: absolute;
  324. background: $bg-color;
  325. left: 0;
  326. right: 0;
  327. bottom: 0;
  328. top: 0;
  329. margin: auto;
  330. .text-content{
  331. width: 448rpx;
  332. height: 264rpx;
  333. padding: 35rpx;
  334. float: left;
  335. .title{
  336. line-height: 40rpx;
  337. font-size: $font-size-base;
  338. color: $text-color;
  339. text-align: center;
  340. font-weight: bold;
  341. margin-bottom: 32rpx;
  342. }
  343. .text{
  344. line-height: 36rpx;
  345. font-size: $font-size-sb;
  346. color: $text-color;
  347. text-align: justify;
  348. margin-top: 22rpx;
  349. }
  350. .tel{
  351. line-height: 36rpx;
  352. font-size: $font-size-sb;
  353. color: $text-color;
  354. text-align: justify;
  355. margin-top: 22rpx;
  356. font-weight: bold;
  357. .txt{
  358. margin-left: 10rpx;
  359. }
  360. }
  361. }
  362. .btn{
  363. width: 100%;
  364. height: 88rpx;
  365. float: left;
  366. background: #000000;
  367. line-height: 88rpx;
  368. font-size: $font-size-base;
  369. text-align: center;
  370. color: #FFFFFF;
  371. border-radius: 0;
  372. padding: 0;
  373. }
  374. }
  375. }
  376. .invoice-balance{
  377. width: 702rpx;
  378. height: auto;
  379. padding:0 24rpx;
  380. background: #FFFFFF;
  381. float: left;
  382. margin-top: 24rpx;
  383. margin-bottom: 24rpx;
  384. .balabce-t{
  385. width: 100%;
  386. height: 86rpx;
  387. line-height: 86rpx;
  388. font-size: $font-size-base;
  389. color: $text-color;
  390. float: left;
  391. .balabce-t-le{
  392. float: left;
  393. font-weight: bold;
  394. }
  395. .balabce-t-ri{
  396. float: right;
  397. display: flex;
  398. align-items: center;
  399. .money{
  400. display: flex;
  401. float: left;
  402. }
  403. .checkbox-box{
  404. display: flex;
  405. width: 60rpx;
  406. float: left;
  407. height: 100%;
  408. font-size: $font-size-sm;
  409. .checkbox{
  410. width: 40rpx;
  411. text-align: right;
  412. box-sizing: border-box;
  413. text-align: center;
  414. text-decoration: none;
  415. border-radius: 0;
  416. -webkit-tap-highlight-color: transparent;
  417. overflow: hidden;
  418. }
  419. }
  420. }
  421. }
  422. .balabce-b{
  423. width: 100%;
  424. float: left;
  425. overflow: hidden;
  426. .balabce-b-text{
  427. width: 100%;
  428. line-height: 58rpx;
  429. font-size: $font-size-sm;
  430. color: #FF2A2A;
  431. text-align: right;
  432. float: right;
  433. }
  434. &.balabce-b--hide {
  435. padding: 0 0;
  436. height: 0px;
  437. line-height: 0px;
  438. }
  439. }
  440. }
  441. .footer{
  442. position: fixed;
  443. left: 0;
  444. bottom: 0;
  445. z-index: 995;
  446. display: flex;
  447. align-items: center;
  448. width: 100%;
  449. height: 110rpx;
  450. line-height: 110rpx;
  451. justify-content: space-between;
  452. font-size: $font-size-base;
  453. background-color: #FFFFFF;
  454. z-index: 998;
  455. color: $text-color;
  456. .footer-le{
  457. width:550rpx;
  458. height:100%;
  459. float: left;
  460. }
  461. .footer-count{
  462. float: left;
  463. padding-left: 24rpx;
  464. font-weight: bold;
  465. }
  466. .footer-price{
  467. float: right;
  468. text-align: right;
  469. color: $text-color;
  470. font-weight: bold;
  471. padding-right: 24rpx;
  472. .price{
  473. font-size: $font-size-lg;
  474. color: #FF2A2A;
  475. }
  476. }
  477. .footer-submit{
  478. display:flex;
  479. align-items:center;
  480. justify-content: center;
  481. width: 200rpx;
  482. height: 100%;
  483. color: #FFFFFF;
  484. background:linear-gradient(135deg,rgba(242,143,49,1) 0%,rgba(225,86,22,1) 100%);
  485. }
  486. }
  487. </style>