create-order.vue 13 KB

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