|
|
@@ -20,12 +20,12 @@ const config = {
|
|
|
const lk = new ToolKit(`光予助手`, `GandartHelper`, `gandartHelper.js`);
|
|
|
|
|
|
const GandartConstKey = {
|
|
|
+ // -----通用助手相关的-----
|
|
|
Token: 'lkGandartToken',
|
|
|
UserData: 'lkGandartUserData',
|
|
|
PrivCollectionBrief: 'lkGandartPrivCollectionBrief',
|
|
|
PrivCollectionDetail: 'lkGandartPrivCollectionDetail',
|
|
|
CollectionName: 'lkGandartCollectionName',
|
|
|
- CollectionName: 'lkGandartCollectionName',
|
|
|
CastingId: 'lkGandartCastingId',
|
|
|
LimitPrice: 'lkGandartLimitPrice',
|
|
|
TransactionRecordId: 'lkGandartTransactionRecordId',
|
|
|
@@ -73,10 +73,13 @@ function checkHanldeRequest() {
|
|
|
break;
|
|
|
case '/base/user/getUser':
|
|
|
handleUserInfo();
|
|
|
- break
|
|
|
+ break;
|
|
|
case '/base/v2/order/nftorder/selectCollection':
|
|
|
handleMyOwnCollection();
|
|
|
break;
|
|
|
+ case '/base/order/nftorder/collectionDetails':
|
|
|
+ handleMyCollectionDetails();
|
|
|
+ break;
|
|
|
case '/base/v2/resaleManage/resale/findAllIsOpenResale':
|
|
|
handleFindAllIsOpenResale();
|
|
|
break;
|
|
|
@@ -90,6 +93,9 @@ function checkHanldeRequest() {
|
|
|
handleCollectionDetailsByCastingId();
|
|
|
break;
|
|
|
default:
|
|
|
+ if (path.match(/\/read\/api\/composite\/getDetailByCasting/)) {
|
|
|
+ handleMyCollectionDetailByCasting();
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
@@ -118,13 +124,36 @@ function handleVerifyCodeLogin() {
|
|
|
lk.msg('');
|
|
|
}
|
|
|
|
|
|
+function handleUserInfo() {
|
|
|
+ try {
|
|
|
+ let data = lk.getResponseBody();
|
|
|
+ if (!data) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ lk.log(`获取用户信息`);
|
|
|
+ data = JSON.parse(data);
|
|
|
+ if (data.user) {
|
|
|
+ lk.setVal(GandartConstKey.UserData, JSON.stringify(data.user));
|
|
|
+ lk.log('成功获取光予用户信息');
|
|
|
+ lk.appendNotifyInfo('🎉成功获取光予用户信息');
|
|
|
+ } else {
|
|
|
+ lk.execFail();
|
|
|
+ lk.appendNotifyInfo('❌获取光予用户信息失败,请稍后再试');
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ lk.execFail();
|
|
|
+ lk.appendNotifyInfo('❌获取光予用户信息失败');
|
|
|
+ }
|
|
|
+ // lk.msg('');
|
|
|
+}
|
|
|
+
|
|
|
function handleMyOwnCollection() {
|
|
|
try {
|
|
|
let data = lk.getResponseBody();
|
|
|
if (!data) {
|
|
|
return;
|
|
|
}
|
|
|
- lk.log(`获取个人产品简要列表`);
|
|
|
+ lk.log(`获取个人拥有的产品简要列表`);
|
|
|
data = JSON.parse(data);
|
|
|
if (data.rows) {
|
|
|
let jsonStr = lk.getVal(GandartConstKey.PrivCollectionBrief, '[]');
|
|
|
@@ -140,9 +169,22 @@ function handleMyOwnCollection() {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ let pageRows = data.rows;
|
|
|
+ for (let i = 0; i < pageRows.length; i++) {
|
|
|
+ const ele = pageRows[i];
|
|
|
+ const info = {
|
|
|
+ castingId: ele.castingId,
|
|
|
+ number: ele.number,
|
|
|
+ collectionName: ele.collectionName,
|
|
|
+ page: curPage,
|
|
|
+ }
|
|
|
+ cacheLst.push(info);
|
|
|
+ }
|
|
|
+ jsonStr = JSON.stringify(cacheLst, null, 2);
|
|
|
+ lk.setVal(GandartConstKey.PrivCollectionBrief, jsonStr);
|
|
|
|
|
|
lk.log('成功获取个人产品简要列表');
|
|
|
- lk.appendNotifyInfo('🎉成功获取个人产品简要列表');
|
|
|
+ lk.appendNotifyInfo('🎉成功获取光予个人产品简要列表');
|
|
|
} else {
|
|
|
lk.execFail();
|
|
|
lk.appendNotifyInfo('❌获取光予个人产品简要列表失败,请稍后再试');
|
|
|
@@ -154,29 +196,129 @@ function handleMyOwnCollection() {
|
|
|
// lk.msg('');
|
|
|
}
|
|
|
|
|
|
-function handleUserInfo() {
|
|
|
+function handleMyCollectionDetails() {
|
|
|
try {
|
|
|
let data = lk.getResponseBody();
|
|
|
if (!data) {
|
|
|
return;
|
|
|
}
|
|
|
- lk.log(`获取用户信息`);
|
|
|
+ lk.log(`获取个人拥有的产品详情列表`);
|
|
|
data = JSON.parse(data);
|
|
|
- if (data.user) {
|
|
|
- lk.setVal(GandartConstKey.UserData, JSON.stringify(data.user));
|
|
|
- lk.log('成功获取光予用户信息');
|
|
|
- lk.appendNotifyInfo('🎉成功获取光予用户信息');
|
|
|
+ if (data.rows) {
|
|
|
+ let params = {};
|
|
|
+ let reqBody = lk.getRequestBody();
|
|
|
+ if (reqBody) {
|
|
|
+ params = lk.parseQueryStr(reqBody);
|
|
|
+ }
|
|
|
+ let jsonStr = lk.getVal(GandartConstKey.PrivCollectionDetail, '{}');
|
|
|
+ let cacheDetails = JSON.parse(jsonStr);
|
|
|
+ let pageRows = data.rows;
|
|
|
+
|
|
|
+ let castingId = params.castingId;
|
|
|
+ if (pageRows[0]) {
|
|
|
+ castingId = pageRows[0].castingId;
|
|
|
+ }
|
|
|
+ let cacheLst = cacheDetails[castingId] || [];
|
|
|
+ let curPage = data.page;
|
|
|
+ if (curPage == 1) {
|
|
|
+ //全部清理
|
|
|
+ cacheLst = [];
|
|
|
+ } else {
|
|
|
+ for (let i = cacheLst.length - 1; i >= 0; i--) {
|
|
|
+ if (cacheLst[i].page == curPage) {
|
|
|
+ cacheLst.splice(i, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (let i = 0; i < pageRows.length; i++) {
|
|
|
+ const ele = pageRows[i];
|
|
|
+ const info = {
|
|
|
+ id: ele.id,
|
|
|
+ viewSort: ele.viewSort,
|
|
|
+ castingId: ele.castingId,
|
|
|
+ collectionName: ele.collectionName,
|
|
|
+ page: curPage,
|
|
|
+ }
|
|
|
+ cacheLst.push(info);
|
|
|
+ }
|
|
|
+ cacheDetails[castingId] = cacheLst;
|
|
|
+ jsonStr = JSON.stringify(cacheDetails, null, 2);
|
|
|
+ lk.setVal(GandartConstKey.PrivCollectionBrief, jsonStr);
|
|
|
+
|
|
|
+ lk.log('成功获取个人产品详情列表');
|
|
|
+ lk.appendNotifyInfo('🎉成功获取光予个人产品详情列表');
|
|
|
} else {
|
|
|
lk.execFail();
|
|
|
- lk.appendNotifyInfo('❌获取光予用户信息失败,请稍后再试');
|
|
|
+ lk.appendNotifyInfo('❌获取光予个人产品详情列表失败,请稍后再试');
|
|
|
}
|
|
|
} catch (e) {
|
|
|
lk.execFail();
|
|
|
- lk.appendNotifyInfo('❌获取光予用户信息失败');
|
|
|
+ lk.appendNotifyInfo('❌获取光予个人产品详情列表发生错误');
|
|
|
}
|
|
|
// lk.msg('');
|
|
|
}
|
|
|
|
|
|
+function handleMyCollectionDetailByCasting() {
|
|
|
+ try {
|
|
|
+ let data = lk.getResponseBody();
|
|
|
+ if (!data) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ lk.log(`获取个人拥有的产品详情列表#合成选择`);
|
|
|
+ data = JSON.parse(data);
|
|
|
+ if (data.success) {
|
|
|
+ const url = $request.url;
|
|
|
+ const params = lk.parseQueryStr(url);
|
|
|
+ if (!params.castingId) {
|
|
|
+ let reqBody = lk.getRequestBody();
|
|
|
+ if (reqBody) {
|
|
|
+ params = lk.parseQueryStr(reqBody);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let jsonStr = lk.getVal(GandartConstKey.PrivCollectionDetail, '{}');
|
|
|
+ let cacheDetails = JSON.parse(jsonStr);
|
|
|
+ let obj = data.obj;
|
|
|
+ let itemLst = obj.list;
|
|
|
+
|
|
|
+ let castingId = params.castingId;
|
|
|
+ if (itemLst[0]) {
|
|
|
+ castingId = itemLst[0].castingId;
|
|
|
+ }
|
|
|
+ let cacheLst = cacheDetails[castingId] || [];
|
|
|
+ let curPage = obj.page;
|
|
|
+ if (curPage == 1) {
|
|
|
+ //全部清理
|
|
|
+ cacheLst = [];
|
|
|
+ } else {
|
|
|
+ //删除对应页码的
|
|
|
+ for (let i = cacheLst.length - 1; i >= 0; i--) {
|
|
|
+ if (cacheLst[i].page == curPage) {
|
|
|
+ cacheLst.splice(i, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (let i = 0; i < itemLst.length; i++) {
|
|
|
+ const ele = itemLst[i];
|
|
|
+ const info = {
|
|
|
+ id: ele.id,
|
|
|
+ viewSort: ele.viewSort,
|
|
|
+ castingId: ele.castingId,
|
|
|
+ collectionName: ele.collectionName,
|
|
|
+ }
|
|
|
+ cacheLst.push(info);
|
|
|
+ }
|
|
|
+
|
|
|
+ cacheDetails[castingId] = cacheLst;
|
|
|
+ jsonStr = JSON.stringify(cacheDetails, null, 2);
|
|
|
+ lk.setVal(GandartConstKey.PrivCollectionDetail, jsonStr);
|
|
|
+ lk.log('成功获取个人产品详情列表');
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ lk.log('获取个人产品详情列表发生错误');
|
|
|
+ lk.logErr(error);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
function handleFindAllIsOpenResale() {
|
|
|
try {
|
|
|
let data = lk.getResponseBody();
|