|
|
@@ -16,7 +16,7 @@
|
|
|
|
|
|
<script>
|
|
|
import { mapGetters } from 'vuex';
|
|
|
- import {getRealLink,handleFsUserWx,isAddCompanyUser} from "@/api/course.js"
|
|
|
+ import {getRealLink,handleFsUserWx,isAddCompanyUser,loginByMp} from "@/api/course.js"
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
@@ -24,7 +24,8 @@
|
|
|
isRegister: 0,
|
|
|
isLoading: false,
|
|
|
urlOption: {},
|
|
|
- sortLink: ''
|
|
|
+ sortLink: '',
|
|
|
+ isLoginH5: 0, // 1服务号授权
|
|
|
}
|
|
|
},
|
|
|
computed:{
|
|
|
@@ -77,17 +78,31 @@
|
|
|
if(res.code == 200) {
|
|
|
if(res.config&&res.config.userCourseAuthDomain) {
|
|
|
uni.setStorageSync('weixinOauth',res.config.userCourseAuthDomain)
|
|
|
- this.utils.isLoginResCourse().then(
|
|
|
- isLogin => {
|
|
|
- this.isLogin = isLogin
|
|
|
- if(this.isLogin) {
|
|
|
- this.getAddCompanyUser()
|
|
|
- } else {
|
|
|
- this.goLogin()
|
|
|
- }
|
|
|
- },
|
|
|
- rej => {}
|
|
|
- );
|
|
|
+ if(this.isLoginH5==0) {
|
|
|
+ this.utils.isLoginCourse().then(
|
|
|
+ isLogin => {
|
|
|
+ this.isLogin = isLogin
|
|
|
+ if(this.isLogin) {
|
|
|
+ this.getAddCompanyUser()
|
|
|
+ } else {
|
|
|
+ this.goLogin()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ rej => {}
|
|
|
+ );
|
|
|
+ }else {
|
|
|
+ this.utils.isLoginResCourse().then(
|
|
|
+ isLogin => {
|
|
|
+ this.isLogin = isLogin
|
|
|
+ if(this.isLogin) {
|
|
|
+ this.getAddCompanyUser()
|
|
|
+ } else {
|
|
|
+ this.goLogin()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ rej => {}
|
|
|
+ );
|
|
|
+ }
|
|
|
}else {
|
|
|
uni.showToast({
|
|
|
title: '授权地址错误',
|
|
|
@@ -109,6 +124,10 @@
|
|
|
})
|
|
|
},
|
|
|
goLogin(data) {
|
|
|
+ if(this.isLoginH5==0) {
|
|
|
+ this.goWXLogin()
|
|
|
+ return
|
|
|
+ }
|
|
|
if(data) {
|
|
|
this.utils.getProvider().then(provider=>{
|
|
|
console.log('当前的环境商',provider)
|
|
|
@@ -171,6 +190,50 @@
|
|
|
});
|
|
|
}
|
|
|
})
|
|
|
+ },
|
|
|
+ goWXLogin() {
|
|
|
+ this.utils.getProvider().then(provider=>{
|
|
|
+ console.log('当前的环境商',provider)
|
|
|
+ if (!provider) {
|
|
|
+ reject()
|
|
|
+ }
|
|
|
+ uni.login({
|
|
|
+ provider: provider,
|
|
|
+ success: async loginRes => {
|
|
|
+ console.log(loginRes)
|
|
|
+ uni.getUserInfo({
|
|
|
+ provider: provider,
|
|
|
+ success: (infoRes)=> {
|
|
|
+ uni.showToast({
|
|
|
+ title: '注册中...',
|
|
|
+ icon: 'loading'
|
|
|
+ });
|
|
|
+ loginByMp({code: loginRes.code,encryptedData:infoRes.encryptedData,iv:infoRes.iv,appId:getApp().globalData.appId}).then(res=>{
|
|
|
+ uni.hideLoading();
|
|
|
+ if (res.code == 200) {
|
|
|
+ this.$store.commit('setCoureLogin', 1);
|
|
|
+ uni.setStorageSync('AppTokenmini_RTCourse', res.token);
|
|
|
+ uni.setStorageSync('auto_userInfo', JSON.stringify(res.user));
|
|
|
+ this.isLogin = true
|
|
|
+ this.getAddCompanyUser()
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: res.msg,
|
|
|
+ icon: 'none'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }).catch(err=>{
|
|
|
+ uni.hideLoading();
|
|
|
+ uni.showToast({
|
|
|
+ icon:'none',
|
|
|
+ title: "登录失败,请重新登录",
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }).catch(err => {})
|
|
|
}
|
|
|
}
|
|
|
}
|