Commit 34f2ae67 by 孙亚楠

dd

parent 77b289c0
......@@ -13,6 +13,7 @@ class LaoActionApi extends APIBase {
// this.restClient = system.getObject("util.restClient");
this.smsClient = system.getObject("util.smsClient");
this.vcodePrev = "lwb_vcode_";
this.testPhones = ['13691046554', '13333333333'];
}
async test(pobj, query) {
......@@ -74,17 +75,21 @@ class LaoActionApi extends APIBase {
if (!/^1[23456789]\d{9}$/.test(phone_no)) {
return system.getResult(null, "手机号码格式不正确");
}
var isTest = this.testPhones.indexOf(phone_no) != -1;
// 生成验证码
var key = this.vcodePrev + phone_no;
var vcode = await this.redisClient.get(key + "t");
if (!vcode) {
vcode = await this.getVCode();
vcode = isTest ? "123123" : await this.getVCode();
await this.redisClient.setWithEx(key, vcode, 5 * 60);
await this.redisClient.setWithEx(key + "t", vcode, 60);
var msg = "您的验证码为" + vcode + ", (切勿将验证码告知别人, 请在5分钟内输入完成验证, 如有问题请联系客服。)";
if(!isTest) {
var rs = await this.smsClient.sendMsg(phone_no, msg);
console.log(rs);
}
}
return system.getResultSuccess("发送成功");
} catch (error) {
return system.getResultFail(500, "接口异常:" + error.message);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment