feat(帮助中心): 实现帮助文章接口对接及页面调整
- 新增帮助相关API接口文件 - 修改帮助列表和详情页,使用接口获取数据 - 调整页面字段映射,移除本地存储逻辑
Showing
3 changed files
with
45 additions
and
43 deletions
src/api/help.js
0 → 100644
| 1 | +/* | ||
| 2 | + * @Date: 2025-06-11 17:22:43 | ||
| 3 | + * @LastEditors: hookehuyr hookehuyr@gmail.com | ||
| 4 | + * @LastEditTime: 2025-06-11 17:31:26 | ||
| 5 | + * @FilePath: /mlaj/src/api/help.js | ||
| 6 | + * @Description: 帮助相关接口 | ||
| 7 | + */ | ||
| 8 | + | ||
| 9 | +import { fn, fetch } from './fn' | ||
| 10 | + | ||
| 11 | +const Api = { | ||
| 12 | + ARTICLE_LIST: '/srv/?a=get_article_list&sn=HELP', | ||
| 13 | + ARTICLE_INFO: '/srv/?a=get_article', | ||
| 14 | +} | ||
| 15 | + | ||
| 16 | +/** | ||
| 17 | + * @description: 帮助列表 | ||
| 18 | + */ | ||
| 19 | +export const getArticleListAPI = (params) => fn(fetch.get(Api.ARTICLE_LIST, params)) | ||
| 20 | + | ||
| 21 | +/** | ||
| 22 | + * @description: 帮助详情 | ||
| 23 | + */ | ||
| 24 | +export const getArticleInfoAPI = (params) => fn(fetch.get(Api.ARTICLE_INFO, params)) |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2025-03-24 13:04:31 | 2 | * @Date: 2025-03-24 13:04:31 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-03-24 13:04:32 | 4 | + * @LastEditTime: 2025-06-11 17:33:45 |
| 5 | * @FilePath: /mlaj/src/views/profile/HelpDetailPage.vue | 5 | * @FilePath: /mlaj/src/views/profile/HelpDetailPage.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -10,9 +10,9 @@ | ... | @@ -10,9 +10,9 @@ |
| 10 | <div class="bg-gradient-to-br from-green-50 via-green-100/30 to-blue-50/30 min-h-screen"> | 10 | <div class="bg-gradient-to-br from-green-50 via-green-100/30 to-blue-50/30 min-h-screen"> |
| 11 | <div class="px-4 py-6"> | 11 | <div class="px-4 py-6"> |
| 12 | <FrostedGlass class="rounded-xl overflow-hidden p-4"> | 12 | <FrostedGlass class="rounded-xl overflow-hidden p-4"> |
| 13 | - <h2 class="text-xl font-semibold text-gray-900 mb-4">{{ helpItem?.title }}</h2> | 13 | + <h2 class="text-xl font-semibold text-gray-900 mb-4">{{ helpItem?.post_title }}</h2> |
| 14 | <div class="prose prose-sm max-w-none"> | 14 | <div class="prose prose-sm max-w-none"> |
| 15 | - <pre class="whitespace-pre-wrap text-gray-600 font-normal text-base">{{ helpItem?.content }}</pre> | 15 | + <div class="whitespace-pre-wrap text-gray-600 font-normal text-base" v-html="helpItem?.post_content"></div> |
| 16 | </div> | 16 | </div> |
| 17 | </FrostedGlass> | 17 | </FrostedGlass> |
| 18 | </div> | 18 | </div> |
| ... | @@ -26,6 +26,8 @@ import { useRoute, useRouter } from 'vue-router'; | ... | @@ -26,6 +26,8 @@ import { useRoute, useRouter } from 'vue-router'; |
| 26 | import AppLayout from '@/components/layout/AppLayout.vue'; | 26 | import AppLayout from '@/components/layout/AppLayout.vue'; |
| 27 | import FrostedGlass from '@/components/ui/FrostedGlass.vue'; | 27 | import FrostedGlass from '@/components/ui/FrostedGlass.vue'; |
| 28 | import { useTitle } from '@vueuse/core'; | 28 | import { useTitle } from '@vueuse/core'; |
| 29 | +// 导入接口 | ||
| 30 | +import { getArticleInfoAPI } from "@/api/help"; | ||
| 29 | 31 | ||
| 30 | const $route = useRoute(); | 32 | const $route = useRoute(); |
| 31 | const $router = useRouter(); | 33 | const $router = useRouter(); |
| ... | @@ -34,12 +36,12 @@ useTitle($route.meta.title); | ... | @@ -34,12 +36,12 @@ useTitle($route.meta.title); |
| 34 | const route = useRoute(); | 36 | const route = useRoute(); |
| 35 | const helpItem = ref(null); | 37 | const helpItem = ref(null); |
| 36 | 38 | ||
| 37 | -onMounted(() => { | 39 | +onMounted(async() => { |
| 38 | // 从本地存储中获取帮助项数据 | 40 | // 从本地存储中获取帮助项数据 |
| 39 | const id = route.params.id; | 41 | const id = route.params.id; |
| 40 | - const storedItem = localStorage.getItem(`help_item_${id}`); | 42 | + const res = await getArticleInfoAPI({i: id}); |
| 41 | - if (storedItem) { | 43 | + if (res.code) { |
| 42 | - helpItem.value = JSON.parse(storedItem); | 44 | + helpItem.value = res.data; |
| 43 | } | 45 | } |
| 44 | }); | 46 | }); |
| 45 | </script> | 47 | </script> | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2025-03-24 13:04:21 | 2 | * @Date: 2025-03-24 13:04:21 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-03-24 13:04:23 | 4 | + * @LastEditTime: 2025-06-11 17:34:52 |
| 5 | * @FilePath: /mlaj/src/views/profile/HelpPage.vue | 5 | * @FilePath: /mlaj/src/views/profile/HelpPage.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -18,8 +18,8 @@ | ... | @@ -18,8 +18,8 @@ |
| 18 | @click="handleItemClick(item)" | 18 | @click="handleItemClick(item)" |
| 19 | > | 19 | > |
| 20 | <div class="flex-1"> | 20 | <div class="flex-1"> |
| 21 | - <h3 class="text-base font-medium text-gray-900 mb-1">{{ item.title }}</h3> | 21 | + <h3 class="text-base font-medium text-gray-900 mb-1">{{ item.post_title }}</h3> |
| 22 | - <p class="text-sm text-gray-500">{{ item.description }}</p> | 22 | + <p class="text-sm text-gray-500">{{ item.post_excerpt }}</p> |
| 23 | </div> | 23 | </div> |
| 24 | <svg | 24 | <svg |
| 25 | xmlns="http://www.w3.org/2000/svg" | 25 | xmlns="http://www.w3.org/2000/svg" |
| ... | @@ -47,6 +47,8 @@ import { useRouter, useRoute } from 'vue-router'; | ... | @@ -47,6 +47,8 @@ import { useRouter, useRoute } from 'vue-router'; |
| 47 | import AppLayout from '@/components/layout/AppLayout.vue'; | 47 | import AppLayout from '@/components/layout/AppLayout.vue'; |
| 48 | import FrostedGlass from '@/components/ui/FrostedGlass.vue'; | 48 | import FrostedGlass from '@/components/ui/FrostedGlass.vue'; |
| 49 | import { useTitle } from '@vueuse/core'; | 49 | import { useTitle } from '@vueuse/core'; |
| 50 | +// 导入接口 | ||
| 51 | +import { getArticleListAPI } from "@/api/help"; | ||
| 50 | 52 | ||
| 51 | const $route = useRoute(); | 53 | const $route = useRoute(); |
| 52 | const $router = useRouter(); | 54 | const $router = useRouter(); |
| ... | @@ -54,42 +56,16 @@ useTitle($route.meta.title); | ... | @@ -54,42 +56,16 @@ useTitle($route.meta.title); |
| 54 | 56 | ||
| 55 | const router = useRouter(); | 57 | const router = useRouter(); |
| 56 | 58 | ||
| 57 | -const helpItems = ref([ | 59 | +const helpItems = ref([]); |
| 58 | - { | 60 | + |
| 59 | - id: 1, | 61 | +onMounted(async() => { |
| 60 | - title: '如何开始学习课程?', | 62 | + const res = await getArticleListAPI(); |
| 61 | - description: '了解如何选择和开始学习课程的详细指南', | 63 | + if (res.code) { |
| 62 | - content: '1. 浏览课程列表\n2. 选择感兴趣的课程\n3. 点击课程进入详情页\n4. 点击开始学习按钮\n5. 按照课程章节顺序学习' | 64 | + helpItems.value = res.list; |
| 63 | - }, | ||
| 64 | - { | ||
| 65 | - id: 2, | ||
| 66 | - title: '如何参与打卡活动?', | ||
| 67 | - description: '学习打卡功能使用说明和注意事项', | ||
| 68 | - content: '1. 在首页或个人中心点击打卡按钮\n2. 选择打卡类型(阅读、运动、学习、写作)\n3. 填写打卡内容\n4. 上传相关图片(可选)\n5. 提交打卡' | ||
| 69 | - }, | ||
| 70 | - { | ||
| 71 | - id: 3, | ||
| 72 | - title: '如何参加线下活动?', | ||
| 73 | - description: '线下活动报名流程和参与方式说明', | ||
| 74 | - content: '1. 进入活动页面\n2. 查看活动详情和时间地点\n3. 点击报名按钮\n4. 填写报名信息\n5. 确认提交\n6. 等待审核通过\n7. 按时参加活动' | ||
| 75 | - }, | ||
| 76 | - { | ||
| 77 | - id: 4, | ||
| 78 | - title: '订单和支付说明', | ||
| 79 | - description: '了解订单流程和支付方式的详细说明', | ||
| 80 | - content: '1. 选择要购买的课程或服务\n2. 点击购买按钮\n3. 确认订单信息\n4. 选择支付方式(微信支付/支付宝)\n5. 完成支付\n6. 查看订单状态' | ||
| 81 | - }, | ||
| 82 | - { | ||
| 83 | - id: 5, | ||
| 84 | - title: '常见问题解答', | ||
| 85 | - description: '解答用户最常遇到的问题和疑难', | ||
| 86 | - content: '1. 账号相关问题\n - 如何修改密码\n - 如何绑定手机号\n - 如何更新个人信息\n\n2. 课程相关问题\n - 课程有效期说明\n - 如何获取课程证书\n - 课程退款规则\n\n3. 技术支持\n - 视频无法播放解决方案\n - 系统使用要求\n - 如何清除缓存' | ||
| 87 | } | 65 | } |
| 88 | -]); | 66 | +}) |
| 89 | 67 | ||
| 90 | const handleItemClick = (item) => { | 68 | const handleItemClick = (item) => { |
| 91 | - // 将帮助项数据存储到本地存储 | ||
| 92 | - localStorage.setItem(`help_item_${item.id}`, JSON.stringify(item)); | ||
| 93 | router.push({ | 69 | router.push({ |
| 94 | path: `/profile/help/${item.id}` | 70 | path: `/profile/help/${item.id}` |
| 95 | }); | 71 | }); | ... | ... |
-
Please register or login to post a comment