注意每次接口调用需重新请求,其他接口签名计算方法均一致
// 接口1
const object1 = {
// 获取AccessToken
name: 'getImouAccessToken',
// 请求地址
url: 'https://openapi.lechange.cn/openapi/accessToken',
// 请求方式
method: 'post',
// 请求参数 json
// const params = getParams()
// {
// system: {
// ver: "1.0",
// time: params.time,
// appId: appId,
// sign: params.sign,
// nonce: params.nonce
// },
// id: params.id
// }
}
function getParams() {
let target = {}
target.time = Math.round(new Date().getTime() / 1000);
target.nonce = Math.random().toString(36).substring(2);
target.sign = getSign(target.time, target.nonce, appSecret)
target.id = Math.floor(Math.random() * (50 - 1 + 1) + 1); // id仅供参考
return target
}
function getSign(timestamp, nonce, secret) {
let str = `time:${timestamp},nonce:${nonce},appSecret:${secret}`
let sign = CryptoJS.MD5(str).toString()
return sign
}