shawenguan 2 lat temu
rodzic
commit
70cc2081c4
1 zmienionych plików z 63 dodań i 60 usunięć
  1. 63 60
      Scripts/telecom/telecom.js

+ 63 - 60
Scripts/telecom/telecom.js

@@ -102,71 +102,74 @@ function transPhone(phoneNum) {
 }
 
 async function doLogin(){
-    if (getSignCount() > 10) {
-        lk.appendNotifyInfo('⚠️ 当日登录已超过10次!  请明天再试');
-        return;
-    }
-    let timestamp = lk.formatDate(new Date(),'yyyyMMddHHmm00')
-    let loginStr = `iPhone 14 16.6.1${telecomMobile}${telecomMobile}${timestamp}${telecomPassword}0$$$0.`;
-    let body = {
-        content: {
-            fieldData: {
-                accountType: '',
-                authentication: telecomPassword,
-                deviceUid: `3${telecomMobile}`,
-                isChinatelecom: '0',
-                loginAuthCipherAsymmertric: encryptRSA(loginStr),
-                loginType: "4",
-                phoneNum: transPhone(telecomMobile),
-                systemVersion: "16.6.1",
+    return new Promise((resolve, _reject) => {
+        if (getSignCount() > 10) {
+            lk.appendNotifyInfo('⚠️ 当日登录已超过10次!  请明天再试');
+            resolve();
+            return;
+        }
+        let timestamp = lk.formatDate(new Date(),'yyyyMMddHHmm00')
+        let loginStr = `iPhone 14 16.6.1${telecomMobile}${telecomMobile}${timestamp}${telecomPassword}0$$$0.`;
+        let body = {
+            content: {
+                fieldData: {
+                    accountType: '',
+                    authentication: telecomPassword,
+                    deviceUid: `3${telecomMobile}`,
+                    isChinatelecom: '0',
+                    loginAuthCipherAsymmertric: encryptRSA(loginStr),
+                    loginType: "4",
+                    phoneNum: transPhone(telecomMobile),
+                    systemVersion: "16.6.1",
+                },
+                attach: "iPhone",
             },
-            attach: "iPhone",
-        },
-        headerInfos: {
-            clientType: '#9.6.1#channel50#iPhone 14 Pro#',
-            code: 'userLoginNormal',
-            shopId: '20002',
-            source: '110003',
-            sourcePassword: 'Sid98s',
-            timestamp: timestamp,
-            userLoginName: telecomMobile,
+            headerInfos: {
+                clientType: '#9.6.1#channel50#iPhone 14 Pro#',
+                code: 'userLoginNormal',
+                shopId: '20002',
+                source: '110003',
+                sourcePassword: 'Sid98s',
+                timestamp: timestamp,
+                userLoginName: telecomMobile,
+            }
         }
-    }
-    lk.log('--- request body:');
-    lk.log(JSON.stringify(body));
-
-    let reqData = {
-        url: "https://appgologin.189.cn:9031/login/client/userLoginNormal",
-        headers: GCommoTelecomHeads,
-        body: JSON.stringify(body),
-    };
-    lk.post(reqData, async (error, _response, data) => {
-        let ret;
-        try {
-            if (error) {
-                lk.log(`请求发生错误`);
-                lk.execFail();
-            } else {
-                lk.log('--- response body:');
-                lk.log(data);
-                let info = JSON.parse(data);
-                let loginInfo = info.responseData.data.loginSuccessResult;
-                if (loginInfo && loginInfo.token) {
-                    lk.setVal(TelecomConstKey.Token, loginInfo.token);
-                }else{
-                    let errMsg = data.responseData.resultDesc || data.headerInfos.reason;
-                    if(errMsg){
-                        lk.appendNotifyInfo(`⚠️ ${errMsg}`);
+        lk.log('--- request body:');
+        lk.log(JSON.stringify(body));
+
+        let reqData = {
+            url: "https://appgologin.189.cn:9031/login/client/userLoginNormal",
+            headers: GCommoTelecomHeads,
+            body: JSON.stringify(body),
+        };
+        lk.post(reqData, async (error, _response, data) => {
+            let ret;
+            try {
+                if (error) {
+                    lk.log(`请求发生错误`);
+                    lk.execFail();
+                } else {
+                    lk.log('--- response body:');
+                    lk.log(data);
+                    let info = JSON.parse(data);
+                    let loginInfo = info.responseData.data.loginSuccessResult;
+                    if (loginInfo && loginInfo.token) {
+                        lk.setVal(TelecomConstKey.Token, loginInfo.token);
+                    }else{
+                        let errMsg = data.responseData.resultDesc || data.headerInfos.reason;
+                        if(errMsg){
+                            lk.appendNotifyInfo(`⚠️ ${errMsg}`);
+                        }
                     }
                 }
+            } catch (e) {
+                lk.log(`请求发生错误`);
+                lk.logErr(e);
+                lk.execFail();
+            } finally {
+                resolve(ret);
             }
-        } catch (e) {
-            lk.log(`请求发生错误`);
-            lk.logErr(e);
-            lk.execFail();
-        } finally {
-            resolve(ret);
-        }
+        });
     });
 }