Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
a412177e
Commit
a412177e
authored
Dec 30, 2019
by
王昆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gsb
parent
3ccca8c1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
19 deletions
+50
-19
laowubao/app/base/api/impl/operator/laoActionApi.js
+50
-19
No files found.
laowubao/app/base/api/impl/operator/laoActionApi.js
View file @
a412177e
...
...
@@ -132,6 +132,52 @@ class LaoActionApi extends APIBase {
}
}
// async SendSms(obj) { //用户登录,返回用户信息
// if (!obj.phone_no) {
// return system.getResult(null, "电话号码不能为空");
// }
// var phone_no = this.trim(obj.phone_no);
//
// try {
// if (!/^1[23456789]\d{9}$/.test(phone_no)) {
// return system.getResult(null, "手机号码格式不正确");
// }
// let data=null,_result={data:"发送成功"};
// //如果是短信模板则直接发送短信
// if(obj.templateName=="smsTemplate"){
// data= {
// "templateName": "smsTemplate", // 模板类型 loginTemplate(登陆) authenticationTemplate(验证) smsTemplate(短信通知)
// "phoneNumbers": phone_no, // 手机号
// "name":this.trim(obj.name), // 模板参数 默认字段 如果是短信通知模板,则请勿传值
// }
// _result = await this.msSve.SendSms(data);
// }else{
// 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 = 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);
// data = {
// "templateName": obj.templateName, // 模板类型 loginTemplate(登陆) authenticationTemplate(验证) smsTemplate(短信通知)
// "phoneNumbers": phone_no, // 手机号
// "code":vcode, // 模板参数 默认字段 如果是短信通知模板,则请勿传值
// }
// _result = await this.msSve.SendSms(data);
// }
// }
// }
// return _result;
// } catch (error) {
// return system.getResultFail(500, "接口异常:" + error.message);
// }
// }
async
SendSms
(
obj
)
{
//用户登录,返回用户信息
if
(
!
obj
.
phone_no
)
{
return
system
.
getResult
(
null
,
"电话号码不能为空"
);
...
...
@@ -142,16 +188,7 @@ class LaoActionApi extends APIBase {
if
(
!
/^1
[
23456789
]\d{9}
$/
.
test
(
phone_no
))
{
return
system
.
getResult
(
null
,
"手机号码格式不正确"
);
}
let
data
=
null
,
_result
=
{
data
:
"发送成功"
};
//如果是短信模板则直接发送短信
if
(
obj
.
templateName
==
"smsTemplate"
){
data
=
{
"templateName"
:
"smsTemplate"
,
// 模板类型 loginTemplate(登陆) authenticationTemplate(验证) smsTemplate(短信通知)
"phoneNumbers"
:
phone_no
,
// 手机号
"name"
:
this
.
trim
(
obj
.
name
),
// 模板参数 默认字段 如果是短信通知模板,则请勿传值
}
_result
=
await
this
.
msSve
.
SendSms
(
data
);
}
else
{
var
isTest
=
this
.
testPhones
.
indexOf
(
phone_no
)
!=
-
1
;
// 生成验证码
var
key
=
this
.
vcodePrev
+
phone_no
;
...
...
@@ -162,17 +199,11 @@ class LaoActionApi extends APIBase {
await
this
.
redisClient
.
setWithEx
(
key
+
"t"
,
vcode
,
60
);
var
msg
=
"您的验证码为"
+
vcode
+
", (切勿将验证码告知别人, 请在5分钟内输入完成验证, 如有问题请联系客服。)"
;
if
(
!
isTest
)
{
// var rs = await this.smsClient.sendMsg(phone_no, msg);
data
=
{
"templateName"
:
obj
.
templateName
,
// 模板类型 loginTemplate(登陆) authenticationTemplate(验证) smsTemplate(短信通知)
"phoneNumbers"
:
phone_no
,
// 手机号
"code"
:
vcode
,
// 模板参数 默认字段 如果是短信通知模板,则请勿传值
}
_result
=
await
this
.
msSve
.
SendSms
(
data
);
}
var
rs
=
await
this
.
smsClient
.
sendMsg
(
phone_no
,
msg
);
console
.
log
(
rs
);
}
}
return
_result
;
return
system
.
getResultSuccess
(
"发送成功"
)
;
}
catch
(
error
)
{
return
system
.
getResultFail
(
500
,
"接口异常:"
+
error
.
message
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment