1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <template>
- <view>
- <Home :height="height" :token="token" :userInfo="userInfo" :orderStatistics="orderStatistics"
- v-if="nowchos === 0" :key="Math.random()"></Home>
- <Mine :height="height" ref="mine" :token="token" :userInfo="userInfo" v-else-if="nowchos === 1"></Mine>
- <view class="bottomboxs">
- <x-navbottom :nowchos='nowchos' @botomchos='botomchos'></x-navbottom>
- </view>
- </view>
- </template>
- <script>
- import Home from './home/index.vue' // 引入首页
- import Mine from './mine/index.vue' // 我的
- export default {
- components: { //在这里注册相应的组件
- Home,
- Mine,
- },
- data() {
- return {
- nowchos: 0, //当前选择了那个底部菜单
- isorders: 0,
- userType: 3,
- token: '',
- userInfo: {},
- orderStatistics: {},
- height: '',
- }
- },
- mounted() {
- const arr = uni.getSystemInfoSync().statusBarHeight
- this.height = arr
- },
- onShow() {
- var token = this.$cache.getToken()
- this.token = token
- var userInfo = this.$cache.getCache('userInfo')
- if (userInfo) {
- this.userInfo = userInfo
- } else {
- this.userInfo = {}
- }
- this.getUserInfo()
- },
- methods: {
- getUserInfo() {
- this.$api.get('/api/user/profile').then(res => {
- if (res.code == 200) {
- this.userInfo = res.data.user
- this.$cache.setCache('userInfo', this.userInfo)
- this.getHomeList()
- } else {
- this.$cache.removeToken()
- this.$cache.removeCache('userInfo')
- uni.showToast({
- title: '当前用户不存在',
- icon: 'none'
- });
- }
- })
- },
- // 获取订单统计
- getHomeList() {
- this.$api.get('/api/waybill/applet-count').then(res => {
- if (res.code == 200) {
- this.orderStatistics = res.data
- }
- })
- },
- // tab
- botomchos(e) {
- const that = this
- if (e == 2) {
- that.$nextTick(() => {
- setTimeout(function() {
- that.$refs.mine.refreshTokenil()
- }, 100);
- })
- }
- uni.setStorageSync('nowchos', e);
- that.nowchos = e
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- .bottomboxs {
- position: relative;
- bottom: 0;
- z-index: 2023;
- height: 100rpx;
- }
- </style>
|