Blame view

src/pages/cart/cart.vue 14 KB
0db291810   BigBoss   “-mcomfirmOder页面
1
  <template>
a3d2beaa8   范牧   立即支付功能
2
3
    <view class="content">
      <block v-if="cartList.length==0">
7a7226fea   范牧   冲突合并
4
  
a3d2beaa8   范牧   立即支付功能
5
6
7
8
9
10
      </block>
      <block v-else>
        <view class="card">
          <view class="cardHeader">
            <view
              v-bind:class="pIsoPen? 'partentChecked' : 'partentCheck'"
15af636b4   BigBoss   购物车逻辑
11
  			@click="pClick"
a3d2beaa8   范牧   立即支付功能
12
13
14
15
16
17
18
19
20
            >
              <span class="correct"></span>
            </view>
            <image
              src="../../static/store.png"
              mode="aspectFill"
            ></image>
            <text>非常戴镜</text>
          </view>
a3d2beaa8   范牧   立即支付功能
21
22
23
          <view
            class="cardBody"
            v-for="(item,index) in cartList"
93e6a2650   喻鹏   首页懒加载
24
            :key="index"
a3d2beaa8   范牧   立即支付功能
25
26
27
            @longpress="delCart(item.cart_id,index)"
          >
            <view
15af636b4   BigBoss   购物车逻辑
28
              v-bind:class="childIsOpenArr[index]? 'partentChecked':'partentCheck'"
7c4ec5932   BigBoss   修改逻辑
29
  			@click="childClick(index)"
a3d2beaa8   范牧   立即支付功能
30
31
32
33
34
35
36
37
38
39
40
            >
              <span class="correct"></span>
            </view>
            <view class="imageWrap">
              <image
                :src="item.img_index_url"
                mode="aspectFit"
                style="width: 188rpx;height: 168rpx;"
              ></image>
            </view>
            <view class="goodInfo">
55420a8a9   范牧   解决冲突
41
42
43
              <!-- <view class="imageWrap">
                <image :src="item.img_index_url" mode="aspectFit" style="width: 188rpx;height: 168rpx;"></image>
              </view> -->
a3d2beaa8   范牧   立即支付功能
44
45
46
47
48
              <view class="infoRight">
                <view
                  class="goodName"
                  @tap="toGoods(item.pid,item.sk_id)"
                >{{item.p_name}}</view>
22e1420fa   BigBoss   弹窗组件修改
49
50
51
52
53
54
55
56
57
58
59
60
                <view class="describ"  @click="showBottom(3,item.pid,item.sk_id,item.mp_id,item.cart_id,index)">
  				  <view class="desL">
  						<view class="people">
  							使用人:{{item.peopleName}}
  						</view>
  						<view class="skuInfo">
  							{{item.sku_name}}
  						</view>
  				  </view>
  				  <view class="desR">
  						<image src="../../static/right.png" mode="aspectFit" style="width: 18rpx;height: 18rpx;"></image>
  				  </view>
0bda9efec   BigBoss   购物车功能修改
61
                </view>
a3d2beaa8   范牧   立即支付功能
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
                <view class="priceBox">
                  <view class="price">¥{{item.nowPrice*item.num}}</view>
                  <text class="maxCount">(限购{{maxCount}}副)</text>
                  <view class="counter">
                    <view
                      class="btn"
                      disabled="this.addDisabled"
                      type="default"
                      @tap="counter(index,false,item)"
                    >-</view>
                    <text>{{item.num}}</text>
                    <view
                      class="btn"
                      disabled="this.desDisabled"
                      type="default"
                      @tap="counter(index,true,item)"
                    >+</view>
                  </view>
                </view>
              </view>
            </view>
          </view>
        </view>
      </block>
      <view class="footer">
        <view class="footerLeft">实付金额:<text>¥{{totalPrice}}</text></view>
        <view class="footerRight">
0bda9efec   BigBoss   购物车功能修改
89
            <view class="paybtn" @click="toComfirmOrder">立即结算</view>
a3d2beaa8   范牧   立即支付功能
90
91
        </view>
      </view>
22e1420fa   BigBoss   弹窗组件修改
92
93
94
  	<BottomSheet v-if="isShowBottom" :isCart="isCart" @addCart="addCart" :sk_id="sk_id" :propMpId="mp_id" @chooseCartModi="chooseCartModi" :cart_id="cart_id"
  	:index="cartIndex"
  	 :pid="pid" :goodInfo="goodInfo" :isShowBottom="isShowBottom"  @closeBottom="closeBottom"></BottomSheet>
a3d2beaa8   范牧   立即支付功能
95
    </view>
0db291810   BigBoss   “-mcomfirmOder页面
96
97
98
  </template>
  
  <script>
0bda9efec   BigBoss   购物车功能修改
99
  
7a7226fea   范牧   冲突合并
100
  import store from '@/store'
22e1420fa   BigBoss   弹窗组件修改
101
102
103
104
105
  import BottomSheet from '../../components/BottomSheet/BottomSheet.vue';
  export default {  
  	components:{
  		BottomSheet,
  	},
7a7226fea   范牧   冲突合并
106
107
    data() {
      return {
22e1420fa   BigBoss   弹窗组件修改
108
109
110
111
112
  		pid:Number,
  		isCart:Number,
  		sk_id:String,
  		mp_id:String,
  		isShowBottom : false,	//底部弹窗开关
15af636b4   BigBoss   购物车逻辑
113
114
115
  		// totalPrice: 0,
  		pIsoPen: Boolean,
  		childIsOpenArr:[],
22e1420fa   BigBoss   弹窗组件修改
116
117
118
  		cart_id:Number,
  		maxCount: 20,
  		cartIndex:Number
7a7226fea   范牧   冲突合并
119
120
121
      }
    },
    computed: {
15af636b4   BigBoss   购物车逻辑
122
  
22e1420fa   BigBoss   弹窗组件修改
123
  	goodInfo () {
22e1420fa   BigBoss   弹窗组件修改
124
125
  	  return this.$store.state.read.goodInfo
  	},
7a7226fea   范牧   冲突合并
126
      cartList() {
637a02b07   尹聃   添加购物车
127
        return this.$store.state.cart.cartList
7a7226fea   范牧   冲突合并
128
      },
15af636b4   BigBoss   购物车逻辑
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
  	totalPrice() {
  		const itemPriceArr = []
  		this.cartList.map(item =>{
  			itemPriceArr.push(item.num*item.nowPrice)
  		})
  		let total = 0
  		if(this.pIsoPen){
  			itemPriceArr.map(item =>{
  				total += item
  			})
  		}else{
  			this.childIsOpenArr.map((item,index) =>{
  				if(item){
  					total += itemPriceArr[index]
  				}
  			})
  		}
  		return total
  	},
  
7a7226fea   范牧   冲突合并
149
    },
22e1420fa   BigBoss   弹窗组件修改
150
    onShow() {
22e1420fa   BigBoss   弹窗组件修改
151
    },
7a7226fea   范牧   冲突合并
152
    onLoad: function() {
15af636b4   BigBoss   购物车逻辑
153
154
  	  //全选置否
    	this.pIsoPen = false
7a7226fea   范牧   冲突合并
155
      store.dispatch('cart/getCartList', {
a3d2beaa8   范牧   立即支付功能
156
        uid: this.$store.state.user.userInfo.uid, // 用户id
7a7226fea   范牧   冲突合并
157
      })
15af636b4   BigBoss   购物车逻辑
158
159
160
161
162
163
164
165
166
  	.then((res)=>{
  		//单选置否
  		  const temp = []
  		  temp.length = this.$store.state.cart.cartList.length
  		  for (let i = 0; i < temp.length; i++) {
  		    temp[i] = false
  		  }
  		  this.childIsOpenArr = temp
  	})
7a7226fea   范牧   冲突合并
167
    },
7a7226fea   范牧   冲突合并
168
    methods: {
15af636b4   BigBoss   购物车逻辑
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
  	  //全选按钮
  	  pClick(){
  		  if(this.pIsoPen){
  			  this.pIsoPen = false
  			  this.childIsOpenArr.map((item,index)=> {
  				  this.childIsOpenArr[index] = false
  			  })
  		  }else{
  			  this.pIsoPen = true
  			  this.childIsOpenArr.map((item,index)=> {
  				  this.childIsOpenArr[index] = true
  			  })
  		  }
  	  },
  	  //单选按钮
7c4ec5932   BigBoss   修改逻辑
184
185
  	  childClick(index){
  		  this.childIsOpenArr[index] = !this.childIsOpenArr[index]
15af636b4   BigBoss   购物车逻辑
186
187
  		  if(this.childIsOpenArr.find(item => item == false)==undefined){
  			  this.pIsoPen = true
7c4ec5932   BigBoss   修改逻辑
188
189
  		  }else{
  			  this.pIsoPen = false
15af636b4   BigBoss   购物车逻辑
190
  		  }
15af636b4   BigBoss   购物车逻辑
191
  	  },
22e1420fa   BigBoss   弹窗组件修改
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
  	  //修改购物车
  	  chooseCartModi(mp_id,sk_id,price,pid,num,cart_id,index){
  		  // console.log('modi',mp_id,sk_id,price,pid,num,cart_id)
  		  store.dispatch('cart/modiCart', {
  		    uid: this.$store.state.user.userInfo.uid,
  		    openid: this.$store.state.user.userInfo.openid,
  		    mp_id: mp_id,
  		    sk_id: sk_id,
  		    price: price,
  		    pid: pid,
  		    num: num,
  		    cart_id: cart_id,
  			args: {
  			  index: index,
  			},
  		  })
  		  store.dispatch('cart/getCartList', {
  			uid: this.$store.state.user.userInfo.uid, // 用户id
  		  })
  	  
  		  this.$forceUpdate()
15af636b4   BigBoss   购物车逻辑
213
  		  // console.log('21212121212',this.cartList)
22e1420fa   BigBoss   弹窗组件修改
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
  	  },
  	  //底部弹窗开关
  	  showBottom(isCart,pid,skId,mp_id,cart_id,index){
  		  store.dispatch('read/fetch', {
  			pid,
  			sk_id: skId,
  		  }).then(()=>{
  			  this.cartIndex = index
  			  this.sk_id = skId;
  			  this.pid = pid;
  			  this.mp_id = mp_id;
  			  this.isCart = isCart;
  			  this.cart_id = cart_id;
  			  this.isShowBottom = true;
  		  })
  	  },
  	  closeBottom(){
  	  	this.isShowBottom = false;
  	  },
b9fb65756   喻鹏   购物车和推荐产品根据sk_id来对应价格
233
      toGoods(id, sk_id) {
55420a8a9   范牧   解决冲突
234
235
236
237
238
239
        uni.navigateTo({
          url: '../frameDetail/frameDetail?pid=' + id + '&sk_id=' + sk_id,
          success: res => {},
          fail: () => {},
          complete: () => {},
        })
7a7226fea   范牧   冲突合并
240
      },
0bda9efec   BigBoss   购物车功能修改
241
242
243
  	toComfirmOrder(){
  		uni.navigateTo({
  			url:`../confirmOrder/confirmOrder`,
0bda9efec   BigBoss   购物车功能修改
244
245
  		})
  	},
b83c44fe1   喻鹏   购物车和用户推荐传参
246
      counter(index, isadd, item) {
15af636b4   BigBoss   购物车逻辑
247
248
        // console.log('item=====>', item)
        // console.log('num=====>', item.num)
a3d2beaa8   范牧   立即支付功能
249
        const nums = parseInt(item.num)
7a7226fea   范牧   冲突合并
250
        if (isadd) {
b83c44fe1   喻鹏   购物车和用户推荐传参
251
          if (nums >= this.maxCount) {
7a7226fea   范牧   冲突合并
252
253
254
            this.addDisabled = true
          } else {
            this.addDisabled = true
7a7226fea   范牧   冲突合并
255
            store.dispatch('cart/modiCart', {
acc7ee230   喻鹏   购物车,用户推荐,新增验光逻辑修改
256
257
              uid: this.$store.state.user.userInfo.uid,
              openid: this.$store.state.user.userInfo.openid,
b83c44fe1   喻鹏   购物车和用户推荐传参
258
259
              mp_id: item.mp_id,
              sk_id: item.sk_id,
a3d2beaa8   范牧   立即支付功能
260
261
              price: item.nowPrice,
              pid: item.pid,
b83c44fe1   喻鹏   购物车和用户推荐传参
262
              num: nums + 1,
a3d2beaa8   范牧   立即支付功能
263
              cart_id: item.cart_id,
7a7226fea   范牧   冲突合并
264
265
              args: {
                index: index,
a3d2beaa8   范牧   立即支付功能
266
267
                isadd: isadd,
              },
7a7226fea   范牧   冲突合并
268
269
270
271
            })
            this.addDisabled = false
          }
        } else {
b83c44fe1   喻鹏   购物车和用户推荐传参
272
          if (nums <= 1) {
7a7226fea   范牧   冲突合并
273
274
275
            this.desDisabled = true
          } else {
            this.desDisabled = false
15af636b4   BigBoss   购物车逻辑
276
         
7a7226fea   范牧   冲突合并
277
            store.dispatch('cart/modiCart', {
acc7ee230   喻鹏   购物车,用户推荐,新增验光逻辑修改
278
279
              uid: this.$store.state.user.userInfo.uid,
              openid: this.$store.state.user.userInfo.openid,
b83c44fe1   喻鹏   购物车和用户推荐传参
280
281
              mp_id: item.mp_id,
              sk_id: item.sk_id,
a3d2beaa8   范牧   立即支付功能
282
283
              price: item.nowPrice,
              pid: item.pid,
b83c44fe1   喻鹏   购物车和用户推荐传参
284
              num: nums - 1,
a3d2beaa8   范牧   立即支付功能
285
              cart_id: item.cart_id,
7a7226fea   范牧   冲突合并
286
287
              args: {
                index: index,
a3d2beaa8   范牧   立即支付功能
288
289
                isadd: isadd,
              },
7a7226fea   范牧   冲突合并
290
291
292
293
            })
            this.desDisabled = true
          }
        }
22e1420fa   BigBoss   弹窗组件修改
294
  
7a7226fea   范牧   冲突合并
295
296
      },
      delCart(cart_id, index) {
7a7226fea   范牧   冲突合并
297
        cart_id = parseInt(cart_id)
93e6a2650   喻鹏   首页懒加载
298
299
  	  uni.showModal({
  	    title: '是否删除该商品',
93e6a2650   喻鹏   首页懒加载
300
301
  	    success: function (res) {
  	      if (res.confirm) { 
15af636b4   BigBoss   购物车逻辑
302
  	
93e6a2650   喻鹏   首页懒加载
303
304
305
306
307
308
309
310
311
  	        store.dispatch('cart/delCart', {
  	          uid: this.$store.state.user.userInfo.uid,
  	          openid: this.$store.state.user.userInfo.openid,
  	          cart_id: cart_id, // 要修改的购物车id
  	          arg: index, // 由于action 传参是能接收两参数,因此将index放入对象
  	        })
  	      }
  	    }.bind(this),
  	  })	  
a3d2beaa8   范牧   立即支付功能
312
313
      },
    },
7a7226fea   范牧   冲突合并
314
  }
0db291810   BigBoss   “-mcomfirmOder页面
315
316
  </script>
  
6111092e8   BigBoss   update cart
317
  <style lang="scss">
637a02b07   尹聃   添加购物车
318
  .content {
a3d2beaa8   范牧   立即支付功能
319
320
321
322
323
324
325
326
    min-height: 100vh;
    background-color: #f2f2f2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 20rpx 40rpx;
    box-sizing: border-box;
66638e4bb   喻鹏   购物车样式和新增验光单样式修改
327
  
a3d2beaa8   范牧   立即支付功能
328
329
330
331
332
333
    .partentCheck {
      width: 16px;
      height: 16px;
      border-radius: 22px;
      border: 1px solid #cfcfcf;
      background-color: #ffffff;
93e6a2650   喻鹏   首页懒加载
334
      margin: 24rpx 12rpx 24rpx 24rpx;
a3d2beaa8   范牧   立即支付功能
335
336
337
338
339
340
    }
    .partentChecked {
      width: 18px;
      height: 18px;
      border-radius: 22px;
      background-color: #ff6b4a;
93e6a2650   喻鹏   首页懒加载
341
      margin: 24rpx 12rpx 24rpx 24rpx;
a3d2beaa8   范牧   立即支付功能
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
      .correct {
        display: inline-block;
        position: relative;
        width: 10rpx;
        height: 2rpx;
        background: #ffffff;
        line-height: 0;
        font-size: 0;
        position: relative;
        top: -7px;
        left: 4px;
        -webkit-transform: rotate(45deg);
      }
      .correct:after {
        content: "/";
        display: block;
        width: 16rpx;
        height: 2rpx;
        background: #ffffff;
        -webkit-transform: rotate(-90deg) translateY(50%) translateX(50%);
      }
    }
66638e4bb   喻鹏   购物车样式和新增验光单样式修改
364
  
a3d2beaa8   范牧   立即支付功能
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
    .card {
      background-color: #ffffff;
      border-radius: 16rpx;
      box-sizing: border-box;
      padding: 36rpx 36rpx 36rpx 18rpx;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 180rpx;
      .cardHeader {
        width: 100%;
        height: 36rpx;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        margin-bottom: 20rpx;
        image {
          height: 32rpx;
          width: 32rpx;
          padding-left: 6px;
          padding-right: 10px;
        }
        text {
          // font-family: PingFangSC-Regular;
          font-size: 14px;
          color: #333333;
          letter-spacing: -0.26px;
        }
      }
      .cardBody {
        width: 100%;
        min-height: 300rpx;
        display: flex;
        align-items: center;
        justify-content: space-between;
        .goodInfo {
          width: 390rpx;
          display: flex;
          flex-direction: row;
          justify-content: flex-start;
          padding-left: 6px;
7a7226fea   范牧   冲突合并
407
  
a3d2beaa8   范牧   立即支付功能
408
409
410
411
          .imageWrap {
            height: 188rpx;
            width: 188rpx;
            margin-right: 28rpx;
7a7226fea   范牧   冲突合并
412
  
a3d2beaa8   范牧   立即支付功能
413
414
415
416
417
418
419
420
421
422
423
424
            image {
              border-radius: 4px;
              height: 188rpx;
              width: 188rpx;
            }
          }
          .infoRight {
            display: flex;
            flex-direction: column;
            align-items: flex-start;
            justify-content: space-between;
            min-height: 240rpx;
22e1420fa   BigBoss   弹窗组件修改
425
  		  width: 100%;
a3d2beaa8   范牧   立即支付功能
426
427
428
429
430
431
432
433
434
435
436
            .goodName {
              display: -webkit-box;
              -webkit-box-orient: vertical;
              -webkit-line-clamp: 2;
              text-align: justify;
              overflow: hidden;
              font-size: 28rpx;
              color: #333333;
            }
            .describ {
              width: 100%;
0bda9efec   BigBoss   购物车功能修改
437
              min-height: 80rpx;
22e1420fa   BigBoss   弹窗组件修改
438
439
440
441
  			background: #F9F9F9;
  			border-radius: 2px;
              box-sizing: border-box;
              padding: 10rpx;
a3d2beaa8   范牧   立即支付功能
442
443
              font-size: 20rpx;
              letter-spacing: -0.23px;
a3d2beaa8   范牧   立即支付功能
444
              color: #999999;
22e1420fa   BigBoss   弹窗组件修改
445
446
447
448
449
450
451
452
  			display: flex;
  			justify-content: space-between;
  			align-items: center;
  			.desL{
  				
  				view{
  					margin: 10rpx 0 10rpx 0 ;
  				}
0bda9efec   BigBoss   购物车功能修改
453
  			}
22e1420fa   BigBoss   弹窗组件修改
454
  			
a3d2beaa8   范牧   立即支付功能
455
456
457
458
459
460
461
462
463
464
465
            }
            .priceBox {
              display: flex;
              justify-content: space-between;
              align-items: center;
              // margin-top: 26px;
              width: 100%;
              font-size: 14px;
              color: #999999;
              .maxCount {
                color: #999999;
22e1420fa   BigBoss   弹窗组件修改
466
                font-size: 20rpx;
a3d2beaa8   范牧   立即支付功能
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
              }
              .price {
                color: #ff6b4a;
                font-size: 28rpx;
              }
              .counter {
                display: flex;
                flex-direction: row;
                justify-content: space-between;
                align-items: center;
                font-size: 28rpx;
                color: #333333;
                width: 122rpx;
                .btn {
                  display: flex;
                  justify-content: center;
                  line-height: 32rpx;
                  height: 32rpx;
                  width: 32rpx;
                  background-color: #f2f2f2;
                  color: #cfcfcf;
                }
              }
            }
          }
        }
      }
    }
a3d2beaa8   范牧   立即支付功能
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
    .footer {
      position: fixed;
      left: 0;
      bottom: 0px;
      height: 112rpx;
      width: 100%;
      background-color: #ffffff;
      font-size: 16px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      .footerLeft {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 50%;
        color: #333333;
        text {
          color: #ff6b4a;
        }
      }
      .footerRight {
        display: flex;
        justify-content: flex-end;
        align-items: center;
        width: 50%;
        margin-right: 26rpx;
        .paybtn {
          display: flex;
          justify-content: center;
          align-items: center;
          background: #ff6b4a;
          border-radius: 20px;
          border-radius: 20px;
          color: #ffffff;
          width: 204rpx;
          height: 80rpx;
        }
      }
    }
  }
22e1420fa   BigBoss   弹窗组件修改
536
537
538
539
540
541
  /* 隐藏滚动条 */
   ::-webkit-scrollbar {
  	width: 0;
  	height: 0;
  	color: transparent;
    }
7a7226fea   范牧   冲突合并
542
  </style>