create-order.vue 13 KB

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