create-order.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  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. </seller-freight>
  12. <!-- 底部 -->
  13. <view class="footer" :style="{paddingBottom :isIphoneX ? '68rpx' : '0rpx'}">
  14. <view class="footer-le">
  15. <view class="footer-count">
  16. <text>共{{allCount}}件商品</text>
  17. </view>
  18. <view class="footer-price">
  19. <view class="sum" :class="totalFullReduction == 0 ? 'none' : ''">总价:<text class="price">¥{{payAllPrice | NumFormat}}</text></view>
  20. </view>
  21. </view>
  22. <view class="footer-submit" @click.stop="orderSubmitMit">
  23. <view class="btn" :class="isSubLoading ? 'disabled' : ''">提交订单</view>
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. import choiceAddress from '@/components/cm-module/creatOrder/address'
  30. import goodsList from '@/components/cm-module/creatOrder/goodsList'
  31. import sellerFreight from '@/components/cm-module/creatOrder/sellerFreight'
  32. export default {
  33. components:{
  34. choiceAddress,
  35. goodsList,
  36. sellerFreight
  37. },
  38. data() {
  39. return {
  40. isSubLoading:false,
  41. productIds:'', //获取上一级页面商品信息
  42. productCount:'', //获取上一级页面商品数量
  43. allCount:1, //订单提交总数量
  44. totalOriginalPrice:0, //订单总原价(划线部分)
  45. totalFullReduction:0, //满减金额
  46. payAllPrice:0.00, //订单提交总金额
  47. allPrice:0.00, //订单总金额
  48. townId:'', //区ID
  49. isRequest:false, //是否加载完成渲染子组件
  50. isFreight:false, //是否加载完成渲染子组件
  51. isAddress:false, //是否加载完成地址
  52. ischecked:false, //是否勾选余额
  53. addressData:{},//初始化地址信息
  54. goodsData:[],//初始化商品信息
  55. freightData:{}, //邮费数据
  56. isIphoneX:this.$store.state.isIphoneX,
  57. productsList:[],
  58. params:{
  59. userId:0,
  60. productIds:'',
  61. productCount:0
  62. },
  63. subParams:{
  64. userId:0,
  65. orderInfo:[],//提交的商品信息
  66. addressId:0,
  67. cartType:0,
  68. payInfo:{
  69. orderShouldPayFee:0
  70. }
  71. }
  72. }
  73. },
  74. onLoad(option){//商品数据
  75. let data = JSON.parse(option.data);
  76. this.allCount = data.data.allCount;
  77. if(option.type =='prodcut'){
  78. this.subParams.cartType = 2
  79. this.params.productCount = data.data.productCount
  80. this.params.productIds = data.data.productIds
  81. }else{
  82. this.subParams.cartType = 1
  83. this.params.productCount = data.data.productCount
  84. this.params.productIds = data.data.productIds
  85. }
  86. this.$api.getStorage().then((resolve) =>{
  87. this.params.userId = this.subParams.userId = resolve.userId ? resolve.userId : 0
  88. this.getInitCrearOrder(this.params);
  89. })
  90. },
  91. filters:{
  92. NumFormat(value) {//处理金额
  93. return Number(value).toFixed(2);
  94. },
  95. },
  96. methods: {
  97. getInitCrearOrder(params){//确认订单初始化信息
  98. this.OrderService.QueryOrderConfirm(params)
  99. .then(response =>{
  100. let data = response.data
  101. let productIds = []
  102. this.isRequest = true
  103. this.goodsData = data.shopList
  104. // this.totalFullReduction = data.totalFullReduction
  105. // this.totalOriginalPrice = data.totalFullReduction + data.totalPrice
  106. this.allPrice = this.payAllPrice = data.totalPrice
  107. this.subParams.payInfo.orderShouldPayFee = this.payAllPrice.toFixed(2)
  108. console.log('this.subParams.payInfo.orderShouldPayFee',this.subParams.payInfo.orderShouldPayFee)
  109. })
  110. .catch(error =>{
  111. this.$util.msg(error.msg,2000)
  112. })
  113. },
  114. getAddressData(){//获取地址信息
  115. this.$api.getStorage().then((resolve) => {
  116. this.UserService.QueryAddressList({pageNum:1,pageSize:1,userId:resolve.userId})
  117. .then(response =>{
  118. this.isAddress = true
  119. this.addressData = {}
  120. if(response.data.list != ''){
  121. this.subParams.addressId = response.data.list[0].addressId;
  122. this.townId = response.data.list[0].townId;
  123. this.addressData = response.data.list[0];
  124. }else{
  125. this.addressData = this.addressData;
  126. }
  127. })
  128. })
  129. },
  130. handChangeInputGoodsList(data){//对应供应商的留言信息
  131. this.goodsData = data;
  132. },
  133. orderSubmitMit(){//提交订单
  134. if(this.isSubLoading){ return; }
  135. if(this.subParams.addressId == ''){
  136. this.$util.msg('请先添加收货地址~',2000)
  137. return
  138. }
  139. // 处理商品信息及留言
  140. this.subParams.orderInfo = this.goodsData.map(el => {
  141. let productInfo = [];
  142. el.productList.forEach(item => {
  143. productInfo.push({
  144. productId:item.productId,
  145. productNum:item.productCount
  146. })
  147. })
  148. return {shopId:el.shopId,note:el.note?el.note:'',productInfo:productInfo}
  149. })
  150. console.log(this.subParams)
  151. this.isSubLoading = true;
  152. this.OrderService.CreatedOrderSubmit(this.subParams).then(response =>{
  153. const data = response.data;
  154. this.$util.msg('订单提交成功',2000,true,'success')
  155. setTimeout(()=>{
  156. this.isSubLoading = false;
  157. },2000)
  158. setTimeout(()=>{
  159. this.$api.redirectTo(`/pages/user/order/success?orderId=${data.orderId}`)
  160. },2000)
  161. }).catch(error =>{
  162. this.$util.msg(error.msg,2000);
  163. })
  164. },
  165. },
  166. onShow() {
  167. let pages = getCurrentPages();
  168. let currPage = pages[pages.length-1];
  169. if(currPage.data.select =='select'){
  170. this.isAddress = true
  171. let SelectData = uni.getStorageSync('selectAddress');
  172. this.subParams.addressId = SelectData.addressId;
  173. this.addressData = SelectData
  174. }else{
  175. this.getAddressData()
  176. }
  177. }
  178. }
  179. </script>
  180. <style lang="scss">
  181. page {
  182. height: auto;
  183. background:#F7F7F7;
  184. }
  185. .btn-hover{
  186. background: #FFFFFF;
  187. }
  188. .animation{
  189. /* transition: transform 0.3s ease;*/
  190. transition-property: transform;
  191. transition-duration: 0.3s;
  192. transition-timing-function: ease;
  193. }
  194. .invoice-freight{
  195. width: 702rpx;
  196. padding: 0 24rpx;
  197. height: 86rpx;
  198. line-height: 86rpx;
  199. font-size: $font-size-28;
  200. color: $text-color;
  201. background: #FFFFFF;
  202. float: left;
  203. font-weight: bold;
  204. .freight-left{
  205. float: left;
  206. .icon-yunfeishuoming{
  207. height: 100%;
  208. padding: 0 15rpx;
  209. color: $color-system;
  210. font-weight: normal;
  211. }
  212. }
  213. .freight-right{
  214. float: right;
  215. color: #2A81FF;
  216. }
  217. }
  218. .invoice-balance{
  219. width: 702rpx;
  220. height: auto;
  221. padding:0 24rpx;
  222. background: #FFFFFF;
  223. float: left;
  224. margin-top: 24rpx;
  225. margin-bottom: 24rpx;
  226. .balabce-t{
  227. width: 100%;
  228. height: 86rpx;
  229. line-height: 86rpx;
  230. font-size: $font-size-28;
  231. color: $text-color;
  232. float: left;
  233. .balabce-t-le{
  234. float: left;
  235. font-weight: bold;
  236. }
  237. .balabce-t-ri{
  238. float: right;
  239. display: flex;
  240. align-items: center;
  241. .money{
  242. display: flex;
  243. float: left;
  244. }
  245. .checkbox-box{
  246. display: flex;
  247. width: 60rpx;
  248. float: left;
  249. height: 100%;
  250. font-size: $font-size-24;
  251. .checkbox{
  252. width: 40rpx;
  253. text-align: right;
  254. box-sizing: border-box;
  255. text-align: center;
  256. text-decoration: none;
  257. border-radius: 0;
  258. -webkit-tap-highlight-color: transparent;
  259. overflow: hidden;
  260. color: $color-system;
  261. padding: 5rpx;
  262. }
  263. }
  264. }
  265. }
  266. .balabce-b{
  267. width: 100%;
  268. float: left;
  269. overflow: hidden;
  270. .balabce-b-text{
  271. width: 100%;
  272. line-height: 58rpx;
  273. font-size: $font-size-24;
  274. color: #FF2A2A;
  275. text-align: right;
  276. float: right;
  277. }
  278. &.balabce-b--hide {
  279. padding: 0 0;
  280. height: 0px;
  281. line-height: 0px;
  282. }
  283. }
  284. }
  285. .footer{
  286. position: fixed;
  287. left: 0;
  288. bottom: 0;
  289. z-index: 995;
  290. display: flex;
  291. align-items: center;
  292. width: 100%;
  293. height: 110rpx;
  294. line-height: 110rpx;
  295. justify-content: space-between;
  296. font-size: $font-size-28;
  297. background-color: #FFFFFF;
  298. z-index: 998;
  299. color: $text-color;
  300. .footer-le{
  301. width:570rpx;
  302. height:100%;
  303. float: left;
  304. }
  305. .footer-count{
  306. float: left;
  307. padding-left: 24rpx;
  308. width:170rpx;
  309. box-sizing: border-box;
  310. font-size: $font-size-26;
  311. }
  312. .footer-price{
  313. float: right;
  314. text-align: right;
  315. color: $text-color;
  316. padding-right:20rpx;
  317. box-sizing: border-box;
  318. width: 370rpx;
  319. .sum{
  320. width: 100%;
  321. height: 110rpx;
  322. line-height: 110rpx;
  323. float: left;
  324. .price{
  325. font-size: $font-size-32;
  326. color: $color-system;
  327. }
  328. }
  329. }
  330. .footer-submit{
  331. display:flex;
  332. align-items:center;
  333. justify-content: center;
  334. width: 210rpx;
  335. height: 100%;
  336. box-sizing: border-box;
  337. padding: 15rpx 5rpx;
  338. .btn{
  339. width: 100%;
  340. height: 100%;
  341. color: #FFFFFF;
  342. background:$btn-confirm;
  343. font-size: $font-size-26;
  344. text-align: center;
  345. line-height: 80rpx;
  346. border-radius: 40rpx;
  347. &.disabled{
  348. background: #e4e8eb;
  349. color: #999999;
  350. }
  351. }
  352. }
  353. }
  354. .Rebate{
  355. width: 702rpx;
  356. height: auto;
  357. padding: 0 24rpx;
  358. background: #FFFFFF;
  359. float: left;
  360. margin-bottom: 24rpx;
  361. margin-bottom: 24rpx;
  362. line-height: 86rpx;
  363. .rebate-title{
  364. float: left;
  365. font-weight: bold;
  366. color: #333333;
  367. font-size: $font-size-28;
  368. }
  369. .iconfont{
  370. float: right;
  371. color: #b2b2b2;
  372. font-size: 40rpx;
  373. &.icon-yixuanze{
  374. color: $color-system;
  375. }
  376. }
  377. }
  378. </style>