From b79f9515146afef56b5814e083f4e62f94a360ce Mon Sep 17 00:00:00 2001 From: Agent Date: Tue, 24 Mar 2026 00:53:43 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=95=86=E5=93=81?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E9=A1=B5=E9=9D=A2=E5=92=8C=E8=A7=92=E8=89=B2?= =?UTF-8?q?=E6=9D=83=E9=99=90=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages.json | 6 + src/pages/index/index.vue | 71 ++++- src/pages/login/index.vue | 21 +- src/pages/product/manage.vue | 496 +++++++++++++++++++++++++++++++++++ src/utils/auth.js | 38 ++- 5 files changed, 615 insertions(+), 17 deletions(-) create mode 100644 src/pages/product/manage.vue diff --git a/src/pages.json b/src/pages.json index 4cd62dc..5ea2792 100644 --- a/src/pages.json +++ b/src/pages.json @@ -18,6 +18,12 @@ "navigationBarTitleText": "商品列表" } }, + { + "path": "pages/product/manage", + "style": { + "navigationBarTitleText": "商品管理" + } + }, { "path": "pages/order/create", "style": { diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 0dd06cc..1bd444d 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -10,9 +10,9 @@ - - - + + + 📦 商品管理 @@ -30,8 +30,41 @@ + + + + 📦 + 商品浏览 + + + 📝 + 创建订单 + + + 📋 + 订单列表 + + + - + + + 📦 + 商品浏览 + + + 📋 + 我的订单 + + + + + + + 🔑 + 请先登录 + + 📦 商品浏览 @@ -62,7 +95,7 @@ - + 温馨提示 • 您可以浏览商品 @@ -71,8 +104,17 @@ + + + 欢迎使用 + + • 请登录后使用完整功能 + • 登录后可浏览商品和查看订单 + + + - + @@ -80,14 +122,17 @@ import authApi from '@/api/auth' import orderApi from '@/api/order' import productApi from '@/api/product' -import { getRole, isCustomer as checkIsCustomer } from '@/utils/auth' +import { getRole, isAdmin, isSales, isCustomer as checkIsCustomer, isGuest as checkIsGuest, canManageProduct, canCreateOrder, canViewStats } from '@/utils/auth' export default { data() { return { userInfo: {}, - role: 'admin', + role: 'guest', + isAdmin: false, + isSales: false, isCustomer: false, + isGuest: false, stats: { orderCount: 0, actualAmount: 0, @@ -97,14 +142,20 @@ export default { }, computed: { roleText() { - return this.isCustomer ? '顾客' : '销售员' + if (this.isAdmin) return '管理员' + if (this.isSales) return '销售员' + if (this.isCustomer) return '顾客' + return '游客' } }, onLoad() { this.role = getRole() + this.isAdmin = isAdmin() + this.isSales = isSales() this.isCustomer = checkIsCustomer() + this.isGuest = checkIsGuest() this.loadUserInfo() - if (!this.isCustomer) { + if (canViewStats()) { this.loadStats() } }, diff --git a/src/pages/login/index.vue b/src/pages/login/index.vue index 528a122..fec4a30 100644 --- a/src/pages/login/index.vue +++ b/src/pages/login/index.vue @@ -96,6 +96,7 @@ export default { } // 假登录(演示用) + // 管理员 if (this.username === 'admin' && this.password === 'admin') { const mockData = { token: 'mock-token-admin', @@ -106,7 +107,25 @@ export default { uni.setStorageSync('userId', mockData.userId) uni.setStorageSync('role', mockData.role) - uni.showToast({ title: '登录成功', icon: 'success' }) + uni.showToast({ title: '管理员登录成功', icon: 'success' }) + setTimeout(() => { + uni.reLaunch({ url: '/pages/index/index' }) + }, 1000) + return + } + + // 销售人员 + if (this.username === 'sales' && this.password === 'sales') { + const mockData = { + token: 'mock-token-sales', + userId: 'sales-001', + role: 'sales' + } + uni.setStorageSync('token', mockData.token) + uni.setStorageSync('userId', mockData.userId) + uni.setStorageSync('role', mockData.role) + + uni.showToast({ title: '销售人员登录成功', icon: 'success' }) setTimeout(() => { uni.reLaunch({ url: '/pages/index/index' }) }, 1000) diff --git a/src/pages/product/manage.vue b/src/pages/product/manage.vue new file mode 100644 index 0000000..27f088a --- /dev/null +++ b/src/pages/product/manage.vue @@ -0,0 +1,496 @@ +