create-order.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  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. this.payAllPrice = this.allPrice;
  176. },
  177. attributeHashfreight(freight){//计算需要邮费的支付价格
  178. this.payAllPrice = this.allPrice+parseInt(freight)//计算不包邮的价格 总价等于商品价格+邮费
  179. },
  180. orderSubmitMit(){//提交订单
  181. if(this.addressId == ''){
  182. this.$util.msg('请先添加收货地址~',2000)
  183. return
  184. }
  185. // 处理商品信息及留言
  186. this.orderInfo = this.goodsData.map(el => {
  187. let productInfo = [];
  188. el.productList.forEach(item => {
  189. productInfo.push({
  190. productId:item.productId,
  191. productNum:item.productCount,
  192. productType:item.productType ? Number(item.productType) : 0,
  193. presentNum:0,
  194. })
  195. })
  196. return {shopId:el.shopId,note:el.note?el.note:'',productInfo:productInfo}
  197. })
  198. //订单信息
  199. this.payInfo = {
  200. orderShouldPayFee:this.payAllPrice.toFixed(2),//提交的总价
  201. balancePayFlag:this.balanceDeductionFlag,//余额抵扣的状态
  202. freight:parseInt(this.freightData.freight).toFixed(2),//邮费
  203. freePostFlag:parseInt(this.freightData.freePostFlag)//运费形式
  204. }
  205. console.log(this.payInfo)
  206. let params = {
  207. clubUserId:this.userId,
  208. addressId:this.addressId, //地址ID
  209. orderInfo:this.orderInfo, //商品信息
  210. payInfo:this.payInfo, //订单信息
  211. orderInvoice:this.invoiceData //发票信息
  212. }
  213. this.modalLayer = true;
  214. this.OrderService.CreatedOrderSubmit(params).then(response =>{
  215. const data = response.data;
  216. this.$util.msg('订单提交成功',2000,true,'success')
  217. setTimeout(()=>{
  218. this.$api.redirectTo(`/pages/user/order/success?orderId=${data.orderId}`)
  219. },2000)
  220. }).catch(error =>{
  221. this.$util.msg(error.msg,2000);
  222. })
  223. },
  224. handFreightAlertShow(){//显示邮费弹窗
  225. this.isfreightTip = true;
  226. },
  227. hideFreight(){//关闭邮费弹窗
  228. this.isfreightTip = false;
  229. },
  230. },
  231. onShow() {
  232. // this.addressId = ''
  233. let pages = getCurrentPages();
  234. let currPage = pages[pages.length-1];
  235. if(currPage.data.select =='select'){
  236. this.isAddress = true
  237. let SelectData = uni.getStorageSync('selectAddress');
  238. this.addressId = SelectData.addressId;
  239. this.addressData = SelectData
  240. this.getFreightData()
  241. }else{
  242. this.getAddressData()
  243. }
  244. }
  245. }
  246. </script>
  247. <style lang="scss">
  248. page {
  249. height: auto;
  250. background:#F7F7F7;
  251. }
  252. .btn-hover{
  253. background: #FFFFFF;
  254. }
  255. .animation{
  256. /* transition: transform 0.3s ease;*/
  257. transition-property: transform;
  258. transition-duration: 0.3s;
  259. transition-timing-function: ease;
  260. }
  261. .invoice-freight{
  262. width: 702rpx;
  263. padding: 0 24rpx;
  264. height: 86rpx;
  265. line-height: 86rpx;
  266. font-size: $font-size-28;
  267. color: $text-color;
  268. background: #FFFFFF;
  269. float: left;
  270. font-weight: bold;
  271. .freight-left{
  272. float: left;
  273. .icon-yunfeishuoming{
  274. height: 100%;
  275. padding: 0 15rpx;
  276. color: $color-system;
  277. font-weight: normal;
  278. }
  279. }
  280. .freight-right{
  281. float: right;
  282. color: #2A81FF;
  283. }
  284. }
  285. .invoice-balance{
  286. width: 702rpx;
  287. height: auto;
  288. padding:0 24rpx;
  289. background: #FFFFFF;
  290. float: left;
  291. margin-top: 24rpx;
  292. margin-bottom: 24rpx;
  293. .balabce-t{
  294. width: 100%;
  295. height: 86rpx;
  296. line-height: 86rpx;
  297. font-size: $font-size-28;
  298. color: $text-color;
  299. float: left;
  300. .balabce-t-le{
  301. float: left;
  302. font-weight: bold;
  303. }
  304. .balabce-t-ri{
  305. float: right;
  306. display: flex;
  307. align-items: center;
  308. .money{
  309. display: flex;
  310. float: left;
  311. }
  312. .checkbox-box{
  313. display: flex;
  314. width: 60rpx;
  315. float: left;
  316. height: 100%;
  317. font-size: $font-size-24;
  318. .checkbox{
  319. width: 40rpx;
  320. text-align: right;
  321. box-sizing: border-box;
  322. text-align: center;
  323. text-decoration: none;
  324. border-radius: 0;
  325. -webkit-tap-highlight-color: transparent;
  326. overflow: hidden;
  327. color: $color-system;
  328. padding: 5rpx;
  329. }
  330. }
  331. }
  332. }
  333. .balabce-b{
  334. width: 100%;
  335. float: left;
  336. overflow: hidden;
  337. .balabce-b-text{
  338. width: 100%;
  339. line-height: 58rpx;
  340. font-size: $font-size-24;
  341. color: #FF2A2A;
  342. text-align: right;
  343. float: right;
  344. }
  345. &.balabce-b--hide {
  346. padding: 0 0;
  347. height: 0px;
  348. line-height: 0px;
  349. }
  350. }
  351. }
  352. .footer{
  353. position: fixed;
  354. left: 0;
  355. bottom: 0;
  356. z-index: 995;
  357. display: flex;
  358. align-items: center;
  359. width: 100%;
  360. height: 110rpx;
  361. line-height: 110rpx;
  362. justify-content: space-between;
  363. font-size: $font-size-28;
  364. background-color: #FFFFFF;
  365. z-index: 998;
  366. color: $text-color;
  367. .footer-le{
  368. width:570rpx;
  369. height:100%;
  370. float: left;
  371. }
  372. .footer-count{
  373. float: left;
  374. padding-left: 24rpx;
  375. width:190rpx;
  376. box-sizing: border-box;
  377. font-size: $font-size-26;
  378. }
  379. .footer-price{
  380. float: right;
  381. text-align: right;
  382. color: $text-color;
  383. padding: 10rpx 20rpx 10rpx 0;
  384. box-sizing: border-box;
  385. .sum-none{
  386. width: 100%;
  387. height: 45rpx;
  388. line-height: 45rpx;
  389. color: $text-color;
  390. float: left;
  391. text-align: right;
  392. .money{
  393. font-size: $font-size-26;
  394. color: #999999;
  395. text-decoration: line-through;
  396. }
  397. .money-sign{
  398. font-size: $font-size-26;
  399. color: #999999;
  400. text-decoration: line-through;
  401. }
  402. .money-reduced{
  403. margin-left: 10rpx;
  404. font-size: $font-size-26;
  405. color:$color-system;
  406. }
  407. }
  408. .sum{
  409. width: 100%;
  410. height: 45rpx;
  411. line-height: 45rpx;
  412. float: left;
  413. &.none{
  414. height: 90rpx;
  415. line-height: 90rpx;
  416. }
  417. .price{
  418. font-size: $font-size-32;
  419. color: #FF2A2A;
  420. }
  421. }
  422. }
  423. .footer-submit{
  424. display:flex;
  425. align-items:center;
  426. justify-content: center;
  427. width: 200rpx;
  428. height: 100%;
  429. box-sizing: border-box;
  430. padding: 15rpx 5rpx;
  431. .btn{
  432. width: 100%;
  433. height: 100%;
  434. color: #FFFFFF;
  435. background:#ff2a2a;
  436. font-size: $font-size-26;
  437. text-align: center;
  438. line-height: 80rpx;
  439. border-radius: 40rpx;
  440. }
  441. }
  442. }
  443. .Rebate{
  444. width: 702rpx;
  445. height: auto;
  446. padding: 0 24rpx;
  447. background: #FFFFFF;
  448. float: left;
  449. margin-bottom: 24rpx;
  450. margin-bottom: 24rpx;
  451. line-height: 86rpx;
  452. .rebate-title{
  453. float: left;
  454. font-weight: bold;
  455. color: #333333;
  456. font-size: $font-size-28;
  457. }
  458. .iconfont{
  459. float: right;
  460. color: #b2b2b2;
  461. font-size: 40rpx;
  462. &.icon-yixuanze{
  463. color: $color-system;
  464. }
  465. }
  466. }
  467. </style>