shawenguan пре 1 година
родитељ
комит
c91d710922
1 измењених фајлова са 120 додато и 122 уклоњено
  1. 120 122
      Scripts/imaotai/imaotaiHelper.js

+ 120 - 122
Scripts/imaotai/imaotaiHelper.js

@@ -708,129 +708,127 @@ async function getProvinceCityMapData() {
     });
 }
 
-// async function login(phone, vCode, deviceId) {
-//     const mtK = `${new Date().getTime()}`;
-//     const mtV = await getMtv(deviceId, G_MT_VERSION);
-//     const headers = {
-//         'mt-device-id': deviceId,
-//         'mt-user-tag': '0',
-//         'accept': '*/*',
-//         'mt-network-type': 'WIFI',
-//         'mt-token': '',
-//         "mt-team-id": "",
-//         'mt-k': mtK,
-//         'mt-bundle-id': 'com.moutai.mall',
-//         'mt-v': mtV,
-//         'user-agent': 'iOS;16.0.1;Apple;iPhone 14 ProMax',
-//         'accept-language': 'zh-Hans-CN;q=1',
-//         'mt-request-id': `${new Date().getTime()}18342`,
-//         'mt-r': G_MT_R,
-//         'mt-app-version': G_MT_VERSION,
-//     };
-//     return new Promise((resolve, _reject) => {
-//         try {
-//             const data = {
-//                 'ydToken': '',
-//                 'mobile': phone,
-//                 'vCode': vCode,
-//                 'ydLogId': '',
-//             };
-//             const body = JSON.stringify(data);
-//             const url = `https://app.moutai519.com.cn/xhr/front/user/register/login`;
-//             let options = {
-//                 url: url,
-//                 headers: headers,
-//                 body: body
-//             };
-//             lk.post(options, async (error, _response, data) => {
-//                 let ret;
-//                 try {
-//                     if (error) {
-//                         lk.execFail();
-//                     } else {
-//                         const jsonRetObj = JSON.parse(data);
-//                         ret = jsonRetObj.data || {};
-//                     }
-//                 } catch (e) {
-//                     lk.logErr(e);
-//                     lk.execFail();
-//                 } finally {
-//                     resolve(ret);
-//                 }
-//             });
-//         } catch (e) {
-//             lk.logErr(e);
-//             resolve();
-//         }
-//     });
-// }
-
-// async function getLoginVCode(mobile, deviceId) {
-//     const headers = {
-//         "content-type": "application/json",
-//         "mt-device-id": deviceId,
-//         "mt-user-tag": "0",
-//         "accept": "*/*",
-//         "mt-network-type": "WIFI",
-//         "mt-token": "",
-//         "mt-team-id": "",
-//         "accept-language": "zh-Hans-CN;q=1",
-//         "bs-dvid": "2Sm2hFjywxztKDX9gqT1T5dL3COGJA-L2cWr5_E8aLjndr7-Sy0gx8JuiwLa6uPC-RPQY1azn6-c8vVloGoZ57g",
-//         "mt-request-id": `${new Date().getTime()}40625`,
-//         "mt-app-version": "1.5.9",
-//         "user-agent": "iOS;16.6.1;Apple;?unrecognized?",
-//         "mt-r": G_MT_R,
-//         "mt-bundle-id": "com.moutai.mall",
-//         "accept-encoding": "gzip, deflate, br"
-//     };
-//     return new Promise((resolve, _reject) => {
-//         try {
-//             let timestamp = `${new Date().getTime()}`;
-//             let md5Str = '2af72f100c356273d46284f6fd1dfc08' + mobile + timestamp;
-//             let CryptoJS = createCryptoJS();
-//             let hash = CryptoJS.MD5(md5Str);
-//             md5Str = hash.toString(CryptoJS.enc.Hex);
-
-//             const data = {
-//                 "md5": md5Str,
-//                 "mobile": mobile,
-//                 "timestamp": timestamp,
-//             };
-//             const body = JSON.stringify(data);
-//             const url = `https://app.moutai519.com.cn/xhr/front/user/register/vcode`;
-//             let options = {
-//                 url: url,
-//                 headers: headers,
-//                 body: body
-//             };
-//             lk.post(options, async (error, _response, data) => {
-//                 let ret;
-//                 try {
-//                     if (error) {
-//                         lk.execFail();
-//                     } else {
-//                         const jsonRetObj = JSON.parse(data);
-//                         if (jsonRetObj.code == 2000) {
-//                             ret = true;
-//                         } else {
-//                             ret = false;
-//                         }
-//                     }
-//                 } catch (e) {
-//                     lk.logErr(e);
-//                     lk.execFail();
-//                 } finally {
-//                     resolve(ret);
-//                 }
-//             });
-//         } catch (e) {
-//             lk.logErr(e);
-//             resolve();
-//         }
-//     });
-// }
-
+async function login(phone, vCode, deviceId) {
+    const mtK = `${new Date().getTime()}`;
+    const mtV = await getMtv(deviceId, G_MT_VERSION);
+    const headers = {
+        'mt-device-id': deviceId,
+        'mt-user-tag': '0',
+        'accept': '*/*',
+        'mt-network-type': 'WIFI',
+        'mt-token': '',
+        "mt-team-id": "",
+        'mt-k': mtK,
+        'mt-bundle-id': 'com.moutai.mall',
+        'mt-v': mtV,
+        'user-agent': 'iOS;16.0.1;Apple;iPhone 14 ProMax',
+        'accept-language': 'zh-Hans-CN;q=1',
+        'mt-request-id': `${new Date().getTime()}18342`,
+        'mt-r': G_MT_R,
+        'mt-app-version': G_MT_VERSION,
+    };
+    return new Promise((resolve, _reject) => {
+        try {
+            const data = {
+                'ydToken': '',
+                'mobile': phone,
+                'vCode': vCode,
+                'ydLogId': '',
+            };
+            const body = JSON.stringify(data);
+            const url = `https://app.moutai519.com.cn/xhr/front/user/register/login`;
+            let options = {
+                url: url,
+                headers: headers,
+                body: body
+            };
+            lk.post(options, async (error, _response, data) => {
+                let ret;
+                try {
+                    if (error) {
+                        lk.execFail();
+                    } else {
+                        const jsonRetObj = JSON.parse(data);
+                        ret = jsonRetObj.data || {};
+                    }
+                } catch (e) {
+                    lk.logErr(e);
+                    lk.execFail();
+                } finally {
+                    resolve(ret);
+                }
+            });
+        } catch (e) {
+            lk.logErr(e);
+            resolve();
+        }
+    });
+}
 
+async function getLoginVCode(mobile, deviceId) {
+    const headers = {
+        "content-type": "application/json",
+        "mt-device-id": deviceId,
+        "mt-user-tag": "0",
+        "accept": "*/*",
+        "mt-network-type": "WIFI",
+        "mt-token": "",
+        "mt-team-id": "",
+        "accept-language": "zh-Hans-CN;q=1",
+        "bs-dvid": "2Sm2hFjywxztKDX9gqT1T5dL3COGJA-L2cWr5_E8aLjndr7-Sy0gx8JuiwLa6uPC-RPQY1azn6-c8vVloGoZ57g",
+        "mt-request-id": `${new Date().getTime()}40625`,
+        "mt-app-version": "1.5.9",
+        "user-agent": "iOS;16.6.1;Apple;?unrecognized?",
+        "mt-r": G_MT_R,
+        "mt-bundle-id": "com.moutai.mall",
+        "accept-encoding": "gzip, deflate, br"
+    };
+    return new Promise((resolve, _reject) => {
+        try {
+            let timestamp = `${new Date().getTime()}`;
+            let md5Str = '2af72f100c356273d46284f6fd1dfc08' + mobile + timestamp;
+            let CryptoJS = createCryptoJS();
+            let hash = CryptoJS.MD5(md5Str);
+            md5Str = hash.toString(CryptoJS.enc.Hex);
+
+            const data = {
+                "md5": md5Str,
+                "mobile": mobile,
+                "timestamp": timestamp,
+            };
+            const body = JSON.stringify(data);
+            const url = `https://app.moutai519.com.cn/xhr/front/user/register/vcode`;
+            let options = {
+                url: url,
+                headers: headers,
+                body: body
+            };
+            lk.post(options, async (error, _response, data) => {
+                let ret;
+                try {
+                    if (error) {
+                        lk.execFail();
+                    } else {
+                        const jsonRetObj = JSON.parse(data);
+                        if (jsonRetObj.code == 2000) {
+                            ret = true;
+                        } else {
+                            ret = false;
+                        }
+                    }
+                } catch (e) {
+                    lk.logErr(e);
+                    lk.execFail();
+                } finally {
+                    resolve(ret);
+                }
+            });
+        } catch (e) {
+            lk.logErr(e);
+            resolve();
+        }
+    });
+}
 
 class Encrypt {
     constructor(key, iv) {