|
|
@@ -24,6 +24,7 @@ const gardartCollectionNameKey = 'lkGandartCollectionName';
|
|
|
const gardartCastingIdKey = 'lkGandartCastingId';
|
|
|
const gardartLimitPriceKey = 'lkGandartLimitPrice';
|
|
|
const gandartTransactionRecordIdKey = 'lkGandartTransactionRecordId';
|
|
|
+const gandartCollectionCateLstKey = 'lkGandartCollectionCateLst';
|
|
|
|
|
|
let gandartToken = lk.getVal(gandartTokenKey, '');
|
|
|
|
|
|
@@ -61,13 +62,26 @@ function getInfo() {
|
|
|
return;
|
|
|
}
|
|
|
if(url.match(/\/market\/api\/v3\/resaleManage\/resale\/tradingMarket/)){
|
|
|
- lk.log(`开始获取Token`);
|
|
|
+ lk.log(`获取最新Token并更新产品列表`);
|
|
|
// lk.log(JSON.stringify($request.headers));
|
|
|
if ($request.headers['token']) {
|
|
|
let jwktoken = $request.headers['token'];
|
|
|
lk.setVal(gandartTokenKey, jwktoken);
|
|
|
lk.appendNotifyInfo('🎉成功获取光予token,可以关闭相应脚本');
|
|
|
}
|
|
|
+ let data = lk.getResponseBody();
|
|
|
+ try {
|
|
|
+ data = JSON.parse(data);
|
|
|
+ if (data["success"]) {
|
|
|
+ let obj = data["obj"];
|
|
|
+ let oldItemlst = JSON.parse(lk.getVal(gandartCollectionCateLstKey, []));
|
|
|
+ let pageItemlst = obj["list"];
|
|
|
+ let newLst = checkAppendCollectionItemsDiff(oldItemlst, pageItemlst);
|
|
|
+ lk.setVal(gandartCollectionCateLstKey, JSON.stringify(newLst));
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ lk.execFail();
|
|
|
+ }
|
|
|
lk.msg('');
|
|
|
return;
|
|
|
}
|
|
|
@@ -79,12 +93,23 @@ function getInfo() {
|
|
|
data = JSON.parse(data);
|
|
|
if (data["success"]) {
|
|
|
let obj = data["obj"];
|
|
|
- lk.setVal(gardartCollectionNameKey, obj["collectionName"]);
|
|
|
- lk.log(gardartCastingIdKey+"="+obj["castingId"]);
|
|
|
-
|
|
|
- lk.setVal(gardartCastingIdKey, String(obj["castingId"]));
|
|
|
-
|
|
|
- lk.appendNotifyInfo('🎉成功获取产品信息');
|
|
|
+ let castingId = String(obj["castingId"]);
|
|
|
+ if(castingId == ""){
|
|
|
+ lk.log(`打印$request#start`);
|
|
|
+ for(let k in $request){
|
|
|
+ lk.log(JSON.stringify($request[k]));
|
|
|
+ }
|
|
|
+ lk.log(`打印$request#end`);
|
|
|
+ }
|
|
|
+ if(castingId != ""){
|
|
|
+ lk.setVal(gardartCastingIdKey, castingId);
|
|
|
+ let collectionName = obj["collectionName"];
|
|
|
+ lk.setVal(gardartCollectionNameKey, collectionName);
|
|
|
+ lk.log(collectionName+" castingId="+obj["castingId"]);
|
|
|
+ lk.appendNotifyInfo(`🎉成功获取[${collectionName}]信息`);
|
|
|
+ } else {
|
|
|
+ lk.appendNotifyInfo('❌获取产品信息失败');
|
|
|
+ }
|
|
|
} else {
|
|
|
lk.execFail();
|
|
|
lk.appendNotifyInfo('❌获取产品信息失败,请稍后再试');
|
|
|
@@ -99,6 +124,38 @@ function getInfo() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+function checkAppendCollectionItemsDiff(cLst, pageLst){
|
|
|
+ let dic = {};
|
|
|
+ for (const d of cLst) {
|
|
|
+ dic[d.castingId] = d;
|
|
|
+ }
|
|
|
+ for (const d of pageLst) {
|
|
|
+ dic[d.castingId] = d;
|
|
|
+ }
|
|
|
+ let newLst = [];
|
|
|
+ for(let k in dic){
|
|
|
+ let ele = {
|
|
|
+ castingId: dic[k].castingId,
|
|
|
+ collectionName: dic[k].collectionName,
|
|
|
+ resalePrice: dic[k].resalePrice,
|
|
|
+ };
|
|
|
+ newLst.push(ele);
|
|
|
+ }
|
|
|
+ return newLst;
|
|
|
+}
|
|
|
+
|
|
|
+function getCollectionNameById(castingId) {
|
|
|
+ let name = '未获取';
|
|
|
+ let clst = JSON.parse(lk.getVal(gandartCollectionCateLstKey, []));
|
|
|
+ for (const d of clst) {
|
|
|
+ if(d.castingId == castingId){
|
|
|
+ name = d.collectionName;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return name;
|
|
|
+}
|
|
|
+
|
|
|
async function all() {
|
|
|
let hasNeedSendNotify = true;
|
|
|
if (gandartToken == '') {
|
|
|
@@ -106,7 +163,7 @@ async function all() {
|
|
|
lk.appendNotifyInfo(`⚠️请先打开光予登录获取token`);
|
|
|
} else {
|
|
|
// await checkBuy();
|
|
|
- let price = lk.getVal(gardartLimitPriceKey, 0);
|
|
|
+ let price = Number(lk.getVal(gardartLimitPriceKey, 0));
|
|
|
lk.log(`test111111`);
|
|
|
lk.log(String(price));
|
|
|
lk.log(gardartLimitPriceKey + "="+typeof(price)+":"+price);
|
|
|
@@ -123,7 +180,14 @@ function checkBuy() {
|
|
|
return new Promise((resolve, _reject) => {
|
|
|
try {
|
|
|
let price = lk.getVal(gardartLimitPriceKey, 0);
|
|
|
- lk.log(gardartLimitPriceKey + "="+type(price)+":"+price);
|
|
|
+ price = Number(price);
|
|
|
+ if(price < 0){
|
|
|
+ lk.prependNotifyInfo('请设置监控价格');
|
|
|
+ resolve(1);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
} catch (e) {
|
|
|
lk.logErr(e);
|
|
|
} finally {
|