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
c4125e0e
Commit
c4125e0e
authored
Aug 14, 2020
by
v_vjyjiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d
parent
bc8e3354
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
55 deletions
+55
-55
center-manage/app/base/db/cache/vcodeCache.js
+1
-1
center-manage/app/base/utils/smsClient.js
+54
-54
No files found.
center-manage/app/base/db/cache/vcodeCache.js
View file @
c4125e0e
...
@@ -23,7 +23,7 @@ class VCodeCache extends CacheBase {
...
@@ -23,7 +23,7 @@ class VCodeCache extends CacheBase {
var
signName
=
items
?
items
[
0
]
:
""
;
var
signName
=
items
?
items
[
0
]
:
""
;
var
vcode
=
await
this
.
smsUtil
.
getUidStr
(
6
,
10
);
var
vcode
=
await
this
.
smsUtil
.
getUidStr
(
6
,
10
);
if
(
!
tmplCode
&&
!
signName
)
{
if
(
!
tmplCode
&&
!
signName
)
{
console
.
log
(
"====================================="
)
console
.
log
(
"====================================="
,
mobile
,
vcode
)
this
.
smsUtil
.
sendMsg
(
mobile
,
vcode
);
this
.
smsUtil
.
sendMsg
(
mobile
,
vcode
);
}
//tmplCode为发送短信编码,需在阿里开通,signName为短信头描述信息,二者没有传递则用默认的发送验证码
}
//tmplCode为发送短信编码,需在阿里开通,signName为短信头描述信息,二者没有传递则用默认的发送验证码
else
{
else
{
...
...
center-manage/app/base/utils/smsClient.js
View file @
c4125e0e
const
system
=
require
(
"../system"
);
const
system
=
require
(
"../system"
);
const
Core
=
require
(
'@alicloud/pop-core'
);
const
Core
=
require
(
'@alicloud/pop-core'
);
class
SmsClient
{
class
SmsClient
{
constructor
(){
constructor
()
{
this
.
smsTeml
=
"http://123.57.156.109:4103/api/Send"
;
this
.
smsTeml
=
"http://123.57.156.109:4103/api/Send"
;
this
.
restClient
=
system
.
getObject
(
"util.restClient"
);
this
.
restClient
=
system
.
getObject
(
"util.restClient"
);
this
.
aliclient
=
new
Core
({
this
.
aliclient
=
new
Core
({
accessKeyId
:
'LTAI4FtNp3wcqFzaADvo1WtZ'
,
accessKeyId
:
'LTAI4FtNp3wcqFzaADvo1WtZ'
,
accessKeySecret
:
'VBKn1Anx4UmMF0LKNz7PVaCFG1phcg'
,
accessKeySecret
:
'VBKn1Anx4UmMF0LKNz7PVaCFG1phcg'
,
endpoint
:
'https://dysmsapi.aliyuncs.com'
,
endpoint
:
'https://dysmsapi.aliyuncs.com'
,
apiVersion
:
'2017-05-25'
apiVersion
:
'2017-05-25'
});
});
}
async
aliSendMsg
(
to
,
tmplcode
,
signName
,
jsonContent
){
}
var
params
=
{
"RegionId"
:
"default"
,
async
aliSendMsg
(
to
,
tmplcode
,
signName
,
jsonContent
)
{
"PhoneNumbers"
:
to
,
var
params
=
{
"SignName"
:
signName
,
"RegionId"
:
"default"
,
"TemplateCode"
:
tmplcode
,
"PhoneNumbers"
:
to
,
"TemplateParam"
:
jsonContent
"SignName"
:
signName
,
}
"TemplateCode"
:
tmplcode
,
var
requestOption
=
{
"TemplateParam"
:
jsonContent
method
:
'POST'
};
this
.
aliclient
.
request
(
'SendSms'
,
params
,
requestOption
).
then
((
result
)
=>
{
console
.
log
(
JSON
.
stringify
(
result
));
},
(
ex
)
=>
{
console
.
log
(
ex
);
})
}
}
var
requestOption
=
{
method
:
'POST'
};
this
.
aliclient
.
request
(
'SendSms'
,
params
,
requestOption
).
then
((
result
)
=>
{
console
.
log
(
JSON
.
stringify
(
result
));
},
(
ex
)
=>
{
console
.
log
(
ex
);
})
}
async
sendMsg
(
to
,
content
){
async
sendMsg
(
to
,
content
)
{
var
txtObj
=
{
var
txtObj
=
{
"appId"
:
8
,
"appId"
:
8
,
"mobilePhone"
:
to
,
"mobilePhone"
:
to
,
"content"
:
content
"content"
:
content
}
return
this
.
restClient
.
execPost
(
txtObj
,
this
.
smsTeml
);
}
}
async
getUidStr
(
len
,
radix
)
{
return
this
.
restClient
.
execPost
(
txtObj
,
this
.
smsTeml
);
var
chars
=
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
.
split
(
''
);
}
var
uuid
=
[],
i
;
async
getUidStr
(
len
,
radix
)
{
radix
=
radix
||
chars
.
length
;
var
chars
=
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
.
split
(
''
);
if
(
len
)
{
var
uuid
=
[],
i
;
for
(
i
=
0
;
i
<
len
;
i
++
)
uuid
[
i
]
=
chars
[
0
|
Math
.
random
()
*
radix
];
radix
=
radix
||
chars
.
length
;
}
else
{
if
(
len
)
{
var
r
;
for
(
i
=
0
;
i
<
len
;
i
++
)
uuid
[
i
]
=
chars
[
0
|
Math
.
random
()
*
radix
];
uuid
[
8
]
=
uuid
[
13
]
=
uuid
[
18
]
=
uuid
[
23
]
=
'-'
;
}
else
{
uuid
[
14
]
=
'4'
;
var
r
;
for
(
i
=
0
;
i
<
36
;
i
++
)
{
uuid
[
8
]
=
uuid
[
13
]
=
uuid
[
18
]
=
uuid
[
23
]
=
'-'
;
if
(
!
uuid
[
i
])
{
uuid
[
14
]
=
'4'
;
r
=
0
|
Math
.
random
()
*
16
;
for
(
i
=
0
;
i
<
36
;
i
++
)
{
uuid
[
i
]
=
chars
[(
i
==
19
)
?
(
r
&
0x3
)
|
0x8
:
r
];
if
(
!
uuid
[
i
])
{
}
r
=
0
|
Math
.
random
()
*
16
;
uuid
[
i
]
=
chars
[(
i
==
19
)
?
(
r
&
0x3
)
|
0x8
:
r
];
}
}
}
}
return
uuid
.
join
(
''
);
}
}
return
uuid
.
join
(
''
);
}
}
}
module
.
exports
=
SmsClient
;
module
.
exports
=
SmsClient
;
// var sms=new SmsClient();
// var sms=new SmsClient();
// sms.aliSendMsg("13381139519","SMS_173946419","iboss",JSON.stringify({code:"hello"}));
// sms.aliSendMsg("13381139519","SMS_173946419","iboss",JSON.stringify({code:"hello"}));
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