Commit 678d6b48aaed6062bd4e9d050ebcaf689484f806

Authored by 范牧
1 parent a196efbcb1
Exists in master

async函数修改

src/pages/cart/cart.vue
1 <template> 1 <template>
2 <view class="content"> 2 <view class="content">
3 <block v-if="cartList.length==0"> 3 <block v-if="cartList.length==0">
4 4
5 </block> 5 </block>
6 <block v-else> 6 <block v-else>
7 <view class="card"> 7 <view class="card">
8 <view class="cardHeader"> 8 <view class="cardHeader">
9 <view 9 <view
10 v-bind:class="pIsoPen? 'partentChecked' : 'partentCheck'" 10 v-bind:class="pIsoPen? 'partentChecked' : 'partentCheck'"
11 @click="pClick" 11 @click="pClick"
12 > 12 >
13 <span class="correct"></span> 13 <span class="correct"></span>
14 </view> 14 </view>
15 <image 15 <image
16 src="../../static/store.png" 16 src="../../static/store.png"
17 mode="aspectFill" 17 mode="aspectFill"
18 ></image> 18 ></image>
19 <text>非常戴镜</text> 19 <text>非常戴镜</text>
20 </view> 20 </view>
21 <view 21 <view
22 class="cardBody" 22 class="cardBody"
23 v-for="(item,index) in cartList" 23 v-for="(item,index) in cartList"
24 :key="index" 24 :key="index"
25 @longpress="delCart(item.cart_id,index)" 25 @longpress="delCart(item.cart_id,index)"
26 > 26 >
27 <view 27 <view
28 v-bind:class="cartList[index].isChecked? 'partentChecked':'partentCheck'" 28 v-bind:class="cartList[index].isChecked? 'partentChecked':'partentCheck'"
29 @click="childClick(cartList[index],index)" 29 @click="childClick(cartList[index],index)"
30 > 30 >
31 <span class="correct"></span> 31 <span class="correct"></span>
32 </view> 32 </view>
33 <view class="imageWrap"> 33 <view class="imageWrap">
34 <image 34 <image
35 :src="item.img_index_url" 35 :src="item.img_index_url"
36 mode="aspectFit" 36 mode="aspectFit"
37 style="width: 188rpx;height: 168rpx;" 37 style="width: 188rpx;height: 168rpx;"
38 ></image> 38 ></image>
39 </view> 39 </view>
40 <view class="goodInfo"> 40 <view class="goodInfo">
41 <!-- <view class="imageWrap"> 41 <!-- <view class="imageWrap">
42 <image :src="item.img_index_url" mode="aspectFit" style="width: 188rpx;height: 168rpx;"></image> 42 <image :src="item.img_index_url" mode="aspectFit" style="width: 188rpx;height: 168rpx;"></image>
43 </view> --> 43 </view> -->
44 <view class="infoRight"> 44 <view class="infoRight">
45 <view 45 <view
46 class="goodName" 46 class="goodName"
47 @tap="toGoods(item.pid,item.sk_id)" 47 @tap="toGoods(item.pid,item.sk_id)"
48 >{{item.p_name}}</view> 48 >{{item.p_name}}</view>
49 <view 49 <view
50 class="describ" 50 class="describ"
51 @click="showBottom(3,item.pid,item.sk_id,item.mp_id,item.cart_id,index)" 51 @click="showBottom(3,item.pid,item.sk_id,item.mp_id,item.cart_id,index)"
52 > 52 >
53 <view class="desL"> 53 <view class="desL">
54 <view class="people"> 54 <view class="people">
55 使用人:{{item.peopleName}} 55 使用人:{{item.peopleName}}
56 </view> 56 </view>
57 <view class="skuInfo"> 57 <view class="skuInfo">
58 {{item.sku_name}} 58 {{item.sku_name}}
59 </view> 59 </view>
60 </view> 60 </view>
61 <view class="desR"> 61 <view class="desR">
62 <image 62 <image
63 src="../../static/right.png" 63 src="../../static/right.png"
64 mode="aspectFit" 64 mode="aspectFit"
65 style="width: 18rpx;height: 18rpx;" 65 style="width: 18rpx;height: 18rpx;"
66 ></image> 66 ></image>
67 </view> 67 </view>
68 </view> 68 </view>
69 <view class="priceBox"> 69 <view class="priceBox">
70 <view class="price">¥{{item.nowPrice*item.num}}</view> 70 <view class="price">¥{{item.nowPrice*item.num}}</view>
71 <text class="maxCount">(限购{{maxCount}}副)</text> 71 <text class="maxCount">(限购{{maxCount}}副)</text>
72 <view class="counter"> 72 <view class="counter">
73 <view 73 <view
74 class="btn" 74 class="btn"
75 disabled="this.addDisabled" 75 disabled="this.addDisabled"
76 type="default" 76 type="default"
77 @tap="counter(index,false,item)" 77 @tap="counter(index,false,item)"
78 >-</view> 78 >-</view>
79 <text>{{item.num}}</text> 79 <text>{{item.num}}</text>
80 <view 80 <view
81 class="btn" 81 class="btn"
82 disabled="this.desDisabled" 82 disabled="this.desDisabled"
83 type="default" 83 type="default"
84 @tap="counter(index,true,item)" 84 @tap="counter(index,true,item)"
85 >+</view> 85 >+</view>
86 </view> 86 </view>
87 </view> 87 </view>
88 </view> 88 </view>
89 </view> 89 </view>
90 </view> 90 </view>
91 </view> 91 </view>
92 </block> 92 </block>
93 <view class="footer"> 93 <view class="footer">
94 <view class="footerLeft">实付金额:<text>¥{{totalPrice}}</text></view> 94 <view class="footerLeft">实付金额:<text>¥{{totalPrice}}</text></view>
95 <view class="footerRight"> 95 <view class="footerRight">
96 <view 96 <view
97 class="paybtn" 97 class="paybtn"
98 @click="toComfirmOrder" 98 @click="toComfirmOrder"
99 >立即结算</view> 99 >立即结算</view>
100 </view> 100 </view>
101 </view> 101 </view>
102 <BottomSheet 102 <BottomSheet
103 v-if="isShowBottom" 103 v-if="isShowBottom"
104 :isCart="isCart" 104 :isCart="isCart"
105 @addCart="addCart" 105 @addCart="addCart"
106 :sk_id="sk_id" 106 :sk_id="sk_id"
107 :propMpId="mp_id" 107 :propMpId="mp_id"
108 @chooseCartModi="chooseCartModi" 108 @chooseCartModi="chooseCartModi"
109 :cart_id="cart_id" 109 :cart_id="cart_id"
110 :index="cartIndex" 110 :index="cartIndex"
111 :pid="pid" 111 :pid="pid"
112 :goodInfo="goodInfo" 112 :goodInfo="goodInfo"
113 :isShowBottom="isShowBottom" 113 :isShowBottom="isShowBottom"
114 @closeBottom="closeBottom" 114 @closeBottom="closeBottom"
115 ></BottomSheet> 115 ></BottomSheet>
116 </view> 116 </view>
117 </template> 117 </template>
118 118
119 <script> 119 <script>
120 120
121 import store from '@/store' 121 import store from '@/store'
122 import BottomSheet from '../../components/BottomSheet/BottomSheet.vue' 122 import BottomSheet from '../../components/BottomSheet/BottomSheet.vue'
123 export default { 123 export default {
124 components: { 124 components: {
125 BottomSheet, 125 BottomSheet,
126 }, 126 },
127 data() { 127 data() {
128 return { 128 return {
129 pid: Number, 129 pid: Number,
130 isCart: Number, 130 isCart: Number,
131 sk_id: String, 131 sk_id: String,
132 mp_id: String, 132 mp_id: String,
133 isShowBottom: false, // 底部弹窗开关 133 isShowBottom: false, // 底部弹窗开关
134 cart_id: Number, 134 cart_id: Number,
135 maxCount: 20, 135 maxCount: 20,
136 cartIndex: Number, 136 cartIndex: Number,
137 cartList: [], 137 cartList: [],
138 } 138 }
139 }, 139 },
140 computed: { 140 computed: {
141 pIsoPen () { 141 pIsoPen () {
142 if (this.cartList.length > 0) { 142 if (this.cartList.length > 0) {
143 return !this.cartList.find(item => !item.isChecked) 143 return !this.cartList.find(item => !item.isChecked)
144 } 144 }
145 return false 145 return false
146 }, 146 },
147 goodInfo () { 147 goodInfo () {
148 return this.$store.state.read.goodInfo 148 return this.$store.state.read.goodInfo
149 }, 149 },
150 totalPrice() { 150 totalPrice() {
151 let totalPrice = 0 151 let totalPrice = 0
152 this.cartList.forEach((item) => { 152 this.cartList.forEach((item) => {
153 if (item.isChecked) { 153 if (item.isChecked) {
154 totalPrice += item.nowPrice * item.num 154 totalPrice += item.nowPrice * item.num
155 } 155 }
156 }) 156 })
157 return totalPrice 157 return totalPrice
158 }, 158 },
159 }, 159 },
160 onShow() { 160 onShow: async function() {
161 await this.$store.dispatch('cart/getCartList', { 161 await this.$store.dispatch('cart/getCartList', {
162 uid: this.$store.state.user.userInfo.uid, // 用户id 162 uid: this.$store.state.user.userInfo.uid, // 用户id
163 }) 163 })
164 164
165 this.cartList = this.$store.state.cart.cartList 165 this.cartList = this.$store.state.cart.cartList
166 this.cartList.forEach((item) => { 166 this.cartList.forEach((item) => {
167 item.isChecked = false 167 item.isChecked = false
168 }) 168 })
169 }, 169 },
170 onLoad: async function() { 170 onLoad: async function() {
171 }, 171 },
172 methods: { 172 methods: {
173 // 全选按钮 173 // 全选按钮
174 pClick() { 174 pClick() {
175 const pStatus = !this.cartList.find(item => !item.isChecked) 175 const pStatus = !this.cartList.find(item => !item.isChecked)
176 const oldList = this.cartList 176 const oldList = this.cartList
177 oldList.forEach((item, index) => { 177 oldList.forEach((item, index) => {
178 item.isChecked = !pStatus 178 item.isChecked = !pStatus
179 this.cartList.splice(index, 1, item) 179 this.cartList.splice(index, 1, item)
180 }) 180 })
181 }, 181 },
182 // 单选按钮 182 // 单选按钮
183 childClick(type, index) { 183 childClick(type, index) {
184 this.cartList[index].isChecked = !this.cartList[index].isChecked 184 this.cartList[index].isChecked = !this.cartList[index].isChecked
185 // vue没有办法监听数组内部值的变化,所以需要通过这个方法去触发 185 // vue没有办法监听数组内部值的变化,所以需要通过这个方法去触发
186 this.cartList.splice(index, 1, this.cartList[index]) 186 this.cartList.splice(index, 1, this.cartList[index])
187 }, 187 },
188 // 修改购物车 188 // 修改购物车
189 chooseCartModi(mp_id, sk_id, price, pid, num, cart_id, index) { 189 chooseCartModi(mp_id, sk_id, price, pid, num, cart_id, index) {
190 // console.log('modi',mp_id,sk_id,price,pid,num,cart_id) 190 // console.log('modi',mp_id,sk_id,price,pid,num,cart_id)
191 store.dispatch('cart/modiCart', { 191 store.dispatch('cart/modiCart', {
192 uid: this.$store.state.user.userInfo.uid, 192 uid: this.$store.state.user.userInfo.uid,
193 openid: this.$store.state.user.userInfo.openid, 193 openid: this.$store.state.user.userInfo.openid,
194 mp_id: mp_id, 194 mp_id: mp_id,
195 sk_id: sk_id, 195 sk_id: sk_id,
196 price: price, 196 price: price,
197 pid: pid, 197 pid: pid,
198 num: num, 198 num: num,
199 cart_id: cart_id, 199 cart_id: cart_id,
200 args: { 200 args: {
201 index: index, 201 index: index,
202 }, 202 },
203 }) 203 })
204 this.$nextTick(function() { 204 this.$nextTick(function() {
205 store.dispatch('cart/getCartList', { 205 store.dispatch('cart/getCartList', {
206 uid: this.$store.state.user.userInfo.uid, // 用户id 206 uid: this.$store.state.user.userInfo.uid, // 用户id
207 }).then(() => { 207 }).then(() => {
208 this.cartList = this.$store.state.cart.cartList 208 this.cartList = this.$store.state.cart.cartList
209 }) 209 })
210 }) 210 })
211 }, 211 },
212 // 底部弹窗开关 212 // 底部弹窗开关
213 showBottom(isCart, pid, skId, mp_id, cart_id, index) { 213 showBottom(isCart, pid, skId, mp_id, cart_id, index) {
214 store.dispatch('read/fetch', { 214 store.dispatch('read/fetch', {
215 pid, 215 pid,
216 sk_id: skId, 216 sk_id: skId,
217 }).then(() => { 217 }).then(() => {
218 this.cartIndex = index 218 this.cartIndex = index
219 this.sk_id = skId 219 this.sk_id = skId
220 this.pid = pid 220 this.pid = pid
221 this.mp_id = mp_id 221 this.mp_id = mp_id
222 this.isCart = isCart 222 this.isCart = isCart
223 this.cart_id = cart_id 223 this.cart_id = cart_id
224 this.isShowBottom = true 224 this.isShowBottom = true
225 }) 225 })
226 }, 226 },
227 closeBottom() { 227 closeBottom() {
228 this.isShowBottom = false 228 this.isShowBottom = false
229 }, 229 },
230 toGoods(id, skId) { 230 toGoods(id, skId) {
231 uni.navigateTo({ 231 uni.navigateTo({
232 url: '../details/details?pid=' + id + '&sk_id=' + skId, 232 url: '../details/details?pid=' + id + '&sk_id=' + skId,
233 success: res => {}, 233 success: res => {},
234 fail: () => {}, 234 fail: () => {},
235 complete: () => {}, 235 complete: () => {},
236 }) 236 })
237 }, 237 },
238 238
239 toComfirmOrder() { 239 toComfirmOrder() {
240 this.$store.state.cart.checkedCartLst = this.cartList.filter(item => item.isChecked) 240 this.$store.state.cart.checkedCartLst = this.cartList.filter(item => item.isChecked)
241 if (this.$store.state.cart.checkedCartLst.length > 0) { 241 if (this.$store.state.cart.checkedCartLst.length > 0) {
242 uni.navigateTo({ 242 uni.navigateTo({
243 url: '../confirmOrder/confirmOrder?isCart=true', 243 url: '../confirmOrder/confirmOrder?isCart=true',
244 }) 244 })
245 } else { 245 } else {
246 uni.showToast({ 246 uni.showToast({
247 title: '您还没有选择宝贝哦~', 247 title: '您还没有选择宝贝哦~',
248 icon: 'none', 248 icon: 'none',
249 }) 249 })
250 } 250 }
251 }, 251 },
252 counter(index, isadd, item) { 252 counter(index, isadd, item) {
253 // console.log('item=====>', item) 253 // console.log('item=====>', item)
254 // console.log('num=====>', item.num) 254 // console.log('num=====>', item.num)
255 const nums = parseInt(item.num) 255 const nums = parseInt(item.num)
256 if (isadd) { 256 if (isadd) {
257 if (nums >= this.maxCount) { 257 if (nums >= this.maxCount) {
258 this.addDisabled = true 258 this.addDisabled = true
259 } else { 259 } else {
260 this.addDisabled = true 260 this.addDisabled = true
261 store.dispatch('cart/modiCart', { 261 store.dispatch('cart/modiCart', {
262 uid: this.$store.state.user.userInfo.uid, 262 uid: this.$store.state.user.userInfo.uid,
263 openid: this.$store.state.user.userInfo.openid, 263 openid: this.$store.state.user.userInfo.openid,
264 mp_id: item.mp_id, 264 mp_id: item.mp_id,
265 sk_id: item.sk_id, 265 sk_id: item.sk_id,
266 price: item.nowPrice, 266 price: item.nowPrice,
267 pid: item.pid, 267 pid: item.pid,
268 num: nums + 1, 268 num: nums + 1,
269 cart_id: item.cart_id, 269 cart_id: item.cart_id,
270 args: { 270 args: {
271 index: index, 271 index: index,
272 isadd: isadd, 272 isadd: isadd,
273 }, 273 },
274 }) 274 })
275 this.addDisabled = false 275 this.addDisabled = false
276 } 276 }
277 } else { 277 } else {
278 if (nums <= 1) { 278 if (nums <= 1) {
279 this.desDisabled = true 279 this.desDisabled = true
280 } else { 280 } else {
281 this.desDisabled = false 281 this.desDisabled = false
282 282
283 store.dispatch('cart/modiCart', { 283 store.dispatch('cart/modiCart', {
284 uid: this.$store.state.user.userInfo.uid, 284 uid: this.$store.state.user.userInfo.uid,
285 openid: this.$store.state.user.userInfo.openid, 285 openid: this.$store.state.user.userInfo.openid,
286 mp_id: item.mp_id, 286 mp_id: item.mp_id,
287 sk_id: item.sk_id, 287 sk_id: item.sk_id,
288 price: item.nowPrice, 288 price: item.nowPrice,
289 pid: item.pid, 289 pid: item.pid,
290 num: nums - 1, 290 num: nums - 1,
291 cart_id: item.cart_id, 291 cart_id: item.cart_id,
292 args: { 292 args: {
293 index: index, 293 index: index,
294 isadd: isadd, 294 isadd: isadd,
295 }, 295 },
296 }) 296 })
297 this.desDisabled = true 297 this.desDisabled = true
298 } 298 }
299 } 299 }
300 }, 300 },
301 delCart(cart_id, index) { 301 delCart(cart_id, index) {
302 cart_id = parseInt(cart_id) 302 cart_id = parseInt(cart_id)
303 uni.showModal({ 303 uni.showModal({
304 title: '是否删除该商品', 304 title: '是否删除该商品',
305 success: function (res) { 305 success: function (res) {
306 if (res.confirm) { 306 if (res.confirm) {
307 store.dispatch('cart/delCart', { 307 store.dispatch('cart/delCart', {
308 uid: this.$store.state.user.userInfo.uid, 308 uid: this.$store.state.user.userInfo.uid,
309 openid: this.$store.state.user.userInfo.openid, 309 openid: this.$store.state.user.userInfo.openid,
310 cart_id: cart_id, // 要修改的购物车id 310 cart_id: cart_id, // 要修改的购物车id
311 arg: index, // 由于action 传参是能接收两参数,因此将index放入对象 311 arg: index, // 由于action 传参是能接收两参数,因此将index放入对象
312 }) 312 })
313 } 313 }
314 }.bind(this), 314 }.bind(this),
315 }) 315 })
316 // this.cartList.splice(index,1) 316 // this.cartList.splice(index,1)
317 }, 317 },
318 }, 318 },
319 } 319 }
320 </script> 320 </script>
321 321
322 <style lang="scss"> 322 <style lang="scss">
323 .content { 323 .content {
324 min-height: 100vh; 324 min-height: 100vh;
325 background-color: #f2f2f2; 325 background-color: #f2f2f2;
326 display: flex; 326 display: flex;
327 flex-direction: column; 327 flex-direction: column;
328 align-items: center; 328 align-items: center;
329 justify-content: space-between; 329 justify-content: space-between;
330 padding: 20rpx 40rpx; 330 padding: 20rpx 40rpx;
331 box-sizing: border-box; 331 box-sizing: border-box;
332 332
333 .partentCheck { 333 .partentCheck {
334 width: 16px; 334 width: 16px;
335 height: 16px; 335 height: 16px;
336 border-radius: 22px; 336 border-radius: 22px;
337 border: 1px solid #cfcfcf; 337 border: 1px solid #cfcfcf;
338 background-color: #ffffff; 338 background-color: #ffffff;
339 margin: 24rpx 12rpx 24rpx 24rpx; 339 margin: 24rpx 12rpx 24rpx 24rpx;
340 } 340 }
341 .partentChecked { 341 .partentChecked {
342 width: 18px; 342 width: 18px;
343 height: 18px; 343 height: 18px;
344 border-radius: 22px; 344 border-radius: 22px;
345 background-color: #ff6b4a; 345 background-color: #ff6b4a;
346 margin: 24rpx 12rpx 24rpx 24rpx; 346 margin: 24rpx 12rpx 24rpx 24rpx;
347 .correct { 347 .correct {
348 display: inline-block; 348 display: inline-block;
349 position: relative; 349 position: relative;
350 width: 10rpx; 350 width: 10rpx;
351 height: 2rpx; 351 height: 2rpx;
352 background: #ffffff; 352 background: #ffffff;
353 line-height: 0; 353 line-height: 0;
354 font-size: 0; 354 font-size: 0;
355 position: relative; 355 position: relative;
356 top: -7px; 356 top: -7px;
357 left: 4px; 357 left: 4px;
358 -webkit-transform: rotate(45deg); 358 -webkit-transform: rotate(45deg);
359 } 359 }
360 .correct:after { 360 .correct:after {
361 content: "/"; 361 content: "/";
362 display: block; 362 display: block;
363 width: 16rpx; 363 width: 16rpx;
364 height: 2rpx; 364 height: 2rpx;
365 background: #ffffff; 365 background: #ffffff;
366 -webkit-transform: rotate(-90deg) translateY(50%) translateX(50%); 366 -webkit-transform: rotate(-90deg) translateY(50%) translateX(50%);
367 } 367 }
368 } 368 }
369 369
370 .card { 370 .card {
371 background-color: #ffffff; 371 background-color: #ffffff;
372 border-radius: 16rpx; 372 border-radius: 16rpx;
373 box-sizing: border-box; 373 box-sizing: border-box;
374 padding: 36rpx 36rpx 36rpx 18rpx; 374 padding: 36rpx 36rpx 36rpx 18rpx;
375 display: flex; 375 display: flex;
376 flex-direction: column; 376 flex-direction: column;
377 align-items: center; 377 align-items: center;
378 justify-content: space-between; 378 justify-content: space-between;
379 margin-bottom: 180rpx; 379 margin-bottom: 180rpx;
380 .cardHeader { 380 .cardHeader {
381 width: 100%; 381 width: 100%;
382 height: 36rpx; 382 height: 36rpx;
383 display: flex; 383 display: flex;
384 align-items: center; 384 align-items: center;
385 justify-content: flex-start; 385 justify-content: flex-start;
386 margin-bottom: 20rpx; 386 margin-bottom: 20rpx;
387 image { 387 image {
388 height: 32rpx; 388 height: 32rpx;
389 width: 32rpx; 389 width: 32rpx;
390 padding-left: 6px; 390 padding-left: 6px;
391 padding-right: 10px; 391 padding-right: 10px;
392 } 392 }
393 text { 393 text {
394 // font-family: PingFangSC-Regular; 394 // font-family: PingFangSC-Regular;
395 font-size: 14px; 395 font-size: 14px;
396 color: #333333; 396 color: #333333;
397 letter-spacing: -0.26px; 397 letter-spacing: -0.26px;
398 } 398 }
399 } 399 }
400 .cardBody { 400 .cardBody {
401 width: 100%; 401 width: 100%;
402 min-height: 300rpx; 402 min-height: 300rpx;
403 display: flex; 403 display: flex;
404 align-items: center; 404 align-items: center;
405 justify-content: space-between; 405 justify-content: space-between;
406 .goodInfo { 406 .goodInfo {
407 width: 390rpx; 407 width: 390rpx;
408 display: flex; 408 display: flex;
409 flex-direction: row; 409 flex-direction: row;
410 justify-content: flex-start; 410 justify-content: flex-start;
411 padding-left: 6px; 411 padding-left: 6px;
412 412
413 .imageWrap { 413 .imageWrap {
414 height: 188rpx; 414 height: 188rpx;
415 width: 188rpx; 415 width: 188rpx;
416 margin-right: 28rpx; 416 margin-right: 28rpx;
417 417
418 image { 418 image {
419 border-radius: 4px; 419 border-radius: 4px;
420 height: 188rpx; 420 height: 188rpx;
421 width: 188rpx; 421 width: 188rpx;
422 } 422 }
423 } 423 }
424 .infoRight { 424 .infoRight {
425 display: flex; 425 display: flex;
426 flex-direction: column; 426 flex-direction: column;
427 align-items: flex-start; 427 align-items: flex-start;
428 justify-content: space-between; 428 justify-content: space-between;
429 min-height: 240rpx; 429 min-height: 240rpx;
430 width: 100%; 430 width: 100%;
431 .goodName { 431 .goodName {
432 display: -webkit-box; 432 display: -webkit-box;
433 -webkit-box-orient: vertical; 433 -webkit-box-orient: vertical;
434 -webkit-line-clamp: 2; 434 -webkit-line-clamp: 2;
435 text-align: justify; 435 text-align: justify;
436 overflow: hidden; 436 overflow: hidden;
437 font-size: 28rpx; 437 font-size: 28rpx;
438 color: #333333; 438 color: #333333;
439 } 439 }
440 .describ { 440 .describ {
441 width: 100%; 441 width: 100%;
442 min-height: 80rpx; 442 min-height: 80rpx;
443 background: #f9f9f9; 443 background: #f9f9f9;
444 border-radius: 2px; 444 border-radius: 2px;
445 box-sizing: border-box; 445 box-sizing: border-box;
446 padding: 10rpx; 446 padding: 10rpx;
447 font-size: 20rpx; 447 font-size: 20rpx;
448 letter-spacing: -0.23px; 448 letter-spacing: -0.23px;
449 color: #999999; 449 color: #999999;
450 display: flex; 450 display: flex;
451 justify-content: space-between; 451 justify-content: space-between;
452 align-items: center; 452 align-items: center;
453 .desL { 453 .desL {
454 view { 454 view {
455 margin: 10rpx 0 10rpx 0; 455 margin: 10rpx 0 10rpx 0;
456 } 456 }
457 } 457 }
458 } 458 }
459 .priceBox { 459 .priceBox {
460 display: flex; 460 display: flex;
461 justify-content: space-between; 461 justify-content: space-between;
462 align-items: center; 462 align-items: center;
463 // margin-top: 26px; 463 // margin-top: 26px;
464 width: 100%; 464 width: 100%;
465 font-size: 14px; 465 font-size: 14px;
466 color: #999999; 466 color: #999999;
467 .maxCount { 467 .maxCount {
468 color: #999999; 468 color: #999999;
469 font-size: 20rpx; 469 font-size: 20rpx;
470 } 470 }
471 .price { 471 .price {
472 color: #ff6b4a; 472 color: #ff6b4a;
473 font-size: 28rpx; 473 font-size: 28rpx;
474 } 474 }
475 .counter { 475 .counter {
476 display: flex; 476 display: flex;
477 flex-direction: row; 477 flex-direction: row;
478 justify-content: space-between; 478 justify-content: space-between;
479 align-items: center; 479 align-items: center;
480 font-size: 28rpx; 480 font-size: 28rpx;
481 color: #333333; 481 color: #333333;
482 width: 122rpx; 482 width: 122rpx;
483 .btn { 483 .btn {
484 display: flex; 484 display: flex;
485 justify-content: center; 485 justify-content: center;
486 line-height: 32rpx; 486 line-height: 32rpx;
487 height: 32rpx; 487 height: 32rpx;
488 width: 32rpx; 488 width: 32rpx;
489 background-color: #f2f2f2; 489 background-color: #f2f2f2;
490 color: #cfcfcf; 490 color: #cfcfcf;
491 } 491 }
492 } 492 }
493 } 493 }
494 } 494 }
495 } 495 }
496 } 496 }
497 } 497 }
498 .footer { 498 .footer {
499 position: fixed; 499 position: fixed;
500 left: 0; 500 left: 0;
501 bottom: 0px; 501 bottom: 0px;
502 height: 112rpx; 502 height: 112rpx;
503 width: 100%; 503 width: 100%;
504 background-color: #ffffff; 504 background-color: #ffffff;
505 font-size: 16px; 505 font-size: 16px;
506 display: flex; 506 display: flex;
507 justify-content: space-between; 507 justify-content: space-between;
508 align-items: center; 508 align-items: center;
509 .footerLeft { 509 .footerLeft {
510 display: flex; 510 display: flex;
511 justify-content: center; 511 justify-content: center;
512 align-items: center; 512 align-items: center;
513 width: 50%; 513 width: 50%;
514 color: #333333; 514 color: #333333;
515 text { 515 text {
516 color: #ff6b4a; 516 color: #ff6b4a;
517 } 517 }
518 } 518 }
519 .footerRight { 519 .footerRight {
520 display: flex; 520 display: flex;
521 justify-content: flex-end; 521 justify-content: flex-end;
522 align-items: center; 522 align-items: center;
523 width: 50%; 523 width: 50%;
524 margin-right: 26rpx; 524 margin-right: 26rpx;
525 .paybtn { 525 .paybtn {
526 display: flex; 526 display: flex;
527 justify-content: center; 527 justify-content: center;
528 align-items: center; 528 align-items: center;
529 background: #ff6b4a; 529 background: #ff6b4a;
530 border-radius: 20px; 530 border-radius: 20px;
531 border-radius: 20px; 531 border-radius: 20px;
532 color: #ffffff; 532 color: #ffffff;
533 width: 204rpx; 533 width: 204rpx;
534 height: 80rpx; 534 height: 80rpx;
535 } 535 }
536 } 536 }
537 } 537 }
538 } 538 }
539 /* 隐藏滚动条 */ 539 /* 隐藏滚动条 */
540 ::-webkit-scrollbar { 540 ::-webkit-scrollbar {
541 width: 0; 541 width: 0;
542 height: 0; 542 height: 0;
543 color: transparent; 543 color: transparent;
544 } 544 }
545 </style> 545 </style>
546 546
src/pages/confirmOrder/confirmOrder.vue
1 <template> 1 <template>
2 <view class="wrap"> 2 <view class="wrap">
3 <view></view> 3 <view></view>
4 <view 4 <view
5 class="addAddress" 5 class="addAddress"
6 @tap="toaddAddress" 6 @tap="toaddAddress"
7 v-if="this.showAddress" 7 v-if="this.showAddress"
8 > 8 >
9 <view class="addIcon"> 9 <view class="addIcon">
10 <image 10 <image
11 src="../../static/add.png" 11 src="../../static/add.png"
12 mode="aspectFill" 12 mode="aspectFill"
13 ></image> 13 ></image>
14 </view> 14 </view>
15 <view class="addressText">{{addAddress}}</view> 15 <view class="addressText">{{addAddress}}</view>
16 <image 16 <image
17 src="../../static/right.png" 17 src="../../static/right.png"
18 mode="aspectFill" 18 mode="aspectFill"
19 ></image> 19 ></image>
20 </view> 20 </view>
21 <view 21 <view
22 v-else 22 v-else
23 @tap="toaddAddress" 23 @tap="toaddAddress"
24 class="list order-user" 24 class="list order-user"
25 > 25 >
26 <view class="order-user-head"> 26 <view class="order-user-head">
27 <view class="name"> 27 <view class="name">
28 <view 28 <view
29 v-if="addressInfo.default === '1'" 29 v-if="addressInfo.default === '1'"
30 class="default" 30 class="default"
31 ><text>默认</text></view>{{addressInfo.name}} 31 ><text>默认</text></view>{{addressInfo.name}}
32 </view> 32 </view>
33 <text class="mobile">{{addressInfo.mobile}}</text> 33 <text class="mobile">{{addressInfo.mobile}}</text>
34 </view> 34 </view>
35 <view class="order-user-body"> 35 <view class="order-user-body">
36 <image src="../../static/myorder-paying-location.png"></image> 36 <image src="../../static/myorder-paying-location.png"></image>
37 <text class="address">{{addressInfo.address}}\n{{addressInfo.add_detail}}</text> 37 <text class="address">{{addressInfo.address}}\n{{addressInfo.add_detail}}</text>
38 </view> 38 </view>
39 <image 39 <image
40 class="arrow" 40 class="arrow"
41 src="../../static/right.png" 41 src="../../static/right.png"
42 mode="aspectFill" 42 mode="aspectFill"
43 ></image> 43 ></image>
44 </view> 44 </view>
45 <view class="content"> 45 <view class="content">
46 <view class="orderInfo"> 46 <view class="orderInfo">
47 <view class="title"> 47 <view class="title">
48 <image 48 <image
49 src="../../static/store.png" 49 src="../../static/store.png"
50 mode="aspectFill" 50 mode="aspectFill"
51 style="width: 40rpx;height: 40rpx;" 51 style="width: 40rpx;height: 40rpx;"
52 ></image> 52 ></image>
53 <text>非常戴镜</text> 53 <text>非常戴镜</text>
54 </view> 54 </view>
55 55
56 <view class="infoBox" v-if="isCart == 'true'" v-for="(item, index) in checkedCartLst" :key="index"> 56 <view
57 <view class="infoTop"> 57 class="infoBox"
58 <image 58 v-if="isCart == 'true'"
59 :src="item.img_index_url" 59 v-for="(item, index) in checkedCartLst"
60 mode="aspectFill" 60 :key="index"
61 ></image> 61 >
62 <view class="infoRight"> 62 <view class="infoTop">
63 <text class="goodName">{{item.p_name}}</text> 63 <image
64 <text class="remarks">支持7天无理由退货 顺丰发货</text> 64 :src="item.img_index_url"
65 <view class="priceBox"> 65 mode="aspectFill"
66 <view class="price">¥{{Number(item.nowPrice) * item.num}}<text class="originCost"> 66 ></image>
67 ¥{{item.oldPrice*item.num}} 67 <view class="infoRight">
68 </text></view> 68 <text class="goodName">{{item.p_name}}</text>
69 <view class="counter"> 69 <text class="remarks">支持7天无理由退货 顺丰发货</text>
70 <view 70 <view class="priceBox">
71 class="btn" 71 <view class="price">¥{{Number(item.nowPrice) * item.num}}<text class="originCost">
72 disabled="this.disabled" 72 ¥{{item.oldPrice*item.num}}
73 type="default" 73 </text></view>
74 @click="counter(false,index)" 74 <view class="counter">
75 >-</view> 75 <view
76 <text>{{checkedCartLst[index].num}}</text> 76 class="btn"
77 <view 77 disabled="this.disabled"
78 class="btn" 78 type="default"
79 type="default" 79 @click="counter(false,index)"
80 @click="counter(true,index)" 80 >-</view>
81 >+</view> 81 <text>{{checkedCartLst[index].num}}</text>
82 </view> 82 <view
83 </view> 83 class="btn"
84 </view> 84 type="default"
85 </view> 85 @click="counter(true,index)"
86 <view class="infoBottom"> 86 >+</view>
87 <view class="norm">规格 <text> 87 </view>
88 <!-- 长度超出变省略号未做 --> 88 </view>
89 <block >{{item.sku_name}}<block v-if="index !== current.length -1">/</block> 89 </view>
90 </block> 90 </view>
91 </text></view> 91 <view class="infoBottom">
92 <view class="shippingMethod">使用人 <text> 92 <view class="norm">规格 <text>
93 {{item.peopleName}} 93 <!-- 长度超出变省略号未做 -->
94 </text></view> 94 <block>{{item.sku_name}}<block v-if="index !== current.length -1">/</block>
95 <view class="shippingMethod">配送方式 <text>快递</text></view> 95 </block>
96 <view class="message">买家留言 96 </text></view>
97 <input 97 <view class="shippingMethod">使用人 <text>
98 type="text" 98 {{item.peopleName}}
99 :value="note" 99 </text></view>
100 placeholder="建议提前协商(50字以内)" 100 <view class="shippingMethod">配送方式 <text>快递</text></view>
101 /> 101 <view class="message">买家留言
102 </view> 102 <input
103 </view> 103 type="text"
104 </view> 104 :value="note"
105 105 placeholder="建议提前协商(50字以内)"
106 <view class="infoBox" v-if="isCart !== 'true'"> 106 />
107 </view>
108 </view>
109 </view>
110
111 <view
112 class="infoBox"
113 v-if="isCart !== 'true'"
114 >
107 <view class="infoTop"> 115 <view class="infoTop">
108 <image 116 <image
109 :src="buyItem.pic" 117 :src="buyItem.pic"
110 mode="aspectFill" 118 mode="aspectFill"
111 ></image> 119 ></image>
112 <view class="infoRight"> 120 <view class="infoRight">
113 <text class="goodName">{{goodInfo.p_name}}</text> 121 <text class="goodName">{{goodInfo.p_name}}</text>
114 <text class="remarks">支持7天无理由退货 顺丰发货</text> 122 <text class="remarks">支持7天无理由退货 顺丰发货</text>
115 <view class="priceBox"> 123 <view class="priceBox">
116 <view class="price">¥{{buyItem.real_price * count}}<text class="originCost"> 124 <view class="price">¥{{buyItem.real_price * count}}<text class="originCost">
117 ¥{{buyItem.out_price * count}} 125 ¥{{buyItem.out_price * count}}
118 </text></view> 126 </text></view>
119 <view class="counter"> 127 <view class="counter">
120 <view 128 <view
121 class="btn" 129 class="btn"
122 disabled="this.disabled" 130 disabled="this.disabled"
123 type="default" 131 type="default"
124 @click="counter(false)" 132 @click="counter(false)"
125 >-</view> 133 >-</view>
126 <text>{{count}}</text> 134 <text>{{count}}</text>
127 <view 135 <view
128 class="btn" 136 class="btn"
129 type="default" 137 type="default"
130 @click="counter(true)" 138 @click="counter(true)"
131 >+</view> 139 >+</view>
132 </view> 140 </view>
133 </view> 141 </view>
134 </view> 142 </view>
135 </view> 143 </view>
136 <view class="infoBottom"> 144 <view class="infoBottom">
137 <view class="norm">规格 <text> 145 <view class="norm">规格 <text>
138 <!-- 长度超出变省略号未做 --> 146 <!-- 长度超出变省略号未做 -->
139 <block 147 <block
140 v-for="(item, index) in current" 148 v-for="(item, index) in current"
141 :key="index" 149 :key="index"
142 >{{attrList[index].attr[item].name}}<block v-if="index !== current.length -1">/</block> 150 >{{attrList[index].attr[item].name}}<block v-if="index !== current.length -1">/</block>
143 </block> 151 </block>
144 </text></view> 152 </text></view>
145 <view class="shippingMethod">使用人 <text> 153 <view class="shippingMethod">使用人 <text>
146 {{name}} 154 {{name}}
147 </text></view> 155 </text></view>
148 <view class="shippingMethod">配送方式 <text>快递</text></view> 156 <view class="shippingMethod">配送方式 <text>快递</text></view>
149 <view class="message">买家留言 157 <view class="message">买家留言
150 <input 158 <input
151 type="text" 159 type="text"
152 :value="note" 160 :value="note"
153 placeholder="建议提前协商(50字以内)" 161 placeholder="建议提前协商(50字以内)"
154 /> 162 />
155 </view> 163 </view>
156 </view> 164 </view>
157 </view> 165 </view>
158 </view> 166 </view>
159 <view class="payWay"> 167 <view class="payWay">
160 <view class="item"> 168 <view class="item">
161 <text>支付方式</text> 169 <text>支付方式</text>
162 <view class="itemRight"> 170 <view class="itemRight">
163 <view class="rightText"> 171 <view class="rightText">
164 <view class="choosePayWay"> 172 <view class="choosePayWay">
165 <image 173 <image
166 src="../../static/chat_logo.png" 174 src="../../static/chat_logo.png"
167 mode="aspectFill" 175 mode="aspectFill"
168 ></image> 176 ></image>
169 <text>微信支付</text> 177 <text>微信支付</text>
170 </view> 178 </view>
171 <!-- <view class="randomSubstraction">最高随机立减¥99</view> --> 179 <!-- <view class="randomSubstraction">最高随机立减¥99</view> -->
172 </view> 180 </view>
173 <!-- <image 181 <!-- <image
174 src="../../static/right.png" 182 src="../../static/right.png"
175 mode="aspectFill" 183 mode="aspectFill"
176 ></image> --> 184 ></image> -->
177 </view> 185 </view>
178 </view> 186 </view>
179 <!-- <view class="item"> 187 <!-- <view class="item">
180 <text>优惠券</text> 188 <text>优惠券</text>
181 <view class="itemRight"> 189 <view class="itemRight">
182 <view class="rightText"> 190 <view class="rightText">
183 <view class="chooseOffers"> 191 <view class="chooseOffers">
184 <text>-¥70.00</text> 192 <text>-¥70.00</text>
185 </view> 193 </view>
186 <view class="preferentialWay">最大优惠</view> 194 <view class="preferentialWay">最大优惠</view>
187 </view> 195 </view>
188 <image 196 <image
189 src="../../static/right.png" 197 src="../../static/right.png"
190 mode="aspectFill" 198 mode="aspectFill"
191 ></image> 199 ></image>
192 </view> 200 </view>
193 </view> --> 201 </view> -->
194 <view class="item"> 202 <view class="item">
195 <text>运费</text> 203 <text>运费</text>
196 <view class="itemRight"> 204 <view class="itemRight">
197 <view class="freight">免运费</view> 205 <view class="freight">免运费</view>
198 </view> 206 </view>
199 </view> 207 </view>
200 <view class="item"> 208 <view class="item">
201 <text>合计</text> 209 <text>合计</text>
202 <view class="itemRight"> 210 <view class="itemRight">
203 <view class="total">¥{{totalPrice}}</view> 211 <view class="total">¥{{totalPrice}}</view>
204 <!-- <view class="total" v-else>¥{{Number(skuInfo.real_price) * count}}</view> --> 212 <!-- <view class="total" v-else>¥{{Number(skuInfo.real_price) * count}}</view> -->
205 </view> 213 </view>
206 </view> 214 </view>
207 </view> 215 </view>
208 <!-- 216 <!--
209 <view class="checkBox"> 217 <view class="checkBox">
210 <checkbox-group> 218 <checkbox-group>
211 <label> 219 <label>
212 <checkbox color="#FF6B4A" value="isAnonymous" checked="true" />匿名购买 220 <checkbox color="#FF6B4A" value="isAnonymous" checked="true" />匿名购买
213 </label> 221 </label>
214 </checkbox-group> 222 </checkbox-group>
215 </view> --> 223 </view> -->
216 </view> 224 </view>
217 <view class="last_zhanwei"></view> 225 <view class="last_zhanwei"></view>
218 <view class="footer"> 226 <view class="footer">
219 <view class="footerLeft">实付金额: 227 <view class="footerLeft">实付金额:
220 <text >¥{{totalPrice}}</text> 228 <text>¥{{totalPrice}}</text>
221 <!-- <text v-else>¥{{Number(skuInfo.real_price) * count}}</text> --> 229 <!-- <text v-else>¥{{Number(skuInfo.real_price) * count}}</text> -->
222 </view> 230 </view>
223 <view class="footerRight"> 231 <view class="footerRight">
224 <view 232 <view
225 class="paybtn" 233 class="paybtn"
226 @tap="orderBuild" 234 @tap="orderBuild"
227 >立即支付</view> 235 >立即支付</view>
228 </view> 236 </view>
229 </view> 237 </view>
230 </view> 238 </view>
231 </template> 239 </template>
232 240
233 <script> 241 <script>
234 import store from '@/store' 242 import store from '@/store'
235 import MD5Util from '../../utils/md5' 243 import MD5Util from '../../utils/md5'
236 244
237 export default { 245 export default {
238 data() { 246 data() {
239 return { 247 return {
240 name:String, 248 name: String,
241 addAddress: '添加收货地址', 249 addAddress: '添加收货地址',
242 count: 1, 250 count: 1,
243 pid: 0, 251 pid: 0,
244 disabled: false, 252 disabled: false,
245 freight: 0.0, 253 freight: 0.0,
246 showAddress: false, 254 showAddress: false,
247 note: '', 255 note: '',
248 addressInfo: { 256 addressInfo: {
249 address: '', 257 address: '',
250 }, 258 },
251 isCart:Boolean, 259 isCart: Boolean,
252 // isAnonymous: 260 // isAnonymous:
253 checkedCartLst:[] 261 checkedCartLst: [],
254 } 262 }
255 }, 263 },
256 onShow(addressId) { 264 onShow(addressId) {
257 // console.log('+-+-*-*-+-+',addressId) 265 // console.log('+-+-*-*-+-+',addressId)
258 if (addressId) { 266 if (addressId) {
259 store 267 store
260 .dispatch('address/details', { 268 .dispatch('address/details', {
261 add_id: addressId, 269 add_id: addressId,
262 }) 270 })
263 .then(({ code, data }) => { 271 .then(({ code, data }) => {
264 if (code === 1) { 272 if (code === 1) {
265 // console.log('code', code, data) 273 // console.log('code', code, data)
266 this.showAddress = true 274 this.showAddress = true
267 this.addressInfo = data 275 this.addressInfo = data
268 } 276 }
269 }) 277 })
270 } 278 }
271 }, 279 },
272 onLoad({ pid, addressId,isCart ,count,name}) { 280 onLoad({ pid, addressId, isCart, count, name }) {
273 if(isCart == 'false'){ 281 if (isCart == 'false') {
274 282 this.pid = pid
275 this.pid = pid; 283 store.dispatch('read/fetch', {
276 store.dispatch('read/fetch', {
277 pid, 284 pid,
278 }) 285 })
279 } 286 }
280 this.count = count; 287 this.count = count
281 this.name = name; 288 this.name = name
282 this.isCart = isCart; 289 this.isCart = isCart
283 290
284 console.log('++++++++++++'+pid,addressId,isCart) 291 console.log('++++++++++++' + pid, addressId, isCart)
285 this.checkedCartLst = this.$store.state.cart.checkedCartLst 292 this.checkedCartLst = this.$store.state.cart.checkedCartLst
286 // console.log('++++++++++6666666666++',this.$store.state.cart.checkedCartLst) 293 // console.log('++++++++++6666666666++',this.$store.state.cart.checkedCartLst)
287 // 若已经选择地址 294 // 若已经选择地址
288 if (addressId) { 295 if (addressId) {
289 store 296 store
290 .dispatch('address/details', { 297 .dispatch('address/details', {
291 add_id: addressId, 298 add_id: addressId,
292 }) 299 })
293 .then(({ code, data }) => { 300 .then(({ code, data }) => {
294 if (code === 1) { 301 if (code === 1) {
295 // console.log('code', code, data) 302 // console.log('code', code, data)
296 this.showAddress = true 303 this.showAddress = true
297 this.addressInfo = data 304 this.addressInfo = data
298 } 305 }
299 }) 306 })
300 } else { 307 } else {
301 store.dispatch('address/default').then(({ code, data }) => { 308 store.dispatch('address/default').then(({ code, data }) => {
302 if (code === 1) { 309 if (code === 1) {
303 // console.log('code', code, data) 310 // console.log('code', code, data)
304 this.showAddress = true 311 this.showAddress = true
305 this.addressInfo = data 312 this.addressInfo = data
306 } 313 }
307 }) 314 })
308 } 315 }
309 }, 316 },
310 computed: { 317 computed: {
311 totalPrice(){ 318 totalPrice() {
312 if(this.isCart == 'true'){ 319 if (this.isCart == 'true') {
313 let total = 0 320 let total = 0
314 this.$store.state.cart.checkedCartLst.map(item =>{ 321 this.$store.state.cart.checkedCartLst.map(item => {
315 total += item.nowPrice*item.num 322 total += item.nowPrice * item.num
316 }) 323 })
317 return total 324 return total
318 }else{ 325 } else {
319 return this.buyItem.real_price* this.count 326 return this.buyItem.real_price * this.count
320 } 327 }
321 }, 328 },
322 buyItem(){ 329 buyItem() {
323 return this.$store.state.cart.buyItem 330 return this.$store.state.cart.buyItem
324 }, 331 },
325 // checkedCartLst(){ 332 // checkedCartLst(){
326 // console.log('checkedCartLst',this.$store.state.cart.checkedCartLst) 333 // console.log('checkedCartLst',this.$store.state.cart.checkedCartLst)
327 // return this.$store.state.cart.checkedCartLst 334 // return this.$store.state.cart.checkedCartLst
328 // }, 335 // },
329 goodInfo() { 336 goodInfo() {
330 console.log('state', this.$store.state.read.goodInfo) 337 console.log('state', this.$store.state.read.goodInfo)
331 return this.$store.state.read.goodInfo 338 return this.$store.state.read.goodInfo
332 }, 339 },
333 skuInfo() { 340 skuInfo() {
334 return this.$store.state.order.param.sk_id_arr 341 return this.$store.state.order.param.sk_id_arr
335 }, 342 },
336 attrList() { 343 attrList() {
337 return this.$store.state.order.param.attrList 344 return this.$store.state.order.param.attrList
338 }, 345 },
339 current() { 346 current() {
340 return this.$store.state.order.param.current 347 return this.$store.state.order.param.current
341 }, 348 },
342 }, 349 },
343 methods: { 350 methods: {
344 counter(isadd,index) { 351 counter(isadd, index) {
345 if (isadd) { 352 if (isadd) {
346 if(this.isCart =='true'){ 353 if (this.isCart == 'true') {
347 this.checkedCartLst[index].num++ 354 this.checkedCartLst[index].num++
348 }else{ 355 } else {
349 this.count++ 356 this.count++
350 } 357 }
351 } else { 358 } else {
352 if(this.isCart =='true'){ 359 if (this.isCart == 'true') {
353 this.checkedCartLst[index].num<= 1 ? (this.disabled = true) : this.checkedCartLst[index].num-- 360 this.checkedCartLst[index].num <= 1 ? (this.disabled = true) : this.checkedCartLst[index].num--
354 }else{ 361 } else {
355 this.count <= 1 ? (this.disabled = true) : this.count-- 362 this.count <= 1 ? (this.disabled = true) : this.count--
356 } 363 }
357 } 364 }
358 }, 365 },
359 // 跳转添加地址页面 366 // 跳转添加地址页面
360 toaddAddress() { 367 toaddAddress() {
361 uni.navigateTo({ 368 uni.navigateTo({
362 url: `../address/addressList?edit=${1}`, 369 url: `../address/addressList?edit=${1}`,
363 success: res => {}, 370 success: res => {},
364 fail: error => { 371 fail: error => {
365 console.log('跳转到地址列表页面失败====>', error) 372 console.log('跳转到地址列表页面失败====>', error)
366 }, 373 },
367 complete: () => {}, 374 complete: () => {},
368 }) 375 })
369 }, 376 },
370 // 下单 377 // 下单
371 orderBuild() { 378 orderBuild() {
372 uni.showLoading({ 379 uni.showLoading({
373 title: '支付中', 380 title: '支付中',
374 }) 381 })
375 if(this.isCart == 'true'){ 382 if (this.isCart == 'true') {
376 const checkedGoods = [] 383 const checkedGoods = []
377 const sk_id_arr = [] 384 const sk_id_arr = []
378 this.checkedCartLst.map(item=>{ 385 this.checkedCartLst.map(item => {
379 checkedGoods.push(item.pid) 386 checkedGoods.push(item.pid)
380 sk_id_arr.push(item.sk_id) 387 sk_id_arr.push(item.sk_id)
381 }) 388 })
382 store.dispatch('order/build', { 389 store.dispatch('order/build', {
383 uid: this.$store.state.user.userInfo.uid, 390 uid: this.$store.state.user.userInfo.uid,
384 address: JSON.stringify(this.addressInfo), 391 address: JSON.stringify(this.addressInfo),
385 checkedGoods:checkedGoods, 392 checkedGoods: checkedGoods,
386 sk_id_arr: sk_id_arr, 393 sk_id_arr: sk_id_arr,
387 totalPrice: this.totalPrice, 394 totalPrice: this.totalPrice,
388 }).then((res) => { 395 }).then((res) => {
389 this.pay(res.data) 396 this.pay(res.data)
390 }) 397 })
391 } 398 }
392 if(this.isCart == 'false'){ 399 if (this.isCart == 'false') {
393 const { sk_id_arr: skId, mp_id: mpId } = this.$store.state.order.param 400 const { sk_id_arr: skId, mp_id: mpId } = this.$store.state.order.param
394 store.dispatch('order/buyNow', { 401 store.dispatch('order/buyNow', {
395 pid: skId.pid, 402 pid: skId.pid,
396 sk_id: skId.sk_id, 403 sk_id: skId.sk_id,
397 number: this.count, 404 number: this.count,
398 mp_id: mpId, 405 mp_id: mpId,
399 address: JSON.stringify(this.addressInfo), 406 address: JSON.stringify(this.addressInfo),
400 totalPrice: this.totalPrice, 407 totalPrice: this.totalPrice,
401 liuyan: this.note, 408 liuyan: this.note,
402 dir: 1, 409 dir: 1,
403 }).then((res) => { 410 }).then((res) => {
404 this.pay(res.data) 411 this.pay(res.data)
405 }) 412 })
406 } 413 }
407 }, 414 },
408 // 支付 415 // 支付
409 pay(res) { 416 pay(res) {
410 console.log('pay', res) 417 console.log('pay', res)
411 const { data, exKeyName: keyName } = res 418 const { data, exKeyName: keyName } = res
412 const uid = uni.getStorageSync('uid') 419 const uid = uni.getStorageSync('uid')
413 const timeStamp = new Date().getTime().toString() 420 const timeStamp = new Date().getTime().toString()
414 const nonceStr = 'asfafasfasfasfasf' 421 const nonceStr = 'asfafasfasfasfasf'
415 // 支付参数 422 // 支付参数
416 const fieldSet = { 423 const fieldSet = {
417 openid: this.$store.state.user.userInfo.openid, 424 openid: this.$store.state.user.userInfo.openid,
418 uid: this.$store.state.user.userInfo.uid, 425 uid: this.$store.state.user.userInfo.uid,
419 shopid: 0, 426 shopid: 0,
420 payCate: 2020, 427 payCate: 2020,
421 payMoney: this.totalPrice, 428 payMoney: this.totalPrice,
422 payWoodId: `fcdj-${uid}-${keyName}`, 429 payWoodId: `fcdj-${uid}-${keyName}`,
423 payWoodDesc: '在【非常戴镜】的微信付款凭证', 430 payWoodDesc: '在【非常戴镜】的微信付款凭证',
424 nonceStr, 431 nonceStr,
425 signType: 'MD5', 432 signType: 'MD5',
426 app_uid: 2020, 433 app_uid: 2020,
427 timeStamp, 434 timeStamp,
428 keyname: keyName, 435 keyname: keyName,
429 billInfo: JSON.stringify(data), 436 billInfo: JSON.stringify(data),
430 } 437 }
431 // 请求后台支付接口 438 // 请求后台支付接口
432 store.dispatch('order/pay', fieldSet).then(({ data, data2, pay_id: payId }) => { 439 store.dispatch('order/pay', fieldSet).then(({ data, data2, pay_id: payId }) => {
433 if (data.return_code === 'SUCCESS' && data.result_code === 'SUCCESS') { 440 if (data.return_code === 'SUCCESS' && data.result_code === 'SUCCESS') {
434 const stringA = `appId=wx115b25aa396d27ac&nonceStr=${nonceStr}&package=prepay_id=${data.prepay_id}&signType=MD5&timeStamp=${timeStamp}` 441 const stringA = `appId=wx115b25aa396d27ac&nonceStr=${nonceStr}&package=prepay_id=${data.prepay_id}&signType=MD5&timeStamp=${timeStamp}`
435 const stringSignTemp = stringA + '&key=NewMoney2017hatemydaddy123456789' 442 const stringSignTemp = stringA + '&key=NewMoney2017hatemydaddy123456789'
436 443
437 // 微信支付接口 444 // 微信支付接口
438 uni.requestPayment({ 445 uni.requestPayment({
439 appId: data.appid, 446 appId: data.appid,
440 timeStamp, 447 timeStamp,
441 nonceStr, 448 nonceStr,
442 total_fee: this.totalPrice, 449 total_fee: this.totalPrice,
443 package: `prepay_id=${data.prepay_id}`, 450 package: `prepay_id=${data.prepay_id}`,
444 signType: 'MD5', 451 signType: 'MD5',
445 paySign: MD5Util.MD5(stringSignTemp).toUpperCase(), 452 paySign: MD5Util.MD5(stringSignTemp).toUpperCase(),
446 success: (res) => { 453 success: (res) => {
447 // 支付成功 454 // 支付成功
448 uni.showModal({ 455 uni.showModal({
449 content: '支付成功', 456 content: '支付成功',
450 showCancel: false, 457 showCancel: false,
451 }) 458 })
452 // 跳转订单详情页->状态 待收货 459 // 跳转订单详情页->状态 待收货
453 uni.reLaunch({ 460 uni.reLaunch({
454 url: `../myOrderPaying/myOrderPaying?payId=${payId}&status=1&isPay=1`, 461 url: `../myOrderPaying/myOrderPaying?payId=${payId}&status=1&isPay=1`,
455 }) 462 })
456 }, 463 },
457 fail: (res) => { 464 fail: (res) => {
458 // 支付失败 465 // 支付失败
459 uni.showModal({ 466 uni.showModal({
460 content: '支付失败', 467 content: '支付失败',
461 showCancel: false, 468 showCancel: false,
462 }) 469 })
463 // 跳转订单详情页->状态 待付款 470 // 跳转订单详情页->状态 待付款
464 uni.reLaunch({ 471 uni.reLaunch({
465 url: `../myOrderPaying/myOrderPaying?payId=${payId}&status=0&isPay=1`, 472 url: `../myOrderPaying/myOrderPaying?payId=${payId}&status=0&isPay=1`,
466 }) 473 })
467 }, 474 },
468 complete: () => { 475 complete: () => {
469 uni.hideLoading() 476 uni.hideLoading()
470 }, 477 },
471 }) 478 })
472 } else { 479 } else {
473 uni.showModal({ 480 uni.showModal({
474 content: '支付失败', 481 content: '支付失败',
475 showCancel: false, 482 showCancel: false,
476 }) 483 })
477 console.log('支付失败') 484 console.log('支付失败')
478 uni.hideLoading() 485 uni.hideLoading()
479 } 486 }
480 }) 487 })
481 }, 488 },
482 }, 489 },
483 } 490 }
484 </script> 491 </script>
485 492
486 <style lang="scss"> 493 <style lang="scss">
487 .wrap { 494 .wrap {
488 height: 100vh; 495 height: 100vh;
489 background-color: #f2f2f2; 496 background-color: #f2f2f2;
490 font-family: PingFangSC-Regular; 497 font-family: PingFangSC-Regular;
491 letter-spacing: -0.23px; 498 letter-spacing: -0.23px;
492 position: absolute; 499 position: absolute;
493 } 500 }
494 .addAddress { 501 .addAddress {
495 background-color: #ffffff; 502 background-color: #ffffff;
496 box-sizing: border-box; 503 box-sizing: border-box;
497 height: 124rpx; 504 height: 124rpx;
498 width: 100%; 505 width: 100%;
499 display: flex; 506 display: flex;
500 align-items: center; 507 align-items: center;
501 padding: 0 40rpx; 508 padding: 0 40rpx;
502 .addIcon { 509 .addIcon {
503 background-color: #f2f2f2; 510 background-color: #f2f2f2;
504 height: 56rpx; 511 height: 56rpx;
505 width: 60rpx; 512 width: 60rpx;
506 border-radius: 4rpx; 513 border-radius: 4rpx;
507 display: flex; 514 display: flex;
508 justify-content: center; 515 justify-content: center;
509 align-items: center; 516 align-items: center;
510 margin-right: 40rpx; 517 margin-right: 40rpx;
511 } 518 }
512 image { 519 image {
513 height: 28rpx; 520 height: 28rpx;
514 width: 30rpx; 521 width: 30rpx;
515 } 522 }
516 .addressText { 523 .addressText {
517 font-size: 28rpx; 524 font-size: 28rpx;
518 color: #333333; 525 color: #333333;
519 margin-right: 364rpx; 526 margin-right: 364rpx;
520 } 527 }
521 } 528 }
522 .content { 529 .content {
523 background-color: #f2f2f2; 530 background-color: #f2f2f2;
524 width: 100%; 531 width: 100%;
525 display: flex; 532 display: flex;
526 flex-direction: column; 533 flex-direction: column;
527 justify-content: center; 534 justify-content: center;
528 align-items: center; 535 align-items: center;
529 padding: 40rpx; 536 padding: 40rpx;
530 box-sizing: border-box; 537 box-sizing: border-box;
531 .orderInfo { 538 .orderInfo {
532 width: 670rpx; 539 width: 670rpx;
533 min-height: 488rpx; 540 min-height: 488rpx;
534 background-color: #ffffff; 541 background-color: #ffffff;
535 border-radius: 20rpx; 542 border-radius: 20rpx;
536 box-sizing: border-box; 543 box-sizing: border-box;
537 padding: 0 40rpx 40rpx 40rpx; 544 padding: 0 40rpx 40rpx 40rpx;
538 .title { 545 .title {
539 display: flex; 546 display: flex;
540 align-items: center; 547 align-items: center;
541 font-size: 28rpx; 548 font-size: 28rpx;
542 color: #333333; 549 color: #333333;
543 height: 60rpx; 550 height: 60rpx;
544 line-height: 40rpx; 551 line-height: 40rpx;
545 padding: 10rpx 10rpx 10rpx 0rpx; 552 padding: 10rpx 10rpx 10rpx 0rpx;
546 image { 553 image {
547 margin-right: 20rpx; 554 margin-right: 20rpx;
548 } 555 }
549 } 556 }
550 .infoBox { 557 .infoBox {
551 margin-top: 42rpx; 558 margin-top: 42rpx;
552 .infoTop { 559 .infoTop {
553 display: flex; 560 display: flex;
554 flex-direction: row; 561 flex-direction: row;
555 image { 562 image {
556 height: 188rpx; 563 height: 188rpx;
557 width: 188rpx; 564 width: 188rpx;
558 margin-right: 24rpx; 565 margin-right: 24rpx;
559 } 566 }
560 .infoRight { 567 .infoRight {
561 width: 374rpx; 568 width: 374rpx;
562 display: flex; 569 display: flex;
563 flex-direction: column; 570 flex-direction: column;
564 align-items: flex-start; 571 align-items: flex-start;
565 justify-content: space-between; 572 justify-content: space-between;
566 .goodName { 573 .goodName {
567 font-size: 28rpx; 574 font-size: 28rpx;
568 color: #333333; 575 color: #333333;
569 } 576 }
570 .remarks { 577 .remarks {
571 font-size: 20rpx; 578 font-size: 20rpx;
572 color: #999999; 579 color: #999999;
573 } 580 }
574 .priceBox { 581 .priceBox {
575 display: flex; 582 display: flex;
576 justify-content: space-between; 583 justify-content: space-between;
577 align-items: center; 584 align-items: center;
578 width: 100%; 585 width: 100%;
579 .price { 586 .price {
580 color: #ff6b4a; 587 color: #ff6b4a;
581 font-size: 28rpx; 588 font-size: 28rpx;
582 } 589 }
583 .originCost { 590 .originCost {
584 text-decoration: line-through; 591 text-decoration: line-through;
585 color: #999999; 592 color: #999999;
586 font-size: 20rpx; 593 font-size: 20rpx;
587 } 594 }
588 .counter { 595 .counter {
589 display: flex; 596 display: flex;
590 flex-direction: row; 597 flex-direction: row;
591 justify-content: space-between; 598 justify-content: space-between;
592 font-size: 28rpx; 599 font-size: 28rpx;
593 color: #333333; 600 color: #333333;
594 width: 122rpx; 601 width: 122rpx;
595 .btn { 602 .btn {
596 display: flex; 603 display: flex;
597 justify-content: center; 604 justify-content: center;
598 line-height: 32rpx; 605 line-height: 32rpx;
599 height: 32rpx; 606 height: 32rpx;
600 width: 32rpx; 607 width: 32rpx;
601 background-color: #f2f2f2; 608 background-color: #f2f2f2;
602 color: #cfcfcf; 609 color: #cfcfcf;
603 } 610 }
604 } 611 }
605 } 612 }
606 } 613 }
607 } 614 }
608 .infoBottom { 615 .infoBottom {
609 display: flex; 616 display: flex;
610 flex-direction: column; 617 flex-direction: column;
611 justify-content: flex-start; 618 justify-content: flex-start;
612 font-size: 24rpx; 619 font-size: 24rpx;
613 color: #333333; 620 color: #333333;
614 text { 621 text {
615 color: #999999; 622 color: #999999;
616 margin-left: 20rpx; 623 margin-left: 20rpx;
617 } 624 }
618 625
619 .norm { 626 .norm {
620 margin-top: 28rpx; 627 margin-top: 28rpx;
621 } 628 }
622 .shippingMethod { 629 .shippingMethod {
623 margin-top: 12rpx; 630 margin-top: 12rpx;
624 } 631 }
625 .message { 632 .message {
626 display: flex; 633 display: flex;
627 flex-direction: row; 634 flex-direction: row;
628 align-items: center; 635 align-items: center;
629 margin-top: 18rpx; 636 margin-top: 18rpx;
630 input { 637 input {
631 margin-left: 20rpx; 638 margin-left: 20rpx;
632 width: 75%; 639 width: 75%;
633 } 640 }
634 } 641 }
635 } 642 }
636 } 643 }
637 } 644 }
638 .payWay { 645 .payWay {
639 height: 464rpx; 646 height: 464rpx;
640 width: 670rpx; 647 width: 670rpx;
641 background-color: #ffffff; 648 background-color: #ffffff;
642 color: #333333; 649 color: #333333;
643 font-size: 24rpx; 650 font-size: 24rpx;
644 border-radius: 20rpx; 651 border-radius: 20rpx;
645 box-sizing: border-box; 652 box-sizing: border-box;
646 padding: 0 52rpx 0rpx 40rpx; 653 padding: 0 52rpx 0rpx 40rpx;
647 margin-top: 20rpx; 654 margin-top: 20rpx;
648 display: flex; 655 display: flex;
649 flex-direction: column; 656 flex-direction: column;
650 justify-content: center; 657 justify-content: center;
651 align-items: flex-start; 658 align-items: flex-start;
652 .item { 659 .item {
653 display: flex; 660 display: flex;
654 flex-direction: row; 661 flex-direction: row;
655 justify-content: space-between; 662 justify-content: space-between;
656 align-items: center; 663 align-items: center;
657 width: 100%; 664 width: 100%;
658 height: 115rpx; 665 height: 115rpx;
659 .itemRight { 666 .itemRight {
660 display: flex; 667 display: flex;
661 flex-direction: row; 668 flex-direction: row;
662 justify-content: space-between; 669 justify-content: space-between;
663 align-items: center; 670 align-items: center;
664 image { 671 image {
665 height: 24rpx; 672 height: 24rpx;
666 width: 12rpx; 673 width: 12rpx;
667 } 674 }
668 .rightText { 675 .rightText {
669 margin-right: 20rpx; 676 margin-right: 20rpx;
670 text-align: right; 677 text-align: right;
671 .choosePayWay { 678 .choosePayWay {
672 display: flex; 679 display: flex;
673 align-items: center; 680 align-items: center;
674 text { 681 text {
675 color: #333333; 682 color: #333333;
676 } 683 }
677 image { 684 image {
678 height: 36rpx; 685 height: 36rpx;
679 width: 40rpx; 686 width: 40rpx;
680 margin-right: 8px; 687 margin-right: 8px;
681 } 688 }
682 } 689 }
683 .randomSubstraction { 690 .randomSubstraction {
684 color: #ff6b4a; 691 color: #ff6b4a;
685 } 692 }
686 .preferentialWay { 693 .preferentialWay {
687 color: #999999; 694 color: #999999;
688 } 695 }
689 } 696 }
690 .freight, 697 .freight,
691 .total { 698 .total {
692 margin-right: 32rpx; 699 margin-right: 32rpx;
693 } 700 }
694 text { 701 text {
695 color: #ff6b4a; 702 color: #ff6b4a;
696 } 703 }
697 } 704 }
698 } 705 }
699 } 706 }
700 // .checkBox { 707 // .checkBox {
701 // height: 58rpx; 708 // height: 58rpx;
702 // line-height: 58rpx; 709 // line-height: 58rpx;
703 // width: 100%; 710 // width: 100%;
704 // margin-top: 36rpx; 711 // margin-top: 36rpx;
705 // margin-left: 40rpx; 712 // margin-left: 40rpx;
706 // font-size: 12px; 713 // font-size: 12px;
707 // color: #999999; 714 // color: #999999;
708 // } 715 // }
709 } 716 }
710 .footer { 717 .footer {
711 height: 112rpx; 718 height: 112rpx;
712 width: 100%; 719 width: 100%;
713 background-color: #fff; 720 background-color: #fff;
714 font-size: 16px; 721 font-size: 16px;
715 display: flex; 722 display: flex;
716 justify-content: space-between; 723 justify-content: space-between;
717 align-items: center; 724 align-items: center;
718 position: fixed; 725 position: fixed;
719 bottom: 0; 726 bottom: 0;
720 z-index: 9999; 727 z-index: 9999;
721 .footerLeft { 728 .footerLeft {
722 display: flex; 729 display: flex;
723 justify-content: center; 730 justify-content: center;
724 align-items: center; 731 align-items: center;
725 width: 50%; 732 width: 50%;
726 color: #333333; 733 color: #333333;
727 text { 734 text {
728 color: #ff6b4a; 735 color: #ff6b4a;
729 } 736 }
730 } 737 }
731 .footerRight { 738 .footerRight {
732 display: flex; 739 display: flex;
733 justify-content: flex-end; 740 justify-content: flex-end;
734 align-items: center; 741 align-items: center;
735 width: 50%; 742 width: 50%;
736 margin-right: 26rpx; 743 margin-right: 26rpx;
737 .paybtn { 744 .paybtn {
738 display: flex; 745 display: flex;
739 justify-content: center; 746 justify-content: center;
740 align-items: center; 747 align-items: center;
741 background: #ff6b4a; 748 background: #ff6b4a;
742 border-radius: 20px; 749 border-radius: 20px;
743 border-radius: 20px; 750 border-radius: 20px;
744 color: #ffffff; 751 color: #ffffff;
745 width: 204rpx; 752 width: 204rpx;
746 height: 80rpx; 753 height: 80rpx;
747 } 754 }
748 } 755 }
749 } 756 }
750 // 地址信息样式 757 // 地址信息样式
751 .order-user { 758 .order-user {
752 width: 670rpx; 759 width: 670rpx;
753 height: 228rpx; 760 height: 228rpx;
754 background: #ffffff; 761 background: #ffffff;
755 border-radius: 14rpx; 762 border-radius: 14rpx;
756 margin: 0 auto; 763 margin: 0 auto;
757 margin-top: 20rpx; 764 margin-top: 20rpx;
758 position: relative; 765 position: relative;
759 .order-user-head { 766 .order-user-head {
760 display: flex; 767 display: flex;
761 height: 108rpx; 768 height: 108rpx;
762 width: 100%; 769 width: 100%;
763 align-items: center; 770 align-items: center;
764 padding-left: 126rpx; 771 padding-left: 126rpx;
765 box-sizing: border-box; 772 box-sizing: border-box;
766 .name { 773 .name {
767 display: flex; 774 display: flex;
768 justify-content: space-between; 775 justify-content: space-between;
769 font-size: 14px; 776 font-size: 14px;
770 color: #333333; 777 color: #333333;
771 letter-spacing: -0.26px; 778 letter-spacing: -0.26px;
772 margin-right: 20rpx; 779 margin-right: 20rpx;
773 .default { 780 .default {
774 height: 40rpx; 781 height: 40rpx;
775 width: 80rpx; 782 width: 80rpx;
776 background-color: #4a90e2; 783 background-color: #4a90e2;
777 border-radius: 13px; 784 border-radius: 13px;
778 border-radius: 13px; 785 border-radius: 13px;
779 text-align: center; 786 text-align: center;
780 margin-right: 20rpx; 787 margin-right: 20rpx;
781 text { 788 text {
782 display: flex; 789 display: flex;
783 justify-content: center; 790 justify-content: center;
784 align-items: center; 791 align-items: center;
785 font-size: 12px; 792 font-size: 12px;
786 color: #ffffff; 793 color: #ffffff;
787 letter-spacing: -0.23px; 794 letter-spacing: -0.23px;
788 } 795 }
789 } 796 }
790 } 797 }
791 .mobile { 798 .mobile {
792 font-size: 14px; 799 font-size: 14px;
793 color: #999999; 800 color: #999999;
794 letter-spacing: -0.26px; 801 letter-spacing: -0.26px;
795 } 802 }
796 } 803 }
797 .order-user-body { 804 .order-user-body {
798 display: flex; 805 display: flex;
799 width: 100%; 806 width: 100%;
800 image { 807 image {
801 width: 24px; 808 width: 24px;
802 height: 28px; 809 height: 28px;
803 margin: 12rpx 32rpx 0 40rpx; 810 margin: 12rpx 32rpx 0 40rpx;
804 } 811 }
805 .address { 812 .address {
806 font-weight: bold; 813 font-weight: bold;
807 font-size: 14px; 814 font-size: 14px;
808 color: #333333; 815 color: #333333;
809 letter-spacing: -0.26px; 816 letter-spacing: -0.26px;
810 } 817 }
811 } 818 }
812 .arrow { 819 .arrow {
813 width: 12px; 820 width: 12px;
814 height: 12px; 821 height: 12px;
815 position: absolute; 822 position: absolute;
816 right: 40rpx; 823 right: 40rpx;
817 bottom: 104rpx; 824 bottom: 104rpx;
818 } 825 }
819 } 826 }
820 .last_zhanwei{ 827 .last_zhanwei {
821 background: #f2f2f2; 828 background: #f2f2f2;
822 height: 60px; 829 height: 60px;
823 } 830 }
824 </style> 831 </style>