奇怪的是,安卓上没有问题,只有在iOS上才会出现这个问题
/**
* 生成token
*/
queryToken() {
if (this.token) {
return Promise.resolve(this.token);
}
const obj = {
apiKey: this.config.apiKey,
expires: 86400,
timestamp: Date.now(),
acl: `[{"service":"ecs:crs","effect":"Allow","resource":["${this.config.crsAppId}"],"permission":["READ","WRITE"]}]`
};
const str = Object.keys(obj)
.sort()
.map((k) => k + obj[k])
.join('');
obj.signature = CryptoJS.SHA256(`${str}${this.config.apiSecret}`, '').toString();
// console.log(obj);
return new Promise((resolve, reject) => {
fetch('
https://uac.easyar.com/token/v2/', {
method: 'POST',
body: JSON.stringify(obj),
credentials: 'include',
headers: {
'content-type': 'application/json',
'Accept': 'application/json',
}}).then(response => {
//handle response
return response.json();
}).then(data => {
//handle data
console.log(data)
this.token = data.result.token;
resolve(this.token);
}).catch(error => {
//handle error
reject(error)
});
});
}