Commit f554123c authored by liuxinjun's avatar liuxinjun

修复getButtonConfig的次数bug

parent 04fa9758
......@@ -197,8 +197,12 @@ var sdk = {
}
//为了方便技术在浏览器中调试
this.setWeChatListener();
}
this.setWeChatListener();
},
/**
......@@ -2455,6 +2459,14 @@ var sdk = {
*/
getButtonConfig(buttonKey){
return this.getButtonConfig2(buttonKey,1);
},
getButtonConfig2(buttonKey,isCount)
{
var c3 = this.getConfig3();
if(c3.length>0)
......@@ -2472,24 +2484,25 @@ var sdk = {
var d = dl[i];
var nowTime =new Date().getTime();
var date = this.formatTime(new Date(),"date","");
if(nowTime >=d.s_time && nowTime <=d.e_time)
{
if(c.type==='mix')
{
var countKey = "getButtonConfig:"+i+":count";
var countKey = buttonKey+":"+date+":"+i+":count";
var count = this.getItem(countKey);
console.log("getButtonConfig->"+countKey,count);
console.log(buttonKey+"->"+countKey,count);
if(!count)
{
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);
console.log("getButtonConfig->"+startKey,startVal);
console.log(buttonKey+"->"+startKey,startVal);
if(!startVal)
{
startVal = 0;
......@@ -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
{
//当前记录的次数小于配置次数
startVal++;
this.setItem(startKey,startVal);
d.data.start.left_count = d.data.start.count-startVal;
d.data.start.use_count = startVal;
if(isCount==1)
{
startVal++;
this.setItem(startKey,startVal);
d.data.start.left_count = d.data.start.count-startVal;
d.data.start.use_count = startVal;
}
return d.data.start;
}
......@@ -2536,17 +2553,16 @@ var sdk = {
}else{
return null;
}
},
nextConfig(data,nextKey,i,count)
nextConfig(buttonKey,date,data,nextKey,i,count,isCount)
{
if(nextKey=='end')
{
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);
console.log("nextConfig->"+nextCacheKey,nextCacheVal);
if(!nextCacheVal)
......@@ -2557,7 +2573,12 @@ var sdk = {
nextCacheVal = nextCacheVal+1;
}
this.setItem(nextCacheKey,nextCacheVal);
//计数的话
if(isCount==1)
{
this.setItem(nextCacheKey,nextCacheVal);
}
......@@ -2567,18 +2588,22 @@ var sdk = {
if(data[nextKey].next=='start')
{
var countKey = "getButtonConfig:"+i+":count";
var countKey = buttonKey+":"+date+":"+i+":count";
count=count+1;
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
{
data[nextKey].left_count = data[nextKey].count-nextCacheVal;
data[nextKey].use_count = nextCacheVal;
//计数的话
if(isCount==1)
{
data[nextKey].left_count = data[nextKey].count-nextCacheVal;
data[nextKey].use_count = nextCacheVal;
}
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