create-order.vue 15 KB

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