|
|
@@ -371,125 +371,125 @@ async function mtAdd(sessionId, itemId, shopId, userId, token, deviceId) {
|
|
|
}
|
|
|
|
|
|
|
|
|
-// async function getSessionId(deviceId, token, timeKeys) {
|
|
|
-// return new Promise((resolve, _reject) => {
|
|
|
-// try {
|
|
|
-// const headers = {
|
|
|
-// "mt-device-id": deviceId,
|
|
|
-// "mt-user-tag": "0",
|
|
|
-// "mt-lat": "23.122443",
|
|
|
-// "accept": "*/*",
|
|
|
-// "mt-network-type": "WIFI",
|
|
|
-// "mt-token": token,
|
|
|
-// "mt-team-id": "",
|
|
|
-// "mt-bundle-id": "com.moutai.mall",
|
|
|
-// "accept-language": "zh-Hans-CN;q=1",
|
|
|
-// "mt-app-version": G_MT_VERSION,
|
|
|
-// "user-agent": G_USER_AGENT,
|
|
|
-// "mt-request-id": getMTRequestId(),
|
|
|
-// "mt-r": G_MT_R,
|
|
|
-// "mt-lng": "113.380126",
|
|
|
-// "accept-encoding": "gzip, deflate, br"
|
|
|
-// };
|
|
|
-// const body = '';
|
|
|
-// const url = `https://static.moutai519.com.cn/mt-backend/xhr/front/mall/index/session/get/${timeKeys}`;
|
|
|
-// let options = {
|
|
|
-// url: url,
|
|
|
-// headers: headers,
|
|
|
-// body: body
|
|
|
-// };
|
|
|
-// lk.get(options, async (error, _response, data) => {
|
|
|
-// let ret;
|
|
|
-// try {
|
|
|
-// if (error) {
|
|
|
-// lk.execFail();
|
|
|
-// } else {
|
|
|
-// const jsonRetObj = JSON.parse(data);
|
|
|
-// if (jsonRetObj.code == 2000) {
|
|
|
-// const sessionId = jsonRetObj.data?.sessionId;
|
|
|
-// const itemList = jsonRetObj.data?.itemList || [];
|
|
|
-// const itemCodes = itemList.map(item => item.itemCode);
|
|
|
-// ret = { sessionId: sessionId, itemCodes: itemCodes, itemList: itemList };
|
|
|
-// }
|
|
|
-// }
|
|
|
-// } catch (e) {
|
|
|
-// lk.logErr(e);
|
|
|
-// lk.execFail();
|
|
|
-// } finally {
|
|
|
-// resolve(ret);
|
|
|
-// }
|
|
|
-// });
|
|
|
-// } catch (e) {
|
|
|
-// lk.logErr(e);
|
|
|
-// resolve();
|
|
|
-// }
|
|
|
-// });
|
|
|
-// }
|
|
|
+async function getSessionId(deviceId, token, timeKeys) {
|
|
|
+ return new Promise((resolve, _reject) => {
|
|
|
+ try {
|
|
|
+ const headers = {
|
|
|
+ "mt-device-id": deviceId,
|
|
|
+ "mt-user-tag": "0",
|
|
|
+ "mt-lat": "23.122443",
|
|
|
+ "accept": "*/*",
|
|
|
+ "mt-network-type": "WIFI",
|
|
|
+ "mt-token": token,
|
|
|
+ "mt-team-id": "",
|
|
|
+ "mt-bundle-id": "com.moutai.mall",
|
|
|
+ "accept-language": "zh-Hans-CN;q=1",
|
|
|
+ "mt-app-version": G_MT_VERSION,
|
|
|
+ "user-agent": G_USER_AGENT,
|
|
|
+ "mt-request-id": getMTRequestId(),
|
|
|
+ "mt-r": G_MT_R,
|
|
|
+ "mt-lng": "113.380126",
|
|
|
+ "accept-encoding": "gzip, deflate, br"
|
|
|
+ };
|
|
|
+ const body = '';
|
|
|
+ const url = `https://static.moutai519.com.cn/mt-backend/xhr/front/mall/index/session/get/${timeKeys}`;
|
|
|
+ let options = {
|
|
|
+ url: url,
|
|
|
+ headers: headers,
|
|
|
+ body: body
|
|
|
+ };
|
|
|
+ lk.get(options, async (error, _response, data) => {
|
|
|
+ let ret;
|
|
|
+ try {
|
|
|
+ if (error) {
|
|
|
+ lk.execFail();
|
|
|
+ } else {
|
|
|
+ const jsonRetObj = JSON.parse(data);
|
|
|
+ if (jsonRetObj.code == 2000) {
|
|
|
+ const sessionId = jsonRetObj.data?.sessionId;
|
|
|
+ const itemList = jsonRetObj.data?.itemList || [];
|
|
|
+ const itemCodes = itemList.map(item => item.itemCode);
|
|
|
+ ret = { sessionId: sessionId, itemCodes: itemCodes, itemList: itemList };
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ lk.logErr(e);
|
|
|
+ lk.execFail();
|
|
|
+ } finally {
|
|
|
+ resolve(ret);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } catch (e) {
|
|
|
+ lk.logErr(e);
|
|
|
+ resolve();
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
|
|
|
-// function getMTRequestId() {
|
|
|
-// return `${new Date().getTime()}${getRandomNumber(11111, 99999)}`;
|
|
|
-// }
|
|
|
+function getMTRequestId() {
|
|
|
+ return `${new Date().getTime()}${getRandomNumber(11111, 99999)}`;
|
|
|
+}
|
|
|
|
|
|
-// async function getShopItem(sessionId, itemId, token, deviceId, province, city, timeKeys) {
|
|
|
-// return new Promise((resolve, _reject) => {
|
|
|
-// try {
|
|
|
-// const headers = {
|
|
|
-// "mt-device-id": deviceId,
|
|
|
-// "mt-user-tag": "0",
|
|
|
-// "mt-lat": "23.122443",
|
|
|
-// "accept": "*/*",
|
|
|
-// "mt-network-type": "WIFI",
|
|
|
-// "mt-token": token,
|
|
|
-// "mt-team-id": "",
|
|
|
-// "mt-bundle-id": "com.moutai.mall",
|
|
|
-// "accept-language": "zh-Hans-CN;q=1",
|
|
|
-// "mt-app-version": G_MT_VERSION,
|
|
|
-// "user-agent": G_USER_AGENT,
|
|
|
-// "mt-request-id": getMTRequestId(),
|
|
|
-// "mt-r": G_MT_R,
|
|
|
-// "mt-lng": "113.380126",
|
|
|
-// "accept-encoding": "gzip, deflate, br"
|
|
|
-// };
|
|
|
-// const body = '';
|
|
|
-// const url = `https://static.moutai519.com.cn/mt-backend/xhr/front/mall/shop/list/slim/v3/${sessionId}/${province}/${city}/${timeKeys}`;
|
|
|
-// let options = {
|
|
|
-// url: url,
|
|
|
-// headers: headers,
|
|
|
-// body: body
|
|
|
-// };
|
|
|
-// lk.get(options, async (error, _response, data) => {
|
|
|
-// let ret;
|
|
|
-// try {
|
|
|
-// if (error) {
|
|
|
-// lk.execFail();
|
|
|
-// } else {
|
|
|
-// const jsonRetObj = JSON.parse(data);
|
|
|
-// if (jsonRetObj.code == 2000) {
|
|
|
-// const rspData = jsonRetObj.data || {};
|
|
|
-// const shops = rspData.shops || [];
|
|
|
-// const shopId = G_P_C_MAP[province][city];
|
|
|
-// for (let i = 0; i < shops.lenght; i++) {
|
|
|
-// const shopObj = shops[i];
|
|
|
-// if (shopObj.shopId && shopId.indexOf(shopObj.shopId) > -1) {
|
|
|
-// ret = shopObj.shopId;
|
|
|
-// break;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// } catch (e) {
|
|
|
-// lk.logErr(e);
|
|
|
-// lk.execFail();
|
|
|
-// } finally {
|
|
|
-// resolve(ret);
|
|
|
-// }
|
|
|
-// });
|
|
|
-// } catch (e) {
|
|
|
-// lk.logErr(e);
|
|
|
-// resolve();
|
|
|
-// }
|
|
|
-// });
|
|
|
-// }
|
|
|
+async function getShopItem(sessionId, itemId, token, deviceId, province, city, timeKeys) {
|
|
|
+ return new Promise((resolve, _reject) => {
|
|
|
+ try {
|
|
|
+ const headers = {
|
|
|
+ "mt-device-id": deviceId,
|
|
|
+ "mt-user-tag": "0",
|
|
|
+ "mt-lat": "23.122443",
|
|
|
+ "accept": "*/*",
|
|
|
+ "mt-network-type": "WIFI",
|
|
|
+ "mt-token": token,
|
|
|
+ "mt-team-id": "",
|
|
|
+ "mt-bundle-id": "com.moutai.mall",
|
|
|
+ "accept-language": "zh-Hans-CN;q=1",
|
|
|
+ "mt-app-version": G_MT_VERSION,
|
|
|
+ "user-agent": G_USER_AGENT,
|
|
|
+ "mt-request-id": getMTRequestId(),
|
|
|
+ "mt-r": G_MT_R,
|
|
|
+ "mt-lng": "113.380126",
|
|
|
+ "accept-encoding": "gzip, deflate, br"
|
|
|
+ };
|
|
|
+ const body = '';
|
|
|
+ const url = `https://static.moutai519.com.cn/mt-backend/xhr/front/mall/shop/list/slim/v3/${sessionId}/${province}/${city}/${timeKeys}`;
|
|
|
+ let options = {
|
|
|
+ url: url,
|
|
|
+ headers: headers,
|
|
|
+ body: body
|
|
|
+ };
|
|
|
+ lk.get(options, async (error, _response, data) => {
|
|
|
+ let ret;
|
|
|
+ try {
|
|
|
+ if (error) {
|
|
|
+ lk.execFail();
|
|
|
+ } else {
|
|
|
+ const jsonRetObj = JSON.parse(data);
|
|
|
+ if (jsonRetObj.code == 2000) {
|
|
|
+ const rspData = jsonRetObj.data || {};
|
|
|
+ const shops = rspData.shops || [];
|
|
|
+ const shopId = G_P_C_MAP[province][city];
|
|
|
+ for (let i = 0; i < shops.lenght; i++) {
|
|
|
+ const shopObj = shops[i];
|
|
|
+ if (shopObj.shopId && shopId.indexOf(shopObj.shopId) > -1) {
|
|
|
+ ret = shopObj.shopId;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ lk.logErr(e);
|
|
|
+ lk.execFail();
|
|
|
+ } finally {
|
|
|
+ resolve(ret);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } catch (e) {
|
|
|
+ lk.logErr(e);
|
|
|
+ resolve();
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
|
|
|
// async function getUserId(token, deviceId) {
|
|
|
// return new Promise((resolve, _reject) => {
|