create-order.vue 18 KB

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