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