lilei há 10 meses atrás
pai
commit
da86d95b5c
1 ficheiros alterados com 17 adições e 16 exclusões
  1. 17 16
      pagesB/promoDetail.vue

+ 17 - 16
pagesB/promoDetail.vue

@@ -142,7 +142,6 @@
 				choosePageSize: 8, // 已选产品每页数
 				chooseTotal: 0 ,// 已选产品总记录数
 				promoActiveSn: null, // 活动sn
-				cacheChooseList: [] // 缓存得已选列表
 			}
 		},
 		computed: {
@@ -175,12 +174,12 @@
 			uni.setNavigationBarTitle({
 				title: opts.title||'促销活动产品'
 			})
+			this.screenWidth = uni.getSystemInfoSync().windowWidth
 			this.$store.state.vuex_tempData = null
 			this.promoActiveSn = opts.promoActiveSn
 			// 购物车是否有缓存
 			const cacheList = this.$store.state.vuex_cartList.find(k => k.sn == this.promoActiveSn)
-			this.cacheChooseList = cacheList ? cacheList.list : []
-			this.screenWidth = uni.getSystemInfoSync().windowWidth
+			this.chooseList = cacheList ? JSON.parse(JSON.stringify(cacheList.list)) : []
 			// 查询产品列表
 			this.pageInit()
 		},
@@ -210,9 +209,9 @@
 					item.checked = true
 					item.qty = 1
 					item.show = false
-					this.chooseList.unshift(item)
+					this.chooseList.unshift(this.$u.deepClone(item))
 				}else{
-					// item.qty = item.qty + 1
+					item.qty = item.qty + 1
 					// 已添加,则增加数量
 					const row = this.chooseList.find(key => key.id == item.id)
 					if(row){
@@ -229,6 +228,7 @@
 			},
 			// 关闭已选列表弹框
 			closePopu(){
+				this.chooseAllList = []
 				this.chooseProductList = []
 				this.showChoosePopu=false
 			},
@@ -273,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)
@@ -336,10 +336,14 @@
 			// 清空已选数据
 			clearChooseData(){
 				this.chooseList = []
+				this.chooseAllList = []
 				this.chooseProductList = []
 				this.showChoosePopu = false
 				// 重置已选状态
-				this.list.filter(item => item.checked).map(item=>item.checked = false)
+				this.list.filter(item => item.checked).map(item=>{
+					item.checked = false
+					item.qty = 0
+				})
 			},
 			// scroll-view到底部加载更多
 			onreachBottom() {
@@ -363,13 +367,9 @@
 			  queryPromoProductByPage(params).then(res => {
 				if (res.code == 200 || res.status == 204 || res.status == 200) {
 				  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
@@ -377,6 +377,7 @@
 						  k.qty = hasChecked.qty
 					  }
 				  })
+				  
 				  _this.list = _this.list.concat(list)
 				  _this.total = res.data.count || 0
 				} else {