create-order.vue 19 KB

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