Commit 34f2ae67 by 孙亚楠

dd

parent 77b289c0
...@@ -13,6 +13,7 @@ class LaoActionApi extends APIBase { ...@@ -13,6 +13,7 @@ class LaoActionApi extends APIBase {
// this.restClient = system.getObject("util.restClient"); // this.restClient = system.getObject("util.restClient");
this.smsClient = system.getObject("util.smsClient"); this.smsClient = system.getObject("util.smsClient");
this.vcodePrev = "lwb_vcode_"; this.vcodePrev = "lwb_vcode_";
this.testPhones = ['13691046554', '13333333333'];
} }
async test(pobj, query) { async test(pobj, query) {
...@@ -74,16 +75,20 @@ class LaoActionApi extends APIBase { ...@@ -74,16 +75,20 @@ class LaoActionApi extends APIBase {
if (!/^1[23456789]\d{9}$/.test(phone_no)) { if (!/^1[23456789]\d{9}$/.test(phone_no)) {
return system.getResult(null, "手机号码格式不正确"); return system.getResult(null, "手机号码格式不正确");
} }
var isTest = this.testPhones.indexOf(phone_no) != -1;
// 生成验证码 // 生成验证码
var key = this.vcodePrev + phone_no; var key = this.vcodePrev + phone_no;
var vcode = await this.redisClient.get(key + "t"); var vcode = await this.redisClient.get(key + "t");
if (!vcode) { 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, vcode, 5 * 60);
await this.redisClient.setWithEx(key + "t", vcode, 60); await this.redisClient.setWithEx(key + "t", vcode, 60);
var msg = "您的验证码为" + vcode + ", (切勿将验证码告知别人, 请在5分钟内输入完成验证, 如有问题请联系客服。)"; var msg = "您的验证码为" + vcode + ", (切勿将验证码告知别人, 请在5分钟内输入完成验证, 如有问题请联系客服。)";
var rs = await this.smsClient.sendMsg(phone_no, msg); if(!isTest) {
console.log(rs); var rs = await this.smsClient.sendMsg(phone_no, msg);
console.log(rs);
}
} }
return system.getResultSuccess("发送成功"); return system.getResultSuccess("发送成功");
} catch (error) { } catch (error) {
......
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