create-order.vue 19 KB

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