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.
162 lines
3.8 KiB
162 lines
3.8 KiB
<template> |
|
<u-navbar |
|
:title="title" |
|
:auto-back="false" |
|
left-icon="" |
|
left-icon-size="40rpx" |
|
:safe-area-inset-top="true" |
|
:placeholder="true"></u-navbar> |
|
<view :class="{show:(footCheck === 'home')}"> |
|
<HomePage v-show="(footCheck === 'home')"></HomePage> |
|
</view> |
|
<view :class="{show:(footCheck === 'order')}"> |
|
<HomePage v-show="(footCheck === 'order')"></HomePage> |
|
</view> |
|
<view :class="{show:(footCheck === 'chat')}"> |
|
<HomePage v-show="(footCheck === 'chat')"></HomePage> |
|
</view> |
|
<view :class="{show:(footCheck === 'user')}"> |
|
<HomePage v-show="(footCheck === 'user')"></HomePage> |
|
</view> |
|
<u-tabbar |
|
:value="value1" |
|
@change="change1" |
|
|
|
> |
|
<FooterNav style="width:100%;"></FooterNav> |
|
</u-tabbar> |
|
<u-modal :show="show" title="登录" content="当前未登录是否前往登录" @confirm="userLogin" @cancel="this.show = false;" |
|
:closeOnClickOverlay="true" showCancelButton></u-modal> |
|
</template> |
|
|
|
<script> |
|
import RightNav from '@/components/RightNav/Index.vue'; |
|
import FooterNav from '@/components/FooterNav/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"; |
|
import {imghost} from "@/config/host"; |
|
|
|
export default { |
|
components: { |
|
RightNav, |
|
HeaderNav, |
|
HomePage, |
|
OrderPage, |
|
ChatPage, |
|
UserPage, |
|
FooterNav, |
|
}, |
|
data() { |
|
return { |
|
value1: 0, |
|
footCheck: 'home', |
|
show: false, |
|
title: '标题', |
|
content: 'uview-plus的目标是成为uni-app生态最优秀的UI框架', |
|
staticImage: { |
|
foot1:imghost+'/static/image/foot-1', |
|
foot2:imghost+'/static/image/foot-2', |
|
foot3:imghost+'/static/image/foot-3', |
|
foot4:imghost+'/static/image/foot-4', |
|
}, |
|
} |
|
}, |
|
onLoad() { |
|
|
|
}, |
|
methods: { |
|
change1(e) { |
|
this.value1=e |
|
}, |
|
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> |