发送短信

发送短信

安装MD5

1
npm i md5

使用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const timestamp = Date.parse(new Date()) / 1000
const nonce = this.generateCode()
const originString = this.platform.jscode + timestamp + nonce + this.state.phoneNumber
const sign = md5(originString)

const self = this
self
.am('sms', {
mobile: this.state.phoneNumber,
// jscode: this.state.jscode,
timestamp,
nonce,
sign
})

// 生成6位随机数字
generateCode() {
let arr = []
for(let i = 0; i < 6; i++){
let num = Math.random() * 9
num = parseInt(num, 10)
arr.push(num);
}
return arr.join('')
}