create-order.vue 12 KB

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