Commit f554123c authored by liuxinjun's avatar liuxinjun

修复getButtonConfig的次数bug

parent 04fa9758
...@@ -197,9 +197,13 @@ var sdk = { ...@@ -197,9 +197,13 @@ var sdk = {
} }
} //为了方便技术在浏览器中调试
this.setWeChatListener(); this.setWeChatListener();
}
}, },
/** /**
* @apiGroup C * @apiGroup C
...@@ -2455,6 +2459,14 @@ var sdk = { ...@@ -2455,6 +2459,14 @@ var sdk = {
*/ */
getButtonConfig(buttonKey){ getButtonConfig(buttonKey){
return this.getButtonConfig2(buttonKey,1);
},
getButtonConfig2(buttonKey,isCount)
{
var c3 = this.getConfig3(); var c3 = this.getConfig3();
if(c3.length>0) if(c3.length>0)
...@@ -2472,24 +2484,25 @@ var sdk = { ...@@ -2472,24 +2484,25 @@ var sdk = {
var d = dl[i]; var d = dl[i];
var nowTime =new Date().getTime(); var nowTime =new Date().getTime();
var date = this.formatTime(new Date(),"date","");
if(nowTime >=d.s_time && nowTime <=d.e_time) if(nowTime >=d.s_time && nowTime <=d.e_time)
{ {
if(c.type==='mix') if(c.type==='mix')
{ {
var countKey = "getButtonConfig:"+i+":count"; var countKey = buttonKey+":"+date+":"+i+":count";
var count = this.getItem(countKey); var count = this.getItem(countKey);
console.log("getButtonConfig->"+countKey,count); console.log(buttonKey+"->"+countKey,count);
if(!count) if(!count)
{ {
count = 1; count = 1;
} }
var startKey = "getButtonConfig:"+i+":start:"+d.data.start.type+":"+count; var startKey = buttonKey+":"+date+":"+i+":start:"+d.data.start.type+":"+count;
var startVal = this.getItem(startKey); var startVal = this.getItem(startKey);
console.log("getButtonConfig->"+startKey,startVal); console.log(buttonKey+"->"+startKey,startVal);
if(!startVal) if(!startVal)
{ {
startVal = 0; startVal = 0;
...@@ -2499,18 +2512,22 @@ var sdk = { ...@@ -2499,18 +2512,22 @@ var sdk = {
{ {
return this.nextConfig(d.data,d.data.start.next,i,count); return this.nextConfig(buttonKey,date,d.data,d.data.start.next,i,count,isCount);
}else }else
{ {
//当前记录的次数小于配置次数 //当前记录的次数小于配置次数
if(isCount==1)
{
startVal++; startVal++;
this.setItem(startKey,startVal); this.setItem(startKey,startVal);
d.data.start.left_count = d.data.start.count-startVal; d.data.start.left_count = d.data.start.count-startVal;
d.data.start.use_count = startVal; d.data.start.use_count = startVal;
}
return d.data.start; return d.data.start;
} }
...@@ -2536,17 +2553,16 @@ var sdk = { ...@@ -2536,17 +2553,16 @@ var sdk = {
}else{ }else{
return null; return null;
} }
}, },
nextConfig(data,nextKey,i,count) nextConfig(buttonKey,date,data,nextKey,i,count,isCount)
{ {
if(nextKey=='end') if(nextKey=='end')
{ {
return null; return null;
} }
var nextCacheKey = "getButtonConfig:"+i+":"+nextKey+":"+data[nextKey].type+":"+count; var nextCacheKey = buttonKey+":"+date+":"+i+":"+nextKey+":"+data[nextKey].type+":"+count;
var nextCacheVal = this.getItem(nextCacheKey); var nextCacheVal = this.getItem(nextCacheKey);
console.log("nextConfig->"+nextCacheKey,nextCacheVal); console.log("nextConfig->"+nextCacheKey,nextCacheVal);
if(!nextCacheVal) if(!nextCacheVal)
...@@ -2557,7 +2573,12 @@ var sdk = { ...@@ -2557,7 +2573,12 @@ var sdk = {
nextCacheVal = nextCacheVal+1; nextCacheVal = nextCacheVal+1;
} }
//计数的话
if(isCount==1)
{
this.setItem(nextCacheKey,nextCacheVal); this.setItem(nextCacheKey,nextCacheVal);
}
...@@ -2567,17 +2588,21 @@ var sdk = { ...@@ -2567,17 +2588,21 @@ var sdk = {
if(data[nextKey].next=='start') if(data[nextKey].next=='start')
{ {
var countKey = "getButtonConfig:"+i+":count"; var countKey = buttonKey+":"+date+":"+i+":count";
count=count+1; count=count+1;
this.setItem(countKey,count); this.setItem(countKey,count);
} }
//往下递归 //往下递归
return this.nextConfig(data,data[nextKey].next,i,count); return this.nextConfig(buttonKey,date,data,data[nextKey].next,i,count,isCount);
}else }else
{
//计数的话
if(isCount==1)
{ {
data[nextKey].left_count = data[nextKey].count-nextCacheVal; data[nextKey].left_count = data[nextKey].count-nextCacheVal;
data[nextKey].use_count = nextCacheVal; data[nextKey].use_count = nextCacheVal;
}
return data[nextKey]; return data[nextKey];
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment