From fce9701254be3f35175409476da5ced5baf565d7 Mon Sep 17 00:00:00 2001 From: 17792275749 <812100002@qq.com> Date: Thu, 20 Aug 2026 17:13:57 +0800 Subject: [PATCH] =?UTF-8?q?feat(helpCenter):=20=E5=B8=AE=E5=8A=A9=E4=B8=AD?= =?UTF-8?q?=E5=BF=83=E5=88=97=E8=A1=A8=E6=8E=A5=E5=85=A5=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E3=80=81=E9=97=AE=E9=A2=98=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E9=A1=B5=E5=AF=8C=E6=96=87=E6=9C=AC=E6=B8=B2=E6=9F=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- miniprogram/pages/helpCenter/helpCenter.less | 17 ++++-- miniprogram/pages/helpCenter/helpCenter.ts | 60 ++++++++++++++----- miniprogram/pages/helpCenter/helpCenter.wxml | 24 ++++---- .../questionDetails/questionDetails.less | 56 ++++------------- .../pages/questionDetails/questionDetails.ts | 41 +++++++++---- .../questionDetails/questionDetails.wxml | 15 ++--- 6 files changed, 117 insertions(+), 96 deletions(-) diff --git a/miniprogram/pages/helpCenter/helpCenter.less b/miniprogram/pages/helpCenter/helpCenter.less index 2c74d9d..0f672e9 100644 --- a/miniprogram/pages/helpCenter/helpCenter.less +++ b/miniprogram/pages/helpCenter/helpCenter.less @@ -1,11 +1,14 @@ .helpCenter { width: 100%; - min-height: 100%; + height: 100vh; + display: flex; + flex-direction: column; padding: 24rpx 32rpx; box-sizing: border-box; background-color: #F5F7FB; .search { + flex-shrink: 0; display: flex; flex-direction: column; margin-bottom: 48rpx; @@ -28,12 +31,14 @@ } .tabs { - display: flex; - gap: 20rpx; + flex-shrink: 0; + width: 100%; + white-space: nowrap; margin-bottom: 24rpx; .tab { - flex: 1; + display: inline-block; + padding: 0 30rpx; height: 56rpx; line-height: 56rpx; text-align: center; @@ -41,6 +46,7 @@ font-size: 24rpx; background-color: #FFFFFF; color: #77849E; + margin-right: 20rpx; } .tab--active { @@ -50,6 +56,9 @@ } .list { + flex: 1; + min-height: 0; + .question { width: 100%; height: 112rpx; diff --git a/miniprogram/pages/helpCenter/helpCenter.ts b/miniprogram/pages/helpCenter/helpCenter.ts index bd82896..22fda9f 100644 --- a/miniprogram/pages/helpCenter/helpCenter.ts +++ b/miniprogram/pages/helpCenter/helpCenter.ts @@ -1,32 +1,64 @@ -// pages/helpCenter/helpCenter.ts +import { get } from '../../utils/request/index' + +/** 展示用问题项 */ +interface QuestionItem { + id: string + title: string +} + +/** 内容列表项 */ +interface ContentRecord { + id: string + title: string +} + Page({ data: { tabs: [ - { name: '全部', active: true }, - { name: '连接配对', active: false }, - { name: '使用测量', active: false }, - { name: '数据管理', active: false } + { name: '全部', categoryId: '', active: true }, + { name: '操作说明', categoryId: '1', active: false }, + { name: '常见问题', categoryId: '2', active: false }, + { name: '新手指引', categoryId: '3', active: false }, + { name: '系统版本', categoryId: '4', active: false }, + { name: '其他', categoryId: '5', active: false }, ], - questions: [ - { id: 1, title: '如何连接蓝牙设备?' }, - { id: 2, title: '设备无法连接WiFi怎么办?' }, - { id: 3, title: '如何添加和管理成员?' }, - { id: 4, title: '测量数据不准确如何校准?' }, - { id: 5, title: '数据补传功能如何使用?' }, - { id: 6, title: '设备电量消耗过快?' } - ] + questions: [] as QuestionItem[], + }, + + onLoad() { + this.loadQuestions('') + }, + + /** 拉取内容列表(categoryId 为空查全部) */ + async loadQuestions(categoryId: string) { + try { + const res = await get<{ records: ContentRecord[] }>( + 'weighingScale/v6/content/list', + categoryId ? { categoryId } : undefined, + ) + this.setData({ + questions: res.result.records.map(item => ({ + id: item.id, + title: item.title, + })), + }) + } catch { + // 请求失败已由 request 层统一 toast + } }, onTapTab(e: WechatMiniprogram.TouchEvent) { const index = e.currentTarget.dataset.index as number const tabs = this.data.tabs.map((t, i) => ({ ...t, active: i === index })) this.setData({ tabs }) + this.loadQuestions(tabs[index].categoryId) }, onTapQuestion(e: WechatMiniprogram.TouchEvent) { + const id = e.currentTarget.dataset.id as string const title = e.currentTarget.dataset.title as string wx.navigateTo({ - url: '/pages/questionDetails/questionDetails?title=' + encodeURIComponent(title) + url: '/pages/questionDetails/questionDetails?id=' + id + '&title=' + encodeURIComponent(title) }) } }) diff --git a/miniprogram/pages/helpCenter/helpCenter.wxml b/miniprogram/pages/helpCenter/helpCenter.wxml index 699a158..0ed8f18 100644 --- a/miniprogram/pages/helpCenter/helpCenter.wxml +++ b/miniprogram/pages/helpCenter/helpCenter.wxml @@ -5,18 +5,22 @@ - - {{ item.name }} - + + + {{ item.name }} + + - - - - {{ item.title }} - - - + + + + + {{ item.title }} + + + + diff --git a/miniprogram/pages/questionDetails/questionDetails.less b/miniprogram/pages/questionDetails/questionDetails.less index 64aadfd..5fbc39f 100644 --- a/miniprogram/pages/questionDetails/questionDetails.less +++ b/miniprogram/pages/questionDetails/questionDetails.less @@ -1,55 +1,19 @@ .questionDetails { width: 100%; - min-height: 100%; - padding: 24rpx 32rpx; - box-sizing: border-box; - background-color: #F5F7FB; + height: 100%; - .card { + .scrollViewContent { width: 100%; - background-color: #FFFFFF; - border-radius: 24rpx; - padding: 0 40rpx; + height: 100%; + padding: 24rpx 30rpx; box-sizing: border-box; - .title { - color: #1385FA; - height: 36rpx; - font-size: 36rpx; - line-height: 36rpx; - padding: 40rpx 0; - border-bottom: 2rpx solid #EAECF1; - } - - .step { - display: flex; - align-items: flex-start; - padding: 32rpx 0; - border-bottom: 2rpx solid #EAECF1; - - &:last-of-type { - border-bottom: none; - } - - .badge { - width: 36rpx; - height: 36rpx; - border-radius: 50%; - background-color: #1385FA; - color: #FFFFFF; - font-size: 24rpx; - line-height: 36rpx; - text-align: center; - flex-shrink: 0; - margin-right: 20rpx; - } - - .step-text { - flex: 1; - color: #252535; - font-size: 26rpx; - line-height: 26rpx; - } + .card { + width: 100%; + padding: 30rpx; + box-sizing: border-box; + border-radius: 24rpx; + background-color: #FFFFFF; } } } diff --git a/miniprogram/pages/questionDetails/questionDetails.ts b/miniprogram/pages/questionDetails/questionDetails.ts index 1e2c4e1..b24e6e9 100644 --- a/miniprogram/pages/questionDetails/questionDetails.ts +++ b/miniprogram/pages/questionDetails/questionDetails.ts @@ -1,19 +1,34 @@ -// pages/questionDetails/questionDetails.ts +import { get } from '../../utils/request/index' + +/** 内容详情 */ +interface ContentDetail { + id: string + title: string + content: string +} + Page({ data: { - title: '如何连接蓝牙设备', - steps: [ - '进入"设备"页面,点击设备的"成员管理"按钮;', - '点击"添加新成员"进入添加页面;', - '选择用户类型(员工/家庭成员);', - '填写成员信息后保存;', - '在设备连接状态下,点击"同步成员至设备"将用户信息同步到设备。' - ] + content: '', }, - onLoad(options: { title?: string }) { - if (options.title) { - this.setData({ title: options.title }) + onLoad(options: { id?: string }) { + if (options.id) { + this.loadDetail(options.id) } - } + }, + + async loadDetail(id: string) { + try { + const res = await get('weighingScale/v6/content/detail', { id }) + wx.setNavigationBarTitle({ + title: res.result.title + }) + this.setData({ + content: res.result.content, + }) + } catch { + // 请求失败已由 request 层统一 toast + } + }, }) diff --git a/miniprogram/pages/questionDetails/questionDetails.wxml b/miniprogram/pages/questionDetails/questionDetails.wxml index 1f0788b..fbbc08e 100644 --- a/miniprogram/pages/questionDetails/questionDetails.wxml +++ b/miniprogram/pages/questionDetails/questionDetails.wxml @@ -1,12 +1,9 @@ - - {{ title }} - - - - {{ index + 1 }} - {{ item }} + + + + - - + +