9.20/1
This commit is contained in:
152
frontend/pages/my/index.vue
Normal file
152
frontend/pages/my/index.vue
Normal file
@@ -0,0 +1,152 @@
|
||||
<template>
|
||||
<view class="me">
|
||||
<view class="card user">
|
||||
<image class="avatar" :src="avatarUrl" mode="aspectFill" @error="onAvatarError" />
|
||||
<view class="meta">
|
||||
<text class="name">{{ shopName }}</text>
|
||||
<text class="phone">{{ mobileDisplay }}</text>
|
||||
<text class="role">老板</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="group">
|
||||
<view class="group-title">会员与订单</view>
|
||||
<view class="cell" @click="goVip">
|
||||
<text>VIP会员</text>
|
||||
<text class="arrow">›</text>
|
||||
</view>
|
||||
<view class="cell" @click="goMyOrders">
|
||||
<text>我的订单</text>
|
||||
<text class="arrow">›</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="group">
|
||||
<view class="group-title">基础管理</view>
|
||||
<view class="cell" @click="goSupplier">
|
||||
<text>供应商管理</text>
|
||||
<text class="arrow">›</text>
|
||||
</view>
|
||||
<view class="cell" @click="goCustomer">
|
||||
<text>客户管理</text>
|
||||
<text class="arrow">›</text>
|
||||
</view>
|
||||
<view class="cell" @click="goCustomerQuote">
|
||||
<text>客户报价</text>
|
||||
<text class="arrow">›</text>
|
||||
</view>
|
||||
<view class="cell" @click="goShop">
|
||||
<text>店铺管理</text>
|
||||
<text class="arrow">›</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="group">
|
||||
<view class="group-title">设置中心</view>
|
||||
<view class="cell" @click="editProfile">
|
||||
<text>账号与安全</text>
|
||||
<text class="desc">修改头像、姓名、密码</text>
|
||||
<text class="arrow">›</text>
|
||||
</view>
|
||||
<view class="cell" @click="goProductSettings">
|
||||
<text>商品设置</text>
|
||||
<text class="arrow">›</text>
|
||||
</view>
|
||||
<view class="cell" @click="goSystemParams">
|
||||
<text>系统参数</text>
|
||||
<text class="desc">低价提示、默认收款、单行折扣等</text>
|
||||
<text class="arrow">›</text>
|
||||
</view>
|
||||
<view class="cell" @click="goAbout">
|
||||
<text>关于与协议</text>
|
||||
<text class="arrow">›</text>
|
||||
</view>
|
||||
<view class="cell danger" @click="logout">
|
||||
<text>退出登录</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { get } from '../../common/http.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
avatarUrl: '/static/logo.png',
|
||||
shopName: '我的店铺',
|
||||
mobile: ''
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.fetchProfile()
|
||||
},
|
||||
computed: {
|
||||
mobileDisplay() {
|
||||
const m = String(this.mobile || '')
|
||||
return m.length === 11 ? m.slice(0,3) + '****' + m.slice(7) : (m || '未绑定手机号')
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async fetchProfile() {
|
||||
// 后端暂无专门店铺/用户信息接口,先使用概览接口作为在线性检测与占位数据来源
|
||||
try { await get('/api/dashboard/overview') } catch(e) {}
|
||||
// 读取本地可能保存的店铺名与头像
|
||||
try {
|
||||
const storeName = uni.getStorageSync('SHOP_NAME') || ''
|
||||
const avatar = uni.getStorageSync('USER_AVATAR') || ''
|
||||
const phone = uni.getStorageSync('USER_MOBILE') || ''
|
||||
if (storeName) this.shopName = storeName
|
||||
if (avatar) this.avatarUrl = avatar
|
||||
this.mobile = phone
|
||||
} catch(e) {}
|
||||
},
|
||||
onAvatarError() {
|
||||
this.avatarUrl = '/static/logo.png'
|
||||
},
|
||||
goVip() { uni.showToast({ title: 'VIP会员(开发中)', icon: 'none' }) },
|
||||
goMyOrders() { uni.navigateTo({ url: '/pages/detail/index' }) },
|
||||
goSupplier() { uni.navigateTo({ url: '/pages/supplier/select' }) },
|
||||
goCustomer() { uni.navigateTo({ url: '/pages/customer/select' }) },
|
||||
goCustomerQuote() { uni.showToast({ title: '客户报价(开发中)', icon: 'none' }) },
|
||||
goShop() { uni.showToast({ title: '店铺管理(开发中)', icon: 'none' }) },
|
||||
editProfile() { uni.showToast({ title: '账号与安全(开发中)', icon: 'none' }) },
|
||||
goProductSettings() { uni.navigateTo({ url: '/pages/product/settings' }) },
|
||||
goSystemParams() { uni.showToast({ title: '系统参数(开发中)', icon: 'none' }) },
|
||||
goAbout() { uni.navigateTo({ url: '/pages/my/about' }) },
|
||||
logout() {
|
||||
try {
|
||||
uni.removeStorageSync('TOKEN')
|
||||
uni.removeStorageSync('USER_AVATAR')
|
||||
uni.removeStorageSync('USER_NAME')
|
||||
uni.removeStorageSync('USER_MOBILE')
|
||||
uni.removeStorageSync('SHOP_NAME')
|
||||
uni.showToast({ title: '已退出', icon: 'none' })
|
||||
setTimeout(() => { uni.reLaunch({ url: '/pages/index/index' }) }, 300)
|
||||
} catch(e) {
|
||||
uni.reLaunch({ url: '/pages/index/index' })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.me { padding: 24rpx; }
|
||||
.card.user { display: flex; gap: 18rpx; padding: 22rpx; background: #fff; border-radius: 16rpx; box-shadow: 0 6rpx 16rpx rgba(0,0,0,0.06); align-items: center; }
|
||||
.avatar { width: 120rpx; height: 120rpx; border-radius: 60rpx; background: #f5f5f5; }
|
||||
.meta { display: flex; flex-direction: column; gap: 6rpx; }
|
||||
.name { font-size: 34rpx; font-weight: 700; color: #333; }
|
||||
.phone { font-size: 26rpx; color: #888; }
|
||||
.role { font-size: 22rpx; color: #999; }
|
||||
|
||||
.group { margin-top: 24rpx; background: #fff; border-radius: 16rpx; overflow: hidden; }
|
||||
.group-title { padding: 18rpx 22rpx; font-size: 26rpx; color: #999; background: #fafafa; }
|
||||
.cell { display: flex; align-items: center; padding: 26rpx 22rpx; border-top: 1rpx solid #f0f0f0; color: #333; }
|
||||
.cell .desc { margin-left: auto; margin-right: 8rpx; font-size: 22rpx; color: #999; }
|
||||
.cell .arrow { margin-left: auto; color: #bbb; }
|
||||
.cell.danger { color: #dd524d; justify-content: center; font-weight: 700; }
|
||||
</style>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user