create-order.vue 18 KB

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