| 69 | |
| 70 | |
| 71 | function getToken() { |
| 72 | if ($request && $request.method != 'OPTIONS' && /\/common\/(alipaymini|wxmini)\?_ENCRYPT=/.test($request.url)) { //WX、ALI |
| 73 | let ENCRYPT = $request.url.split("_ENCRYPT=")[1].split("&")[0]; |
| 74 | ENCRYPT = base64decode(ENCRYPT); |
| 75 | let obj = {}, abc = {}; |
| 76 | ENCRYPT.split('&').forEach(item => obj[item.split('=')[0]] = (item.split('=')[1])) |
| 77 | abc.userId = obj.userId; |
| 78 | abc.adiu = obj.deviceId; |
| 79 | abc.sessionid = obj.sessionId; |
| 80 | if (abc.sessionid.length > 30) { |
| 81 | $.setdata($.toStr(abc), _key); |
| 82 | $.msg($.name, '从小程序获取签到sessionid成功🎉', $.toStr(abc)); |
| 83 | } |
| 84 | } else if ($request && $request.method != 'OPTIONS') { //WX、ALI、APP |
| 85 | let abc = {}; |
| 86 | let obj = $.toObj($response.body); |
| 87 | abc.userId = obj.content.uid; |
| 88 | abc.adiu = obj.content.adiu; |
| 89 | let hed = $request.headers; |
| 90 | abc.sessionid = hed['sessionid'] || hed['sessionid']; |
| 91 | if (abc.sessionid.length > 30) { |
| 92 | $.setdata($.toStr(abc), _key); |
| 93 | $.msg($.name, '', '获取签到sessionid成功🎉'); |
| 94 | } else { |
| 95 | let ck = hed['Cookie'] || hed['cookie']; |
| 96 | if (ck.includes('sessionid=')) { |
| 97 | abc.sessionid = ck.split("sessionid=")[1].split(";")[0]; |
| 98 | if (abc.sessionid.length > 30) { |
| 99 | $.setdata($.toStr(abc), _key); |
| 100 | $.msg($.name, '从Cookie中获取签到sessionid成功🎉', $.toStr(abc)); |
| 101 | } |
| 102 | } |
| 103 | } |
| 104 | } |
| 105 | } |
| 106 | function getKey() { |
| 107 | for (var t = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678', n = t.length, r = "", i = 0; i < 16; i++) |
| 108 | r += t.charAt(Math.floor(Math.random() * n)); |