create-order.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  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"></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. import { queryAddressList } from "@/api/cart.js"
  62. import { sellerSettlement,createOrderSubmit,getOrderPostage } from "@/api/seller.js"
  63. export default {
  64. components:{
  65. choiceAddress,
  66. goodsList,
  67. invoiceTent,
  68. freight,
  69. freightAlert,
  70. modalLayer
  71. },
  72. data() {
  73. return {
  74. modallayer:false,
  75. orderID:0,
  76. clubID:'',
  77. productIds:'', //获取上一级页面商品信息
  78. productCount:'', //获取上一级页面商品数量
  79. classifyIDS:'', //获取上一级页面商品分类
  80. serviceProviderId:'', //协销ID
  81. cartType:1, //购买类型(1购物车提交,2直接购买提交)
  82. submitState:'', //提交状态
  83. balanceDeductionFlag:2, //勾选余额的状态(1使用,2不使用)
  84. allCount:1, //订单提交总数量
  85. payAllPrice:0.00, //订单提交总金额
  86. allPrice:0.00, //订单总金额
  87. surplusMoney:0.00, //显示勾选后的剩余抵扣
  88. userMoney:0.00, //显示可使用余额
  89. deductMoney:0.00, //显示已使用的余额
  90. addressID:'', //地址ID
  91. townID:'', //区ID
  92. isRequest:false, //是否加载完成渲染子组件
  93. isAddress:false, //是否加载完成地址
  94. isfreightTip:false, //控制邮费弹窗
  95. ischecked:false, //是否勾选余额
  96. addressData:{}, //初始化地址信息
  97. goodsData:[], //初始化商品信息
  98. invoiceData:{}, //初始化发票信息
  99. freightData:{}, //邮费数据
  100. orderInfo:[], //提交的商品信息
  101. isIphoneX:this.$store.state.isIphoneX
  102. }
  103. },
  104. onLoad(option){//商品数据
  105. let data = JSON.parse(option.data);
  106. this.allPrice = data.data.allPrice;
  107. this.allCount = data.data.allCount;
  108. this.payAllPrice = this.allPrice;
  109. this.clubId = data.data.clubId
  110. this.productCount = data.data.productCount
  111. this.productIds = data.data.productID
  112. this.getInitCrearOrder();
  113. },
  114. methods: {
  115. getInitCrearOrder(option){//获取订单商品信息&&邮费信息&&发票信息
  116. this.$api.getStorage().then((resolve) =>{
  117. this.serviceProviderId = resolve.serviceProviderID
  118. let params ={clubId:this.clubId,serviceProviderId:this.serviceProviderId,count:this.productCount,productIds:this.productIds}
  119. sellerSettlement(params).then(response =>{
  120. let resData = response.data
  121. this.isRequest = true
  122. this.goodsData = resData.shopList
  123. this.userMoney = resData.userMoney
  124. this.freightData = {freePostFlag:resData.freight}
  125. this.invoiceData = resData.invoice
  126. this.goodsData = resData.shopList
  127. }).catch(response =>{
  128. this.$util.msg(response.msg,2000)
  129. })
  130. })
  131. },
  132. getAddressData(){//获取地址信息
  133. this.$api.getStorage().then((resolve) =>{
  134. queryAddressList({pageNum:1,pageSize:1,userID:resolve.userID}).then(response =>{
  135. this.isAddress = true
  136. this.addressData = {}
  137. if(response.data.results != ''){
  138. this.addressID = response.data.results[0].addressID;
  139. this.townID = response.data.results[0].townID;
  140. this.addressData = response.data.results[0];
  141. }else{
  142. this.addressData = this.addressData;
  143. }
  144. })
  145. })
  146. },
  147. handChangeInputGoodsList(data){//对应供应商的留言信息
  148. this.goodsData = data;
  149. // console.log(this.goodsData)
  150. },
  151. submit(){//提交订单
  152. if(this.addressID == ''){
  153. this.$util.msg('请先添加收货地址~',2000)
  154. return
  155. }
  156. this.orderInfo = this.goodsData.map(el => {
  157. let productInfo = [];
  158. el.productsList.forEach(item => {
  159. productInfo.push({
  160. productId:item.productID,
  161. productNum:item.productCount
  162. })
  163. })
  164. if(el.note == null){
  165. el.note = ''
  166. }else{
  167. el.note = el.note
  168. }
  169. return {shopId:el.shopID,note:el.note,productInfo:productInfo}
  170. })
  171. let orderInvoice;
  172. if(this.invoiceData != null){
  173. orderInvoice= Object.assign(this.invoiceData,'',{type:0})
  174. }else{
  175. orderInvoice ={
  176. type:0,
  177. invoiceTitleType:'',
  178. invoiceTitle:'',
  179. corporationTaxNum:'',
  180. registeredAddress:'',
  181. registeredPhone:'',
  182. bankAccountNo:'',
  183. openBank:'',
  184. }
  185. }
  186. let param = {
  187. orderSource:6,
  188. userId:this.userID,
  189. cartType:this.cartType,
  190. addressId:this.addressID,
  191. orderInfo:this.orderInfo,
  192. balanceDeductionFlag:this.balanceDeductionFlag,
  193. orderShouldPayFee:this.payAllPrice,
  194. orderInvoice:orderInvoice
  195. }
  196. this.modalLayer = true;
  197. // console.log(JSON.stringify(param))
  198. createOrderSubmit({'params':JSON.stringify(param)}).then(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,2000);
  214. }
  215. }).catch(response =>{
  216. })
  217. },
  218. getPostage(){
  219. this.$api.getStorage().then((resolve) =>{
  220. let params ={
  221. userId:resolve.userID,
  222. productIds:this.productIds,
  223. totalPrice:this.allPrice,
  224. townID:this.addressData.townID
  225. }
  226. getOrderPostage(params).then(response =>{
  227. console.log(response)
  228. })
  229. })
  230. },
  231. handFreightAlertShow(){//显示邮费弹窗
  232. this.isfreightTip = true;
  233. },
  234. hideFreight(){//关闭邮费弹窗
  235. this.isfreightTip = false;
  236. },
  237. checkedBalabce(){//勾选使用余额
  238. if(this.userMoney == 0){
  239. return
  240. }else{
  241. this.ischecked = !this.ischecked
  242. if(this.ischecked){
  243. this.balanceDeductionFlag =1
  244. if(this.userMoney>this.payAllPrice){
  245. this.payAllPrice =0.00
  246. this.deductMoney = this.allPrice //勾选后使用抵余额
  247. this.surplusMoney = this.userMoney - this.deductMoney //勾选后的剩余抵扣
  248. }else{
  249. this.payAllPrice = this.allPrice - this.userMoney //勾选后的总价
  250. this.deductMoney = this.userMoney //勾选后使用抵余额
  251. this.surplusMoney = this.userMoney - this.deductMoney //勾选后的剩余抵扣
  252. }
  253. }else{
  254. this.payAllPrice = this.allPrice
  255. this.balanceDeductionFlag = 2
  256. }
  257. }
  258. }
  259. },
  260. onShow() {
  261. // this.addressID = ''
  262. let pages = getCurrentPages();
  263. let currPage = pages[pages.length-1];
  264. if(currPage.data.select =='select'){
  265. this.isAddress = true
  266. let SelectData = uni.getStorageSync('selectAddress');
  267. this.addressID = SelectData.addressID;
  268. this.addressData = SelectData
  269. this.getPostage()
  270. }else{
  271. this.getAddressData()
  272. }
  273. }
  274. }
  275. </script>
  276. <style lang="scss">
  277. page {
  278. height: auto;
  279. background:#F7F7F7;
  280. }
  281. .btn-hover{
  282. background: #FFFFFF;
  283. }
  284. .animation{
  285. /* transition: transform 0.3s ease;*/
  286. transition-property: transform;
  287. transition-duration: 0.3s;
  288. transition-timing-function: ease;
  289. }
  290. .order{
  291. padding-bottom: 134rpx;
  292. }
  293. .invoice-freight{
  294. width: 702rpx;
  295. padding: 0 24rpx;
  296. height: 86rpx;
  297. line-height: 86rpx;
  298. font-size: $font-size-28;
  299. color: $text-color;
  300. background: #FFFFFF;
  301. float: left;
  302. font-weight: bold;
  303. .freight-left{
  304. float: left;
  305. .icon-yunfeishuoming{
  306. height: 100%;
  307. padding: 0 15rpx;
  308. color: $color-system;
  309. font-weight: normal;
  310. }
  311. }
  312. .freight-right{
  313. float: right;
  314. color: #2A81FF;
  315. }
  316. }
  317. .invoice-balance{
  318. width: 702rpx;
  319. height: auto;
  320. padding:0 24rpx;
  321. background: #FFFFFF;
  322. float: left;
  323. margin-top: 24rpx;
  324. margin-bottom: 24rpx;
  325. .balabce-t{
  326. width: 100%;
  327. height: 86rpx;
  328. line-height: 86rpx;
  329. font-size: $font-size-28;
  330. color: $text-color;
  331. float: left;
  332. .balabce-t-le{
  333. float: left;
  334. font-weight: bold;
  335. }
  336. .balabce-t-ri{
  337. float: right;
  338. display: flex;
  339. align-items: center;
  340. .money{
  341. display: flex;
  342. float: left;
  343. }
  344. .checkbox-box{
  345. display: flex;
  346. width: 60rpx;
  347. float: left;
  348. height: 100%;
  349. font-size: $font-size-24;
  350. .checkbox{
  351. width: 40rpx;
  352. text-align: right;
  353. box-sizing: border-box;
  354. text-align: center;
  355. text-decoration: none;
  356. border-radius: 0;
  357. -webkit-tap-highlight-color: transparent;
  358. overflow: hidden;
  359. color: $color-system;
  360. }
  361. }
  362. }
  363. }
  364. .balabce-b{
  365. width: 100%;
  366. float: left;
  367. overflow: hidden;
  368. .balabce-b-text{
  369. width: 100%;
  370. line-height: 58rpx;
  371. font-size: $font-size-24;
  372. color: #FF2A2A;
  373. text-align: right;
  374. float: right;
  375. }
  376. &.balabce-b--hide {
  377. padding: 0 0;
  378. height: 0px;
  379. line-height: 0px;
  380. }
  381. }
  382. }
  383. .footer{
  384. position: fixed;
  385. left: 0;
  386. bottom: 0;
  387. z-index: 995;
  388. display: flex;
  389. align-items: center;
  390. width: 100%;
  391. height: 110rpx;
  392. line-height: 110rpx;
  393. justify-content: space-between;
  394. font-size: $font-size-28;
  395. background-color: #FFFFFF;
  396. z-index: 998;
  397. color: $text-color;
  398. .footer-le{
  399. width:550rpx;
  400. height:100%;
  401. float: left;
  402. }
  403. .footer-count{
  404. float: left;
  405. padding-left: 24rpx;
  406. font-weight: bold;
  407. }
  408. .footer-price{
  409. float: right;
  410. text-align: right;
  411. color: $text-color;
  412. font-weight: bold;
  413. padding-right: 24rpx;
  414. .price{
  415. font-size: $font-size-32;
  416. color: #FF2A2A;
  417. }
  418. }
  419. .footer-submit{
  420. display:flex;
  421. align-items:center;
  422. justify-content: center;
  423. width: 200rpx;
  424. height: 100%;
  425. color: #FFFFFF;
  426. background:linear-gradient(135deg,rgba(242,143,49,1) 0%,rgba(225,86,22,1) 100%);
  427. }
  428. }
  429. </style>