You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

119 lines
2.8 KiB

4 years ago
<template>
<view class="lottie-bg">
<view id="lottie">
3 years ago
<image src="../../static/loading.gif" rel="preload" mode="widthFix" style="width: 100%;height:100%;" />
4 years ago
</view>
</view>
</template>
<script>
3 years ago
import { mapState, mapMutations, mapActions, mapGetters } from 'vuex'
4 years ago
// 组件
// import request from "@//api/request";
import { wxappAuth } from '@/api/user'
import dayjs from 'dayjs'
import store from '@/store'
import cookie from '@/utils/store/cookie'
import { parseQuery, login, handleQrCode, getCurrentPageUrl, handleUrlParam, getCurrentPageUrlWithArgs } from '@/utils'
export default {
3 years ago
computed: mapGetters(['userInfo']),
4 years ago
name: 'Loading',
data() {
return {}
},
onShow() {
var url = handleQrCode()
if (!url) {
url = handleUrlParam(getCurrentPageUrlWithArgs())
}
3 years ago
// console.log(url)
// console.log('判断是否是分销')
4 years ago
// 判断是否是分销
if (url) {
let urlSpread = parseInt(url.spread)
if (urlSpread) {
cookie.set('spread', urlSpread)
}
}
if (this.$deviceType == 'app' || this.$deviceType == 'weixinh5') {
this.$yrouter.switchTab({
path: '/pages/home/index',
})
return
}
if (this.$store.getters.token) {
// 如果token存在,直接进行进页面
console.log('登录状态存在,直接进页面')
this.toLaunch()
return
}
console.log('进行登录操作')
login().finally(() => {
3 years ago
if(this.userInfo.isPromoter == 1){
this.$yrouter.reLaunch({
path: '/pages/serviceTeacher/index',
})
} else{
this.$yrouter.switchTab({
path: '/pages/home/index',
})
}
4 years ago
})
},
methods: {
...mapActions(['changeAuthorization', 'setUserInfo', 'getUser']),
toLaunch() {
console.log('loading home')
this.changeAuthorization(false)
let redirect = cookie.get('redirect').replace(/\ /g, '')
cookie.remove('redirect')
if (redirect && redirect.indexOf('/pages') != -1) {
this.$yrouter.replace({
path: '/pages' + redirect.split('/pages')[1],
})
} else {
3 years ago
login().finally(() => {
if(this.userInfo.isPromoter == 1){
this.$yrouter.reLaunch({
path: '/pages/serviceTeacher/index',
})
} else{
this.$yrouter.switchTab({
path: '/pages/home/index',
})
}
})
4 years ago
}
},
},
}
</script>
<style scoped lang="less">
.lottie-bg {
position: fixed;
left: 0;
top: 0;
background-color: #fff;
width: 100%;
height: 100%;
z-index: 999;
display: -webkit-flex;
display: flex;
-webkit-align-items: center;
align-items: center;
-webkit-justify-content: center;
justify-content: center;
}
#lottie {
3 years ago
width: 42rpx;
height: 42rpx;
4 years ago
display: block;
overflow: hidden;
transform: translate3d(0, 0, 0);
margin: auto;
}
</style>