create-order.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  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="isRequest"
  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-none" v-if="reducedPrice>0">
  31. <text class="money-sign">¥</text>
  32. <text class="money">{{ totalOriginalPrice | NumFormat }}</text>
  33. <text class="money-reduced">减<text>¥{{ reducedPrice | NumFormat}}</text></text>
  34. </view>
  35. <view class="sum" :class="reducedPrice == 0 ? 'none' : ''">总价:<text class="price">¥{{payAllPrice | NumFormat}}</text></view>
  36. </view>
  37. </view>
  38. <view class="footer-submit" @click.stop="orderSubmitMit">
  39. <view class="btn">提交订单</view>
  40. </view>
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. import choiceAddress from '@/components/cm-module/creatOrder/address'
  46. import goodsList from '@/components/cm-module/creatOrder/goodsList'
  47. import sellerInvoice from '@/components/cm-module/creatOrder/sellerInvoice'
  48. import sellerFreight from '@/components/cm-module/creatOrder/sellerFreight'
  49. import freightAlert from '@/components/cm-module/modelAlert/freightAlert.vue'
  50. import modalLayer from "@/components/modal-layer"
  51. export default {
  52. components:{
  53. choiceAddress,
  54. goodsList,
  55. sellerInvoice,
  56. sellerFreight,
  57. freightAlert,
  58. modalLayer,
  59. },
  60. data() {
  61. return {
  62. modallayer:false,
  63. orderID:0,
  64. userId:'',
  65. productIds:'', //获取上一级页面商品信息
  66. productCount:'', //获取上一级页面商品数量
  67. classifyIDS:'', //获取上一级页面商品分类
  68. serviceProviderId:'', //协销ID
  69. submitState:'', //提交状态
  70. allCount:1, //订单提交总数量
  71. totalOriginalPrice:0, //订单总原价(划线部分)
  72. reducedPrice:0, //满减金额
  73. payAllPrice:0.00, //订单提交总金额
  74. allPrice:0.00, //订单总金额
  75. addressId:'', //地址ID
  76. townId:'', //区ID
  77. isRequest:false, //是否加载完成渲染子组件
  78. isFreight:false, //是否加载完成渲染子组件
  79. isAddress:false, //是否加载完成地址
  80. isfreightTip:false, //控制邮费弹窗
  81. ischecked:false, //是否勾选余额
  82. addressData:{}, //初始化地址信息
  83. goodsData:[], //初始化商品信息
  84. invoiceData:{type:0}, //初始化发票信息
  85. freightData:{}, //邮费数据
  86. orderInfo:[], //提交的商品信息
  87. payInfo:{}, //订单信息
  88. isIphoneX:this.$store.state.isIphoneX,
  89. clauseId:0,
  90. productsList:[],
  91. }
  92. },
  93. onLoad(option){//商品数据
  94. let data = JSON.parse(option.data);
  95. this.allPrice = data.data.allPrice;
  96. this.payAllPrice = this.totalPrice;
  97. this.userId = data.data.userId
  98. this.productIds = data.data.productID
  99. this.getInitCrearOrder();
  100. },
  101. filters:{
  102. NumFormat(value) {//处理金额
  103. return Number(value).toFixed(2);
  104. },
  105. },
  106. methods: {
  107. getInitCrearOrder(option){//确认订单初始化信息
  108. let params ={userId:this.userId,productIds:this.productIds}
  109. this.OrderService.QueryOrderConfirm(params)
  110. .then(response =>{
  111. let data = response.data
  112. let productIds = []
  113. this.isRequest = true
  114. this.goodsData = data.shopList
  115. this.reducedPrice = data.reducedPrice
  116. this.totalOriginalPrice = data.reducedPrice + data.totalAmount
  117. this.allPrice = this.payAllPrice = data.totalPrice
  118. })
  119. .catch(error =>{
  120. this.$util.msg(error.msg,2000)
  121. })
  122. },
  123. getFreightData(){//获取邮费信息
  124. let params ={
  125. userId:this.userId,
  126. productIds:this.productIds,
  127. totalPrice:this.allPrice,
  128. townId:this.addressData.townId
  129. }
  130. this.OrderService.GetOrderPostage(params).then(response =>{
  131. this.isFreight = true
  132. this.freightData = response.data
  133. if(response.data.freePostFlag== 1){
  134. this.payAllPrice = this.allPrice+response.data.freight
  135. }else{
  136. this.payAllPrice = this.allPrice
  137. }
  138. })
  139. },
  140. getAddressData(){//获取地址信息
  141. this.UserService.QueryAddressList({pageNum:1,pageSize:1,userId:this.userId})
  142. .then(response =>{
  143. this.isAddress = true
  144. this.addressData = {}
  145. if(response.data.list != ''){
  146. this.addressId = response.data.list[0].addressId;
  147. this.townId = response.data.list[0].townId;
  148. this.addressData = response.data.list[0];
  149. // this.getFreightData()
  150. }else{
  151. this.addressData = this.addressData;
  152. }
  153. })
  154. },
  155. handChangeInputGoodsList(data){//对应供应商的留言信息
  156. this.goodsData = data;
  157. },
  158. handleChoiceaInvoiceData(data){//获取发票信息
  159. this.invoiceData = data
  160. },
  161. handleChoiceaFreightData(data){//获取运费信息
  162. if(data.freePostFlag == '1'){
  163. this.freightData = data
  164. this.payAllPrice = this.allPrice+parseInt(data.freight)
  165. this.attributePallPrice()
  166. }else{
  167. this.freightData = data
  168. this.payAllPrice = this.allPrice
  169. this.attributePallPrice()
  170. }
  171. },
  172. attributePallPrice(){//计算价格
  173. if(this.freightData.freePostFlag == 1 || this.freightData.freePostFlag == '1'){
  174. this.attributeHashfreight(this.freightData.freight)
  175. }else{
  176. this.attributeNofreight()
  177. }
  178. },
  179. attributeNofreight(){//计算没有邮费的支付价格
  180. this.payAllPrice = this.allPrice;
  181. },
  182. attributeHashfreight(freight){//计算需要邮费的支付价格
  183. this.payAllPrice = this.allPrice+parseInt(freight)//计算不包邮的价格 总价等于商品价格+邮费
  184. },
  185. orderSubmitMit(){//提交订单
  186. if(this.addressId == ''){
  187. this.$util.msg('请先添加收货地址~',2000)
  188. return
  189. }
  190. // 处理商品信息及留言
  191. this.orderInfo = this.goodsData.map(el => {
  192. let productInfo = [];
  193. el.productList.forEach(item => {
  194. productInfo.push({
  195. productId:item.productId,
  196. productNum:item.productCount,
  197. productType:item.productType ? Number(item.productType) : 0,
  198. presentNum:0,
  199. })
  200. })
  201. return {shopId:el.shopId,note:el.note?el.note:'',productInfo:productInfo}
  202. })
  203. //订单信息
  204. this.payInfo = {
  205. orderShouldPayFee:this.payAllPrice.toFixed(2),//提交的总价
  206. balancePayFlag:this.balanceDeductionFlag,//余额抵扣的状态
  207. freight:0,//邮费
  208. freePostFlag:-1//运费形式
  209. }
  210. console.log(this.payInfo)
  211. let params = {
  212. clubUserId:this.userId,
  213. addressId:this.addressId, //地址ID
  214. orderInfo:this.orderInfo, //商品信息
  215. payInfo:this.payInfo, //订单信息
  216. orderInvoice:this.invoiceData //发票信息
  217. }
  218. this.modalLayer = true;
  219. this.OrderService.CreatedOrderSubmit(params).then(response =>{
  220. const data = response.data;
  221. this.$util.msg('订单提交成功',2000,true,'success')
  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:190rpx;
  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. .sum-none{
  391. width: 100%;
  392. height: 45rpx;
  393. line-height: 45rpx;
  394. color: $text-color;
  395. float: left;
  396. text-align: right;
  397. .money{
  398. font-size: $font-size-26;
  399. color: #999999;
  400. text-decoration: line-through;
  401. }
  402. .money-sign{
  403. font-size: $font-size-26;
  404. color: #999999;
  405. text-decoration: line-through;
  406. }
  407. .money-reduced{
  408. margin-left: 10rpx;
  409. font-size: $font-size-26;
  410. color:$color-system;
  411. }
  412. }
  413. .sum{
  414. width: 100%;
  415. height: 45rpx;
  416. line-height: 45rpx;
  417. float: left;
  418. &.none{
  419. height: 90rpx;
  420. line-height: 90rpx;
  421. }
  422. .price{
  423. font-size: $font-size-32;
  424. color: #FF2A2A;
  425. }
  426. }
  427. }
  428. .footer-submit{
  429. display:flex;
  430. align-items:center;
  431. justify-content: center;
  432. width: 200rpx;
  433. height: 100%;
  434. box-sizing: border-box;
  435. padding: 15rpx 5rpx;
  436. .btn{
  437. width: 100%;
  438. height: 100%;
  439. color: #FFFFFF;
  440. background:#ff2a2a;
  441. font-size: $font-size-26;
  442. text-align: center;
  443. line-height: 80rpx;
  444. border-radius: 40rpx;
  445. }
  446. }
  447. }
  448. .Rebate{
  449. width: 702rpx;
  450. height: auto;
  451. padding: 0 24rpx;
  452. background: #FFFFFF;
  453. float: left;
  454. margin-bottom: 24rpx;
  455. margin-bottom: 24rpx;
  456. line-height: 86rpx;
  457. .rebate-title{
  458. float: left;
  459. font-weight: bold;
  460. color: #333333;
  461. font-size: $font-size-28;
  462. }
  463. .iconfont{
  464. float: right;
  465. color: #b2b2b2;
  466. font-size: 40rpx;
  467. &.icon-yixuanze{
  468. color: $color-system;
  469. }
  470. }
  471. }
  472. </style>