create-order.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  1. <template>
  2. <view class="container order clearfix" :style="{paddingBottom :isIphoneX ? '170rpx' : '134rpx'}">
  3. <!-- 透明模态层 -->
  4. <modal-layer v-if='modallayer'></modal-layer>
  5. <!-- 地址选择 -->
  6. <choice-address ref="choiceAddress" v-if="isAddress" :addressData="addressData"></choice-address>
  7. <!-- 商品 -->
  8. <seller-goodsList ref='goods' v-if="isRequest" :goodsData="goodsData" @handleGoodList="handChangeInputGoodsList"></seller-goodsList>
  9. <!-- 发票信息 -->
  10. <seller-invoice ref="invoice"
  11. v-if="isRequest && isDepositFlg"
  12. :invoiceDatas="invoiceData"
  13. @handleChoiceaInvoice="handleChoiceaInvoiceData">
  14. </seller-invoice>
  15. <!-- 运费 -->
  16. <seller-freight ref="freight"
  17. v-if="isFreight && isDepositFlg"
  18. :freightDatas="freightData"
  19. @handleChoiceaFreight="handleChoiceaFreightData"
  20. @showFreightAlert="handFreightAlertShow">
  21. </seller-freight>
  22. <freight-alert v-if="isfreightTip" ref="csPhone"></freight-alert>
  23. <!-- 底部 -->
  24. <view class="footer" :style="{paddingBottom :isIphoneX ? '68rpx' : '0rpx'}">
  25. <view class="footer-le">
  26. <view class="footer-count">
  27. <text>共{{allCount}}件商品</text>
  28. </view>
  29. <view class="footer-price">
  30. <view class="sum-none" v-if="reducedPrice > 0">
  31. <text class="money-sign">¥</text>
  32. <text class="money">{{ totalOriginalPrice | NumFormat }}</text>
  33. <text class="money-reduced">减<text>¥{{ reducedPrice | NumFormat}}</text></text>
  34. </view>
  35. <view class="sum" :class="reducedPrice == 0 ? 'none' : ''">总价:<text class="price">¥{{payAllPrice | NumFormat}}</text></view>
  36. </view>
  37. </view>
  38. <view class="footer-submit" @click.stop="orderSubmitMit">
  39. <view class="btn">提交订单</view>
  40. </view>
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. import choiceAddress from '@/components/cm-module/creatOrder/sellerAddress'
  46. import sellerGoodsList from '@/components/cm-module/creatOrder/sellerGoodsList'
  47. import sellerInvoice from '@/components/cm-module/creatOrder/sellerInvoice'
  48. import sellerFreight from '@/components/cm-module/creatOrder/sellerFreight'
  49. import freightAlert from '@/components/cm-module/modelAlert/freightAlert.vue'
  50. import modalLayer from "@/components/modal-layer"
  51. export default {
  52. components:{
  53. choiceAddress,
  54. sellerGoodsList,
  55. sellerInvoice,
  56. sellerFreight,
  57. freightAlert,
  58. modalLayer,
  59. },
  60. data() {
  61. return {
  62. modallayer:false,
  63. orderID:0,
  64. clubID:'',
  65. productIds:'', //获取上一级页面商品信息
  66. productCount:'', //获取上一级页面商品数量
  67. classifyIDS:'', //获取上一级页面商品分类
  68. serviceProviderId:'', //协销ID
  69. cartType:3, //购买类型(1购物车提交,2直接购买提交,3协销下单)
  70. submitState:'', //提交状态
  71. allCount:1, //订单提交总数量
  72. totalOriginalPrice:0, //订单总原价(划线部分)
  73. reducedPrice:0, //满减金额
  74. payAllPrice:0.00, //订单提交总金额
  75. allPrice:0.00, //订单总金额
  76. addressID:'', //地址ID
  77. townID:'', //区ID
  78. isRequest:false, //是否加载完成渲染子组件
  79. isFreight:false, //是否加载完成渲染子组件
  80. isAddress:false, //是否加载完成地址
  81. isfreightTip:false, //控制邮费弹窗
  82. ischecked:false, //是否勾选余额
  83. addressData:{}, //初始化地址信息
  84. goodsData:[], //初始化商品信息
  85. invoiceData:{type:0}, //初始化发票信息
  86. freightData:{}, //邮费数据
  87. orderInfo:[], //提交的商品信息
  88. payInfo:{}, //订单信息
  89. isIphoneX:this.$store.state.isIphoneX,
  90. clauseId:0,
  91. productsList:[],
  92. }
  93. },
  94. onLoad(option){//商品数据
  95. let data = JSON.parse(option.data);
  96. this.allPrice = data.data.allPrice;
  97. this.allCount = data.data.allCount;
  98. this.payAllPrice = this.allPrice;
  99. this.clubId = data.data.clubId
  100. this.productCount = data.data.productCount
  101. this.productIds = data.data.productID
  102. if(option.type =='prodcut'){
  103. this.getInitProdcutCrearOrder();
  104. }else{
  105. this.getInitCrearOrder();
  106. }
  107. this.$api.getComStorage('orderUserInfo').then((resolve) =>{
  108. this.clubUserId = resolve.userID
  109. })
  110. },
  111. filters:{
  112. NumFormat(value) {//处理金额
  113. return Number(value).toFixed(2);
  114. },
  115. },
  116. methods: {
  117. getInitProdcutCrearOrder(option){//二手下单初始化查询
  118. this.$api.getStorage().then((resolve) =>{
  119. this.serviceProviderId = resolve.serviceProviderID
  120. let params ={clubId:this.clubId,serviceProviderId:this.serviceProviderId,productCount:this.productCount,productId:this.productIds}
  121. this.SellerService.GetSettlementBySencondProduct(params).then(response =>{
  122. let resData = response.data
  123. this.isRequest = true
  124. this.goodsData = resData.shopList
  125. }).catch(error =>{
  126. this.$util.msg(error.msg,2000)
  127. })
  128. })
  129. },
  130. getInitCrearOrder(option){//协销购物车跳转确认订单初始化信息
  131. this.$api.getStorage().then((resolve) =>{
  132. this.serviceProviderId = resolve.serviceProviderID
  133. let params ={clubId:this.clubId,serviceProviderId:this.serviceProviderId,count:this.productCount,productIds:this.productIds}
  134. this.SellerService.SellerSettlement(params).then(response =>{
  135. let data = response.data
  136. let productIds = []
  137. this.isRequest = true
  138. this.goodsData = data.shopList
  139. this.userMoney = data.userMoney
  140. this.reducedPrice = data.reducedPrice
  141. this.totalOriginalPrice = data.reducedPrice + data.totalAmount
  142. this.allPrice = this.payAllPrice = data.totalAmount
  143. }).catch(error =>{
  144. this.$util.msg(error.msg,2000)
  145. })
  146. })
  147. },
  148. getFreightData(){//获取邮费信息
  149. this.$api.getComStorage('orderUserInfo').then((resolve) =>{
  150. let params ={
  151. userId:resolve.userID,
  152. productIds:this.productIds,
  153. totalPrice:this.allPrice,
  154. townId:this.addressData.townID
  155. }
  156. this.OrderService.GetOrderPostage(params).then(response =>{
  157. this.isFreight = true
  158. this.freightData = response.data
  159. if(response.data.freePostFlag== 1){
  160. this.payAllPrice = this.allPrice+response.data.freight
  161. }else{
  162. this.payAllPrice = this.allPrice
  163. }
  164. })
  165. })
  166. },
  167. getAddressData(){//获取地址信息
  168. this.$api.getComStorage('orderUserInfo').then((resolve) =>{
  169. this.UserService.QueryAddressList({pageNum:1,pageSize:1,userID:resolve.userID}).then(response =>{
  170. this.isAddress = true
  171. this.addressData = {}
  172. if(response.data.results != ''){
  173. this.addressID = response.data.results[0].addressID;
  174. this.townID = response.data.results[0].townID;
  175. this.addressData = response.data.results[0];
  176. this.getFreightData()
  177. }else{
  178. this.addressData = this.addressData;
  179. }
  180. })
  181. })
  182. },
  183. handChangeInputGoodsList(data){//对应供应商的留言信息
  184. this.goodsData = data;
  185. },
  186. handleChoiceaInvoiceData(data){//获取发票信息
  187. this.invoiceData = data
  188. },
  189. handleChoiceaFreightData(data){//获取运费信息
  190. if(data.freePostFlag == '1'){
  191. this.freightData = data
  192. this.payAllPrice = this.allPrice+parseInt(data.freight)
  193. this.attributePallPrice()
  194. }else{
  195. this.freightData = data
  196. this.payAllPrice = this.allPrice
  197. this.attributePallPrice()
  198. }
  199. },
  200. attributePallPrice(){//计算价格
  201. if(this.freightData.freePostFlag == 1 || this.freightData.freePostFlag == '1'){
  202. this.attributeHashfreight(this.freightData.freight)
  203. }else{
  204. this.attributeNofreight()
  205. }
  206. },
  207. attributeNofreight(){//计算没有邮费的支付价格
  208. if(this.ischecked){
  209. if(this.userMoney>this.payAllPrice){
  210. this.payAllPrice = 0.00
  211. }else{
  212. this.payAllPrice = this.allPrice - this.userMoney //勾选后的总价
  213. }
  214. }else{
  215. this.payAllPrice = this.allPrice;
  216. }
  217. },
  218. attributeHashfreight(freight){//计算需要邮费的支付价格
  219. this.payAllPrice = this.allPrice+parseInt(freight)//计算不包邮的价格 总价等于商品价格+邮费
  220. if(this.ischecked){
  221. if(this.userMoney>this.payAllPrice){ //余额大于支付金额
  222. this.payAllPrice =0.00
  223. }else{
  224. this.payAllPrice = this.allPrice+parseInt(freight) - this.userMoney //勾选后的总价
  225. }
  226. }else{
  227. this.payAllPrice = this.allPrice+parseInt(freight)
  228. }
  229. },
  230. orderSubmitMit(){//提交订单
  231. if(this.addressID == ''){
  232. this.$util.msg('请先添加收货地址~',2000)
  233. return
  234. }
  235. // 处理商品信息及留言
  236. this.orderInfo = this.goodsData.map(el => {
  237. let productInfo = [];
  238. el.productsList.forEach(item => {
  239. productInfo.push({
  240. productId:item.productID,
  241. productNum:item.productCount,
  242. productType:item.giftType ? Number(item.giftType) : 0,
  243. presentNum:0,
  244. })
  245. })
  246. return {shopId:el.shopID,note:el.note?el.note:'',productInfo:productInfo}
  247. })
  248. //订单信息
  249. this.payInfo = {
  250. orderShouldPayFee:this.payAllPrice.toFixed(2),//提交的总价
  251. balancePayFlag:this.balanceDeductionFlag,//余额抵扣的状态
  252. freight:parseInt(this.freightData.freight).toFixed(2),//邮费
  253. freePostFlag:parseInt(this.freightData.freePostFlag),//运费形式
  254. clauseId:this.clauseId,//售后条款
  255. rebateFlag:this.rebateFlag,//返佣
  256. }
  257. console.log(this.payInfo)
  258. let params = {
  259. orderSource:6, //提交来源
  260. clubUserId:this.clubUserId, //机构UserID
  261. cartType:this.cartType, //从购物车提交
  262. serviceProviderId:this.serviceProviderId,//帮下单协销ID
  263. addressId:this.addressID, //地址ID
  264. orderInfo:this.orderInfo, //商品信息
  265. payInfo:this.payInfo, //订单信息
  266. orderInvoice:this.invoiceData //发票信息
  267. }
  268. this.modalLayer = true;
  269. if(this.rebateFlag == 1){
  270. this.$util.modal('','确定该订单为返佣订单吗?点击确定按钮继续提交订单','确定','取消',true,() =>{
  271. this.SellerService.SellerCreateOrderSubmit({'params':JSON.stringify(params)}).then(response =>{
  272. const data = response.data;
  273. if(data.code === '1'){
  274. this.$util.msg('支付成功',2000,true,'success')
  275. setTimeout(() =>{
  276. this.$api.redirectTo(`/seller/pages/order/order-details?type=cash&orderID=${data.orderID}`)
  277. },2000)
  278. }else{
  279. this.$util.msg('订单提交成功',2000,true,'success')
  280. setTimeout(()=>{
  281. this.$api.redirectTo(`/seller/pages/order/order-details?type=cash&orderID=${data.orderID}`)
  282. },2000)
  283. }
  284. }).catch(error =>{
  285. this.$util.msg(error.msg,2000);
  286. })
  287. })
  288. return
  289. }else{
  290. this.SellerService.SellerCreateOrderSubmit({'params':JSON.stringify(params)}).then(response =>{
  291. const data = response.data;
  292. if(data.code === '1'){
  293. this.$util.msg('支付成功',2000,true,'success')
  294. setTimeout(() =>{
  295. this.$api.redirectTo(`/seller/pages/order/order-details?type=cash&orderID=${data.orderID}`)
  296. },2000)
  297. }else{
  298. this.$util.msg('订单提交成功',2000,true,'success')
  299. setTimeout(()=>{
  300. this.$api.redirectTo(`/seller/pages/order/order-details?type=cash&orderID=${data.orderID}`)
  301. },2000)
  302. }
  303. }).catch(error =>{
  304. this.$util.msg(error.msg,2000);
  305. })
  306. }
  307. },
  308. handFreightAlertShow(){//显示邮费弹窗
  309. this.isfreightTip = true;
  310. },
  311. hideFreight(){//关闭邮费弹窗
  312. this.isfreightTip = false;
  313. },
  314. },
  315. onShow() {
  316. // this.addressID = ''
  317. let pages = getCurrentPages();
  318. let currPage = pages[pages.length-1];
  319. if(currPage.data.select =='select'){
  320. this.isAddress = true
  321. let SelectData = uni.getStorageSync('selectAddress');
  322. this.addressID = SelectData.addressID;
  323. this.addressData = SelectData
  324. this.getFreightData()
  325. }else{
  326. this.getAddressData()
  327. }
  328. }
  329. }
  330. </script>
  331. <style lang="scss">
  332. page {
  333. height: auto;
  334. background:#F7F7F7;
  335. }
  336. .btn-hover{
  337. background: #FFFFFF;
  338. }
  339. .animation{
  340. /* transition: transform 0.3s ease;*/
  341. transition-property: transform;
  342. transition-duration: 0.3s;
  343. transition-timing-function: ease;
  344. }
  345. .invoice-freight{
  346. width: 702rpx;
  347. padding: 0 24rpx;
  348. height: 86rpx;
  349. line-height: 86rpx;
  350. font-size: $font-size-28;
  351. color: $text-color;
  352. background: #FFFFFF;
  353. float: left;
  354. font-weight: bold;
  355. .freight-left{
  356. float: left;
  357. .icon-yunfeishuoming{
  358. height: 100%;
  359. padding: 0 15rpx;
  360. color: $color-system;
  361. font-weight: normal;
  362. }
  363. }
  364. .freight-right{
  365. float: right;
  366. color: #2A81FF;
  367. }
  368. }
  369. .invoice-balance{
  370. width: 702rpx;
  371. height: auto;
  372. padding:0 24rpx;
  373. background: #FFFFFF;
  374. float: left;
  375. margin-top: 24rpx;
  376. margin-bottom: 24rpx;
  377. .balabce-t{
  378. width: 100%;
  379. height: 86rpx;
  380. line-height: 86rpx;
  381. font-size: $font-size-28;
  382. color: $text-color;
  383. float: left;
  384. .balabce-t-le{
  385. float: left;
  386. font-weight: bold;
  387. }
  388. .balabce-t-ri{
  389. float: right;
  390. display: flex;
  391. align-items: center;
  392. .money{
  393. display: flex;
  394. float: left;
  395. }
  396. .checkbox-box{
  397. display: flex;
  398. width: 60rpx;
  399. float: left;
  400. height: 100%;
  401. font-size: $font-size-24;
  402. .checkbox{
  403. width: 40rpx;
  404. text-align: right;
  405. box-sizing: border-box;
  406. text-align: center;
  407. text-decoration: none;
  408. border-radius: 0;
  409. -webkit-tap-highlight-color: transparent;
  410. overflow: hidden;
  411. color: $color-system;
  412. padding: 5rpx;
  413. }
  414. }
  415. }
  416. }
  417. .balabce-b{
  418. width: 100%;
  419. float: left;
  420. overflow: hidden;
  421. .balabce-b-text{
  422. width: 100%;
  423. line-height: 58rpx;
  424. font-size: $font-size-24;
  425. color: #FF2A2A;
  426. text-align: right;
  427. float: right;
  428. }
  429. &.balabce-b--hide {
  430. padding: 0 0;
  431. height: 0px;
  432. line-height: 0px;
  433. }
  434. }
  435. }
  436. .footer{
  437. position: fixed;
  438. left: 0;
  439. bottom: 0;
  440. z-index: 995;
  441. display: flex;
  442. align-items: center;
  443. width: 100%;
  444. height: 110rpx;
  445. line-height: 110rpx;
  446. justify-content: space-between;
  447. font-size: $font-size-28;
  448. background-color: #FFFFFF;
  449. z-index: 998;
  450. color: $text-color;
  451. .footer-le{
  452. width:570rpx;
  453. height:100%;
  454. float: left;
  455. }
  456. .footer-count{
  457. float: left;
  458. padding-left: 24rpx;
  459. width:190rpx;
  460. box-sizing: border-box;
  461. font-size: $font-size-26;
  462. }
  463. .footer-price{
  464. width:370rpx;
  465. float: right;
  466. text-align: right;
  467. color: $text-color;
  468. padding: 10rpx 20rpx 10rpx 0;
  469. box-sizing: border-box;
  470. .sum-none{
  471. width: 100%;
  472. height: 45rpx;
  473. line-height: 45rpx;
  474. color: $text-color;
  475. float: left;
  476. text-align: right;
  477. .money{
  478. font-size: $font-size-26;
  479. color: #999999;
  480. text-decoration: line-through;
  481. }
  482. .money-sign{
  483. font-size: $font-size-26;
  484. color: #999999;
  485. text-decoration: line-through;
  486. }
  487. .money-reduced{
  488. margin-left: 10rpx;
  489. font-size: $font-size-26;
  490. color:$color-system;
  491. }
  492. }
  493. .sum{
  494. width: 100%;
  495. height: 45rpx;
  496. line-height: 45rpx;
  497. float: left;
  498. &.none{
  499. height: 90rpx;
  500. line-height: 90rpx;
  501. }
  502. .price{
  503. font-size: $font-size-32;
  504. color: #FF2A2A;
  505. }
  506. }
  507. }
  508. .footer-submit{
  509. display:flex;
  510. align-items:center;
  511. justify-content: center;
  512. width: 180rpx;
  513. height: 100%;
  514. box-sizing: border-box;
  515. padding: 15rpx 5rpx;
  516. .btn{
  517. width: 100%;
  518. height: 100%;
  519. color: #FFFFFF;
  520. background:linear-gradient(135deg,rgba(242,143,49,1) 0%,rgba(225,86,22,1) 100%);
  521. font-size: $font-size-26;
  522. text-align: center;
  523. line-height: 80rpx;
  524. border-radius: 40rpx;
  525. }
  526. }
  527. }
  528. .Rebate{
  529. width: 702rpx;
  530. height: auto;
  531. padding: 0 24rpx;
  532. background: #FFFFFF;
  533. float: left;
  534. margin-bottom: 24rpx;
  535. margin-bottom: 24rpx;
  536. line-height: 86rpx;
  537. .rebate-title{
  538. float: left;
  539. font-weight: bold;
  540. color: #333333;
  541. font-size: $font-size-28;
  542. }
  543. .iconfont{
  544. float: right;
  545. color: #b2b2b2;
  546. font-size: 40rpx;
  547. &.icon-yixuanze{
  548. color: $color-system;
  549. }
  550. }
  551. }
  552. </style>