shawenguan 1 éve
szülő
commit
33202fe349
1 módosított fájl, 101 hozzáadás és 101 törlés
  1. 101 101
      Scripts/imaotai/imaotaiHelper.js

+ 101 - 101
Scripts/imaotai/imaotaiHelper.js

@@ -265,110 +265,110 @@ async function getMtv(deviceId, mtVersion) {
 }
 
 
-// async function getActParam(data) {
-//     return new Promise((resolve, _reject) => {
-//         try {
-//             const headers = {};
-//             const body = ``;
-//             const mtK = `${Date.now()}`;
-//             const url = `http://82.157.10.108:8086/get_actParam?key=yaohuo&actParam=${encodeURIComponent(JSON.stringify(data).replace(/\s/g, ''))}`;
-//             let options = {
-//                 url: url,
-//                 headers: headers,
-//                 body: body
-//             };
-//             lk.get(options, async (error, _response, data) => {
-//                 let ret;
-//                 try {
-//                     if (error) {
-//                         lk.execFail();
-//                     } else {
-//                         ret = data;
-//                     }
-//                 } catch (e) {
-//                     lk.logErr(e);
-//                     lk.execFail();
-//                 } finally {
-//                     resolve(ret);
-//                 }
-//             });
-//         } catch (e) {
-//             lk.logErr(e);
-//             resolve();
-//         }
-//     });
-// }
+async function getActParam(data) {
+    return new Promise((resolve, _reject) => {
+        try {
+            const headers = {};
+            const body = ``;
+            const mtK = `${Date.now()}`;
+            const url = `http://82.157.10.108:8086/get_actParam?key=yaohuo&actParam=${encodeURIComponent(JSON.stringify(data).replace(/\s/g, ''))}`;
+            let options = {
+                url: url,
+                headers: headers,
+                body: body
+            };
+            lk.get(options, async (error, _response, data) => {
+                let ret;
+                try {
+                    if (error) {
+                        lk.execFail();
+                    } else {
+                        ret = data;
+                    }
+                } catch (e) {
+                    lk.logErr(e);
+                    lk.execFail();
+                } finally {
+                    resolve(ret);
+                }
+            });
+        } catch (e) {
+            lk.logErr(e);
+            resolve();
+        }
+    });
+}
 
-// async function mtAdd(sessionId, itemId, shopId, userId, token, deviceId) {
-//     const mtK = `${new Date().getTime()}`;
-//     const mtV = await getMtv(deviceId, G_MT_VERSION);
-//     let headers = {
-//         "mt-network-type": "WIFI",
-//         "user-agent": G_USER_AGENT,
-//         "mt-token": token,
-//         "mt-user-tag": "0",
-//         "mt-r": G_MT_R,
-//         "mt-lat": "23.122443",
-//         "mt-k": mtK,
-//         "mt-lng": "113.380126",
-//         "content-length": "257",
-//         "mt-info": "028e7f96f6369cafe1d105579c5b9377",
-//         "mt-team-id": "",
-//         "mt-app-version": G_MT_VERSION,
-//         "mt-request-id": getMTRequestId(),
-//         "accept-language": "zh-Hans-CN;q=1",
-//         "mt-device-id": deviceId,
-//         "accept": "*/*",
-//         "content-type": "application/json",
-//         "accept-encoding": "gzip, deflate, br",
-//         "mt-bundle-id": "com.moutai.mall",
-//         "mt-v": mtV,
-//     };
+async function mtAdd(sessionId, itemId, shopId, userId, token, deviceId) {
+    const mtK = `${new Date().getTime()}`;
+    const mtV = await getMtv(deviceId, G_MT_VERSION);
+    let headers = {
+        "mt-network-type": "WIFI",
+        "user-agent": G_USER_AGENT,
+        "mt-token": token,
+        "mt-user-tag": "0",
+        "mt-r": G_MT_R,
+        "mt-lat": "23.122443",
+        "mt-k": mtK,
+        "mt-lng": "113.380126",
+        "content-length": "257",
+        "mt-info": "028e7f96f6369cafe1d105579c5b9377",
+        "mt-team-id": "",
+        "mt-app-version": G_MT_VERSION,
+        "mt-request-id": getMTRequestId(),
+        "accept-language": "zh-Hans-CN;q=1",
+        "mt-device-id": deviceId,
+        "accept": "*/*",
+        "content-type": "application/json",
+        "accept-encoding": "gzip, deflate, br",
+        "mt-bundle-id": "com.moutai.mall",
+        "mt-v": mtV,
+    };
 
-//     const d = {
-//         "itemInfoList": [{ "count": 1, "itemId": String(itemId) }],
-//         "sessionId": sessionId,
-//         "userId": String(userId),
-//         "shopId": String(shopId),
-//     };
+    const d = {
+        "itemInfoList": [{ "count": 1, "itemId": String(itemId) }],
+        "sessionId": sessionId,
+        "userId": String(userId),
+        "shopId": String(shopId),
+    };
 
-//     const actParam = await getActParam(d);
-//     d['actParam'] = actParam;
-//     return new Promise((resolve, _reject) => {
-//         try {
-//             const body = JSON.stringify(d);
-//             const url = `https://app.moutai519.com.cn/xhr/front/mall/reservation/add`;
-//             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 = jsonRetObj.data?.successDesc || "未知";
-//                         } else {
-//                             ret = '申购失败:' + (data.message || "未知原因");
-//                         }
-//                     }
-//                 } catch (e) {
-//                     lk.logErr(e);
-//                     lk.execFail();
-//                 } finally {
-//                     resolve(ret);
-//                 }
-//             });
-//         } catch (e) {
-//             lk.logErr(e);
-//             resolve();
-//         }
-//     });
-// }
+    const actParam = await getActParam(d);
+    d['actParam'] = actParam;
+    return new Promise((resolve, _reject) => {
+        try {
+            const body = JSON.stringify(d);
+            const url = `https://app.moutai519.com.cn/xhr/front/mall/reservation/add`;
+            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 = jsonRetObj.data?.successDesc || "未知";
+                        } else {
+                            ret = '申购失败:' + (data.message || "未知原因");
+                        }
+                    }
+                } catch (e) {
+                    lk.logErr(e);
+                    lk.execFail();
+                } finally {
+                    resolve(ret);
+                }
+            });
+        } catch (e) {
+            lk.logErr(e);
+            resolve();
+        }
+    });
+}
 
 
 // async function getSessionId(deviceId, token, timeKeys) {