修改验证码逻辑,每次获取都更新新的验证码,更像随机数

This commit is contained in:
2026-02-05 00:18:36 +08:00
parent 6b22238c6e
commit c8a67abdd2
3 changed files with 22 additions and 39 deletions

View File

@@ -3,6 +3,21 @@
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
youle_agent.debug = true; youle_agent.debug = true;
//更新手机验证码
youle_agent.update_phone_code = function(phonenum, smmcode) {
var idx = min_ary_indexof(youle_agent.phonecodes, phonenum, "phonenum");
if (idx == -1){
var info = {};
info.phonenum = phonenum;
info.smmcode = smmcode;
info.sendtime = min_now();
youle_agent.phonecodes.push(info);
} else {
youle_agent.phonecodes[idx].smmcode = smmcode;
youle_agent.phonecodes[idx].sendtime = min_now();
}
}
//发送手机验证码 //发送手机验证码
youle_agent.send_phone_checkcode = function(pack){ youle_agent.send_phone_checkcode = function(pack){
var agentid = pack.data.agentid; var agentid = pack.data.agentid;
@@ -23,40 +38,17 @@ youle_agent.send_phone_checkcode = function(pack){
config.data = md5Geturl3(13619576943, "xieyu2018", phonenum, md5memo); config.data = md5Geturl3(13619576943, "xieyu2018", phonenum, md5memo);
min_http(config); min_http(config);
var idx = min_ary_indexof(youle_agent.phonecodes, phonenum, "phonenum"); youle_agent.update_phone_code(phonenum, smmcode);
if (idx == -1){
var info = {};
info.phonenum = phonenum;
info.smmcode = smmcode;
info.sendtime = min_now();
youle_agent.phonecodes.push(info);
} else {
youle_agent.phonecodes[idx].smmcode = smmcode;
youle_agent.phonecodes[idx].sendtime = min_now();
}
return pack; return pack;
} }
//发送手机验证码-微信小程序版本 //发送手机验证码-微信小程序版本
youle_agent.send_phone_code_wechat = function(pack){ youle_agent.send_phone_code_wechat = function(pack){
var agentid = pack.data.agentid;
var phonenum = pack.data.phonenum; var phonenum = pack.data.phonenum;
var smmcode = min_random(1000, 9999); var smmcode = min_random(1000, 9999);
youle_agent.update_phone_code(phonenum, smmcode);
var idx = min_ary_indexof(youle_agent.phonecodes, phonenum, "phonenum"); pack.data.smmcode = smmcode;
if (idx == -1){
var info = {};
info.phonenum = phonenum;
info.smmcode = smmcode;
info.sendtime = min_now();
youle_agent.phonecodes.push(info);
} else {
youle_agent.phonecodes[idx].smmcode = smmcode;
youle_agent.phonecodes[idx].sendtime = min_now();
}
return pack; return pack;
} }
@@ -83,16 +75,7 @@ youle_agent.get_phone_code_wechat = function(pack){
if (smmcode == 0){ if (smmcode == 0){
smmcode = min_random(1000, 9999); smmcode = min_random(1000, 9999);
if (idx == -1){ youle_agent.update_phone_code(phonenum, smmcode);
var info = {};
info.phonenum = phonenum;
info.smmcode = smmcode;
info.sendtime = min_now();
youle_agent.phonecodes.push(info);
} else {
youle_agent.phonecodes[idx].smmcode = smmcode;
youle_agent.phonecodes[idx].sendtime = min_now();
}
} }
pack.data.smmcode = smmcode; pack.data.smmcode = smmcode;

View File

@@ -42,7 +42,7 @@
"tabIndent": "insertSpaces", "tabIndent": "insertSpaces",
"tabSize": 2 "tabSize": 2
}, },
"libVersion": "3.12.1", "libVersion": "3.14.1",
"packOptions": { "packOptions": {
"ignore": [], "ignore": [],
"include": [] "include": []

View File

@@ -464,7 +464,7 @@ app.post('/api/getPhoneCode', async (req, res) => {
const payload = { const payload = {
"app": "youle", "app": "youle",
"route": "agent", "route": "agent",
"rpc": "get_phone_code_wechat", "rpc": "send_phone_code_wechat",
"data": { "data": {
"agentid": agentid, "agentid": agentid,
"phonenum": phonenum "phonenum": phonenum