create-order.vue 17 KB

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