|
@@ -26,6 +26,9 @@ const HbcpreConstKey = {
|
|
|
exchangeActivityData: 'HbcpreExchangeActivityData',
|
|
exchangeActivityData: 'HbcpreExchangeActivityData',
|
|
|
exchangeActivityId: 'HbcpreExchangeActivityId',
|
|
exchangeActivityId: 'HbcpreExchangeActivityId',
|
|
|
exchangeActivityName: 'HbcpreExchangeActivityName',
|
|
exchangeActivityName: 'HbcpreExchangeActivityName',
|
|
|
|
|
+ exchangeEntryTitleList: 'HbcpreExchangeEntryTitleList',
|
|
|
|
|
+ exchangeEntryTitleCustom: 'HbcpreExchangeEntryTitleCustom',
|
|
|
|
|
+ exchangeActivityTaskMode: 'HbcpreExchangeActivityTaskMode',
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const gUserAgent = `Mozilla/5.0 (iPhone; CPU iPhone OS 16_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1`;
|
|
const gUserAgent = `Mozilla/5.0 (iPhone; CPU iPhone OS 16_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1`;
|
|
@@ -116,7 +119,7 @@ function getActivitDataCache(eventsType, eventsId){
|
|
|
return data;
|
|
return data;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-function saveActivitDataCache(eventsType, actData, eventsId){
|
|
|
|
|
|
|
+function saveActivitDataCache(eventsType, actData, aysncUpdateTask, eventsId){
|
|
|
if(!actData){
|
|
if(!actData){
|
|
|
if(!eventsId){
|
|
if(!eventsId){
|
|
|
return;
|
|
return;
|
|
@@ -142,12 +145,16 @@ function saveActivitDataCache(eventsType, actData, eventsId){
|
|
|
let storeKey = null;
|
|
let storeKey = null;
|
|
|
if(eventsType == 1){
|
|
if(eventsType == 1){
|
|
|
storeKey = HbcpreConstKey.compositeActivityData;
|
|
storeKey = HbcpreConstKey.compositeActivityData;
|
|
|
- magicJS.data.write(HbcpreConstKey.compositeActivityId, actData.eventsId);
|
|
|
|
|
- magicJS.data.write(HbcpreConstKey.compositeActivityName, actData.eventsName);
|
|
|
|
|
|
|
+ if(aysncUpdateTask){
|
|
|
|
|
+ magicJS.data.write(HbcpreConstKey.compositeActivityId, actData.eventsId);
|
|
|
|
|
+ magicJS.data.write(HbcpreConstKey.compositeActivityName, actData.eventsName);
|
|
|
|
|
+ }
|
|
|
}else if(eventsType == 3){
|
|
}else if(eventsType == 3){
|
|
|
storeKey = HbcpreConstKey.exchangeActivityData;
|
|
storeKey = HbcpreConstKey.exchangeActivityData;
|
|
|
- magicJS.data.write(HbcpreConstKey.exchangeActivityId, actData.eventsId);
|
|
|
|
|
- magicJS.data.write(HbcpreConstKey.exchangeActivityName, actData.eventsName);
|
|
|
|
|
|
|
+ if(aysncUpdateTask){
|
|
|
|
|
+ magicJS.data.write(HbcpreConstKey.exchangeActivityId, actData.eventsId);
|
|
|
|
|
+ magicJS.data.write(HbcpreConstKey.exchangeActivityName, actData.eventsName);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
if(!storeKey){
|
|
if(!storeKey){
|
|
|
data = {};
|
|
data = {};
|
|
@@ -189,6 +196,11 @@ function getWillExchangeTaskSearchKeys() {
|
|
|
return keyArr;
|
|
return keyArr;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+function getExchangeTaskMode(){
|
|
|
|
|
+ let mode = magicJS.data.read(HbcpreConstKey.compositeActivityTaskMode, 1);
|
|
|
|
|
+ return Number(mode);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
function getActivityIdByName(activityName){
|
|
function getActivityIdByName(activityName){
|
|
|
let dataDict = getActivitDataCache(3);
|
|
let dataDict = getActivitDataCache(3);
|
|
|
if(!dataDict){
|
|
if(!dataDict){
|
|
@@ -203,24 +215,63 @@ function getActivityIdByName(activityName){
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+function getHomeExchangeEntrySelectList(){
|
|
|
|
|
+ let retArr = magicJS.data.read(HbcpreConstKey.exchangeEntryTitleList, null);
|
|
|
|
|
+ magicJS.logger.error(`select=${retArr}`);
|
|
|
|
|
+ if (retArr && retArr.length > 0) {
|
|
|
|
|
+ let segments = retArr.split(',');
|
|
|
|
|
+ retArr = [];
|
|
|
|
|
+ for (let vstr of segments) {
|
|
|
|
|
+ retArr.push(vstr.trim());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ let customStr = magicJS.data.read(HbcpreConstKey.exchangeEntryTitleCustom, null);
|
|
|
|
|
+ if(customStr && customStr.length > 0){
|
|
|
|
|
+ customStr = customStr.trim();
|
|
|
|
|
+ if(customStr.length > 0){
|
|
|
|
|
+ let segments = customStr.split(',');
|
|
|
|
|
+ retArr = [];
|
|
|
|
|
+ for (let vstr of segments) {
|
|
|
|
|
+ retArr.push(vstr.trim());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return retArr;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
async function tryAllExchange() {
|
|
async function tryAllExchange() {
|
|
|
|
|
+ let taskMode = getExchangeTaskMode();
|
|
|
let idsList = getWillExchangeTaskIds();
|
|
let idsList = getWillExchangeTaskIds();
|
|
|
- if(idsList.length == 0){
|
|
|
|
|
- let namesList = getWillExchangeTaskSearchKeys();
|
|
|
|
|
- for(let name of namesList){
|
|
|
|
|
- let actId = getActivityIdByName(name);
|
|
|
|
|
- if(actId){
|
|
|
|
|
- idsList.push(actId);
|
|
|
|
|
|
|
+ if(taskMode == 1){
|
|
|
|
|
+ magicJS.logger.info(`尝试通过活动名称匹配对应活动ID`);
|
|
|
|
|
+ if(idsList.length == 0){
|
|
|
|
|
+ let namesList = getWillExchangeTaskSearchKeys();
|
|
|
|
|
+ for(let name of namesList){
|
|
|
|
|
+ let actId = getActivityIdByName(name);
|
|
|
|
|
+ if(actId){
|
|
|
|
|
+ idsList.push(actId);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ if(taskMode == 2){
|
|
|
|
|
+ if(idsList.length == 0){
|
|
|
|
|
+ magicJS.logger.info(`尝试通过入口名称匹配对应活动ID`);
|
|
|
|
|
+ let newList = await getActivityIdsByEntryTile();
|
|
|
|
|
+ idsList = idsList.concat(newList);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
if(idsList.length == 0){
|
|
if(idsList.length == 0){
|
|
|
magicJS.logger.info(`缺少兑换活动ID`);
|
|
magicJS.logger.info(`缺少兑换活动ID`);
|
|
|
- magicJS.notification.appendNotifyInfo(`❌兑换活动缺少相关参数!`);
|
|
|
|
|
|
|
+ // magicJS.notification.appendNotifyInfo(`❌兑换活动缺少相关参数!`);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
+ let execFlags = {};
|
|
|
for(let activityId of idsList){
|
|
for(let activityId of idsList){
|
|
|
- await tryOneExchange(activityId);
|
|
|
|
|
|
|
+ if(!execFlags[activityId]){
|
|
|
|
|
+ execFlags[activityId] = true;
|
|
|
|
|
+ await tryOneExchange(activityId);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -228,7 +279,7 @@ async function tryOneExchange(activityId){
|
|
|
let activityData = getActivitDataCache(3, activityId);
|
|
let activityData = getActivitDataCache(3, activityId);
|
|
|
if(!isExchangeOnlyUseCache()){
|
|
if(!isExchangeOnlyUseCache()){
|
|
|
activityData = await getCompositeList(activityId);
|
|
activityData = await getCompositeList(activityId);
|
|
|
- saveActivitDataCache(3, activityData);
|
|
|
|
|
|
|
+ saveActivitDataCache(3, activityData, false);
|
|
|
}
|
|
}
|
|
|
if(!activityData){
|
|
if(!activityData){
|
|
|
magicJS.logger.info(`缺少兑换活动数据`);
|
|
magicJS.logger.info(`缺少兑换活动数据`);
|
|
@@ -268,13 +319,41 @@ async function tryOneExchange(activityId){
|
|
|
magicJS.notification.appendNotifyInfo(`🎉兑换<${activityData.eventsName}>兑换成功!`);
|
|
magicJS.notification.appendNotifyInfo(`🎉兑换<${activityData.eventsName}>兑换成功!`);
|
|
|
// 刷新兑换数据
|
|
// 刷新兑换数据
|
|
|
activityData = await getCompositeList(activityId);
|
|
activityData = await getCompositeList(activityId);
|
|
|
- saveActivitDataCache(3, activityData);
|
|
|
|
|
|
|
+ saveActivitDataCache(3, activityData, false);
|
|
|
} else {
|
|
} else {
|
|
|
magicJS.notification.appendNotifyInfo(`🎉兑换<${activityData.eventsName}>${result.message}`);
|
|
magicJS.notification.appendNotifyInfo(`🎉兑换<${activityData.eventsName}>${result.message}`);
|
|
|
}
|
|
}
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+async function getActivityIdsByEntryTile(){
|
|
|
|
|
+ let titleList = getHomeExchangeEntrySelectList();
|
|
|
|
|
+ if(!titleList || titleList.length == 0){
|
|
|
|
|
+ return [];
|
|
|
|
|
+ }
|
|
|
|
|
+ let reqData = {};
|
|
|
|
|
+ let result = await hbRequest({API: '/mall/homepage/info', METHOD: 'get'}, reqData);
|
|
|
|
|
+ if (result.code != 200) {
|
|
|
|
|
+ return [];
|
|
|
|
|
+ }
|
|
|
|
|
+ let infoList = [];
|
|
|
|
|
+ let idsList = [];
|
|
|
|
|
+ let bannerList = result.data.bannerList || [];
|
|
|
|
|
+ for(let i=0; i < bannerList.length; i++){
|
|
|
|
|
+ const item = bannerList[i];
|
|
|
|
|
+ if(item.url.indexOf('http') == -1){
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(checkKeysInText(titleList, item.name)){
|
|
|
|
|
+ const params = magicJS.parseQueryStr(item.url);
|
|
|
|
|
+ params.name = item.name;
|
|
|
|
|
+ infoList.push(params);
|
|
|
|
|
+ idsList.push(params.id);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return idsList;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
function readMySeriesOwnCntFakeData() {
|
|
function readMySeriesOwnCntFakeData() {
|
|
|
gItemCntRwDict = {};
|
|
gItemCntRwDict = {};
|
|
|
let text = magicJS.data.read(HbcpreConstKey.myOwnSeriesCntFakeData, null);
|
|
let text = magicJS.data.read(HbcpreConstKey.myOwnSeriesCntFakeData, null);
|