create-order.vue 9.4 KB

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