@yoooloo42/beat 1.0.11 → 1.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yoooloo42/beat",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -17,7 +17,7 @@
17
17
  "homepage": "https://github.com/13993193075/beat#readme",
18
18
  "dependencies": {
19
19
  "@alicloud/pop-core": "^1.8.0",
20
- "@yoooloo42/bean": "^1.0.11",
20
+ "@yoooloo42/bean": "^1.0.13",
21
21
  "nodemailer": "^7.0.10"
22
22
  },
23
23
  "exports": {
@@ -6,25 +6,26 @@ const require = createRequire(import.meta.url);
6
6
  // 引入阿里云 SDK 核心依赖
7
7
  const Core = require('@alicloud/pop-core')
8
8
 
9
+ /**
10
+ * 向指定手机号发送短信
11
+ * @param {string} cellphone 接收短信的手机号(例如: '13800000000')
12
+ * @param {object} shortMessageCode 短信模板中的变量对象中code的值(短信有效内容)
13
+ * @param {object} clientBox 客户端参数
14
+ * @returns {Promise<object>} 返回阿里云 API 的响应对象
15
+ */
9
16
  const clientBoxInit = {
10
17
  action: 'SendSms',
11
18
  apiVersion: '2017-05-25',
12
- accessKeyId: "LTAI5tJeX6TS7bqbLzKxJKrd",
13
- accessKeySecret : "qIhbZJaUyYeLI60yXFyT28k1q4uUde",
14
19
  regionId: 'cn-hangzhou', // 短信服务 API 的区域,通常使用杭州(cn-hangzhou)
15
20
  endpoint: 'https://dysmsapi.aliyuncs.com', // 短信服务的 Endpoint
16
21
  signName: 'litafire',
17
- templateCode: 'SMS_182679443',
22
+ templateCode: 'SMS_497935086',
23
+ accessKeyId: ' ',
24
+ accessKeySecret: ' ',
18
25
  }
19
26
 
20
- /**
21
- * 向指定手机号发送短信
22
- * @param {string} cellphone 接收短信的手机号(例如: '13800000000')
23
- * @param {object} shortMessageCode 短信模板中的变量对象中code的值(短信有效内容)
24
- * @param {object} clientBox 客户端参数
25
- * @returns {Promise<object>} 返回阿里云 API 的响应对象
26
- */
27
- function sms(cellphone, shortMessageCode, clientBox = clientBoxInit) {
27
+ function sms(cellphone, shortMessageCode, clientBox) {
28
+ clientBox = Object.assign(clientBoxInit, clientBox)
28
29
  return new Promise(function (resolve, reject) {
29
30
  const client = new Core({
30
31
  accessKeyId: clientBox.accessKeyId,
@@ -47,6 +48,7 @@ function sms(cellphone, shortMessageCode, clientBox = clientBoxInit) {
47
48
 
48
49
  client.request(clientBox.action, params, requestOption).then(
49
50
  result => {
51
+ console.log('测试 000', result)
50
52
  resolve({code: 0, message: '发送短信成功',
51
53
  result
52
54
  })
@@ -58,7 +60,9 @@ function sms(cellphone, shortMessageCode, clientBox = clientBoxInit) {
58
60
  */
59
61
  },
60
62
  err => {
61
- resolve({code: 1, message: '发送短信失败:' + err})
63
+ resolve({code: 1, message: '发送短信失败',
64
+ err
65
+ })
62
66
  }
63
67
  )
64
68
  })
@@ -67,13 +71,9 @@ function sms(cellphone, shortMessageCode, clientBox = clientBoxInit) {
67
71
  // 发送验证码
68
72
  function sendVercode(cellphone, codeLength = 6){
69
73
  return new Promise(function (resolve, reject) {
70
- const vercode = random.vercode6(codeLength);
74
+ const vercode = random.vercode6N(codeLength);
71
75
  sms(cellphone, vercode).then(result=>{
72
- if(result.code === 0){
73
- resolve({code: 0, message: `发送验证码${vercode}成功`})
74
- }else{
75
- resolve({code: 1, message: `发送验证码${vercode}失败`})
76
- }
76
+ resolve(Object.assign(result, {vercode}))
77
77
  })
78
78
  })
79
79
  }
@@ -82,12 +82,4 @@ const beat = {
82
82
  sms,
83
83
  sendVercode
84
84
  }
85
- export default beat
86
-
87
- /*
88
- sendVercode('13993193075').then(result=>{
89
- console.log(result.message)
90
- }).catch(err=>{
91
- console.log(err)
92
- })
93
- */
85
+ export default beat
@@ -0,0 +1,2 @@
1
+ accessKeyId: 'LTAI5tQhdfseU1nW2YYf2qmU'
2
+ accessKeySecret: 'Ngr7KIRnZ1Ub3cE4HTXYllYAyVyfLf'