create-order.vue 18 KB

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