edu/uniapp/src/pages/user/user.vue

62 lines
1.7 KiB
Vue
Raw Normal View History

2022-08-26 09:52:43 +00:00
<template>
2024-10-10 06:10:49 +00:00
<page-meta :page-style="$theme.pageStyle">
<!-- #ifndef H5 -->
<navigation-bar
:front-color="$theme.navColor"
:background-color="$theme.navBgColor"
/>
<!-- #endif -->
</page-meta>
2022-09-08 08:28:56 +00:00
<view class="user">
<view v-for="(item, index) in state.pages" :key="index">
<template v-if="item.name == 'user-info'">
<w-user-info
2024-10-10 06:10:49 +00:00
:pageMeta="state.meta"
2022-09-08 08:28:56 +00:00
:content="item.content"
:styles="item.styles"
:user="userInfo"
:is-login="isLogin"
/>
</template>
<template v-if="item.name == 'my-service'">
<w-my-service :content="item.content" :styles="item.styles" />
</template>
<template v-if="item.name == 'user-banner'">
<w-user-banner :content="item.content" :styles="item.styles" />
</template>
</view>
<tabbar />
2022-09-08 08:28:56 +00:00
</view>
2022-08-26 09:52:43 +00:00
</template>
2022-09-08 08:28:56 +00:00
<script setup lang="ts">
import { getDecorate } from '@/api/shop'
import { useUserStore } from '@/stores/user'
import { onShow } from '@dcloudio/uni-app'
import { storeToRefs } from 'pinia'
import { reactive } from 'vue'
const state = reactive<{
2024-10-10 06:10:49 +00:00
meta: any[]
2022-09-08 08:28:56 +00:00
pages: any[]
}>({
2024-10-10 06:10:49 +00:00
meta: [],
2022-09-08 08:28:56 +00:00
pages: []
})
const getData = async () => {
const data = await getDecorate({ id: 2 })
2024-10-10 06:10:49 +00:00
state.meta = JSON.parse(data.meta)
state.pages = JSON.parse(data.data)
uni.setNavigationBarTitle({
title: state.meta[0].content.title
})
2022-09-08 08:28:56 +00:00
}
const userStore = useUserStore()
const { userInfo, isLogin } = storeToRefs(userStore)
onShow(() => {
userStore.getUser()
})
getData()
</script>
2022-08-26 09:52:43 +00:00
<style></style>