create-order.vue 12 KB

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