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.
139 lines
3.2 KiB
139 lines
3.2 KiB
1 year ago
|
<template>
|
||
|
<HeaderNav :title="title"></HeaderNav>
|
||
|
<view :class="{show:(footCheck === 'home')}">
|
||
|
<HomePage v-show="(footCheck === 'home')"></HomePage>
|
||
|
</view>
|
||
|
<view :class="{show:(footCheck === 'order')}">
|
||
|
<OrderPage v-show="(footCheck === 'order')"></OrderPage>
|
||
|
</view>
|
||
|
<view :class="{show:(footCheck === 'chat')}">
|
||
|
<ChatPage v-show="(footCheck === 'chat')"></ChatPage>
|
||
|
</view>
|
||
|
<view :class="{show:(footCheck === 'user')}">
|
||
|
<UserPage v-show="(footCheck === 'user')"></UserPage>
|
||
|
</view>
|
||
|
<RightNav></RightNav>
|
||
|
<FooterNav></FooterNav>
|
||
|
<u-modal :show="show" title="登录" content="当前未登录是否前往登录" @confirm="userLogin" @cancel="this.show = false;"
|
||
|
:closeOnClickOverlay="true" showCancelButton></u-modal>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
import FooterNav from '@/components/FooterNav/Index.vue';
|
||
|
import RightNav from '@/components/RightNav/Index.vue';
|
||
|
import HeaderNav from '@/components/HeaderNav/Index.vue';
|
||
|
import HomePage from '@/pages/Index/components/HomePage/Index.vue';
|
||
|
import OrderPage from '@/pages/Index/components/OrderPage/Index.vue';
|
||
|
import ChatPage from '@/pages/Index/components/ChatPage/Index.vue';
|
||
|
import UserPage from '@/pages/Index/components/UserPage/Index.vue';
|
||
|
import {
|
||
|
testLogin,
|
||
|
userDetail,
|
||
|
userExtends
|
||
|
} from "../../api/user";
|
||
|
export default {
|
||
|
components: {
|
||
|
FooterNav,
|
||
|
RightNav,
|
||
|
HeaderNav,
|
||
|
HomePage,
|
||
|
OrderPage,
|
||
|
ChatPage,
|
||
|
UserPage,
|
||
|
},
|
||
|
data() {
|
||
|
return {
|
||
|
footCheck: 'home',
|
||
|
show: false,
|
||
|
title: '标题',
|
||
|
content: 'uview-plus的目标是成为uni-app生态最优秀的UI框架'
|
||
|
}
|
||
|
},
|
||
|
onLoad() {
|
||
|
|
||
|
},
|
||
|
methods: {
|
||
|
userLogin() {
|
||
|
testLogin({
|
||
|
user_id: 1
|
||
|
}).then((res) => {
|
||
|
console.log(res.data)
|
||
|
uni.setStorageSync('token', res.data);
|
||
|
this.show = false;
|
||
|
this.getUserDetail();
|
||
|
});
|
||
|
|
||
|
},
|
||
|
getUserDetail() {
|
||
|
userDetail().then((res) => {
|
||
|
uni.setStorageSync('user', res.data);
|
||
|
this.$store.commit('userInfo', res.data);
|
||
|
});
|
||
|
},
|
||
|
getUserExtend() {
|
||
|
userExtends().then((res) => {
|
||
|
uni.setStorageSync('user-extends', res.data);
|
||
|
this.$store.commit('userExtends', res.data);
|
||
|
});
|
||
|
}
|
||
|
// store.
|
||
|
},
|
||
|
onPageScroll(res) {
|
||
|
if (res.scrollTop <= 20) {
|
||
|
uni.$emit('isTop', true);
|
||
|
} else {
|
||
|
uni.$emit('isTop', false);
|
||
|
}
|
||
|
|
||
|
},
|
||
|
created() {
|
||
|
// this.pagePadding = (api.navHeight().navPaddingTop+
|
||
|
// api.navHeight().navHeight + (api.navHeight().headerPadding *2))
|
||
|
},
|
||
|
mounted() {
|
||
|
this.title = this.$store.state.title;
|
||
|
let token = uni.getStorageSync('token');
|
||
|
let user = uni.getStorageSync('user');
|
||
|
let userExtends = uni.getStorageSync('user-extends');
|
||
|
if (!token) {
|
||
|
this.show = true;
|
||
|
} else if (!user) {
|
||
|
this.getUserDetail();
|
||
|
} else if (!userExtends) {
|
||
|
this.getUserExtend();
|
||
|
} else {
|
||
|
this.$store.commit('userInfo', user);
|
||
|
this.$store.commit('userExtends', userExtends);
|
||
|
}
|
||
|
},
|
||
|
watch: {
|
||
|
"$store.state.footCheck": {
|
||
|
handler(newVal, oldVal) {
|
||
|
this.footCheck = newVal;
|
||
|
}
|
||
|
},
|
||
|
"$store.state.title": {
|
||
|
handler(newVal, oldVal) {
|
||
|
this.title = newVal;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
<style lang="scss">
|
||
|
@keyframes show {
|
||
|
0% {
|
||
|
display: block;
|
||
|
opacity: 0;
|
||
|
}
|
||
|
|
||
|
100% {
|
||
|
opacity: 1;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
.show {
|
||
|
animation: show .5s;
|
||
|
}
|
||
|
</style>
|