Files
frontend-uniapp/src/pages/me/index.vue
T

133 lines
3.6 KiB
Vue

<script setup lang="ts">
import type { UserInfo, UserModule } from '@/model/me.ts'
import avatar from '@/static/image/me/avatar.png'
import consult from '@/static/image/me/consult.png'
import coupon from '@/static/image/me/coupon.png'
import memberShop from '@/static/image/me/memberShop.png'
const appStore = useAppStore()
const userInfo = ref<UserInfo>({
age: 0,
avatar,
id: 0,
isLogin: false,
memberType: '无会员',
nickName: '请登录',
})
const userModules = ref<UserModule>({
couponModule: {
id: 1,
name: '优惠券',
imgUrl: coupon,
path: '',
},
memberShopModule: {
id: 2,
name: '会员商城',
imgUrl: memberShop,
path: '',
},
consultModule: {
id: 3,
name: '点我咨询',
imgUrl: consult,
path: '',
},
})
onShow(appStore.fetchCurrentUser)
function goToSetting() {
uni.navigateTo({
url: '/pages/setting/index',
})
}
function goUserInfo() {
uni.navigateTo({
url: '/pages/userInfo/index',
})
}
</script>
<template>
<view class="w-full bg-[#F5F6F7] h-screen">
<view class="me-container p-4 w-full">
<view class="me-card bg-[#FFFFFF] h-[229px] flex flex-col justify-center items-center w-full rounded-xl">
<view class="me-card-info flex flex-1 w-full border-b-1 border-[#E7E7E7] p-4 justify-between items-center">
<view class="me-card-info-login flex items-center ">
<view class="me-card-info-login-avatar mr-4">
<image :src="userInfo.avatar" alt="avatar" class="w-[64px] h-[64px] rounded-full" />
</view>
<view class="me-card-info-login-person flex flex-col justify-between h-[54px]">
<text class="text-[16px] font-bold line-clamp-1">
<template v-if="appStore.user">
{{ appStore.user.username }}
</template>
<span v-else @click="() => appStore.login()">
请登录
</span>
</text>
<view class="h-[fit-content] text-[#999999] ">
<uni-tag :text="`${appStore.age ? (`${appStore.age}岁`) : '年龄'}`" class="mr-2" />
<uni-tag :text="appStore.memberType" />
</view>
</view>
</view>
<view class="me-card-info-edit w-[20px] h-[20px] shrink-0" @tap="goUserInfo">
<image src="@/static/image/me/edit.png" alt="edit" class="w-full h-full" />
</view>
</view>
<view class="me-card-item flex-1 w-full py-4 grid grid-cols-3">
<view
v-for="item in userModules" :key="item.id"
class="flex justify-between items-center flex-col me-card-item-module"
>
<image :src="item.imgUrl" :alt="item.name" class="w-[48px] h-[48px] shrink-0" />
<text class="text-[12px] text-[#000000]">
{{ item.name }}
</text>
</view>
</view>
</view>
</view>
<view class="px-4">
<CellGroup>
<Cell title="关于我们" border />
<Cell title="设置" @tap="goToSetting" />
</CellGroup>
</view>
</view>
</template>
<style lang="scss" scoped>
.me-card {
box-shadow: 0px 0px 3px 1px rgba(0, 0, 0, 0.08);
}
:deep(.uni-card) {
border-radius: 12px !important;
}
:deep(.uni-list-item) {
height: 56px;
}
:deep(.uni-list-item__content-title) {
color: #000000 !important;
font-size: 16px !important;
}
:deep(.uni-icons) {
color: rgba(0, 0, 0, 0.4) !important;
}
:deep(.uni-tag) {
color: #999999 !important;
background: #F3F3F3 !important;
border: none !important;
}
</style>