|
@@ -141,7 +141,8 @@
|
|
|
choosePageNo: 1, // 已选产品当前页
|
|
|
choosePageSize: 8, // 已选产品每页数
|
|
|
chooseTotal: 0 ,// 已选产品总记录数
|
|
|
- promoActiveSn: null
|
|
|
+ promoActiveSn: null, // 活动sn
|
|
|
+ cacheChooseList: [] // 缓存得已选列表
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
@@ -177,10 +178,8 @@
|
|
|
this.$store.state.vuex_tempData = null
|
|
|
this.promoActiveSn = opts.promoActiveSn
|
|
|
// 购物车是否有缓存
|
|
|
- const hasCache = this.$store.state.vuex_cartList.find(k => k.sn == this.promoActiveSn)
|
|
|
- if(hasCache){
|
|
|
- this.chooseList = hasCache.list
|
|
|
- }
|
|
|
+ const cacheList = this.$store.state.vuex_cartList.find(k => k.sn == this.promoActiveSn)
|
|
|
+ this.cacheChooseList = cacheList ? cacheList.list : []
|
|
|
this.screenWidth = uni.getSystemInfoSync().windowWidth
|
|
|
// 查询产品列表
|
|
|
this.pageInit()
|
|
@@ -211,9 +210,9 @@
|
|
|
item.checked = true
|
|
|
item.qty = 1
|
|
|
item.show = false
|
|
|
- this.chooseList.unshift(this.$u.deepClone(item))
|
|
|
+ this.chooseList.unshift(item)
|
|
|
}else{
|
|
|
- item.qty = item.qty + 1
|
|
|
+ // item.qty = item.qty + 1
|
|
|
// 已添加,则增加数量
|
|
|
const row = this.chooseList.find(key => key.id == item.id)
|
|
|
if(row){
|
|
@@ -274,11 +273,11 @@
|
|
|
this.chooseList.splice()
|
|
|
}
|
|
|
// 更新页面产品数据
|
|
|
- const aindex = this.list.findIndex(key => key.id == e.index)
|
|
|
- if(aindex>=0){
|
|
|
- this.list[aindex].qty = e.value
|
|
|
- this.list.splice()
|
|
|
- }
|
|
|
+ // const aindex = this.list.findIndex(key => key.id == e.index)
|
|
|
+ // if(aindex>=0){
|
|
|
+ // this.list[aindex].qty = e.value
|
|
|
+ // this.list.splice()
|
|
|
+ // }
|
|
|
}else{
|
|
|
// 数量为0时,删除
|
|
|
this.chooseClick(e.index,0)
|
|
@@ -366,6 +365,12 @@
|
|
|
const list = res.data.list||[]
|
|
|
// 更新已选状态
|
|
|
list.map(k => {
|
|
|
+ const hascache = this.cacheChooseList.find(s=>s.id == k.id)
|
|
|
+ // 如果缓存中有,添加到当前页面已选列表中
|
|
|
+ if(hascache){
|
|
|
+ this.chooseProduct(k)
|
|
|
+ }
|
|
|
+ // 如果筛选或分页后,重新更新页面列表产品数量
|
|
|
const hasChecked = this.chooseList.find(s=>s.id == k.id)
|
|
|
k.checked = hasChecked
|
|
|
if(hasChecked){
|