create-order.vue 18 KB

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