145 lines
3.2 KiB
Vue
145 lines
3.2 KiB
Vue
<template>
|
|
<view class="lottie-bg">
|
|
<img class="start-img" :src="webUrl+'/20220929145109969605.png'" mode="scaleToFill">
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import {
|
|
mapState,
|
|
mapMutations,
|
|
mapActions
|
|
} from "vuex";
|
|
import {
|
|
wxappAuth,
|
|
getUser,
|
|
userBindParent
|
|
} from "@/api/user";
|
|
import dayjs from "dayjs";
|
|
import cookie from "@/utils/store/cookie";
|
|
import {
|
|
parseQuery,
|
|
login,
|
|
handleQrCode,
|
|
getCurrentPageUrl,
|
|
handleUrlParam,
|
|
checkAuth
|
|
} from "@/utils";
|
|
|
|
export default {
|
|
name: "Loading",
|
|
data() {
|
|
return {
|
|
webUrl: this.$VUE_APP_RESOURCES_URL,
|
|
staticUrl: this.$STATIC_RESOURCE_URL
|
|
};
|
|
},
|
|
onShow() {
|
|
var url = handleQrCode();
|
|
if (!url) {
|
|
url = handleUrlParam(getCurrentPageUrl())
|
|
}
|
|
// 判断是否是分销
|
|
if (url) {
|
|
var spread = cookie.get("spread");
|
|
let urlSpread = parseInt(url.spread);
|
|
// if (!Number.isNaN(urlSpread) && spread !== urlSpread) {
|
|
if (!Number.isNaN(urlSpread)) {
|
|
cookie.set("spread", urlSpread || 0);
|
|
|
|
//绑定上级
|
|
userBindParent({
|
|
spread: urlSpread
|
|
}).finally(() => {
|
|
this.$yrouter.switchTab({
|
|
path: "/pages/home/index"
|
|
});
|
|
})
|
|
return;
|
|
|
|
// //如果是分销强制跳转到授权界面,来绑定关系
|
|
// var path = "/pages/authorization/index";
|
|
// this.$yrouter.reLaunch({path:path});
|
|
// cookie.set('redirect', path)
|
|
// 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() {
|
|
//检查是否有授权信息
|
|
var 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: 100%;
|
|
height: 100%;
|
|
background-color: #C9151E;
|
|
}
|
|
|
|
.start-img {
|
|
position: fixed;
|
|
bottom: 200rpx;
|
|
left: 50%;
|
|
transform: translate(-50%, 0);
|
|
width: 190rpx;
|
|
height: 212rpx;
|
|
}
|
|
</style>
|