|
|
@@ -20,6 +20,9 @@ const HbcpreConstKey = {
|
|
|
floatPriceIntaval: 'HbcpreFloatPriceIntaval',
|
|
|
itemCntRwData: 'HbcpreItemCntRwData',
|
|
|
walletPayPassword: 'HbcpreWalletPayPassword',
|
|
|
+
|
|
|
+ compoundActivityData: 'HbcpreCompoundActivityData',
|
|
|
+ compoundActivityId: 'HbcpreCompoundActivityId',
|
|
|
};
|
|
|
|
|
|
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`;
|
|
|
@@ -52,7 +55,57 @@ async function Main() {
|
|
|
|
|
|
|
|
|
async function tryCompound() {
|
|
|
+ let activityId = magicJS.data.read(HbcpreConstKey.compoundActivityId, null);
|
|
|
+ if(!activityId){
|
|
|
+ magicJS.logger.info(`缺少合成活动ID`);
|
|
|
+ magicJS.notification.appendNotifyInfo(`❌合成活动缺少相关参数!`);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let activityData = getActivitDataCache(activityId);
|
|
|
+ if(!activityData){
|
|
|
+ activityData = await getCompoundData(activityId);
|
|
|
+ cacheActivitData(activityId, activityData);
|
|
|
+ }
|
|
|
+ if(activityData){
|
|
|
+ let randomList = data.activityData;
|
|
|
+ let randomJson = [];
|
|
|
+ let randomId = [];
|
|
|
+ if(randomList.length > 0){
|
|
|
+
|
|
|
+ }
|
|
|
+ let result = await startCompound(activityId, '', JSON.stringify(randomJson), randomId);
|
|
|
+ if(result){
|
|
|
+ magicJS.notification.appendNotifyInfo(`🎉合成活动[${activityId}]合成成功!`);
|
|
|
+ } else {
|
|
|
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function getActivitDataCache(id){
|
|
|
+ return magicJS.data.read(HbcpreConstKey.compoundActivityData, null);
|
|
|
+}
|
|
|
+
|
|
|
+function cacheActivitData(id, data){
|
|
|
+ return magicJS.data.write(HbcpreConstKey.compoundActivityData, data);
|
|
|
+}
|
|
|
+
|
|
|
+async function getCompoundData(id){
|
|
|
+ let reqData = {id: `${id}`};
|
|
|
+ let result = await hbRequest({API: '/api/randomcompound/indexdetail', METHOD: 'post'}, reqData);
|
|
|
+ if(result.code != 1000){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return result.data;
|
|
|
+}
|
|
|
+
|
|
|
+async function startCompound(id, token, randomJson, randomId){
|
|
|
+ let reqData = {id: `${id}`, token: token, random_json: randomJson, random_id: randomId};
|
|
|
+ let result = await hbRequest({API: '/api/randomcompound/compound', METHOD: 'post'}, reqData);
|
|
|
+ if(result.code != 1000){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return result.data;
|
|
|
}
|
|
|
|
|
|
function transformKeys(keyStr) {
|