|
|
@@ -15,7 +15,8 @@ Page({
|
|
|
submitlock:false,
|
|
|
x:0,
|
|
|
currentX: 0,
|
|
|
- seckillruntimearr:[]
|
|
|
+ seckillruntimearr:[],
|
|
|
+ localCartList:{}
|
|
|
},
|
|
|
handleMovableChange: function(e) {
|
|
|
// this.data.currentX = e.detail.x;
|
|
|
@@ -65,15 +66,30 @@ Page({
|
|
|
console.log(res)
|
|
|
if(res.data.list){
|
|
|
var skrt = that.data.seckillruntimearr;
|
|
|
+
|
|
|
+ var localcl = wx.getStorageSync('localCartList') ? wx.getStorageSync('localCartList') : res.data.list;
|
|
|
+ console.log('localcl',localcl);
|
|
|
for(let i in res.data.list){
|
|
|
res.data.list['movex'] = 0;
|
|
|
skrt.push('');
|
|
|
+
|
|
|
+
|
|
|
+ for(let o in localcl){
|
|
|
+ if(res.data.list[i]['id'] == localcl[o]['id']){
|
|
|
+ // if(res.data.list[i]['count'] < localcl[o]['count']){
|
|
|
+ res.data.list[i]['count'] = localcl[o]['count'];
|
|
|
+ // }else{
|
|
|
+ // localcl[o]['count'] = res.data.list[i]['count'];
|
|
|
+ // }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
that.setData({
|
|
|
cartList: res.data.list,
|
|
|
cartCount: res.data.count,
|
|
|
cartTotal: res.data.total,
|
|
|
- seckillruntimearr:skrt
|
|
|
+ seckillruntimearr:skrt,
|
|
|
+ localCartList: localcl
|
|
|
})
|
|
|
|
|
|
that.seckilltime();
|
|
|
@@ -95,10 +111,25 @@ Page({
|
|
|
var success = function (res) {
|
|
|
console.log(res)
|
|
|
if(res.data.list){
|
|
|
+ var localcl = wx.getStorageSync('localCartList') ? wx.getStorageSync('localCartList') : res.data.list;
|
|
|
+ console.log('localcl',localcl);
|
|
|
+ for(let i in res.data.list){
|
|
|
+ for(let o in localcl){
|
|
|
+ if(res.data.list[i]['id'] == localcl[o]['id']){
|
|
|
+ // if(res.data.list[i]['count'] < localcl[o]['count']){
|
|
|
+ res.data.list[i]['count'] = localcl[o]['count'];
|
|
|
+ // }else{
|
|
|
+ // localcl[o]['count'] = res.data.list[i]['count'];
|
|
|
+ // }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
that.setData({
|
|
|
cartList: res.data.list,
|
|
|
cartCount: res.data.count,
|
|
|
- cartTotal: res.data.total
|
|
|
+ cartTotal: res.data.total,
|
|
|
+ localCartList: localcl
|
|
|
})
|
|
|
that.allSelect();
|
|
|
}else{
|
|
|
@@ -112,7 +143,8 @@ Page({
|
|
|
_request.$get(url, params, success)
|
|
|
},
|
|
|
add: function (e) {
|
|
|
- console.log('tapadd',e)
|
|
|
+ console.log('tapadd',e);
|
|
|
+ var that = this;
|
|
|
var itemid = e.currentTarget.dataset.id;
|
|
|
var itemcount = e.currentTarget.dataset.count;
|
|
|
console.log('itemcount',itemcount)
|
|
|
@@ -120,7 +152,8 @@ Page({
|
|
|
var index = e.currentTarget.dataset.index;
|
|
|
var count = itemcount + 1;
|
|
|
this.setData({
|
|
|
- ['cartList[' + index + '].count']:count
|
|
|
+ ['cartList[' + index + '].count']:count,
|
|
|
+ localCartList:that.data.cartList
|
|
|
})
|
|
|
this.checkSelected();
|
|
|
// this.changeServercount(count,itemid);
|
|
|
@@ -135,7 +168,8 @@ Page({
|
|
|
var count = itemcount - 1;
|
|
|
var index = e.currentTarget.dataset.index;
|
|
|
this.setData({
|
|
|
- ['cartList[' + index + '].count']:count
|
|
|
+ ['cartList[' + index + '].count']:count,
|
|
|
+ localCartList:that.data.cartList
|
|
|
})
|
|
|
this.checkSelected();
|
|
|
// this.changeServercount(count,itemid);
|
|
|
@@ -310,11 +344,14 @@ Page({
|
|
|
checkitemnum = checkitemnum.substr(0,checkitemnum.length - 1);
|
|
|
|
|
|
|
|
|
+ //setlocalcartlist
|
|
|
+ wx.setStorageSync('localCartList',cartList);
|
|
|
+
|
|
|
this.setData({
|
|
|
checkeditems:checkitem,
|
|
|
checkeditemsnum:checkitemnum,
|
|
|
cartCount: checkcount,
|
|
|
- cartTotal: checktotal
|
|
|
+ cartTotal: checktotal
|
|
|
})
|
|
|
// this.mulChangeState();
|
|
|
},
|