Feat(时令尝鲜):接口对接
This commit is contained in:
+99
-128
@@ -1,144 +1,115 @@
|
||||
<template>
|
||||
<view class="lottie-bg">
|
||||
<img class="start-img" :src="webUrl+'/20220929145109969605.png'" mode="scaleToFill">
|
||||
</view>
|
||||
<view class="lottie-bg" :style="{ backgroundImage: 'url(' + splashScreen + ')' }"/>
|
||||
</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";
|
||||
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 {
|
||||
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);
|
||||
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;
|
||||
|
||||
// //如果是分销强制跳转到授权界面,来绑定关系
|
||||
// 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(() => {
|
||||
//绑定上级
|
||||
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: 100%;
|
||||
height: 100%;
|
||||
background-color: #C9151E;
|
||||
}
|
||||
|
||||
.start-img {
|
||||
position: fixed;
|
||||
bottom: 200rpx;
|
||||
left: 50%;
|
||||
transform: translate(-50%, 0);
|
||||
width: 190rpx;
|
||||
height: 212rpx;
|
||||
}
|
||||
.lottie-bg {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
background-repeat: no-repeat;
|
||||
background-size: 100vw 100vh;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user