Commit c4125e0e by v_vjyjiang

d

parent bc8e3354
...@@ -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 {
......
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',
...@@ -13,7 +13,7 @@ class SmsClient{ ...@@ -13,7 +13,7 @@ class SmsClient{
} }
async aliSendMsg(to,tmplcode,signName,jsonContent){ async aliSendMsg (to, tmplcode, signName, jsonContent) {
var params = { var params = {
"RegionId": "default", "RegionId": "default",
"PhoneNumbers": to, "PhoneNumbers": to,
...@@ -31,15 +31,15 @@ class SmsClient{ ...@@ -31,15 +31,15 @@ class SmsClient{
}) })
} }
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); return this.restClient.execPost(txtObj, this.smsTeml);
} }
async getUidStr(len, radix) { async getUidStr (len, radix) {
var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''); var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
var uuid = [], i; var uuid = [], i;
radix = radix || chars.length; radix = radix || chars.length;
...@@ -60,7 +60,7 @@ class SmsClient{ ...@@ -60,7 +60,7 @@ class SmsClient{
} }
} }
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"}));
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