优化随机助力功能

This commit is contained in:
lxk0301
2020-12-01 10:16:39 +08:00
parent 7aae2d866b
commit 79a9f0c150

View File

@@ -333,7 +333,16 @@ async function helpFriends() {
console.log(`不能为自己助力,跳过`); console.log(`不能为自己助力,跳过`);
continue; continue;
} }
await assistFriend(code); const assistFriendRes = await assistFriend(code);
if (assistFriendRes && assistFriendRes['ret'] === 0) {
console.log(`助力朋友:${code}成功,因一次只能助力一个,故跳出助力`)
break
} else if (assistFriendRes && assistFriendRes['ret'] === 11009) {
console.log(`助力朋友[${code}]失败:${assistFriendRes.msg},跳出助力`);
break
} else {
console.log(`助力朋友[${code}]失败:${assistFriendRes.msg}`)
}
} }
} }
} }
@@ -362,17 +371,17 @@ function assistFriend(sharepin) {
} else { } else {
if (safeGet(data)) { if (safeGet(data)) {
data = JSON.parse(data); data = JSON.parse(data);
if (data['ret'] === 0) { // if (data['ret'] === 0) {
console.log(`助力朋友:${sharepin}成功`) // console.log(`助力朋友:${sharepin}成功`)
} else { // } else {
console.log(`助力朋友[${sharepin}]失败:${data.msg}`) // console.log(`助力朋友[${sharepin}]失败:${data.msg}`)
} // }
} }
} }
} catch (e) { } catch (e) {
$.logErr(e, resp) $.logErr(e, resp)
} finally { } finally {
resolve(); resolve(data);
} }
}) })
}) })