From 2b0ee0c8b6a507fefa5b29f5c4e06c033f34ab2a Mon Sep 17 00:00:00 2001 From: huangzhenbao <17818024429@163.com> Date: Thu, 22 Jan 2026 18:19:15 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=96=87=E4=BB=B6=E7=BB=93?= =?UTF-8?q?=E6=9E=84=EF=BC=9B=E8=B7=91=E9=80=9Aadmin=E7=AB=AF=EF=BC=9B?= =?UTF-8?q?=E5=88=9D=E6=AD=A5=E8=AE=BE=E8=AE=A1=E9=A1=B5=E9=9D=A2=E7=BB=93?= =?UTF-8?q?=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ak/config.uts | 10 +- components/supadb/aksupa.uts | 29 +- components/supadb/aksupainstance.uts | 15 +- pages.json | 110 +- pages/mall/admin/activity-log.uvue | 64 + pages/mall/admin/complaints.uvue | 64 + pages/mall/admin/coupon-management.uvue | 11 + pages/mall/admin/delivery-management.uvue | 11 + pages/mall/admin/finance-management.uvue | 607 ++++++++ pages/mall/admin/index.uvue | 265 ++-- pages/mall/admin/marketing-management.uvue | 366 +++++ pages/mall/admin/merchant-management.uvue | 13 + pages/mall/admin/merchant-review.uvue | 64 + pages/mall/admin/notifications.uvue | 11 + pages/mall/admin/order-management.uvue | 1380 ++++++++++++++++++ pages/mall/admin/product-management.uvue | 1154 +++++++++++++++ pages/mall/admin/product-review.uvue | 64 + pages/mall/admin/refund-review.uvue | 64 + pages/mall/admin/system-settings.uvue | 528 +++++++ pages/mall/admin/user-management.uvue | 1117 ++++++++++++++ pages/mall/{ => nfc}/nfc-modules-guide.md | 0 pages/mall/{ => nfc}/nfc.md | 0 pages/mall/{ => nfc}/pages-admin.json | 0 pages/mall/{ => nfc}/pages-librarian.json | 0 pages/mall/{ => nfc}/pages-merchant.json | 0 pages/mall/{ => nfc}/pages-parent.json | 0 pages/mall/{ => nfc}/pages-security.json | 0 pages/mall/{ => nfc}/pages-student.json | 0 pages/mall/{ => nfc}/pages-teacher.json | 0 pages/mall/{pages-config.json => pages.json} | 36 + uni_modules/ak-req/ak-req.uts | 13 +- 31 files changed, 5798 insertions(+), 198 deletions(-) create mode 100644 pages/mall/admin/activity-log.uvue create mode 100644 pages/mall/admin/complaints.uvue create mode 100644 pages/mall/admin/coupon-management.uvue create mode 100644 pages/mall/admin/delivery-management.uvue create mode 100644 pages/mall/admin/finance-management.uvue create mode 100644 pages/mall/admin/marketing-management.uvue create mode 100644 pages/mall/admin/merchant-management.uvue create mode 100644 pages/mall/admin/merchant-review.uvue create mode 100644 pages/mall/admin/notifications.uvue create mode 100644 pages/mall/admin/order-management.uvue create mode 100644 pages/mall/admin/product-management.uvue create mode 100644 pages/mall/admin/product-review.uvue create mode 100644 pages/mall/admin/refund-review.uvue create mode 100644 pages/mall/admin/system-settings.uvue create mode 100644 pages/mall/admin/user-management.uvue rename pages/mall/{ => nfc}/nfc-modules-guide.md (100%) rename pages/mall/{ => nfc}/nfc.md (100%) rename pages/mall/{ => nfc}/pages-admin.json (100%) rename pages/mall/{ => nfc}/pages-librarian.json (100%) rename pages/mall/{ => nfc}/pages-merchant.json (100%) rename pages/mall/{ => nfc}/pages-parent.json (100%) rename pages/mall/{ => nfc}/pages-security.json (100%) rename pages/mall/{ => nfc}/pages-student.json (100%) rename pages/mall/{ => nfc}/pages-teacher.json (100%) rename pages/mall/{pages-config.json => pages.json} (94%) diff --git a/ak/config.uts b/ak/config.uts index 93ff692b..f21a4ec5 100644 --- a/ak/config.uts +++ b/ak/config.uts @@ -3,12 +3,12 @@ // export const SUPA_URL: string = 'http://192.168.0.150:8080' // export const SUPA_KEY: string = 'your-anon-key' -// 生产环境 - Supabase 云服务 -export const SUPA_URL: string = 'https://ak3.oulog.com' -export const SUPA_KEY: string = 'your-anon-key' +// 指向你的 Supabase 服务(开发/私有部署) +export const SUPA_URL: string = 'http://192.168.1.64:3000' +export const SUPA_KEY: string = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlzcyI6InN1cGFiYXNlIiwiaWF0IjoxNzY4ODMwNjI0LCJleHAiOjE5MjY1MTA2MjR9.mDVl-kIOdRK9v6VTxo0TDF8r7X7xk3PZXazaavHyVvg' -// WebSocket 实时连接 -export const WS_URL: string = 'wss://ak3.oulog.com/realtime/v1/websocket' +// WebSocket/Realtime 地址(与 HTTP 保持同主机端口) +export const WS_URL: string = 'ws://192.168.1.64:3000/realtime/v1' // 路由配置 export const HOME_REDIRECT: string = '/pages/mall/consumer/index' diff --git a/components/supadb/aksupa.uts b/components/supadb/aksupa.uts index 50f67294..521c4528 100644 --- a/components/supadb/aksupa.uts +++ b/components/supadb/aksupa.uts @@ -646,6 +646,10 @@ export class AkSupa { this.user = null } async signIn(email : string, password : string) : Promise { + // 提前检查 apikey 配置是否为占位符,避免发送无效请求导致 401 + if (this.apikey == null || this.apikey.trim() === '' || this.apikey === 'your-anon-key') { + throw new Error('Supabase 配置错误:请在 ak/config.uts 中设置 SUPA_KEY(当前为占位符)'); + } const res = await AkReq.request({ url: this.baseUrl + '/auth/v1/token?grant_type=password', method: 'POST', @@ -656,13 +660,31 @@ export class AkSupa { data: { email, password } as UTSJSONObject, contentType: 'application/json' }, false); - //console.log(res) - const data = new UTSJSONObject(res.data); // 修正:确保data为UTSJSONObject + // 如果响应不是 2xx(例如 401),提取后端错误信息并抛出,便于上层显示具体原因 + const status = res.status ?? 0; + if (!(status >= 200 && status < 400)) { + let msg = 'user.login.login_failed'; + try { + if (res.data != null) { + const obj = new UTSJSONObject(res.data); + msg = obj.getString('message') ?? obj.getString('error') ?? obj.getString('msg') ?? obj.getString('description') ?? obj.getString('error_description') ?? msg; + } + } catch (e) { + // ignore + } + throw new Error(msg); + } + // 解析成功的返回体 + let data: UTSJSONObject; + try { + data = new UTSJSONObject(res.data); + } catch (e) { + data = new UTSJSONObject({}); + } const access_token = data.getString('access_token') ?? ''; const refresh_token = data.getString('refresh_token') ?? ''; const expires_at = data.getNumber('expires_at') ?? 0; const user = data.getJSON('user'); - //console.log(user, data) AkReq.setToken(access_token, refresh_token, expires_at); const session : AkSupaSignInResult = { access_token: access_token, @@ -675,7 +697,6 @@ export class AkSupa { }; this.session = session; this.user = user; - //console.log(this.user) return session; } diff --git a/components/supadb/aksupainstance.uts b/components/supadb/aksupainstance.uts index 1b25ca34..e0a9a11e 100644 --- a/components/supadb/aksupainstance.uts +++ b/components/supadb/aksupainstance.uts @@ -3,14 +3,19 @@ import { SUPA_URL, SUPA_KEY } from '@/ak/config.uts' const supa = new AkSupa(SUPA_URL, SUPA_KEY) +// Do not perform hard-coded auto sign-in during page preload (development mode may preload pages). +// Instead, mark supa as ready if an existing session is present; otherwise defer sign-in to explicit user action. const supaReady: Promise = (async () => { try { - // await supa.signIn('akoo@163.com', 'Hf2152111') - await supa.signIn('am@163.com', 'kookoo') - return true + const sess = supa.getSession(); + if (sess != null && sess.session != null) { + return true; + } + // No session found — do not auto sign-in with hard-coded credentials. + return true; } catch (err) { - console.error('Supabase auto sign-in failed', err) - return false + console.error('Supabase instance init failed', err) + return false; } })() diff --git a/pages.json b/pages.json index fed5ab00..d729d857 100644 --- a/pages.json +++ b/pages.json @@ -1,5 +1,12 @@ { "pages": [ + { + "path": "pages/mall/admin/index", + "style": { + "navigationBarTitleText": "管理后台", + "navigationStyle": "custom" + } + }, { "path": "pages/mall/consumer/index", "style": { @@ -63,13 +70,6 @@ "navigationStyle": "custom" } }, - { - "path": "pages/mall/admin/index", - "style": { - "navigationBarTitleText": "管理后台", - "navigationStyle": "custom" - } - }, { "path": "pages/mall/service/index", "style": { @@ -143,6 +143,96 @@ "navigationBarTitleText": "用户订阅管理" } }, + { + "path": "admin/user-management", + "style": { + "navigationBarTitleText": "用户管理" + } + }, + { + "path": "admin/merchant-management", + "style": { + "navigationBarTitleText": "商家管理" + } + }, + { + "path": "admin/product-management", + "style": { + "navigationBarTitleText": "商品管理" + } + }, + { + "path": "admin/order-management", + "style": { + "navigationBarTitleText": "订单管理" + } + }, + { + "path": "admin/coupon-management", + "style": { + "navigationBarTitleText": "优惠券管理" + } + }, + { + "path": "admin/delivery-management", + "style": { + "navigationBarTitleText": "配送管理" + } + }, + { + "path": "admin/finance-management", + "style": { + "navigationBarTitleText": "财务管理" + } + }, + { + "path": "admin/marketing-management", + "style": { + "navigationBarTitleText": "营销管理" + } + }, + { + "path": "admin/system-settings", + "style": { + "navigationBarTitleText": "系统设置" + } + }, + { + "path": "admin/notifications", + "style": { + "navigationBarTitleText": "通知中心" + } + }, + { + "path": "admin/merchant-review", + "style": { + "navigationBarTitleText": "商家审核" + } + }, + { + "path": "admin/product-review", + "style": { + "navigationBarTitleText": "商品审核" + } + }, + { + "path": "admin/refund-review", + "style": { + "navigationBarTitleText": "退款处理" + } + }, + { + "path": "admin/complaints", + "style": { + "navigationBarTitleText": "投诉处理" + } + }, + { + "path": "admin/activity-log", + "style": { + "navigationBarTitleText": "活动日志" + } + }, { "path": "nfc/security/index", "style": { @@ -197,8 +287,8 @@ "current": 0, "list": [ { - "name": "消费者端首页", - "path": "pages/mall/consumer/index" + "name": "管理端首页", + "path": "pages/mall/admin/index" }, { "name": "启动页(登录态判断)", @@ -210,4 +300,4 @@ } ] } -} \ No newline at end of file +} diff --git a/pages/mall/admin/activity-log.uvue b/pages/mall/admin/activity-log.uvue new file mode 100644 index 00000000..8310e3df --- /dev/null +++ b/pages/mall/admin/activity-log.uvue @@ -0,0 +1,64 @@ + + + + + + diff --git a/pages/mall/admin/complaints.uvue b/pages/mall/admin/complaints.uvue new file mode 100644 index 00000000..de29cef9 --- /dev/null +++ b/pages/mall/admin/complaints.uvue @@ -0,0 +1,64 @@ + + + + + + \ No newline at end of file diff --git a/pages/mall/admin/coupon-management.uvue b/pages/mall/admin/coupon-management.uvue new file mode 100644 index 00000000..147fbe1a --- /dev/null +++ b/pages/mall/admin/coupon-management.uvue @@ -0,0 +1,11 @@ + + + diff --git a/pages/mall/admin/delivery-management.uvue b/pages/mall/admin/delivery-management.uvue new file mode 100644 index 00000000..af13a237 --- /dev/null +++ b/pages/mall/admin/delivery-management.uvue @@ -0,0 +1,11 @@ + + + diff --git a/pages/mall/admin/finance-management.uvue b/pages/mall/admin/finance-management.uvue new file mode 100644 index 00000000..d45d8d18 --- /dev/null +++ b/pages/mall/admin/finance-management.uvue @@ -0,0 +1,607 @@ + + + + + + diff --git a/pages/mall/admin/index.uvue b/pages/mall/admin/index.uvue index 10326b93..f05c892d 100644 --- a/pages/mall/admin/index.uvue +++ b/pages/mall/admin/index.uvue @@ -1,64 +1,68 @@ - +