create-order.vue 11 KB

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