Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
try {
sessionResponse = await Taro.request({
method: 'POST',
url: `${envConfig.WECHAT_HOST}/oauth/wechat/session`,
data: loginResponse,
});
if (sessionResponse && sessionResponse.data) {
Taro.setStorageSync('openId', sessionResponse.data.openid);
Taro.setStorageSync('sessionKey', sessionResponse.data.session_key);
}
} catch (e) {
console.log(e);
setLoginLoading(false);
await Taro.showToast({ title: '获取 Key 失败' });
return;
}
console.log('sessionResponse', sessionResponse);
//
// ------------------------------------
let userInfoResponse: {
encryptedData: string;
iv: string;
rawData: string; // JSON string
signature: string;
userInfo: {
avatarUrl: string;
city: string;
}).catch((error) => {
showToast(error.message)
});
}
clickReturn () {
Taro.showToast({
'title': '返回',
'duration': 2000,
'icon': 'success'
})
}
clickMy () {
success(res) {
Taro.showToast({
title: '图片已经保存到相册',
icon: 'none',
duration: 1500,
mask: false,
});
},
fail: function (res) {
}).catch((error) => {
showToast(error.message)
});
}
handleClick (title) {
Taro.showToast({
'title': title,
'duration': 2000,
'icon': 'success'
})
}
clickReturn () {
function showError(message, show = true) {
show &&
Taro.showToast({
title: message || "请求异常",
icon: "none"
});
return Promise.reject(message);
}
changePlayMode() {
let { playMode } = this.props.song
if (playMode === 'loop') {
playMode = 'one'
Taro.showToast({
title: '单曲循环',
icon: 'none',
duration: 2000
})
} else if (playMode === 'one') {
playMode = 'shuffle'
Taro.showToast({
title: '随机播放',
icon: 'none',
duration: 2000
})
} else {
playMode = 'loop'
Taro.showToast({
title: '列表循环',
icon: 'none',
duration: 2000
})
}
this.props.changePlayMode({
playMode
})
}