feat: 商家端代码
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<script lang="ts" setup>
|
||||
import { useUserStore, CLIENT_TYPE_CONFIG, ClientType } from '@/store/user'
|
||||
import { useMerchantStore } from '@/store/merchant'
|
||||
import { tabbarStore } from '@/tabbar/store'
|
||||
|
||||
definePage({
|
||||
@@ -9,15 +10,32 @@ definePage({
|
||||
})
|
||||
|
||||
const userStore = useUserStore()
|
||||
const merchantStore = useMerchantStore()
|
||||
const config = CLIENT_TYPE_CONFIG[ClientType.MERCHANT]
|
||||
|
||||
// 菜单列表
|
||||
const menuList = [
|
||||
{ icon: 'i-carbon-settings', label: '店铺设置' },
|
||||
{ icon: 'i-carbon-customer-service', label: '客服中心' },
|
||||
{ icon: 'i-carbon-store', label: '店铺设置', path: '/pagesMerchant/me/shop' },
|
||||
{ icon: 'i-carbon-locked', label: '账号安全', path: '/pagesMerchant/me/account' },
|
||||
{ icon: 'i-carbon-notification', label: '消息中心', count: 3 },
|
||||
{ icon: 'i-carbon-help', label: '帮助中心' },
|
||||
{ icon: 'i-carbon-information', label: '关于我们' },
|
||||
]
|
||||
|
||||
// 加载数据
|
||||
async function loadData() {
|
||||
await merchantStore.fetchStats()
|
||||
await merchantStore.fetchShopInfo()
|
||||
}
|
||||
|
||||
// 菜单跳转
|
||||
function handleMenu(item: any) {
|
||||
if (item.path) {
|
||||
uni.navigateTo({ url: item.path })
|
||||
}
|
||||
}
|
||||
|
||||
// 退出登录
|
||||
function handleLogout() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
@@ -31,29 +49,62 @@ function handleLogout() {
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadData()
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view class="me-page">
|
||||
<!-- 用户信息 -->
|
||||
<!-- 用户信息卡片 -->
|
||||
<view class="user-card" :style="{ background: config.color }">
|
||||
<view class="avatar">
|
||||
<image :src="userStore.userInfo?.avatar || '/static/images/avatar.jpg'" mode="aspectFill"></image>
|
||||
<view class="user-info">
|
||||
<view class="avatar">
|
||||
<image :src="userStore.userInfo?.avatar || '/static/images/avatar.jpg'" mode="aspectFill" />
|
||||
</view>
|
||||
<view class="info">
|
||||
<text class="nickname">{{ merchantStore.shopInfo?.name || userStore.userInfo?.nickname || '商家用户' }}</text>
|
||||
<view class="tags">
|
||||
<text class="tag">{{ config.label }}</text>
|
||||
<text class="tag" v-if="merchantStore.shopInfo">已认证</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="info">
|
||||
<text class="nickname">{{ userStore.userInfo?.nickname || '商家用户' }}</text>
|
||||
<text class="tag">{{ config.label }}</text>
|
||||
|
||||
<!-- 数据统计 -->
|
||||
<view class="stats" v-if="merchantStore.stats">
|
||||
<view class="stat-item">
|
||||
<text class="value">{{ merchantStore.stats.todayOrders }}</text>
|
||||
<text class="label">今日订单</text>
|
||||
</view>
|
||||
<view class="stat-item">
|
||||
<text class="value">{{ merchantStore.stats.totalGoods }}</text>
|
||||
<text class="label">商品数量</text>
|
||||
</view>
|
||||
<view class="stat-item">
|
||||
<text class="value">¥{{ (merchantStore.stats.todaySales / 100).toFixed(0) }}</text>
|
||||
<text class="label">今日销售</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 菜单列表 -->
|
||||
<view class="menu-list">
|
||||
<view v-for="item in menuList" :key="item.label" class="menu-item">
|
||||
<view
|
||||
v-for="item in menuList"
|
||||
:key="item.label"
|
||||
class="menu-item"
|
||||
@click="handleMenu(item)"
|
||||
>
|
||||
<view class="menu-left">
|
||||
<text :class="item.icon" class="menu-icon"></text>
|
||||
<text class="menu-label">{{ item.label }}</text>
|
||||
</view>
|
||||
<text class="i-carbon-chevron-right"></text>
|
||||
<view class="menu-right">
|
||||
<view v-if="item.count" class="badge">{{ item.count }}</view>
|
||||
<text class="i-carbon-chevron-right"></text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -66,42 +117,81 @@ function handleLogout() {
|
||||
.me-page {
|
||||
min-height: 100vh;
|
||||
background: #f5f5f5;
|
||||
width: 100%;
|
||||
max-width: 540px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.user-card {
|
||||
padding: 60rpx 30rpx 40rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 24rpx;
|
||||
padding: 40rpx 30rpx 30rpx;
|
||||
|
||||
.avatar {
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
border-radius: 50%;
|
||||
overflow: hidden;
|
||||
border: 4rpx solid rgba(255, 255, 255, 0.5);
|
||||
.user-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 24rpx;
|
||||
margin-bottom: 30rpx;
|
||||
|
||||
image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
.avatar {
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
border-radius: 50%;
|
||||
overflow: hidden;
|
||||
border: 4rpx solid rgba(255, 255, 255, 0.5);
|
||||
|
||||
image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.info {
|
||||
flex: 1;
|
||||
|
||||
.nickname {
|
||||
font-size: 36rpx;
|
||||
font-weight: 600;
|
||||
color: #fff;
|
||||
display: block;
|
||||
margin-bottom: 12rpx;
|
||||
}
|
||||
|
||||
.tags {
|
||||
display: flex;
|
||||
gap: 12rpx;
|
||||
|
||||
.tag {
|
||||
font-size: 22rpx;
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
padding: 4rpx 16rpx;
|
||||
border-radius: 20rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.info {
|
||||
.nickname {
|
||||
font-size: 36rpx;
|
||||
font-weight: 600;
|
||||
color: #fff;
|
||||
display: block;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
.stats {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
border-radius: 16rpx;
|
||||
padding: 24rpx 0;
|
||||
|
||||
.tag {
|
||||
font-size: 24rpx;
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
padding: 4rpx 16rpx;
|
||||
border-radius: 20rpx;
|
||||
.stat-item {
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
|
||||
.value {
|
||||
font-size: 36rpx;
|
||||
font-weight: 700;
|
||||
display: block;
|
||||
margin-bottom: 4rpx;
|
||||
}
|
||||
|
||||
.label {
|
||||
font-size: 22rpx;
|
||||
opacity: 0.8;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -115,7 +205,7 @@ function handleLogout() {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 30rpx;
|
||||
padding: 32rpx 24rpx;
|
||||
border-bottom: 1rpx solid #f5f5f5;
|
||||
|
||||
&:last-child {
|
||||
@@ -125,11 +215,11 @@ function handleLogout() {
|
||||
.menu-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16rpx;
|
||||
gap: 20rpx;
|
||||
|
||||
.menu-icon {
|
||||
font-size: 40rpx;
|
||||
color: #666;
|
||||
color: #ff8f0d;
|
||||
}
|
||||
|
||||
.menu-label {
|
||||
@@ -137,6 +227,30 @@ function handleLogout() {
|
||||
color: #333;
|
||||
}
|
||||
}
|
||||
|
||||
.menu-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
|
||||
.badge {
|
||||
min-width: 36rpx;
|
||||
height: 36rpx;
|
||||
background: #fa4350;
|
||||
border-radius: 18rpx;
|
||||
padding: 0 10rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 22rpx;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
text {
|
||||
font-size: 28rpx;
|
||||
color: #ccc;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,7 +258,7 @@ function handleLogout() {
|
||||
margin: 40rpx 20rpx;
|
||||
background: #fff;
|
||||
border-radius: 16rpx;
|
||||
padding: 30rpx;
|
||||
padding: 32rpx;
|
||||
text-align: center;
|
||||
font-size: 28rpx;
|
||||
color: #fa4350;
|
||||
|
||||
Reference in New Issue
Block a user