优化代码

This commit is contained in:
黄志军
2021-11-09 14:13:03 +08:00
parent 2458118998
commit a4a738ef0d
2 changed files with 1406 additions and 1339 deletions
+69 -2
View File
@@ -21,6 +21,8 @@
let dingtalk = "https://oapi.dingtalk.com/robot/send?access_token=d2b6042cb38f0df63e20797c002208d2710104750c18a1dc84d54106a859a3f0"
let dingtalk1 = "https://oapi.dingtalk.com/robot/send?access_token=a3e80da6f064321881fc38e43a07bfde7a61b6f18245454520fb749556cebfcd"
let dingtalk2 = "https://oapi.dingtalk.com/robot/send?access_token=a3e80da6f064321881fc38e43a07bfde7a61b6f18245454520fb749556cebfcd"
let getManName = ""
let totalPages = 999999 //总页数
const $ = new Env('京东试用')
const URL = 'https://api.m.jd.com/client.action'
@@ -139,15 +141,40 @@
}
if ($.UserName == "jd_45d917547c763") {
username = "跑腿小弟子"
getManName = username
message = message + "<font color=\'#778899\' size=2>【羊毛姐妹】<font color=\'#FFA500\' size=3>" + username + " </font> </font> \n\n "
await try_MyTrials(1, 2) //申请成功的商品
await showMsg()
//下一个要重新去拉列表
trialActivityIdList = []
trialActivityTitleList = []
args_xh.listCount = 0
postToDingTalk(message)
message = ""
totalPages == 999999
continue
}
if ($.UserName == "jd_66ea783827d30") {
username = "军子"
getManName = username
message = message + "<font color=\'#778899\' size=2>【羊毛姐妹】<font color=\'#FFA500\' size=3>" + username + " </font> </font> \n\n "
await try_MyTrials(1, 2) //申请成功的商品
await showMsg()
//下一个要重新去拉列表
trialActivityIdList = []
trialActivityTitleList = []
args_xh.listCount = 0
postToDingTalk(message)
message = ""
totalPages == 999999
continue
}
if ($.UserName == "jd_4311ac0ff4456") {
username = "居子"
}
getManName = username
args_xh.maxLength = Math.floor(Math.random() * (20) + 10)
let list = getList()
//加上名称
@@ -388,8 +415,6 @@
console.log(data.message) // 抱歉,此试用需为种草官才能申请。查看下方详情了解更多。
} else {
console.log("申请失败", JSON.stringify(data))
message += "<font color=\'#778899\' size=2>" + JSON.stringify(data) + "</font>\n\n"
message += "<font color=\'#778899\' size=2>" + `-------\n\n` + "</font>\n\n"
}
}
} catch (e) {
@@ -459,6 +484,12 @@
message += "<font color=\'#4B0082\' size=1>" + `-----\n\n` + "</font>\n\n"
count++
}
if (item.text.text == '试用资格将保留10天') {
message1 = "<font color=\'#4B0082\' size=1>" + `${getManName},你的商品待领取,请尽快领取` + "</font>\n\n"
message1 += "<font color=\'#4B0082\' size=1>" + `申请商品:${item.trialName}` + "</font>\n\n"
message1 += "<font color=\'#4B0082\' size=1>" + `剩余时间:${remaining(item.leftTime)}` + "</font>\n\n"
postToDingTalk2(message1)
}
console.log()
}
@@ -1228,3 +1259,39 @@
}
}, "json")
}
function postToDingTalk2(messgae) {
const message1 = "" + messgae
// that.log(messgae)
const body = {
"msgtype": "markdown",
"markdown": {
"title": "随机试用(待领取)",
"text": message1
},
"at": {
"atMobiles": [],
"isAtAll": true
}
}
$.post(toDingtalk(dingtalk2, JSON.stringify(body)), (data, status, xhr) => {
try {
that.log(resp)
that.log(data)
if (err) {
that.log(JSON.stringify(err));
$.logErr(err);
} else {
if (safeGet(data)) {
$.duckRes = JSON.parse(data);
}
}
} catch (e) {
$.logErr(e, resp)
} finally {
resolve();
}
}, "json")
}