From 1cc77a8aab3c3b3c6c2b0c65f954f80916e52794 Mon Sep 17 00:00:00 2001 From: smallfawn <860562056@qq.com> Date: Tue, 25 Feb 2025 13:02:21 +0800 Subject: [PATCH] Update wx_ziwi.js --- wxapp/wx_ziwi.js | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/wxapp/wx_ziwi.js b/wxapp/wx_ziwi.js index 07bfcef..2600062 100644 --- a/wxapp/wx_ziwi.js +++ b/wxapp/wx_ziwi.js @@ -1,7 +1,10 @@ /** * cron 25 10 * * * wx_ZIWI+.js * 积分换 猫粮狗粮 + * 变量名wxziwiwxid 值为lufly登录授权的微信id 用于获取微信CODE 来刷新CK + * 变量名luflytoken 谨慎使用加密本 防止偷取TOKEN * 变量名:ZIWIAUTH + * * 变量值:https://ziwi.gzcrm.cn/json-rpc? Headers中的authorization 去掉Bearer 去掉Bearer 去掉Bearer * 多账号& 或新增变量 * scriptVersionNow = "0.0.1"; @@ -14,6 +17,8 @@ let envSplitor = ["&", "\n"]; //多账号分隔符 let strSplitor = "#"; //多变量分隔符 let userIdx = 0; let userList = []; +let appid = 'wxb26a710e583b05dc' +let wxcenter = 'http://w.smallfawn.top:5789' let msg = "" class Task { constructor(str) { @@ -24,6 +29,9 @@ class Task { this.artList = [] } async main() { + if (process.env['wxziwiwxid']) { + await this.getCode() + } await this.task_sign() await this.act_list(); if (this.artList.length > 0) { @@ -33,13 +41,43 @@ class Task { } } } + async getCode() { + let { body: result } = await $.httpRequest({ + method: 'post', headers: { + 'Content-Type': 'application/json' + }, url: wxcenter + '/api/getcode', body: JSON.stringify({ "luflyKey": process.env['luflytoken'], "wxid": "" + process.env['wxziwiwxid'], "appid": "wxb26a710e583b05dc" }) + }) + if (result) { + console.log(result) + if (result.status) { + let code = result.data + + await this.getJwtByCode(code) + + } + + } + } + async getJwtByCode(code) { + + let result = await this.taskRequest('post', 'https://ziwi.gzcrm.cn/json-rpc?__method=WechatMiniProgramCodeToSession', { "id": "", "jsonrpc": "2.0", "method": "WechatMiniProgramCodeToSession", "params": { "appId": "wxb26a710e583b05dc", "code": "" + code, "launchOptions": { "path": "pages/index/index", "query": {}, "referrerInfo": {}, "apiCategory": "default" } } }) + if (result) { + if ('result' in result) { + if ('jwt' in result.result) { + console.log(`刷新CK成功`) + return this.ck = result.result.jwt + } + } + + } + } async taskRequest(method, url, body = "") { // let headers = { "Host": "ziwi.gzcrm.cn", "Connection": "keep-alive", //"Content-Length": "85", - "authorization": "Bearer "+ this.ck, + "authorization": "Bearer " + this.ck, "charset": "utf-8", "User-Agent": "Mozilla/5.0 (Linux; Android 10; MI 8 Lite Build/QKQ1.190910.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/116.0.0.0 Mobile Safari/537.36 XWEB/1160027 MMWEBSDK/20231002 MMWEBID/2585 MicroMessenger/8.0.43.2480(0x28002B51) WeChat/arm64 Weixin NetType/WIFI Language/zh_CN ABI/arm64 MiniProgramEnv/android", "content-type": "application/json;charset=UTF-8",