create-order.vue 15 KB

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