|
@@ -59,6 +59,13 @@
|
|
|
} from "@/utils/common";
|
|
|
import telDialog from './telDialog.vue'
|
|
|
import cacheManager from "@/utils/cacheManager.js";
|
|
|
+
|
|
|
+ import {
|
|
|
+ onShow,
|
|
|
+ onUnload,
|
|
|
+ } from '@dcloudio/uni-app';
|
|
|
+ import {useIsCanBack} from "@/store/isCanBack.js"
|
|
|
+
|
|
|
import {
|
|
|
error
|
|
|
} from "uview-plus";
|
|
@@ -76,24 +83,37 @@
|
|
|
const agreeWxDialog = ref(null);
|
|
|
const telDialogRef = ref(null);
|
|
|
let telDialogFlag = ref(false);
|
|
|
- let showAppleLogin = ref(false);
|
|
|
+ let showAppleLogin = ref(false);
|
|
|
let wxFlag = ref(true);
|
|
|
+
|
|
|
+ const store = useIsCanBack();
|
|
|
+ onUnload(() => {
|
|
|
+ console.log('unload')
|
|
|
+ store.setIsCanBack(false)
|
|
|
+ })
|
|
|
+
|
|
|
+ onShow(() => {
|
|
|
+ setTimeout(() => {
|
|
|
+ console.log('onShow')
|
|
|
+ store.setIsCanBack(true)
|
|
|
+ },500)
|
|
|
+ })
|
|
|
|
|
|
onLoad((options) => {
|
|
|
- showAppleLogin.value = isIOS13OrAbove();
|
|
|
- if(plus.runtime.isApplicationExist({ pname: 'com.tencent.mm', action: 'weixin://' })) {
|
|
|
- console.log('111',"已安装微信");
|
|
|
- wxFlag.value = true
|
|
|
- }else{
|
|
|
- wxFlag.value = false
|
|
|
- }
|
|
|
+ showAppleLogin.value = isIOS13OrAbove();
|
|
|
+ if(plus.runtime.isApplicationExist({ pname: 'com.tencent.mm', action: 'weixin://' })) {
|
|
|
+ console.log('111',"已安装微信");
|
|
|
+ wxFlag.value = true
|
|
|
+ }else{
|
|
|
+ wxFlag.value = false
|
|
|
+ }
|
|
|
console.log('showAppleLogin.value',showAppleLogin.value);
|
|
|
})
|
|
|
|
|
|
const getYzmBtn = () => {
|
|
|
if (indexData.telStatus === 'tel-btn-normal') {
|
|
|
if (indexData.isAgreed === true) {
|
|
|
- uni.navigateTo({
|
|
|
+ uni.redirectTo({
|
|
|
url: `/pages/login/login?telNum=${indexData.phoneNumber}`
|
|
|
})
|
|
|
} else {
|
|
@@ -132,15 +152,15 @@
|
|
|
}
|
|
|
|
|
|
const ykConfirmBtn = () => {
|
|
|
- uni.navigateTo({
|
|
|
+ uni.redirectTo({
|
|
|
url: `/pages/selectGradesTerms/index`
|
|
|
})
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
const wxConfirmBtn= () => {
|
|
|
wxLoginFun();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 手机号校验规则
|
|
|
const validatePhoneNumber = (value) => {
|
|
|
const phoneRegex = /^1[3-9]\d{9}$/;
|
|
@@ -202,41 +222,41 @@
|
|
|
"code": loginRes.appleInfo.user
|
|
|
}
|
|
|
console.log(req);
|
|
|
- console.log(req);
|
|
|
- wxLogin(req).then(res => {
|
|
|
- console.log(res);
|
|
|
- if (!res.data.bind) {
|
|
|
- console.log('未绑定');
|
|
|
- cacheManager.set('wxLogin', {
|
|
|
- bind: res.data.bing
|
|
|
- })
|
|
|
- telDialogFlag.value = true;
|
|
|
- nextTick(() => {
|
|
|
- telDialogRef.value.getOpenId(res.data.openId);
|
|
|
- })
|
|
|
- } else {
|
|
|
- uni.showLoading({
|
|
|
- title: '登录中'
|
|
|
- });
|
|
|
- setTimeout(() => {
|
|
|
- cacheManager.set('auth', res.data.loginVo)
|
|
|
- if (res.data.loginVo.cardId == 0) {
|
|
|
-
|
|
|
- uni.redirectTo({
|
|
|
- url: `/pages/selectGradesTerms/index`
|
|
|
- })
|
|
|
- uni.hideLoading();
|
|
|
- } else {
|
|
|
-
|
|
|
- uni.redirectTo({
|
|
|
- url: `/pages/study/index`
|
|
|
- })
|
|
|
- uni.hideLoading();
|
|
|
- }
|
|
|
- }, 1000)
|
|
|
- }
|
|
|
- }).catch((error) => {
|
|
|
- console.log(error);
|
|
|
+ console.log(req);
|
|
|
+ wxLogin(req).then(res => {
|
|
|
+ console.log(res);
|
|
|
+ if (!res.data.bind) {
|
|
|
+ console.log('未绑定');
|
|
|
+ cacheManager.set('wxLogin', {
|
|
|
+ bind: res.data.bing
|
|
|
+ })
|
|
|
+ telDialogFlag.value = true;
|
|
|
+ nextTick(() => {
|
|
|
+ telDialogRef.value.getOpenId(res.data.openId);
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ uni.showLoading({
|
|
|
+ title: '登录中'
|
|
|
+ });
|
|
|
+ setTimeout(() => {
|
|
|
+ cacheManager.set('auth', res.data.loginVo)
|
|
|
+ if (res.data.loginVo.cardId == 0) {
|
|
|
+
|
|
|
+ uni.redirectTo({
|
|
|
+ url: `/pages/selectGradesTerms/index`
|
|
|
+ })
|
|
|
+ uni.hideLoading();
|
|
|
+ } else {
|
|
|
+
|
|
|
+ uni.redirectTo({
|
|
|
+ url: `/pages/study/index`
|
|
|
+ })
|
|
|
+ uni.hideLoading();
|
|
|
+ }
|
|
|
+ }, 1000)
|
|
|
+ }
|
|
|
+ }).catch((error) => {
|
|
|
+ console.log(error);
|
|
|
})
|
|
|
},
|
|
|
fail: function(err) {
|
|
@@ -246,8 +266,8 @@
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
// 游客登录
|
|
|
const wxLoginClick = () => {
|
|
|
if (indexData.isAgreed === true) {
|
|
@@ -256,7 +276,7 @@
|
|
|
agreeWxDialog.value.handleShow();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
const wxLoginFun= () => {
|
|
|
//获取服务商信息判断手机端是否安装了app
|
|
|
// uni.getProvider({
|
|
@@ -274,68 +294,68 @@
|
|
|
// });
|
|
|
// }
|
|
|
// });
|
|
|
-
|
|
|
- if(plus.runtime.isApplicationExist({ pname: 'com.tencent.mm', action: 'weixin://' })) {
|
|
|
- console.log('111',"已安装微信");
|
|
|
- uni.login({
|
|
|
- "provider": "weixin",
|
|
|
- "onlyAuthorize": true, // 微信登录仅请求授权认证
|
|
|
- success: function(event) {
|
|
|
- console.log(event);
|
|
|
- const {
|
|
|
- code
|
|
|
- } = event
|
|
|
- //客户端成功获取授权临时票据(code),向业务服务器发起登录请求。
|
|
|
- let req = {
|
|
|
- "apple": false,
|
|
|
- "code": code
|
|
|
- }
|
|
|
- console.log(req);
|
|
|
- wxLogin(req).then(res => {
|
|
|
- console.log(res);
|
|
|
- if (!res.data.bind) {
|
|
|
- console.log('未绑定');
|
|
|
- cacheManager.set('wxLogin', {
|
|
|
- bind: res.data.bing
|
|
|
- })
|
|
|
- telDialogFlag.value = true;
|
|
|
- nextTick(() => {
|
|
|
- telDialogRef.value.getOpenId(res.data.openId);
|
|
|
- })
|
|
|
- } else {
|
|
|
- uni.showLoading({
|
|
|
- title: '登录中'
|
|
|
- });
|
|
|
- setTimeout(() => {
|
|
|
- cacheManager.set('auth', res.data.loginVo)
|
|
|
- if (res.data.loginVo.cardId == 0) {
|
|
|
-
|
|
|
- uni.redirectTo({
|
|
|
- url: `/pages/selectGradesTerms/index`
|
|
|
- })
|
|
|
- uni.hideLoading();
|
|
|
- } else {
|
|
|
-
|
|
|
- uni.redirectTo({
|
|
|
- url: `/pages/study/index`
|
|
|
- })
|
|
|
- uni.hideLoading();
|
|
|
- }
|
|
|
- }, 1000)
|
|
|
- }
|
|
|
- }).catch((error) => {
|
|
|
- console.log(error);
|
|
|
- })
|
|
|
- },
|
|
|
- fail: function(err) {
|
|
|
- console.log(err);
|
|
|
- // 登录授权失败
|
|
|
- // err.code是错误码
|
|
|
- }
|
|
|
- })
|
|
|
- } else {
|
|
|
- toast("请重启应用重试")
|
|
|
- return false
|
|
|
+
|
|
|
+ if(plus.runtime.isApplicationExist({ pname: 'com.tencent.mm', action: 'weixin://' })) {
|
|
|
+ console.log('111',"已安装微信");
|
|
|
+ uni.login({
|
|
|
+ "provider": "weixin",
|
|
|
+ "onlyAuthorize": true, // 微信登录仅请求授权认证
|
|
|
+ success: function(event) {
|
|
|
+ console.log(event);
|
|
|
+ const {
|
|
|
+ code
|
|
|
+ } = event
|
|
|
+ //客户端成功获取授权临时票据(code),向业务服务器发起登录请求。
|
|
|
+ let req = {
|
|
|
+ "apple": false,
|
|
|
+ "code": code
|
|
|
+ }
|
|
|
+ console.log(req);
|
|
|
+ wxLogin(req).then(res => {
|
|
|
+ console.log(res);
|
|
|
+ if (!res.data.bind) {
|
|
|
+ console.log('未绑定');
|
|
|
+ cacheManager.set('wxLogin', {
|
|
|
+ bind: res.data.bing
|
|
|
+ })
|
|
|
+ telDialogFlag.value = true;
|
|
|
+ nextTick(() => {
|
|
|
+ telDialogRef.value.getOpenId(res.data.openId);
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ uni.showLoading({
|
|
|
+ title: '登录中'
|
|
|
+ });
|
|
|
+ setTimeout(() => {
|
|
|
+ cacheManager.set('auth', res.data.loginVo)
|
|
|
+ if (res.data.loginVo.cardId == 0) {
|
|
|
+
|
|
|
+ uni.redirectTo({
|
|
|
+ url: `/pages/selectGradesTerms/index`
|
|
|
+ })
|
|
|
+ uni.hideLoading();
|
|
|
+ } else {
|
|
|
+
|
|
|
+ uni.redirectTo({
|
|
|
+ url: `/pages/study/index`
|
|
|
+ })
|
|
|
+ uni.hideLoading();
|
|
|
+ }
|
|
|
+ }, 1000)
|
|
|
+ }
|
|
|
+ }).catch((error) => {
|
|
|
+ console.log(error);
|
|
|
+ })
|
|
|
+ },
|
|
|
+ fail: function(err) {
|
|
|
+ console.log(err);
|
|
|
+ // 登录授权失败
|
|
|
+ // err.code是错误码
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ toast("请重启应用重试")
|
|
|
+ return false
|
|
|
}
|
|
|
}
|
|
|
</script>
|