116 lines
2.6 KiB
Vue
116 lines
2.6 KiB
Vue
<template>
|
|
<view class="lottie-bg" :style="{ backgroundImage: 'url(' + splashScreen + ')' }"/>
|
|
</template>
|
|
|
|
<script>
|
|
import {mapActions} from "vuex";
|
|
import {userBindParent} from "@/api/user";
|
|
import cookie from "@/utils/store/cookie";
|
|
import {checkAuth, getCurrentPageUrl, handleQrCode, handleUrlParam, login} from "@/utils";
|
|
import {getSplashScreen} from "@/api/public";
|
|
|
|
export default {
|
|
name: "Loading",
|
|
data() {
|
|
return {
|
|
splashScreen: ""
|
|
};
|
|
},
|
|
onLoad() {
|
|
getSplashScreen().then(({data}) => this.splashScreen = data);
|
|
},
|
|
onShow() {
|
|
let url = handleQrCode();
|
|
if (!url) {
|
|
url = handleUrlParam(getCurrentPageUrl())
|
|
}
|
|
// 判断是否是分销
|
|
if (url) {
|
|
let spread = cookie.get("spread");
|
|
let urlSpread = parseInt(url.spread);
|
|
if (!Number.isNaN(urlSpread)) {
|
|
cookie.set("spread", urlSpread || 0);
|
|
|
|
//绑定上级
|
|
userBindParent({
|
|
spread: urlSpread
|
|
}).finally(() => {
|
|
this.$yrouter.switchTab({
|
|
path: "/pages/home/index"
|
|
});
|
|
})
|
|
return;
|
|
} else if (spread === 0 || typeof spread !== "number") {
|
|
cookie.set("spread", urlSpread || 0);
|
|
}
|
|
|
|
}
|
|
if (this.$store.getters.token) {
|
|
// 注释下面一行,会停留在启动页
|
|
setTimeout(() => {
|
|
this.toLaunch();
|
|
}, 2000)
|
|
return;
|
|
}
|
|
cookie.get("spread");
|
|
// this.toLaunch();
|
|
if (this.$deviceType == "app") {
|
|
// this.toLaunch();
|
|
this.$yrouter.switchTab({
|
|
path: "/pages/home/index"
|
|
});
|
|
return;
|
|
}
|
|
|
|
//检查授权信息
|
|
this.checkUserInfo();
|
|
},
|
|
methods: {
|
|
...mapActions(["changeAuthorization", "setUserInfo"]),
|
|
toLaunch() {
|
|
this.changeAuthorization(false);
|
|
this.$yrouter.switchTab({
|
|
path: "/pages/home/index"
|
|
});
|
|
},
|
|
checkUserInfo: async function () {
|
|
//检查是否有授权信息
|
|
let loginInfo = null;
|
|
let authUserInfo = await checkAuth().catch(err => {
|
|
});
|
|
|
|
console.log('authUserInfo:' + JSON.stringify(authUserInfo));
|
|
|
|
if (authUserInfo) {
|
|
loginInfo = {
|
|
userInfo: authUserInfo,
|
|
iv: '',
|
|
encryptedData: ''
|
|
}
|
|
}
|
|
|
|
login(loginInfo).finally(() => {
|
|
this.$yrouter.switchTab({
|
|
path: "/pages/home/index"
|
|
});
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
};
|
|
</script>
|
|
|
|
<style scoped lang="less">
|
|
.lottie-bg {
|
|
position: fixed;
|
|
left: 0;
|
|
top: 0;
|
|
width: 100vw;
|
|
height: 100vh;
|
|
background-repeat: no-repeat;
|
|
background-size: 100vw 100vh;
|
|
overflow: hidden;
|
|
}
|
|
</style>
|