create-order.vue 17 KB

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