|
@@ -18,21 +18,28 @@ export const wxAuth = async <Object>(redirectUrl: string): Promise<string> => {
|
|
|
})
|
|
|
const urlParams = getUrlParams() as any;
|
|
|
const code = urlParams["code"];
|
|
|
- const loading = await loadingController.create({
|
|
|
- cssClass: 'my-custom-class',
|
|
|
- message: '微信授权中,请稍后...',
|
|
|
- duration: 2000,
|
|
|
- });
|
|
|
- await loading.present();
|
|
|
+
|
|
|
if (!code) {
|
|
|
+ const loading = await loadingController.create({
|
|
|
+ cssClass: 'my-custom-class',
|
|
|
+ message: '微信授权中,请稍等...',
|
|
|
+ duration: 2000,
|
|
|
+ });
|
|
|
+ await loading.present();
|
|
|
getOAuthUrl(encodeURIComponent(redirectUrl)).then((res: any) => {
|
|
|
if (res) {
|
|
|
- window.location.href = res;
|
|
|
+ window.location.replace(res);
|
|
|
} else {
|
|
|
presentAlert("微信授权失败!");
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
+ const loading = await loadingController.create({
|
|
|
+ cssClass: 'my-custom-class',
|
|
|
+ message: '微信授权成功,请稍等...',
|
|
|
+ duration: 2000,
|
|
|
+ });
|
|
|
+ await loading.present();
|
|
|
await getWxOpenId(code).then((res: any) => {
|
|
|
userStore.setOpenId(res);
|
|
|
});
|