import CryptoJS from "crypto-js";
import urlencode from "urlencode";
methods:{
async initUser () {
try {
const url = "/api/info/self";
let _param = {
uid: this.uid,
utoken: this.token,
version: "1.0",
ak: "test",
ts: new Date().getTime(),
nonce: "1234567890"
}
let sortData = {}
let str = ""
Object.keys(_param).sort().map(key => {
sortData[key] = _param[key]
str += (key + "=" + sortData[key] + "&")
})
let result = CryptoJS.HmacSHA1(str.substring(0, str.length - 1), "1rtncba857db7gg5a0e63edb4");
console.log(result)
let sig = result.toString();
sig = encodeURI(sig);
sig = urlencode(sig);
sortData.sign = sig
const { data: res } = await this.$http[0].get(
url,
{
params: sortData,
},
);
console.log(res.data);
} catch (err) {
console.dir(err);
}
}
手机扫一扫
移动阅读更方便
你可能感兴趣的文章