Преглед на файлове

完成二级页面与项目优化:分包、请求层、下拉刷新、pnpm 补丁

本提交同时包含此前未提交的二级页面开发工作(文化列表、村镇列表、
文章详情、收藏、数据层 src/data 及相关资源)。

优化内容:
- 删除假功能:随机搜索结果、假预订、假推送、静态墨刀轮播等
- 二级页面移入 subpackages/content 分包,首页预加载;跳转路径统一到 utils/routes
- Vant 通过 npm.packageFiles 只复制用到的组件(1.2MB -> 276KB)
- 新增统一请求层 utils/request,合并重复的请求封装与列表格式处理
- 地图点位、村落列表加内存缓存;列表搜索加防抖
- 首页、传承、资讯、文旅、文化列表、村镇列表、收藏支持下拉刷新
- 图片地址统一转 HTTPS(utils/media),列表卡片图片懒加载
- 导航栏布局计算抽到 utils/nav-bar,替换已废弃的 getSystemInfoSync
- TabBar 选中项按页面路径自动计算(utils/tab-bar)

工程调整:
- 补丁流程由 patch-package 改为 pnpm patch,gen:icons 自动生成补丁
  并清理 weapp-vite npm 缓存;移除 patch-package 与 package-lock.json
- ESLint 忽略第三方类型声明与文档目录;.tmp/ 加入 .gitignore
- 删除未使用的 route-card、feature-card 组件与 utils/util.ts

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lzj преди 1 месец
родител
ревизия
79538c7f69
променени са 100 файла, в които са добавени 16444 реда и са изтрити 22076 реда
  1. 3 0
      .gitignore
  2. 0 2
      .npmrc
  3. 5 2
      AGENTS.md
  4. 45 0
      design-qa.md
  5. 19 0
      docs/culture-map.md
  6. 28 0
      docs/user-profile.md
  7. 14 1
      eslint.config.js
  8. 0 19897
      package-lock.json
  9. 1 2
      package.json
  10. 0 455
      patches/weapp-svg-icon+1.0.0.patch
  11. 450 0
      patches/weapp-svg-icon@1.0.0.patch
  12. 11587 0
      pnpm-lock.yaml
  13. 6 0
      pnpm-workspace.yaml
  14. BIN
      public/icons/home/achievements.png
  15. BIN
      public/icons/home/areas.png
  16. BIN
      public/icons/home/experience.png
  17. BIN
      public/icons/home/inheritors.png
  18. BIN
      public/icons/home/map.png
  19. BIN
      public/icons/home/projects.png
  20. BIN
      public/icons/home/relics.png
  21. BIN
      public/icons/home/research.png
  22. BIN
      public/icons/map-pin.png
  23. BIN
      public/images/user-culture-scenery.webp
  24. 54 14
      scripts/generate-svg-icons.mjs
  25. 18 0
      src/app.json
  26. 0 3
      src/components/banner-swiper/index.ts
  27. 5 8
      src/components/banner-swiper/index.wxml
  28. 0 7
      src/components/feature-card/index.json
  29. 0 21
      src/components/feature-card/index.ts
  30. 0 17
      src/components/feature-card/index.wxml
  31. 0 1
      src/components/feature-card/index.wxss
  32. 11 3
      src/components/heritage-card/index.ts
  33. 1 1
      src/components/heritage-card/index.wxml
  34. 28 4
      src/components/heritage-header/index.ts
  35. 2 4
      src/components/heritage-header/index.wxml
  36. 0 12
      src/components/heritage-header/index.wxss
  37. 7 5
      src/components/news-header/index.ts
  38. 1 5
      src/components/news-header/index.wxml
  39. 0 23
      src/components/news-header/index.wxss
  40. 13 3
      src/components/news-item/index.ts
  41. 21 9
      src/components/news-item/index.wxml
  42. 59 1
      src/components/news-item/index.wxss
  43. 12 20
      src/components/page-header/index.ts
  44. 2 1
      src/components/profile-header/index.json
  45. 34 10
      src/components/profile-header/index.ts
  46. 15 12
      src/components/profile-header/index.wxml
  47. 62 19
      src/components/profile-header/index.wxss
  48. 1 4
      src/components/recommend-card/index.json
  49. 20 17
      src/components/recommend-card/index.ts
  50. 6 18
      src/components/recommend-card/index.wxml
  51. 8 1
      src/components/recommend-card/index.wxss
  52. 0 7
      src/components/route-card/index.json
  53. 0 27
      src/components/route-card/index.ts
  54. 0 17
      src/components/route-card/index.wxml
  55. 0 1
      src/components/route-card/index.wxss
  56. 1 1
      src/components/section-header/index.wxml
  57. 1 3
      src/components/travel-header/index.json
  58. 3 15
      src/components/travel-header/index.ts
  59. 0 16
      src/components/travel-header/index.wxml
  60. 0 30
      src/components/travel-header/index.wxss
  61. 1 3
      src/components/volunteer-card/index.json
  62. 5 3
      src/components/volunteer-card/index.ts
  63. 4 12
      src/components/volunteer-card/index.wxml
  64. 3 13
      src/custom-tab-bar/index.ts
  65. 234 0
      src/data/article-content.ts
  66. 67 0
      src/data/article-profile.ts
  67. 72 0
      src/data/culture-content.ts
  68. 55 0
      src/data/culture-map.ts
  69. 98 0
      src/data/heritage-content.ts
  70. 494 0
      src/data/inherit-api.ts
  71. 228 0
      src/data/user-api.ts
  72. 1 2
      src/pages/home/home.json
  73. 151 162
      src/pages/home/home.ts
  74. 31 19
      src/pages/home/home.wxml
  75. 5 1
      src/pages/home/home.wxss
  76. 1 2
      src/pages/inherit/inherit.json
  77. 124 319
      src/pages/inherit/inherit.ts
  78. 49 46
      src/pages/inherit/inherit.wxml
  79. 70 1
      src/pages/inherit/inherit.wxss
  80. 1 6
      src/pages/news/news.json
  81. 93 204
      src/pages/news/news.ts
  82. 34 93
      src/pages/news/news.wxml
  83. 132 4
      src/pages/news/news.wxss
  84. 2 4
      src/pages/travel/travel.json
  85. 158 203
      src/pages/travel/travel.ts
  86. 33 112
      src/pages/travel/travel.wxml
  87. 8 6
      src/pages/travel/travel.wxss
  88. 2 3
      src/pages/user/user.json
  89. 206 60
      src/pages/user/user.ts
  90. 51 71
      src/pages/user/user.wxml
  91. 205 8
      src/pages/user/user.wxss
  92. 10 0
      src/subpackages/content/article-detail/article-detail.json
  93. 426 0
      src/subpackages/content/article-detail/article-detail.scss
  94. 155 0
      src/subpackages/content/article-detail/article-detail.ts
  95. 116 0
      src/subpackages/content/article-detail/article-detail.wxml
  96. 10 0
      src/subpackages/content/culture-list/culture-list.json
  97. 259 0
      src/subpackages/content/culture-list/culture-list.scss
  98. 220 0
      src/subpackages/content/culture-list/culture-list.ts
  99. 87 0
      src/subpackages/content/culture-list/culture-list.wxml
  100. 0 0
      src/subpackages/content/favorites/favorites.json

+ 3 - 0
.gitignore

@@ -37,3 +37,6 @@ dist-web
 
 dist-plugin
 dist/web
+
+# 本地验收截图与临时验证文件
+.tmp/

+ 0 - 2
.npmrc

@@ -1,4 +1,2 @@
 # 默认镜像源
 # registry=https://registry.npmmirror.com
-# 允许安装通过远程 tarball URL 依赖(patch-package 需要在临时目录安装依赖以生成补丁)
-allow-remote=all

+ 5 - 2
AGENTS.md

@@ -38,8 +38,11 @@
 
 - Icons render via the `weapp-svg-icon` npm component, referenced as `weapp-svg-icon/index` in `usingComponents`.
 - Icon data is tree-shaken from `@iconify-json/ph` and `@iconify-json/solar` into a minimal set by `scripts/generate-svg-icons.mjs`.
-- After adding or changing icons in source (new `ph:*` / `solar:*` names), run `npm run gen:icons` to regenerate the minimal data, then `npx patch-package weapp-svg-icon` to refresh `patches/weapp-svg-icon+1.0.0.patch`.
-- IMPORTANT: `wv build` caches compiled npm mini-program packages by `package.json` dependency hash (see `node_modules/weapp-vite/.cache/`). Regenerating only `miniprogram_dist/index.js` does NOT invalidate this cache, so new icons silently stay missing. After `gen:icons`, clear the cache before building, e.g. remove `node_modules/weapp-vite/.cache/-.json`, so the stale `dist/miniprogram_npm/weapp-svg-icon/` is rebuilt.
+- The minimal data ships as a pnpm patch: `patches/weapp-svg-icon@1.0.0.patch`, registered under `patchedDependencies` in `pnpm-workspace.yaml` and applied automatically by `pnpm install`. This project uses pnpm only; do not reintroduce `patch-package` or `package-lock.json`.
+- After adding or changing icons in source (new `ph:*` / `solar:*` names), run `pnpm gen:icons`. It extracts a clean copy with `pnpm patch --ignore-existing`, writes the generated `miniprogram_dist/index.js`, runs `pnpm patch-commit`, and clears the `weapp-vite` npm build cache. Commit the updated patch, `pnpm-workspace.yaml` and `pnpm-lock.yaml` together.
+- IMPORTANT: Never write directly into `node_modules/weapp-svg-icon/`. pnpm hard-links those files to the global store, so in-place edits corrupt the shared store copy (`pnpm store status` reports it as modified) and later patches get diffed against the wrong base.
+- The patch edit directory lives in the OS temp dir on purpose: this project path contains non-ASCII characters, and `pnpm patch-commit` produces an unusable patch when git escapes such paths in the diff.
+- `wv build` caches compiled npm mini-program packages by `package.json` dependency hash (see `node_modules/weapp-vite/.cache/`), which a patch change does not alter. `gen:icons` clears that cache; if you change the patch by other means, remove `node_modules/weapp-vite/.cache/*.json` before building.
 
 ## WeChat DevTools
 

+ 45 - 0
design-qa.md

@@ -0,0 +1,45 @@
+# 用户页设计验收
+
+final result: blocked
+
+## 目标与范围
+
+- 源视觉稿:`C:/Users/Dove/.codex/generated_images/01a124c1-d7e6-74a0-98bb-b6998a97b4aa/exec-03c0deae-a7de-4468-9bf8-bcf82ab50779.png`。
+- 用户明确调整:删除页面标题“我的”和独立微信登录按钮;未登录时点击空白头像,确认微信登录后调用现有登录接口。后续再删除头像下方提示、收藏副标题、底部品牌小字,并添加仅登录后显示的退出登录选项。
+- 实现:`src/pages/user/`、`src/components/profile-header/`。
+- 装饰资产:`public/images/user-culture-scenery.webp`,1170 × 541,9,914 字节;已打开检查,无文字或嵌入的 UI。
+- 保留现有登录令牌处理、收藏接口、收藏详情跳转、关于我们和底部五项导航。
+
+## 视觉证据与限制
+
+源稿已打开检查。设计目标为 390 × 844 的移动页面;源稿实际像素为 853 × 1844,比较时应归一化尺寸,并排除微信原生胶囊和状态栏。用户要求删除的标题和按钮属于有意差异,不应作为设计偏差。
+
+当前实现截图:未获取。未执行密度归一化、全页并排比较或局部区域比较,因此不能判定字体、布局节奏、色彩、图像合成和文案的视觉还原已经通过。
+
+`wv ide doctor --json` 确认 CLI、登录和服务端口可用,但自动化会话不可连接。原生截图命令 `wv screenshot --project . --page pages/user/user --output .tmp/acceptance/user-redesign-native.png --timeout 15000 --json` 返回 `WeChat DevTools HTTP automator fallback returned unsupported response`。随后 `pnpm open` 输出 `Cannot GET /engine/build`,未能取得当前页面的运行时证据。
+
+## 必查视觉项
+
+- 字体与排版:待实际截图检查标题是否单行、昵称省略和辅助文字可读性。
+- 间距与布局:待检查头像与两侧装饰的关系、移除按钮和小字后的垂直节奏、短屏滚动、退出登录选项和底部导航避让。
+- 颜色:源稿暖白、米灰、砖红方向已用于源码;实际渲染和对比度仍待检查。
+- 图片与图标:装饰资产已检查;实际头像、加载指示、心形及信息图标在 DevTools 中的显示仍待检查。
+- 文案与状态:待检查未登录、弹窗、登录中、失败和登录成功的真实 UI。
+
+## 已完成的非视觉验证
+
+- ESLint、TypeScript、Stylelint 检查通过。
+- 模拟检查通过:同意前不发起登录、取消不登录、连续点击不重复弹窗、登录失败后恢复操作、成功登录后进入收藏。
+- 现有登录请求、令牌保存/过期和收藏分页/重试检查通过。
+- 退出登录模拟检查通过:清除业务令牌,复原昵称与头像,后续收藏请求要求重新登录;保留其他本地设置。
+- 新增图标数据和补丁已更新;已使 npm 组件缓存失效并完成构建。
+
+这些结果证明代码和模拟业务流程,不替代原生运行时点击及视觉验收。
+
+## 完成验收所需检查
+
+1. 在能正常编译的微信开发者工具会话中打开当前项目和 `pages/user/user`。
+2. 获取未登录页面截图,对齐源稿和用户指定差异;检查完整布局及头像、功能入口的局部细节。
+3. 点击头像,取消确认后检查没有登录请求;再次同意后检查登录成功和真实资料显示。
+4. 检查收藏导航、关于我们弹窗,以及较短屏幕上内容不遮挡底部导航。
+5. 记录当前截图、真实交互和比较结论,再更新本报告结果。

+ 19 - 0
docs/culture-map.md

@@ -0,0 +1,19 @@
+# 文化地图
+
+`pages/travel/travel` 使用微信小程序原生 `<map>`(腾讯底图),保留在文化地图模块的窗口内。支持地图拖动和双指缩放,点击场所标记显示名称、地址。无需高德 Key 或单独的 HTTPS 网页。
+
+## 数据约定
+
+- 接口:`content/content/getContentList`。
+- `main_body_id=1`、`model_id=17`(文化场所)、`main_body_column_id=''`(全部栏目)。
+- 按 `page` / `pageSize=100` 分页获取全部列表。
+- 使用 `longitude`、`latitude`,支持数字与数字字符串。空值、非数字、越界值和 `(0,0)` 不生成标记点。
+- 后台坐标应使用原生地图的 GCJ-02 坐标系;当前接口没有坐标系字段,前端不猜测或转换。
+- 多点自动适配全部坐标,单点使用街区视野。没有有效坐标时仍可操作漳州市区底图。
+- 所有有效点位一起展示,不受原高德静态图的每组 10 点限制。
+- 原生 `marker` 要求 `iconPath`,统一使用普通定位针 `/icons/map-pin.png`,不使用场所照片或内容图标。
+- 点击“刷新”或切回页面重新加载后台数据,空坐标条目会在后台补齐后自动进入地图。
+
+当前版本不会读取 `.env.local` 中的高德配置,也不请求当前位置。展示地图和后台场所不需要新增定位授权。
+
+参考:[腾讯地图原生组件说明](https://github.com/TencentLBS/tencentmap-miniprogram-skill/blob/main/references/map_component_guide.md)。

+ 28 - 0
docs/user-profile.md

@@ -0,0 +1,28 @@
+# 用户头像与昵称
+
+个人页沿用头像登录入口。登录返回资料缺少头像、使用 `/assets/img/avatar.png` 或内嵌 SVG 默认头像,或昵称为空/`微信用户`(可带数字后缀)时,显示“完善资料”弹窗。用户可跳过,之后点击“修改信息”、头像或昵称修改。
+
+头像通过原生 `button open-type="chooseAvatar"` 选择,昵称通过 `input type="nickname"` 快捷填写或输入。使用原生 form 的 submit 值读取昵称,避免快捷填写未触发 bindinput 时丢失昵称。支持基础库昵称检查事件;旧微信不支持这两项组件能力时提示更新。
+
+## 后端契约
+
+- [微信登录](https://www.showdoc.com.cn/minnanCE/11559060627627644):POST `content/main_body_user/third`。除已有 token、userId、头像和昵称外,将 `mainBodyUserInfo.id` 保存为 `mainBodyUserId`。该值是主体用户 ID,与 `mainBodyUserInfo.user_id` 不同。
+- [头像上传](https://www.showdoc.com.cn/minnanCE/11558683564191866):POST `common/upload`,使用 `wx.uploadFile`,文件字段为 `file`,携带业务 token 请求头。成功返回 `code=1`,优先使用 `data.fullurl`,否则将 `data.url` 转为本站 HTTPS 地址。不能保存 chooseAvatar 返回的临时文件路径。
+- [修改资料](https://www.showdoc.com.cn/minnanCE/11559060627627649):POST `content/main_body_user/editMainBodyUser`,表单字段 `main_body_id`、`main_body_user_id`、`nickname`、修改后的 `avatar`,业务 token 放在请求头。成功返回 `code=1`、`data=null`。保留简介等未编辑字段。
+- [旧缓存升级](https://www.showdoc.com.cn/minnanCE/11559060627627647):缺少主体用户 ID 时,POST `minnansoul/main_body_user/refreshUser`,传 `main_body_id` 和 token,获取 `mainBodyUserInfo.id`。验证返回用户 ID 与当前账号一致;返回信息不完整时提示重新登录,不以普通用户 ID 替代。
+
+资料保存成功后才更新登录缓存和个人页。失败保留草稿,允许重试;保存期间禁用重复提交与关闭。开始上传、提交与回写缓存之间校验登录 token 和用户 ID,避免退出或切换账号后旧请求写入当前资料,旧 token 的 401 也不清除新账号。
+
+资料弹窗使用 form 内的普通 view 承载 flex 布局,避免原生 form 内部容器让头像偏左。原头像未修改时不上传,且不发送可选 avatar 字段;实际后端的默认头像是 SVG data URI,不能作为文件路径传给 wx.uploadFile。
+
+微信临时头像可能使用 `wxfile://` 或 `http(s)://tmp/`、`http(s)://usr/` 地址,不能仅凭 HTTP 协议判断为远程图片。这些地址必须先上传,再将返回的 HTTPS 图片地址提交给 `content/main_body_user/editMainBodyUser`;旧缓存中相同的临时地址也会重新上传。上传响应若仍返回临时地址则拒绝保存。
+
+## 验证
+
+- `.tmp/acceptance/verify-user-profile.mjs`:验证上传/保存参数、头像临时路径转换、旧缓存主体 ID 刷新及账号匹配、快捷填写、登录提示/跳过/收藏跳转、失败重试、重复提交、昵称检查、旧微信提示、退出/账号切换竞态与编辑入口。
+- `.tmp/acceptance/verify-user-login.mjs`:回归登录、授权确认、令牌缓存、退出与收藏分页。
+- 类型检查、目标文件 ESLint/Stylelint 与 `pnpm build`。
+
+`wv screenshot` 的自动化连接仍失败。2026-10-10 使用 Computer Use 直接操作当前仓库的开发者工具窗口,完成头像点击登录、修改信息按钮打开、资料框居中、取消关闭、用原头像原昵称提交成功,以及微信头像选择菜单打开/取消。点击保存时发现默认 SVG 头像误上传,修复后复测成功,页面提示“资料已保存”,未改变现有头像和昵称。
+
+桌面截图记录在 `.tmp/acceptance/user-edit-entry-desktop.png`、`user-edit-dialog-desktop.png`、`user-profile-save-desktop.png`。本次未提交新选择的微信头像,因此新头像实际上传、真机昵称快捷填写仍需微信端联调;mock 测试已验证对应请求契约和失败重试。

+ 14 - 1
eslint.config.js

@@ -5,5 +5,18 @@ export default icebreaker({
   tailwindcss: {
     entryPoint: './src/app.css',
   },
-  ignores: ['CHANGELOG.md', 'README.md', '.turbo/**', 'dist/**', '.weapp-vite/**'],
+  ignores: [
+    'CHANGELOG.md',
+    'README.md',
+    '.turbo/**',
+    'dist/**',
+    '.weapp-vite/**',
+    // 模板自带的微信 API 类型声明,属于第三方代码
+    'typings/**',
+    // 文档、设计验收记录和临时文件
+    'AGENTS.md',
+    'design-qa.md',
+    'docs/**',
+    '.tmp/**',
+  ],
 })

Файловите разлики са ограничени, защото са твърде много
+ 0 - 19897
package-lock.json


+ 1 - 2
package.json

@@ -30,7 +30,7 @@
     "stylelint:fix": "stylelint \"src/**/*.{css,scss,vue,wxss}\" --fix --allow-empty-input",
     "g": "wv generate",
     "gen:icons": "node scripts/generate-svg-icons.mjs",
-    "postinstall": "patch-package && wv prepare"
+    "postinstall": "wv prepare"
   },
   "dependencies": {
     "@vant/weapp": "^1.11.7",
@@ -47,7 +47,6 @@
     "@weapp-vite/dashboard": "^6.25.1",
     "eslint": "^10.9.1",
     "miniprogram-api-typings": "^5.2.3",
-    "patch-package": "^8.0.1",
     "postcss": "^8.5.26",
     "sass": "^1.103.1",
     "stylelint": "^17.14.1",

Файловите разлики са ограничени, защото са твърде много
+ 0 - 455
patches/weapp-svg-icon+1.0.0.patch


Файловите разлики са ограничени, защото са твърде много
+ 450 - 0
patches/weapp-svg-icon@1.0.0.patch


Файловите разлики са ограничени, защото са твърде много
+ 11587 - 0
pnpm-lock.yaml


+ 6 - 0
pnpm-workspace.yaml

@@ -0,0 +1,6 @@
+allowBuilds:
+  '@parcel/watcher': true
+  '@swc/core': true
+  esbuild: true
+patchedDependencies:
+  weapp-svg-icon@1.0.0: patches/weapp-svg-icon@1.0.0.patch

BIN
public/icons/home/achievements.png


BIN
public/icons/home/areas.png


BIN
public/icons/home/experience.png


BIN
public/icons/home/inheritors.png


BIN
public/icons/home/map.png


BIN
public/icons/home/projects.png


BIN
public/icons/home/relics.png


BIN
public/icons/home/research.png


BIN
public/icons/map-pin.png


BIN
public/images/user-culture-scenery.webp


+ 54 - 14
scripts/generate-svg-icons.mjs

@@ -1,28 +1,50 @@
 // 从 @iconify-json/ph 与 @iconify-json/solar 中抽取项目实际用到的图标,
 // 生成一个精简的 iconify 数据文件,供 weapp-svg-icon 组件使用,避免全量打包。
-import { readFile, readdir, writeFile } from 'node:fs/promises'
+//
+// 生成结果通过 pnpm patch 写成补丁(patches/weapp-svg-icon@<version>.patch),安装依赖时由 pnpm 自动应用。
+// 不能直接改 node_modules 里的文件:pnpm 用硬链接指向全局存储,直接写入会污染其他项目共用的包。
+import { execSync } from 'node:child_process'
+import { readdir, readFile, rm, writeFile } from 'node:fs/promises'
+import { tmpdir } from 'node:os'
 import path from 'node:path'
+import process from 'node:process'
 import { fileURLToPath } from 'node:url'
 
 const __dirname = path.dirname(fileURLToPath(import.meta.url))
 const root = path.resolve(__dirname, '..')
 
 const SRC_DIR = path.join(root, 'src')
-const PKG_DIR = path.join(root, 'node_modules', 'weapp-svg-icon')
-const OUTPUT = path.join(PKG_DIR, 'miniprogram_dist', 'index.js')
+const PKG_NAME = 'weapp-svg-icon'
+const PKG_DIR = path.join(root, 'node_modules', PKG_NAME)
+// pnpm patch 取出的可编辑副本。必须放在纯英文路径下:项目路径含中文时,
+// git 生成的 diff 会转义路径,pnpm patch-commit 会产出无法应用的补丁。
+const EDIT_DIR = path.join(tmpdir(), `${PKG_NAME}-patch`)
+// weapp-vite 按 package.json 依赖哈希缓存 npm 构建结果,补丁变化后需清除才会重新复制。
+const WEAPP_VITE_NPM_CACHE_DIR = path.join(root, 'node_modules', 'weapp-vite', '.cache')
+
+function pnpm(args) {
+  // Windows 下 pnpm 是 .cmd 脚本,只能经 shell 执行;参数逐个加引号,避免路径中的空格被拆开。
+  execSync(['pnpm', ...args.map(arg => `"${arg}"`)].join(' '), { cwd: root, stdio: 'inherit' })
+}
 
 const ICON_PREFIXES = ['ph', 'solar']
-const ICON_RE = /(?:^|[^\w])(ph|solar):([a-z0-9-]+)/g
+const ICON_RE = /(?:^|\W)(ph|solar):([a-z0-9-]+)/g
 const SCAN_EXTENSIONS = new Set(['.ts', '.js', '.wxml', '.vue', '.json'])
 
 async function walk(dir) {
   const entries = await readdir(dir, { withFileTypes: true })
   const files = []
   for (const entry of entries) {
-    if (entry.name === 'node_modules' || entry.name.startsWith('.')) continue
+    if (entry.name === 'node_modules' || entry.name.startsWith('.')) {
+      continue
+    }
     const full = path.join(dir, entry.name)
-    if (entry.isDirectory()) files.push(...(await walk(full)))
-    else files.push(full)
+    if (entry.isDirectory()) {
+      files.push(...(await walk(full)))
+    }
+    else {
+      files.push(full)
+    }
   }
   return files
 }
@@ -31,7 +53,9 @@ async function collectUsedIcons() {
   const files = await walk(SRC_DIR)
   const used = new Set()
   for (const file of files) {
-    if (!SCAN_EXTENSIONS.has(path.extname(file))) continue
+    if (!SCAN_EXTENSIONS.has(path.extname(file))) {
+      continue
+    }
     const content = await readFile(file, 'utf8')
     for (const match of content.matchAll(ICON_RE)) {
       used.add(`${match[1]}:${match[2]}`)
@@ -54,17 +78,19 @@ async function main() {
   }
 
   const sets = {}
-  const svgNameSwitch = (id) =>
+  const svgNameSwitch = id =>
     id
-      .split(/:|-|_/)
+      .split(/[:\-_]/)
       .filter(Boolean)
-      .map((s) => s[0].toUpperCase() + s.slice(1).toLowerCase())
+      .map(s => s[0].toUpperCase() + s.slice(1).toLowerCase())
       .join('')
   for (const prefix of ICON_PREFIXES) {
     const source = await loadIconifyJson(prefix)
     const icons = {}
     for (const icon of [...byPrefix[prefix]].sort()) {
-      if (source.icons[icon]) icons[icon] = source.icons[icon]
+      if (source.icons[icon]) {
+        icons[icon] = source.icons[icon]
+      }
     }
     sets[svgNameSwitch(prefix)] = {
       prefix: source.prefix ?? prefix,
@@ -191,8 +217,22 @@ Component({
 })
 `
 
-  await writeFile(OUTPUT, template, 'utf8')
-  console.log(`generated ${path.relative(root, OUTPUT)} with ${used.length} icons`)
+  const { version } = JSON.parse(await readFile(path.join(PKG_DIR, 'package.json'), 'utf8'))
+  await rm(EDIT_DIR, { recursive: true, force: true })
+  // 每次都从原版包重新生成整份文件,不叠加已有补丁。
+  pnpm(['patch', `${PKG_NAME}@${version}`, '--edit-dir', EDIT_DIR, '--ignore-existing'])
+
+  await writeFile(path.join(EDIT_DIR, 'miniprogram_dist', 'index.js'), template, 'utf8')
+  // 原 source map 对应的是被替换掉的打包代码,一并删除。
+  await rm(path.join(EDIT_DIR, 'miniprogram_dist', 'index.js.map'), { force: true })
+
+  pnpm(['patch-commit', EDIT_DIR])
+  await rm(EDIT_DIR, { recursive: true, force: true })
+
+  const cacheFiles = await readdir(WEAPP_VITE_NPM_CACHE_DIR).catch(() => [])
+  await Promise.all(cacheFiles.filter(file => file.endsWith('.json')).map(file => rm(path.join(WEAPP_VITE_NPM_CACHE_DIR, file), { force: true })))
+
+  console.log(`generated ${PKG_NAME} patch with ${used.length} icons`)
   console.log(used.join('\n'))
 }
 

+ 18 - 0
src/app.json

@@ -7,6 +7,24 @@
     "pages/travel/travel",
     "pages/user/user"
   ],
+  "subPackages": [
+    {
+      "root": "subpackages/content",
+      "name": "content",
+      "pages": [
+        "culture-list/culture-list",
+        "village-list/village-list",
+        "article-detail/article-detail",
+        "favorites/favorites"
+      ]
+    }
+  ],
+  "preloadRule": {
+    "pages/home/home": {
+      "network": "all",
+      "packages": ["content"]
+    }
+  },
   "window": {
     "navigationBarTextStyle": "black"
   },

+ 0 - 3
src/components/banner-swiper/index.ts

@@ -24,8 +24,5 @@ Component({
       if (!list.length) return
       this.setData({ current: (current + 1) % list.length })
     },
-    onTapItem(e: WechatMiniprogram.TouchEvent) {
-      this.triggerEvent('select', { index: e.currentTarget.dataset.index })
-    },
   },
 })

+ 5 - 8
src/components/banner-swiper/index.wxml

@@ -8,14 +8,11 @@
     current="{{current}}"
     bindchange="onChange"
   >
-    <swiper-item wx:for="{{list}}" wx:key="title">
-      <view class="relative w-full h-full" data-index="{{index}}" bindtap="onTapItem">
-        <image class="w-full h-full opacity-75" src="{{item.image}}" mode="aspectFill" />
-        <view class="absolute inset-0 bg-gradient-to-t from-[#52241e] via-[#52241e]/25 to-transparent"></view>
-        <view class="absolute top-3 right-3 rounded-full bg-[#f6e2aa]/90 px-2 py-1 text-xs font-semibold text-[#873325]">{{item.tag}}</view>
-        <view class="absolute inset-x-4 bottom-4 text-white">
-          <text class="block text-sm tracking-[.18em] text-[#f6d98c]">{{item.enTitle}}</text>
-          <view class="mt-1 text-xl font-bold">{{item.title}}</view>
+    <swiper-item wx:for="{{list}}" wx:key="id">
+      <view class="relative w-full h-full">
+        <image class="w-full h-full" src="{{item.image}}" mode="aspectFill" />
+        <view wx:if="{{item.tag}}" class="absolute top-3 right-3 rounded-full bg-[#f6e2aa]/90 px-2 py-1 text-xs font-semibold text-[#873325]">{{item.tag}}</view>
+        <view wx:if="{{item.subtitle}}" class="absolute inset-x-4 bottom-4 text-white">
           <view class="mt-1 text-sm text-[#f7e9d2]">{{item.subtitle}}</view>
         </view>
       </view>

+ 0 - 7
src/components/feature-card/index.json

@@ -1,7 +0,0 @@
-{
-  "component": true,
-  "styleIsolation": "apply-shared",
-  "usingComponents": {
-    "svg-icon": "weapp-svg-icon/index"
-  }
-}

+ 0 - 21
src/components/feature-card/index.ts

@@ -1,21 +0,0 @@
-import Toast from '@vant/weapp/toast/toast'
-
-Component({
-  properties: {
-    item: {
-      type: Object,
-      value: {},
-    },
-  },
-
-  methods: {
-    onTap() {
-      const name = (this.data.item as { name: string }).name
-      Toast(`拼图碎片已点亮:${name}`)
-    },
-    onNav() {
-      const name = (this.data.item as { name: string }).name
-      Toast(`导航路线规划完成:${name}`)
-    },
-  },
-})

+ 0 - 17
src/components/feature-card/index.wxml

@@ -1,17 +0,0 @@
-<view class="shrink-0 w-[220px] overflow-hidden rounded-xl bg-white border border-[#ddc18c] shadow-sm" bindtap="onTap">
-  <view class="relative h-[104px] bg-gradient-to-br from-[#8f3528] to-[#d1a052] overflow-hidden flex items-center justify-center">
-    <svg-icon name="{{item.icon}}" size="47px" color="#ffe5a3" />
-    <view class="absolute left-2 top-2 rounded bg-[#fff4d8] px-2 py-1 text-xs text-[#9b3929]">{{item.tag}}</view>
-  </view>
-  <view class="p-3">
-    <view class="flex items-center justify-between gap-2">
-      <text class="min-w-0 flex-1 text-sm font-bold text-[#563d35] truncate">{{item.name}}</text>
-      <svg-icon name="ph:puzzle-piece-duotone" size="19px" color="#c28b32" />
-    </view>
-    <text class="block mt-1 text-xs text-[#917c6d]">{{item.desc}}</text>
-    <view class="mt-3 flex items-center justify-between gap-2">
-      <text class="min-w-0 flex-1 text-xs text-[#a83f2d] truncate">任务:{{item.task}}</text>
-      <view class="flex-none rounded bg-[#a83f2d] px-2 py-1 text-xs text-white" catchtap="onNav">导航</view>
-    </view>
-  </view>
-</view>

+ 0 - 1
src/components/feature-card/index.wxss

@@ -1 +0,0 @@
-/* feature-card */

+ 11 - 3
src/components/heritage-card/index.ts

@@ -1,4 +1,4 @@
-import Toast from '@vant/weapp/toast/toast'
+import { getArticleDetailUrl } from '../../utils/routes'
 
 Component({
   properties: {
@@ -12,10 +12,18 @@ Component({
     imgError: false,
   },
 
+  observers: {
+    'item.image': function () {
+      this.setData({ imgError: false })
+    },
+  },
+
   methods: {
     onTap() {
-      const name = (this.data.item as { name: string }).name
-      Toast(`已选择:${name}`)
+      const id = (this.data.item as { id?: string }).id
+      if (id) {
+        wx.navigateTo({ url: getArticleDetailUrl(id) })
+      }
     },
     onImgError() {
       this.setData({ imgError: true })

+ 1 - 1
src/components/heritage-card/index.wxml

@@ -1,7 +1,7 @@
 <view class="flex-none w-[210px] overflow-hidden rounded-xl border border-[#e4cfad] bg-[#fffaf1] text-left shadow-sm" bindtap="onTap">
   <view class="heritage-card__cover">
     <svg-icon name="{{item.icon}}" size="38px" color="#ffe5ae" />
-    <image wx:if="{{!imgError}}" class="heritage-card__img" src="{{item.image}}" mode="aspectFill" binderror="onImgError" />
+    <image wx:if="{{item.image && !imgError}}" class="heritage-card__img" src="{{item.image}}" mode="aspectFill" lazy-load binderror="onImgError" />
     <view class="heritage-card__frame"></view>
   </view>
   <view class="p-3">

+ 28 - 4
src/components/heritage-header/index.ts

@@ -1,3 +1,5 @@
+import { getNavBarLayout } from '../../utils/nav-bar'
+
 Component({
   properties: {
     value: {
@@ -8,21 +10,43 @@ Component({
 
   data: {
     statusBarHeight: 20,
+    searchTimer: null as ReturnType<typeof setTimeout> | null,
+  },
+
+  observers: {
+    value() {
+      this.clearSearchTimer()
+    },
   },
 
   lifetimes: {
     attached() {
-      const info = wx.getSystemInfoSync()
-      this.setData({ statusBarHeight: info.statusBarHeight || 20 })
+      this.setData({ statusBarHeight: getNavBarLayout().statusBarHeight })
+    },
+    detached() {
+      this.clearSearchTimer()
     },
   },
 
   methods: {
     onInput(e: WechatMiniprogram.Input) {
+      this.clearSearchTimer()
+      const keyword = e.detail.value
+      // 停止输入后再查询,避免连续输入时反复请求四个栏目。
+      this.data.searchTimer = setTimeout(() => {
+        this.data.searchTimer = null
+        this.triggerEvent('search', { keyword })
+      }, 300)
+    },
+    onConfirm(e: WechatMiniprogram.InputConfirm) {
+      this.clearSearchTimer()
       this.triggerEvent('search', { keyword: e.detail.value })
     },
-    onFilter() {
-      this.triggerEvent('filter')
+    clearSearchTimer() {
+      if (this.data.searchTimer !== null) {
+        clearTimeout(this.data.searchTimer)
+        this.data.searchTimer = null
+      }
     },
     onBack() {
       this.triggerEvent('back')

+ 2 - 4
src/components/heritage-header/index.wxml

@@ -7,7 +7,7 @@
       <text class="text-xl font-bold tracking-[.2em] text-white">传承</text>
     </view>
 
-    <view class="mt-4 flex gap-2">
+    <view class="mt-4 flex">
       <view class="heritage-header__search">
         <svg-icon name="ph:magnifying-glass" size="18px" color="#8a7566" />
         <input
@@ -17,11 +17,9 @@
           placeholder-class="heritage-header__placeholder"
           confirm-type="search"
           bindinput="onInput"
+          bindconfirm="onConfirm"
         />
       </view>
-      <view class="heritage-header__filter" bindtap="onFilter">
-        <svg-icon name="ph:sliders-horizontal-bold" size="18px" color="#ffffff" />
-      </view>
     </view>
   </view>
 </view>

+ 0 - 12
src/components/heritage-header/index.wxss

@@ -43,15 +43,3 @@
 .heritage-header__placeholder {
   color: #ab9b8d;
 }
-
-.heritage-header__filter {
-  flex: none;
-  width: 40px;
-  height: 40px;
-  border-radius: 12px;
-  background-color: #d7a951;
-  display: flex;
-  align-items: center;
-  justify-content: center;
-  box-shadow: 0 1px 3px rgb(0 0 0 / 8%);
-}

+ 7 - 5
src/components/news-header/index.ts

@@ -1,5 +1,11 @@
+import { getNavBarLayout } from '../../utils/nav-bar'
+
 Component({
   properties: {
+    showActions: {
+      type: Boolean,
+      value: true,
+    },
     value: {
       type: String,
       value: '',
@@ -12,8 +18,7 @@ Component({
 
   lifetimes: {
     attached() {
-      const info = wx.getSystemInfoSync()
-      this.setData({ statusBarHeight: info.statusBarHeight || 20 })
+      this.setData({ statusBarHeight: getNavBarLayout().statusBarHeight })
     },
   },
 
@@ -21,8 +26,5 @@ Component({
     onInput(e: WechatMiniprogram.Input) {
       this.triggerEvent('search', { keyword: e.detail.value })
     },
-    onNotification() {
-      this.triggerEvent('notification')
-    },
   },
 })

+ 1 - 5
src/components/news-header/index.wxml

@@ -4,7 +4,7 @@
       <text class="text-2xl font-bold tracking-[.24em] text-white">资讯</text>
     </view>
 
-    <view class="mt-4 flex gap-2">
+    <view wx:if="{{showActions}}" class="mt-4 flex gap-2">
       <view class="news-header__search">
         <svg-icon name="ph:magnifying-glass" size="18px" color="#8a7566" />
         <input
@@ -17,10 +17,6 @@
         />
         <svg-icon name="ph:lightbulb-duotone" size="18px" color="#d29b3d" />
       </view>
-      <view class="news-header__bell" bindtap="onNotification">
-        <svg-icon name="ph:bell-ringing-duotone" size="19px" color="#983726" />
-        <view class="news-header__badge"></view>
-      </view>
     </view>
   </view>
 </view>

+ 0 - 23
src/components/news-header/index.wxss

@@ -33,26 +33,3 @@
 .news-header__placeholder {
   color: #aa9787;
 }
-
-.news-header__bell {
-  position: relative;
-  flex: none;
-  width: 40px;
-  height: 40px;
-  border-radius: 50%;
-  background-color: #f5d390;
-  display: flex;
-  align-items: center;
-  justify-content: center;
-}
-
-.news-header__badge {
-  position: absolute;
-  right: 0;
-  top: 0;
-  width: 10px;
-  height: 10px;
-  border-radius: 50%;
-  background-color: #e33e32;
-  border: 2px solid #9d3829;
-}

+ 13 - 3
src/components/news-item/index.ts

@@ -1,4 +1,4 @@
-import Toast from '@vant/weapp/toast/toast'
+import { getArticleDetailUrl } from '../../utils/routes'
 
 Component({
   properties: {
@@ -10,12 +10,22 @@ Component({
       type: Boolean,
       value: false,
     },
+    showIcon: {
+      type: Boolean,
+      value: true,
+    },
+    showImage: {
+      type: Boolean,
+      value: false,
+    },
   },
 
   methods: {
     onTap() {
-      const title = (this.data.item as { title: string }).title
-      Toast(`阅读:${title}`)
+      const id = (this.data.item as { id?: string }).id
+      if (id) {
+        wx.navigateTo({ url: getArticleDetailUrl(id) })
+      }
     },
   },
 })

+ 21 - 9
src/components/news-item/index.wxml

@@ -1,10 +1,22 @@
-<view class="w-full px-3 py-3 flex gap-2.5" bindtap="onTap">
-  <view class="mt-0.5 w-7 h-7 flex-none rounded-lg flex items-center justify-center" style="background-color: {{item.iconBg}};">
-    <svg-icon name="{{item.icon}}" size="15px" color="{{item.iconColor}}" />
-  </view>
-  <view class="min-w-0 flex-1">
-    <text class="block text-sm text-[#51433e] truncate {{bold ? 'font-bold' : ''}}">{{item.title}}</text>
-    <text class="block mt-1 text-xs text-[#9a8c82]">{{item.subtitle}}</text>
-  </view>
-  <text wx:if="{{item.time}}" class="flex-none text-xs text-[#a99686]">{{item.time}}</text>
+<view class="{{showImage ? 'news-item--image' : 'w-full px-3 py-3 flex gap-2.5'}}" bindtap="onTap">
+  <block wx:if="{{showImage}}">
+    <view class="news-item__cover">
+      <image wx:if="{{item.image}}" class="news-item__image" src="{{item.image}}" mode="aspectFill" lazy-load />
+      <text wx:else class="news-item__placeholder">暂无图片</text>
+    </view>
+    <view class="news-item__content">
+      <text class="news-item__title">{{item.title}}</text>
+      <text wx:if="{{item.time}}" class="news-item__time">{{item.time}}</text>
+    </view>
+  </block>
+  <block wx:else>
+    <view wx:if="{{showIcon && item.icon}}" class="mt-0.5 w-7 h-7 flex-none rounded-lg flex items-center justify-center" style="background-color: {{item.iconBg}};">
+      <svg-icon name="{{item.icon}}" size="15px" color="{{item.iconColor}}" />
+    </view>
+    <view class="min-w-0 flex-1">
+      <text class="block text-sm text-[#51433e] truncate {{bold ? 'font-bold' : ''}}">{{item.title}}</text>
+      <text wx:if="{{item.subtitle}}" class="block mt-1 text-xs text-[#9a8c82]">{{item.subtitle}}</text>
+    </view>
+    <text wx:if="{{item.time}}" class="flex-none text-xs text-[#a99686]">{{item.time}}</text>
+  </block>
 </view>

+ 59 - 1
src/components/news-item/index.wxss

@@ -1 +1,59 @@
-/* news-item */
+.news-item--image {
+  display: flex;
+  align-items: center;
+  gap: 24rpx;
+  width: 100%;
+  padding: 24rpx;
+  box-sizing: border-box;
+}
+
+.news-item__cover {
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  flex: none;
+  width: 192rpx;
+  height: 144rpx;
+  overflow: hidden;
+  border-radius: 16rpx;
+  background-color: #f2ebe3;
+}
+
+.news-item__image {
+  display: block;
+  width: 100%;
+  height: 100%;
+}
+
+.news-item__placeholder {
+  font-size: 22rpx;
+  color: #9a8c82;
+}
+
+.news-item__content {
+  display: flex;
+  flex: 1;
+  flex-direction: column;
+  justify-content: space-between;
+  min-width: 0;
+  min-height: 144rpx;
+}
+
+.news-item__title {
+  display: -webkit-box;
+  -webkit-box-orient: vertical;
+  -webkit-line-clamp: 2;
+  overflow: hidden;
+  font-size: 28rpx;
+  font-weight: 500;
+  line-height: 40rpx;
+  color: #51433e;
+  white-space: normal;
+}
+
+.news-item__time {
+  margin-top: 16rpx;
+  font-size: 22rpx;
+  line-height: 30rpx;
+  color: #a99686;
+}

+ 12 - 20
src/components/page-header/index.ts

@@ -1,13 +1,14 @@
+import { getNavBarLayout } from '../../utils/nav-bar'
 import { svgToDataUri } from '../../utils/svgIcon'
 
-const LOGO_SVG =
-  '<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">' +
-  '<path d="M13 31C28 26 36 16 42 7c5 8 10 13 18 16 8-3 13-8 18-16 6 9 14 19 29 24-12-9-19-18-25-29-6 8-13 13-22 16C51 15 44 10 38 2 32 13 25 22 13 31Z" fill="#f05a25"/>' +
-  '<path d="M7 43c18 8 34-2 46-2 7 0 10 2 7 5-3 3-8 4-8 9 0 5 8 7 16 5 11-3 18-10 31-9-17-8-28 0-40 4-8 3-13 1-13-2 0-4 8-7 8-10 0-6-13-4-23-2-9 2-14 4-17 2Z" fill="#008db8"/>' +
-  '<path d="M57 55c13-3 25-10 42-4-17-3-26 7-40 10-9 2-16 0-17-4 3 1 8 1 15-2Z" fill="#0755aa"/>' +
-  '<text fill="#0b397d" font-family="Arial, sans-serif" font-size="19" font-weight="700" letter-spacing="1" x="10" y="82">MINNAN</text>' +
-  '<rect fill="#c8312b" height="17" rx="1" width="14" x="76" y="66"></rect><text fill="white" font-family="serif" font-size="12" font-weight="700" x="78" y="80">闽</text>' +
-  '</svg>'
+const LOGO_SVG
+  = '<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">'
+    + '<path d="M13 31C28 26 36 16 42 7c5 8 10 13 18 16 8-3 13-8 18-16 6 9 14 19 29 24-12-9-19-18-25-29-6 8-13 13-22 16C51 15 44 10 38 2 32 13 25 22 13 31Z" fill="#f05a25"/>'
+    + '<path d="M7 43c18 8 34-2 46-2 7 0 10 2 7 5-3 3-8 4-8 9 0 5 8 7 16 5 11-3 18-10 31-9-17-8-28 0-40 4-8 3-13 1-13-2 0-4 8-7 8-10 0-6-13-4-23-2-9 2-14 4-17 2Z" fill="#008db8"/>'
+    + '<path d="M57 55c13-3 25-10 42-4-17-3-26 7-40 10-9 2-16 0-17-4 3 1 8 1 15-2Z" fill="#0755aa"/>'
+    + '<text fill="#0b397d" font-family="Arial, sans-serif" font-size="19" font-weight="700" letter-spacing="1" x="10" y="82">MINNAN</text>'
+    + '<rect fill="#c8312b" height="17" rx="1" width="14" x="76" y="66"></rect><text fill="white" font-family="serif" font-size="12" font-weight="700" x="78" y="80">闽</text>'
+    + '</svg>'
 
 Component({
   properties: {
@@ -29,19 +30,10 @@ Component({
 
   lifetimes: {
     attached() {
-      const info = wx.getSystemInfoSync()
-      let rightPadding = 16
-      try {
-        const rect = wx.getMenuButtonBoundingClientRect()
-        if (rect && rect.left > 0) {
-          rightPadding = info.windowWidth - rect.left + 8
-        }
-      } catch (e) {
-        // ignore
-      }
+      const { statusBarHeight, capsuleWidth } = getNavBarLayout()
       this.setData({
-        headerPaddingTop: (info.statusBarHeight || 20) + 12,
-        rightPadding,
+        headerPaddingTop: statusBarHeight + 12,
+        rightPadding: capsuleWidth ? capsuleWidth + 8 : 16,
         logoUrl: svgToDataUri(LOGO_SVG),
       })
     },

+ 2 - 1
src/components/profile-header/index.json

@@ -2,6 +2,7 @@
   "component": true,
   "styleIsolation": "apply-shared",
   "usingComponents": {
-    "svg-icon": "weapp-svg-icon/index"
+    "svg-icon": "weapp-svg-icon/index",
+    "van-loading": "@vant/weapp/loading/index"
   }
 }

+ 34 - 10
src/components/profile-header/index.ts

@@ -1,34 +1,58 @@
+import { getNavBarLayout } from '../../utils/nav-bar'
+
 Component({
   properties: {
     nickname: {
       type: String,
-      value: '燕尾巷游客',
+      value: '未登录',
     },
-    avatarIcon: {
+    avatar: {
       type: String,
-      value: 'ph:user-circle-duotone',
+      value: '',
+    },
+    loggedIn: {
+      type: Boolean,
+      value: false,
+    },
+    loggingIn: {
+      type: Boolean,
+      value: false,
     },
   },
 
   data: {
-    headerPaddingTop: 32,
+    headerPaddingTop: 64,
+    avatarFailed: false,
+  },
+
+  observers: {
+    avatar() {
+      this.setData({ avatarFailed: false })
+    },
   },
 
   lifetimes: {
     attached() {
-      const info = wx.getSystemInfoSync()
+      const { statusBarHeight, navHeight } = getNavBarLayout()
       this.setData({
-        headerPaddingTop: (info.statusBarHeight || 20) + 12,
+        headerPaddingTop: statusBarHeight + navHeight,
       })
     },
   },
 
   methods: {
-    onAvatarTap() {
-      this.triggerEvent('changeavatar')
+    onLoginTap() {
+      if (!this.data.loggingIn) {
+        this.triggerEvent(this.data.loggedIn ? 'editprofile' : 'login')
+      }
+    },
+    onNicknameTap() {
+      if (this.data.loggedIn && !this.data.loggingIn) {
+        this.triggerEvent('editprofile')
+      }
     },
-    onEditTap() {
-      this.triggerEvent('edit')
+    onAvatarError() {
+      this.setData({ avatarFailed: true })
     },
   },
 })

+ 15 - 12
src/components/profile-header/index.wxml

@@ -1,16 +1,19 @@
 <view class="profile-header" style="padding-top: {{headerPaddingTop}}px;">
-  <view class="flex items-center gap-3 px-4 pb-5">
-    <view class="profile-header__avatar" bindtap="onAvatarTap">
-      <svg-icon name="{{avatarIcon}}" size="48px" color="#a83f2d" />
-    </view>
-    <view class="min-w-0 flex-1">
-      <view class="flex items-center gap-2">
-        <text class="truncate text-xl font-bold text-white">{{nickname}}</text>
-        <view class="profile-header__edit" bindtap="onEditTap">
-          <svg-icon name="ph:pencil-simple-duotone" size="12px" color="#ffffff" />
-          <text>编辑</text>
-        </view>
+  <image class="profile-header__scenery" src="/images/user-culture-scenery.webp" mode="aspectFit" aria-hidden="{{true}}" />
+  <view class="profile-header__content">
+    <button
+      class="profile-header__avatar"
+      hover-class="profile-header__avatar--pressed"
+      disabled="{{loggingIn}}"
+      aria-label="{{loggedIn ? '修改头像和昵称' : '点击头像,微信登录'}}"
+      bindtap="onLoginTap"
+    >
+      <image wx:if="{{avatar && !avatarFailed}}" class="profile-header__image" src="{{avatar}}" mode="aspectFill" binderror="onAvatarError" />
+      <svg-icon wx:else name="ph:user-fill" size="60px" color="#c6b7a6" />
+      <view wx:if="{{loggingIn}}" class="profile-header__loading">
+        <van-loading size="24px" color="#a83f2d" />
       </view>
-    </view>
+    </button>
+    <text class="profile-header__title" bindtap="onNicknameTap">{{loggedIn ? nickname : '微信登录'}}</text>
   </view>
 </view>

+ 62 - 19
src/components/profile-header/index.wxss

@@ -1,31 +1,74 @@
 .profile-header {
-  flex: none;
-  background-color: #9d3829;
-  background-image: linear-gradient(90deg, rgb(255 240 213 / 9%) 1px, transparent 1px),
-    linear-gradient(rgb(255 240 213 / 9%) 1px, transparent 1px);
-  background-size: 34px 15px;
+  position: relative;
+  padding-bottom: 64rpx;
+}
+
+.profile-header__scenery {
+  position: absolute;
+  top: 146rpx;
+  left: 0;
+  width: 100%;
+  height: 350rpx;
+  pointer-events: none;
+}
+
+.profile-header__content {
+  position: relative;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  padding: 74rpx 40rpx 0;
 }
 
 .profile-header__avatar {
+  position: relative;
+  box-sizing: border-box;
   display: flex;
-  flex: none;
   align-items: center;
   justify-content: center;
-  width: 64px;
-  height: 64px;
-  background-color: #fff5dc;
-  border: 2px solid #f3d18b;
+  width: 200rpx;
+  height: 200rpx;
+  padding: 0;
+  margin: 0;
+  overflow: hidden;
+  background-color: #f1eadf;
+  border: 0;
   border-radius: 50%;
-  box-shadow: 0 4px 12px rgb(0 0 0 / 12%);
 }
 
-.profile-header__edit {
-  display: inline-flex;
-  gap: 2px;
+.profile-header__avatar::after {
+  border: 0;
+}
+
+.profile-header__avatar--pressed {
+  opacity: 0.8;
+}
+
+.profile-header__image {
+  width: 100%;
+  height: 100%;
+  border-radius: 50%;
+}
+
+.profile-header__loading {
+  position: absolute;
+  inset: 0;
+  display: flex;
   align-items: center;
-  padding: 4px 8px;
-  font-size: 9px;
-  color: #fff;
-  background-color: rgb(255 255 255 / 15%);
-  border-radius: 999px;
+  justify-content: center;
+  background-color: rgb(241 234 223 / 85%);
+}
+
+.profile-header__title {
+  display: block;
+  max-width: 100%;
+  margin-top: 52rpx;
+  overflow: hidden;
+  text-overflow: ellipsis;
+  font-size: 50rpx;
+  font-weight: 600;
+  line-height: 1.4;
+  color: #3e3027;
+  text-align: center;
+  white-space: nowrap;
 }

+ 1 - 4
src/components/recommend-card/index.json

@@ -1,7 +1,4 @@
 {
   "component": true,
-  "styleIsolation": "apply-shared",
-  "usingComponents": {
-    "svg-icon": "weapp-svg-icon/index"
-  }
+  "styleIsolation": "apply-shared"
 }

+ 20 - 17
src/components/recommend-card/index.ts

@@ -1,35 +1,38 @@
-import Toast from '@vant/weapp/toast/toast'
+import { getArticleDetailUrl } from '../../utils/routes'
 
 Component({
   properties: {
     item: {
       type: Object,
       value: {},
+      observer() {
+        this.setData({ imageFailed: false })
+      },
+    },
+    clickable: {
+      type: Boolean,
+      value: true,
     },
   },
 
   data: {
-    saved: false,
+    imageFailed: false,
   },
 
   methods: {
     onOpen() {
-      const title = (this.data.item as { title: string }).title
-      Toast(`已进入:${title}`)
-    },
-    onSave() {
-      const title = (this.data.item as { title: string }).title
-      const saved = !this.data.saved
-      this.setData({ saved })
-      Toast(saved ? `已收藏:${title}` : `已取消收藏:${title}`)
+      // 村镇 ID 属于独立接口,不能用于文章详情查询。
+      if (!this.data.clickable) {
+        return
+      }
+      const id = (this.data.item as { id?: string }).id
+      if (id) {
+        wx.navigateTo({ url: getArticleDetailUrl(id) })
+      }
     },
-    onShare() {
-      const title = (this.data.item as { title: string }).title
-      Toast(`已生成"${title}"分享卡片`)
-    },
-    onNav() {
-      const title = (this.data.item as { title: string }).title
-      Toast(`导航已为您规划至${title}`)
+
+    onImageError() {
+      this.setData({ imageFailed: true })
     },
   },
 })

+ 6 - 18
src/components/recommend-card/index.wxml

@@ -1,21 +1,9 @@
-<view class="shrink-0 w-[160px] overflow-hidden rounded-2xl bg-white border border-[#eadcc5] shadow-sm">
-  <view class="h-[100px] relative" style="background-color: {{item.imageBg}};" bindtap="onOpen">
-    <image class="w-full h-full opacity-70" src="{{item.image}}" mode="aspectFill" />
-    <view class="absolute left-2 top-2 rounded-md px-1.5 py-0.5 text-xs text-white" style="background-color: {{item.tagBg}};">{{item.tag}}</view>
+<view class="shrink-0 w-[160px] overflow-hidden rounded-2xl bg-white border border-[#eadcc5] shadow-sm" bindtap="onOpen">
+  <view class="h-[120px] overflow-hidden flex items-center justify-center" style="background-color: {{item.imageBg || '#f2ebe3'}};">
+    <image wx:if="{{item.image && !imageFailed}}" class="block w-full h-full" src="{{item.image}}" mode="aspectFill" lazy-load binderror="onImageError" />
+    <text wx:else class="text-xs text-[#9a8c82]">暂无图片</text>
   </view>
-  <view class="p-2.5">
-    <text class="block text-sm font-bold text-[#51433e] truncate">{{item.title}}</text>
-    <text class="block mt-1 text-xs text-[#8c7e74]">{{item.subtitle}}</text>
-    <view class="mt-2 flex justify-between items-center">
-      <view class="flex items-center justify-center" bindtap="onSave">
-        <svg-icon name="{{saved ? 'solar:bookmark-bold' : 'solar:bookmark-linear'}}" size="17px" color="#b48732" />
-      </view>
-      <view class="flex items-center justify-center" bindtap="onShare">
-        <svg-icon name="solar:share-linear" size="17px" color="#a83f2d" />
-      </view>
-      <view class="flex items-center justify-center" bindtap="onNav">
-        <svg-icon name="solar:map-point-linear" size="17px" color="#59755d" />
-      </view>
-    </view>
+  <view class="h-[60px] px-3 flex items-center">
+    <text class="recommend-card__title text-sm font-bold text-[#51433e]">{{item.title}}</text>
   </view>
 </view>

+ 8 - 1
src/components/recommend-card/index.wxss

@@ -1 +1,8 @@
-/* recommend-card */
+.recommend-card__title {
+  display: -webkit-box;
+  -webkit-box-orient: vertical;
+  -webkit-line-clamp: 2;
+  overflow: hidden;
+  line-height: 20px;
+  white-space: normal;
+}

+ 0 - 7
src/components/route-card/index.json

@@ -1,7 +0,0 @@
-{
-  "component": true,
-  "styleIsolation": "apply-shared",
-  "usingComponents": {
-    "svg-icon": "weapp-svg-icon/index"
-  }
-}

+ 0 - 27
src/components/route-card/index.ts

@@ -1,27 +0,0 @@
-import Toast from '@vant/weapp/toast/toast'
-
-Component({
-  properties: {
-    item: {
-      type: Object,
-      value: {},
-    },
-  },
-
-  data: {
-    saved: false,
-  },
-
-  methods: {
-    onSave() {
-      const title = (this.data.item as { title: string }).title
-      const saved = !this.data.saved
-      this.setData({ saved })
-      Toast(saved ? `已收藏:${title}` : `已取消收藏:${title}`)
-    },
-    onNav() {
-      const title = (this.data.item as { title: string }).title
-      Toast(`已规划前往“${title}”的最佳路线`)
-    },
-  },
-})

+ 0 - 17
src/components/route-card/index.wxml

@@ -1,17 +0,0 @@
-<view class="shrink-0 w-[238px] rounded-2xl border border-[#dec18b] bg-white p-4 shadow-sm">
-  <view class="flex items-center justify-between">
-    <view class="w-10 h-10 rounded-xl bg-[#f2dfba] flex items-center justify-center">
-      <svg-icon name="{{item.icon}}" size="25px" color="#9a3b2d" />
-    </view>
-    <view class="flex items-center justify-center" bindtap="onSave">
-      <svg-icon
-        name="{{saved ? 'ph:heart-fill' : 'ph:heart-duotone'}}"
-        size="21px"
-        color="{{saved ? '#a83f2d' : '#aa8a6f'}}"
-      />
-    </view>
-  </view>
-  <text class="mt-3 block text-sm font-bold text-[#673d33]">{{item.title}}</text>
-  <text class="mt-1 block h-8 text-xs leading-4 text-[#8d7768]">{{item.desc}}</text>
-  <view class="mt-3 w-full rounded-lg bg-[#a83f2d] py-2 text-center text-xs text-white" bindtap="onNav">一键导航</view>
-</view>

+ 0 - 1
src/components/route-card/index.wxss

@@ -1 +0,0 @@
-/* route-card */

+ 1 - 1
src/components/section-header/index.wxml

@@ -4,7 +4,7 @@
     <text class="text-lg font-bold text-[#983726]">{{title}}</text>
   </view>
   <view wx:if="{{showMore}}" class="flex items-center text-sm text-[#a83f2d]" bindtap="onMore">
-    <text>{{displayMoreText}}</text>
+    <text>{{moreText}}</text>
     <svg-icon name="solar:alt-arrow-right-linear" size="13px" color="#a83f2d" />
   </view>
 </view>

+ 1 - 3
src/components/travel-header/index.json

@@ -1,7 +1,5 @@
 {
   "component": true,
   "styleIsolation": "apply-shared",
-  "usingComponents": {
-    "svg-icon": "weapp-svg-icon/index"
-  }
+  "usingComponents": {}
 }

+ 3 - 15
src/components/travel-header/index.ts

@@ -1,25 +1,13 @@
+import { getNavBarLayout } from '../../utils/nav-bar'
+
 Component({
   data: {
     statusBarHeight: 20,
-    keyword: '',
   },
 
   lifetimes: {
     attached() {
-      const info = wx.getSystemInfoSync()
-      this.setData({ statusBarHeight: info.statusBarHeight || 20 })
-    },
-  },
-
-  methods: {
-    onInput(e: WechatMiniprogram.Input) {
-      this.setData({ keyword: e.detail.value })
-    },
-    onSubmit() {
-      this.triggerEvent('search', { keyword: this.data.keyword })
-    },
-    onConfirm() {
-      this.triggerEvent('search', { keyword: this.data.keyword })
+      this.setData({ statusBarHeight: getNavBarLayout().statusBarHeight })
     },
   },
 })

+ 0 - 16
src/components/travel-header/index.wxml

@@ -1,21 +1,5 @@
 <view class="travel-header" style="padding-top: {{statusBarHeight}}px;">
   <view class="travel-header__inner">
     <text class="text-2xl font-bold tracking-[.18em] text-white">趣游漳州</text>
-
-    <view class="travel-header__search">
-      <svg-icon name="ph:magnifying-glass" size="18px" color="#8a372d" />
-      <input
-        class="travel-header__input"
-        value="{{keyword}}"
-        placeholder="逛古城、拍土楼、吃卤面…"
-        placeholder-class="travel-header__placeholder"
-        confirm-type="search"
-        bindinput="onInput"
-        bindconfirm="onConfirm"
-      />
-      <view class="travel-header__submit" bindtap="onSubmit">
-        <svg-icon name="ph:arrow-right-bold" size="14px" color="#8a372d" />
-      </view>
-    </view>
   </view>
 </view>

+ 0 - 30
src/components/travel-header/index.wxss

@@ -10,33 +10,3 @@
 .travel-header__inner {
   padding: 10px 16px 16px;
 }
-
-.travel-header__search {
-  margin-top: 12px;
-  display: flex;
-  align-items: center;
-  height: 40px;
-  background-color: #fff;
-  border-radius: 12px;
-  padding: 0 12px;
-  gap: 8px;
-}
-
-.travel-header__input {
-  min-width: 0;
-  flex: 1;
-  background: transparent;
-  font-size: 11px;
-  color: #8a372d;
-}
-
-.travel-header__placeholder {
-  color: #b69083;
-}
-
-.travel-header__submit {
-  flex: none;
-  display: flex;
-  align-items: center;
-  justify-content: center;
-}

+ 1 - 3
src/components/volunteer-card/index.json

@@ -1,7 +1,5 @@
 {
   "component": true,
   "styleIsolation": "apply-shared",
-  "usingComponents": {
-    "svg-icon": "weapp-svg-icon/index"
-  }
+  "usingComponents": {}
 }

+ 5 - 3
src/components/volunteer-card/index.ts

@@ -1,4 +1,4 @@
-import Toast from '@vant/weapp/toast/toast'
+import { getArticleDetailUrl } from '../../utils/routes'
 
 Component({
   properties: {
@@ -10,8 +10,10 @@ Component({
 
   methods: {
     onTap() {
-      const title = (this.data.item as { title: string }).title
-      Toast(`已打开:${title}`)
+      const id = (this.data.item as { id?: string }).id
+      if (id) {
+        wx.navigateTo({ url: getArticleDetailUrl(id) })
+      }
     },
   },
 })

+ 4 - 12
src/components/volunteer-card/index.wxml

@@ -1,15 +1,7 @@
 <view class="w-full rounded-2xl border border-[#eadcc5] bg-white/90 p-3 shadow-sm" bindtap="onTap">
-  <view class="flex items-center gap-2.5">
-    <view class="w-9 h-9 flex-none rounded-xl flex items-center justify-center" style="background-color: {{item.iconBg}};">
-      <svg-icon name="{{item.icon}}" size="19px" color="{{item.iconColor}}" />
-    </view>
-    <view class="min-w-0 flex-1">
-      <text class="block text-sm text-[#51433e] truncate">{{item.title}}</text>
-    </view>
-    <view class="rounded-md px-1.5 py-1 text-xs" style="background-color: {{item.statusBg}}; color: {{item.statusColor}};">{{item.status}}</view>
-  </view>
-  <view class="mt-2 flex items-center justify-between pl-[46px] text-xs text-[#a99686]">
-    <text>{{item.meta}}</text>
-    <text class="text-[#a83f2d]">{{item.actionText}} ›</text>
+  <text class="block text-sm text-[#51433e] truncate">{{item.title}}</text>
+  <view class="mt-2 flex items-center justify-between gap-2.5 text-xs text-[#a99686]">
+    <text wx:if="{{item.meta}}" class="min-w-0 flex-1">{{item.meta}}</text>
+    <text class="ml-auto flex-none text-[#a83f2d]">{{item.actionText}} ›</text>
   </view>
 </view>

+ 3 - 13
src/custom-tab-bar/index.ts

@@ -1,22 +1,12 @@
-interface TabItem {
-  pagePath: string
-  text: string
-  icon: string
-  inactiveIcon: string
-}
+import type { TabItem } from '../utils/tab-bar'
+import { TAB_ITEMS } from '../utils/tab-bar'
 
 Component({
   data: {
     selected: 0,
     color: '#a79d93',
     activeColor: '#a83f2d',
-    list: [
-      { pagePath: '/pages/home/home', text: '首页', icon: 'ph:house-fill', inactiveIcon: 'ph:house-duotone' },
-      { pagePath: '/pages/inherit/inherit', text: '传承', icon: 'ph:hand-heart-fill', inactiveIcon: 'ph:hand-heart-duotone' },
-      { pagePath: '/pages/news/news', text: '资讯', icon: 'ph:compass-fill', inactiveIcon: 'ph:compass-duotone' },
-      { pagePath: '/pages/travel/travel', text: '文旅', icon: 'ph:map-trifold-fill', inactiveIcon: 'ph:map-trifold-duotone' },
-      { pagePath: '/pages/user/user', text: '我的', icon: 'ph:user-circle-fill', inactiveIcon: 'ph:user-circle-duotone' },
-    ] as TabItem[],
+    list: TAB_ITEMS,
   },
 
   methods: {

+ 234 - 0
src/data/article-content.ts

@@ -0,0 +1,234 @@
+import type { ContentDetail } from './inherit-api'
+import { normalizeMediaUrl } from '../utils/media'
+
+export interface ArticleFact {
+  label: string
+  value: string
+}
+
+export interface ArticleOtherLevel extends ArticleFact {
+  id: string
+  title: string
+  unit: string
+}
+
+export interface ArticleSection {
+  key: string
+  title: string
+  content: string
+}
+
+export interface ArticleRelatedItem {
+  id: string
+  title: string
+  image: string
+  meta: string
+}
+
+export interface ArticleRelatedGroup {
+  key: string
+  title: string
+  items: ArticleRelatedItem[]
+}
+
+export interface ArticlePresentation {
+  type: 'article' | 'relic' | 'heritage' | 'inheritor'
+  pageTitle: string
+  facts: ArticleFact[]
+  sections: ArticleSection[]
+  gallery: string[]
+  exhibitionImage: string
+  relatedGroups: ArticleRelatedGroup[]
+  otherLevels: ArticleOtherLevel[]
+  resourceLinks: { title: string, url: string }[]
+}
+
+export function prepareArticleContent(content: string): string {
+  if (!content.replace(/<[^>]*>/g, '').replace(/&nbsp;|&#160;|&#xA0;/gi, '').trim() && !/<(?:img|hr|table)\b/i.test(content)) {
+    return ''
+  }
+  // rich-text 不继承页面的图片样式,需写入节点样式以避免后台固定尺寸撑出屏幕。
+  return content.replace(/<img\b[^>]*>/gi, (tag) => {
+    let result = tag.replace(/\s(?:width|height)\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi, '')
+      .replace(/\bsrc\s*=\s*(["'])(.*?)\1/gi, (_, quote: string, src: string) => `src=${quote}${normalizeMediaUrl(src)}${quote}`)
+    const responsiveStyle = 'max-width:100%;height:auto;box-sizing:border-box;vertical-align:middle;'
+    if (/\sstyle\s*=\s*["']/i.test(result)) {
+      result = result.replace(/\sstyle\s*=\s*(["'])(.*?)\1/i, (_, quote: string, style: string) => ` style=${quote}${style.replace(/(?:^|;)\s*(?:width|height|min-width|min-height|max-width|max-height)\s*:[^;]*/gi, '')};${responsiveStyle}${quote}`)
+    }
+    else {
+      result = result.replace(/\s*\/?>$/, ` style="${responsiveStyle}" />`)
+    }
+    return result
+  })
+}
+
+function displayText(value: unknown): string {
+  return typeof value === 'string' || typeof value === 'number' ? String(value).trim() : ''
+}
+
+function categoryText(text: unknown, value: unknown): string {
+  const label = displayText(text)
+  const fallback = displayText(value)
+  // 旧文档直接给名称,新接口给分类 ID;不能将 ID 当成名称展示。
+  return label || (/^\d+$/.test(fallback) ? '' : fallback)
+}
+
+function genderText(detail: ContentDetail): string {
+  const text = displayText(detail.gender_text)
+  if (text) {
+    return text
+  }
+  const value = displayText(detail.gender)
+  // 采集端传承人表单约定 0=女、1=男、2=未知;0 不是空值。
+  const labels: Record<string, string> = { 0: '女', 1: '男', 2: '未知' }
+  return labels[value] || (['女', '男', '未知'].includes(value) ? value : '')
+}
+
+function birthDateText(value: unknown): string {
+  const text = displayText(value)
+  // 接口可能只记录出生年份,不能按完整日期补成 1 月 1 日。
+  if (/^\d{4}$/.test(text)) {
+    return `${text}年`
+  }
+  const date = text.match(/^(\d{4})[-/](\d{1,2})[-/](\d{1,2})(?:[ T].*)?$/)
+  return date ? `${date[1]}年${Number(date[2])}月${Number(date[3])}日` : text
+}
+
+function collectionItems(value: unknown): Record<string, unknown>[] {
+  const items = Array.isArray(value) ? value : value && typeof value === 'object' ? Object.values(value) : []
+  return items.filter((item): item is Record<string, unknown> => !!item && typeof item === 'object' && !Array.isArray(item))
+}
+
+function relatedItems(value: unknown): ArticleRelatedItem[] {
+  return collectionItems(value).flatMap((item) => {
+    const title = displayText(item.title)
+    const id = displayText(item.id)
+    if (!title || !id) {
+      return []
+    }
+    return [{
+      id,
+      title,
+      image: normalizeMediaUrl(displayText(item.thumbnail) || displayText(item.image)),
+      meta: [categoryText(item.level_text, item.level), categoryText(item.region_text, item.region)].filter(Boolean).join(' · '),
+    }]
+  })
+}
+
+export function createArticlePresentation(detail: ContentDetail): ArticlePresentation {
+  const type = detail.model_id === 1 ? 'relic' : detail.model_id === 2 ? 'heritage' : detail.model_id === 7 ? 'inheritor' : 'article'
+  const presentation: ArticlePresentation = {
+    type,
+    pageTitle: type === 'relic' ? '文物详情' : type === 'heritage' ? '非遗详情' : type === 'inheritor' ? '传承人详情' : '文章详情',
+    facts: [],
+    sections: [],
+    gallery: Array.isArray(detail.images)
+      ? [...new Set(detail.images.map(image => normalizeMediaUrl(displayText(image))).filter(Boolean))]
+      : [],
+    exhibitionImage: '',
+    relatedGroups: [],
+    otherLevels: [],
+    resourceLinks: [],
+  }
+  if (type === 'article') {
+    return presentation
+  }
+
+  if (type === 'inheritor') {
+    const associated = [...(detail.association ? [detail.association] : []), ...collectionItems(detail.association_me_list)]
+    const projects = relatedItems(associated.filter(item => Number(item.model_id) === 2))
+    const projectItems = [...new Map(projects.map(item => [item.id, item])).values()]
+    const facts: [string, unknown][] = [
+      ['民族', detail.nation],
+      ['性别', genderText(detail)],
+      ['出生日期', birthDateText(detail.date_birth)],
+      // 项目中的 unit 是保护单位,不能替代传承人本人单位。
+      ['单位', detail.unit],
+      ['传承项目', [...new Set(projectItems.map(item => item.title))].join('、')],
+      ['传承人级别', categoryText(detail.level_text, detail.level)],
+      ['公布批次', detail.batch_text],
+    ]
+    presentation.facts = facts.flatMap(([label, value]) => {
+      const text = displayText(value)
+      return text ? [{ label, value: text }] : []
+    })
+    const sections: [string, string, unknown][] = [['intro', '简介', detail.intro], ['content', '更多介绍', detail.content], ['prize', '荣誉奖项', detail.prize]]
+    presentation.sections = sections.flatMap(([key, title, value]) => {
+      const content = prepareArticleContent(displayText(value))
+      return content ? [{ key, title, content }] : []
+    })
+    if (projectItems.length) {
+      presentation.relatedGroups.push({ key: 'projects', title: '非遗项目', items: projectItems })
+    }
+    const news = relatedItems(collectionItems(detail.association_me_list).filter(item => Number(item.model_id) !== 2))
+    if (news.length) {
+      presentation.relatedGroups.push({ key: 'news', title: '相关资讯', items: news })
+    }
+    return presentation
+  }
+
+  const commonFacts: [string, unknown][] = [
+    ['地区', categoryText(detail.region_text, detail.region)],
+    ['保护级别', categoryText(detail.level_text, detail.level)],
+    ['类型', type === 'relic' ? categoryText(detail.cr_type_text, detail.cr_type) : categoryText(detail.ich_type_text, detail.ich_type)],
+  ]
+  const facts: [string, unknown][] = type === 'relic'
+    ? [['文物编码', detail.code], ['年代', detail.age], ...commonFacts, ['地址', detail.address]]
+    : [...commonFacts, ['公布批次', detail.batch_text], ['保护单位', detail.unit], ['地址', detail.address]]
+  presentation.facts = facts.flatMap(([label, value]) => {
+    const text = displayText(value)
+    return text ? [{ label, value: text }] : []
+  })
+
+  const sections: [string, string, unknown][] = type === 'relic'
+    ? [
+        ['intro', '文物简介', detail.intro],
+        ['environment', '建筑环境', detail.environment],
+        ['description', '建筑描述', detail.description],
+        ['value', '价值评估', detail.value],
+        ['director', '责任人', detail.director],
+        ['protected_area', '保护区域', detail.protected_area],
+      ]
+    : [
+        ['intro', '项目简介', detail.intro],
+        // 真实非遗响应的完整项目描述在 description,desc 作为文档约定的兼容来源。
+        ['description', '项目描述', prepareArticleContent(displayText(detail.description)) || detail.desc],
+        ['inheritor', '传承人', detail.inheritor],
+      ]
+  sections.push(['content', '详细内容', detail.content])
+  presentation.sections = sections.flatMap(([key, title, value]) => {
+    const content = prepareArticleContent(displayText(value))
+    return content ? [{ key, title, content }] : []
+  })
+  const groups: [string, string, unknown][] = type === 'heritage'
+    ? [
+        ['inheritors', '关联传承人', detail.inheritors_list],
+        ['sites', '传习中心', detail.ich_sites_list],
+        ['works', '非遗作品', detail.works_list],
+        ['news', '相关资讯', detail.association_me_list],
+      ]
+    : [['news', '相关资讯', detail.association_me_list]]
+  presentation.relatedGroups = groups.flatMap(([key, title, collection]) => {
+    const items = relatedItems(collection)
+    return items.length ? [{ key, title, items }] : []
+  })
+
+  if (type === 'heritage') {
+    presentation.exhibitionImage = normalizeMediaUrl(displayText(detail.zt_image))
+    presentation.otherLevels = collectionItems(detail.other_level).flatMap((item) => {
+      const level = categoryText(item.level_text, item.level)
+      const title = displayText(item.title)
+      const unit = displayText(item.unit)
+      const text = [displayText(item.title), displayText(item.batch_text), displayText(item.approve_time)].filter(Boolean).join(' · ')
+      return level || text || unit ? [{ label: level, value: text || unit || level, id: title ? displayText(item.id) : '', title, unit }] : []
+    })
+  }
+  else {
+    const resources: [string, unknown][] = [['VR 模型', detail.vr], ['传感器示意模型', detail.sensor_schematic]]
+    presentation.resourceLinks = resources.flatMap(([title, value]) => {
+      const url = normalizeMediaUrl(displayText(value))
+      return url ? [{ title, url }] : []
+    })
+  }
+  return presentation
+}

+ 67 - 0
src/data/article-profile.ts

@@ -0,0 +1,67 @@
+import type { ArticleFact, ArticlePresentation, ArticleSection } from './article-content'
+import type { ContentDetail } from './inherit-api'
+import { prepareArticleContent } from './article-content'
+
+export interface ArticleProfileTab {
+  key: string
+  label: string
+}
+
+export interface ArticleProfile {
+  images: string[]
+  facts: ArticleFact[]
+  sections: ArticleSection[]
+  inheritorContent: string
+  prizeContent: string
+  levelBadge: string
+  tabs: ArticleProfileTab[]
+}
+
+export function createArticleProfile(detail: ContentDetail, presentation: ArticlePresentation): ArticleProfile {
+  const images = presentation.gallery
+  const content = prepareArticleContent(detail.content)
+  const sections = presentation.type === 'article'
+    ? content ? [{ key: 'content', title: '', content }] : []
+    : presentation.sections.filter(section => section.key !== 'inheritor' && section.key !== 'prize')
+  const inheritorContent = presentation.sections.find(section => section.key === 'inheritor')?.content || ''
+  const prizeContent = presentation.sections.find(section => section.key === 'prize')?.content || ''
+  const levelBadge = presentation.type === 'inheritor' ? presentation.facts.find(fact => fact.label === '传承人级别')?.value || '' : ''
+  const facts = presentation.type === 'heritage'
+    ? ['保护级别', '类型', '公布批次', '地区', '保护单位', '地址'].flatMap((label) => {
+        const fact = presentation.facts.find(fact => fact.label === label)
+        if (!fact) {
+          return []
+        }
+        const labels: Record<string, string> = { 保护级别: '项目级别', 类型: '项目类别', 公布批次: '批次时间', 地区: '所属区域' }
+        return [{ ...fact, label: labels[label] || label }]
+      })
+    : presentation.facts.map(fact => ({ ...fact, label: fact.label === '地区' ? '所属区域' : fact.label }))
+
+  // 空分区不生成标签;默认选中第一个真实有内容的分区。
+  const tabs: ArticleProfileTab[] = []
+  if (sections.length) {
+    tabs.push({ key: 'intro', label: presentation.type === 'article' ? '正文' : '简介' })
+  }
+  if (images.length) {
+    tabs.push({ key: 'images', label: '图片' })
+  }
+  if (presentation.exhibitionImage) {
+    tabs.push({ key: 'exhibition', label: '展厅' })
+  }
+  if (detail.audio || detail.video) {
+    tabs.push({ key: 'media', label: '资料影像' })
+  }
+  if (prizeContent) {
+    tabs.push({ key: 'prize', label: '荣誉奖项' })
+  }
+  const relatedTabs: [string, string][] = [['sites', '传习所'], ['inheritors', '传承人'], ['works', '作品'], ['projects', '非遗项目'], ['news', '相关资讯']]
+  for (const [key, label] of relatedTabs) {
+    if (presentation.relatedGroups.some(group => group.key === key) || (key === 'inheritors' && inheritorContent)) {
+      tabs.push({ key, label })
+    }
+  }
+  if (presentation.resourceLinks.length) {
+    tabs.push({ key: 'resources', label: '数字资源' })
+  }
+  return { images, facts, sections, inheritorContent, prizeContent, levelBadge, tabs }
+}

+ 72 - 0
src/data/culture-content.ts

@@ -0,0 +1,72 @@
+import type { HeritageKey, HomeCultureKey, InheritFilters } from './inherit-api'
+import { CULTURE_LIST_PAGE } from '../utils/routes'
+import { getHomeCultureList, getInheritList, HERITAGE_COLUMNS, HOME_CULTURE_COLUMNS } from './inherit-api'
+
+export type CultureCategoryKey = HeritageKey | HomeCultureKey
+
+export type CultureFilterKey = 'category' | 'level' | 'district'
+export type CultureFilters = Record<CultureFilterKey, string>
+
+export interface CultureFilterOption {
+  key: CultureFilterKey
+  label: string
+  options: string[]
+  index: number
+  value: string
+  ids?: string[]
+}
+
+export interface CultureItem {
+  id: string
+  image: string
+  title: string
+  description: string
+  date: string
+  tag: string
+  category?: string
+  level?: string
+  district?: string
+}
+
+export interface CultureCategory {
+  key: CultureCategoryKey
+  title: string
+  icon: string
+  items: CultureItem[]
+  supportsFilters?: boolean
+}
+
+export function createCultureFilters(): CultureFilters {
+  return { category: '', level: '', district: '' }
+}
+
+export function createCultureFilterOptions(): CultureFilterOption[] {
+  return [
+    { key: 'category', label: '分类', options: ['全部分类', '民间文学', '传统音乐', '传统舞蹈', '传统戏剧', '曲艺', '传统体育游艺与杂技', '传统美术', '传统技艺', '传统医药', '民俗'], index: 0, value: '' },
+    { key: 'level', label: '级别', options: ['全部级别', '国家级', '省级', '市级', '区级', '县级'], index: 0, value: '' },
+    { key: 'district', label: '地区', options: ['全部地区', '芗城', '龙文', '龙海', '长泰', '漳浦', '云霄', '诏安', '东山', '南靖', '平和', '华安'], index: 0, value: '' },
+  ]
+}
+
+export const CULTURE_CATEGORIES: CultureCategory[] = [
+  ...HERITAGE_COLUMNS.map(column => ({ key: column.key, title: column.label, icon: column.icon, items: [], supportsFilters: true })),
+  ...HOME_CULTURE_COLUMNS.map(column => ({ key: column.key, title: column.label, icon: column.icon, items: [], supportsFilters: false })),
+]
+
+export function findCultureCategory(key: string | undefined): CultureCategory {
+  return CULTURE_CATEGORIES.find(category => category.key === key) || CULTURE_CATEGORIES.find(category => category.key === 'areas')!
+}
+
+export function getCultureListUrl(key: CultureCategoryKey, filters: Partial<InheritFilters> = {}): string {
+  const query = [['category', key], ...Object.entries(filters).filter(([, value]) => value)]
+    .map(([name, value]) => `${name}=${encodeURIComponent(value)}`)
+    .join('&')
+  return `${CULTURE_LIST_PAGE}?${query}`
+}
+
+export function getCultureList(key: CultureCategoryKey, filters: InheritFilters, page = 1, pageSize = 20) {
+  const column = HOME_CULTURE_COLUMNS.find(column => column.key === key)
+  return column
+    ? getHomeCultureList(column.key, filters.keyword, page, pageSize)
+    : getInheritList(key as HeritageKey, filters, page, pageSize)
+}

+ 55 - 0
src/data/culture-map.ts

@@ -0,0 +1,55 @@
+import type { CulturePlace } from './inherit-api'
+import { getCulturePlaces } from './inherit-api'
+
+export interface CultureMapPoint {
+  id: string
+  name: string
+  address: string
+  longitude: number
+  latitude: number
+}
+
+export function normalizeCultureMapPoint(place: CulturePlace): CultureMapPoint | null {
+  // Number(null) 和 Number('') 会变成 0,必须先排除未填写的坐标。
+  if (place.longitude == null || place.latitude == null
+    || String(place.longitude).trim() === '' || String(place.latitude).trim() === '') {
+    return null
+  }
+  const longitude = Number(place.longitude)
+  const latitude = Number(place.latitude)
+  if (!Number.isFinite(longitude) || !Number.isFinite(latitude)
+    || Math.abs(longitude) > 180 || Math.abs(latitude) > 90
+    || (longitude === 0 && latitude === 0)) {
+    return null
+  }
+  return { id: String(place.id), name: place.title, address: place.address || '', longitude, latitude }
+}
+
+export async function getCultureMapData(force = false) {
+  const places = await getCulturePlaces(force)
+  const points = places.map(normalizeCultureMapPoint).filter((point): point is CultureMapPoint => point !== null)
+  return { points, total: places.length }
+}
+
+export interface CultureMapMarker {
+  id: number
+  latitude: number
+  longitude: number
+  title: string
+  iconPath: string
+  width: number
+  height: number
+}
+
+export function getCultureMapMarkers(points: CultureMapPoint[]): CultureMapMarker[] {
+  return points.map((point, index) => ({
+    id: index + 1,
+    latitude: point.latitude,
+    longitude: point.longitude,
+    title: point.name,
+    // 原生 map 要求 iconPath,所有场所统一使用普通定位针,不使用场所图片。
+    iconPath: '/icons/map-pin.png',
+    width: 24,
+    height: 32,
+  }))
+}

+ 98 - 0
src/data/heritage-content.ts

@@ -0,0 +1,98 @@
+export interface HeritageItem {
+  name: string
+  meta: string
+  desc: string
+  icon: string
+  image: string
+  level: string
+  district: string
+  category: string
+}
+
+const MEDIA = 'https://modao.cc/agent-py/media'
+
+export const PROJECTS: HeritageItem[] = [
+  {
+    name: '漳州布袋木偶戏',
+    meta: '国家级 · 芗城',
+    desc: '掌中乾坤,一口道尽千古事',
+    icon: 'ph:mask-happy-duotone',
+    image: `${MEDIA}/generated_images/2026-08-07/a0d729e3db234da0b8ce54c7076e4fed.jpg`,
+    level: '国家级',
+    district: '芗城',
+    category: '传统戏剧',
+  },
+  {
+    name: '漳浦剪纸',
+    meta: '国家级 · 漳浦',
+    desc: '剪刻乡土记忆与吉祥纹样',
+    icon: 'ph:scissors-duotone',
+    image: `${MEDIA}/generated_images/2026-08-07/236e78587aac4527ae84a006f6397167.jpg`,
+    level: '国家级',
+    district: '漳浦',
+    category: '传统美术',
+  },
+  {
+    name: '东山歌册',
+    meta: '省级 · 东山',
+    desc: '方言吟唱里的海岛生活',
+    icon: 'ph:music-notes-duotone',
+    image: `${MEDIA}/generated_images/2026-08-06/49d50567367248718d0d833c46ada65c.jpg`,
+    level: '省级',
+    district: '东山',
+    category: '民间文学',
+  },
+  {
+    name: '南靖土楼营造技艺',
+    meta: '市级 · 南靖',
+    desc: '夯土筑圆楼,聚族而居',
+    icon: 'ph:building-duotone',
+    image: `${MEDIA}/generated_images/2026-08-06/2a2356e6bdb74d3abff8576c1339926f.jpg`,
+    level: '市级',
+    district: '南靖',
+    category: '传统技艺',
+  },
+]
+
+export const INHERITORS: HeritageItem[] = [
+  {
+    name: '陈黎晖',
+    meta: '布袋木偶戏 · 芗城',
+    desc: '四十载掌上演绎漳州故事',
+    icon: 'ph:user-focus-duotone',
+    image: `${MEDIA}/generated_images/2026-08-06/69916b535e7d4045993ee45b945a67d2.jpg`,
+    level: '国家级',
+    district: '芗城',
+    category: '传统戏剧',
+  },
+  {
+    name: '林桃',
+    meta: '剪纸 · 漳浦',
+    desc: '以剪代笔,留住花鸟人情',
+    icon: 'ph:user-focus-duotone',
+    image: `${MEDIA}/generated_images/2026-08-06/ca5ca067074747e8b76d98546b37ea6d.jpg`,
+    level: '省级',
+    district: '漳浦',
+    category: '传统美术',
+  },
+  {
+    name: '沈水仙',
+    meta: '歌册 · 东山',
+    desc: '乡音传唱海岛古韵',
+    icon: 'ph:user-focus-duotone',
+    image: `${MEDIA}/generated_images/2026-08-06/33251f5102fe4de18a2cc548b85035fc.jpg`,
+    level: '市级',
+    district: '东山',
+    category: '民间文学',
+  },
+  {
+    name: '简天佑',
+    meta: '竹编 · 平和',
+    desc: '一篾一挑编出山野风物',
+    icon: 'ph:user-focus-duotone',
+    image: `${MEDIA}/generated_images/2026-08-06/6f7e281e05064529899f0cd60dc9dbf4.jpg`,
+    level: '县级',
+    district: '平和',
+    category: '传统技艺',
+  },
+]

+ 494 - 0
src/data/inherit-api.ts

@@ -0,0 +1,494 @@
+import type { ListData, RequestData } from '../utils/request'
+import type { HeritageItem } from './heritage-content'
+import { cached } from '../utils/cache'
+import { normalizeMediaUrl } from '../utils/media'
+import { MAIN_BODY_ID, normalizeList, request } from '../utils/request'
+
+export { API_BASE_URL, MAIN_BODY_ID } from '../utils/request'
+
+// 地图点位和村落列表变化很少,缓存 5 分钟,文旅页与村镇列表页之间复用;下拉刷新会跳过缓存。
+const STATIC_LIST_CACHE_TTL = 5 * 60 * 1000
+
+// ID 来自后台「内容模型管理」:ID 是主体栏目 ID,模型 ID 是内容模型 ID。
+export const HERITAGE_COLUMNS = [
+  { key: 'projects', label: '非遗项目', modelId: 2, columnId: 2, icon: 'ph:mask-happy-duotone', unit: '项' },
+  { key: 'inheritors', label: '非遗传承人', modelId: 7, columnId: 38, icon: 'ph:user-focus-duotone', unit: '人' },
+  { key: 'units', label: '非遗保护单位', modelId: 17, columnId: 259, icon: 'ph:columns-duotone', unit: '家' },
+  { key: 'centers', label: '非遗传习中心(所)', modelId: 17, columnId: 221, icon: 'ph:storefront-duotone', unit: '处' },
+] as const
+
+export const HOME_CULTURE_COLUMNS = [
+  { key: 'news', label: '最新资讯', modelId: 18, columnId: '', icon: 'ph:newspaper-clipping-duotone' },
+  { key: 'areas', label: '重点区域', modelId: 17, columnId: '435', icon: 'ph:shield-check-duotone' },
+  { key: 'relics', label: '文物古迹', modelId: 1, columnId: '1', icon: 'ph:building-duotone' },
+  { key: 'experience', label: '传承体验', modelId: 18, columnId: '434', icon: 'ph:hand-heart-duotone' },
+  // 栏目 ID 为 0 时查询研究模型下的全部内容。
+  { key: 'research', label: '理论研究', modelId: 19, columnId: '0', icon: 'ph:books-duotone' },
+  { key: 'achievements', label: '特色成果', modelId: 18, columnId: '425', icon: 'ph:trophy-duotone' },
+  { key: 'workshops', label: '非遗工坊', modelId: 17, columnId: '404', icon: 'ph:house-line-duotone' },
+] as const
+
+export type HomeCultureKey = typeof HOME_CULTURE_COLUMNS[number]['key']
+
+export interface NewsColumn {
+  id: string
+  name: string
+  modelId: number
+}
+
+export type HeritageKey = typeof HERITAGE_COLUMNS[number]['key']
+export interface CategoryOption {
+  id: string
+  name: string
+  pid: string
+}
+
+interface ApiCategory {
+  id: number | string
+  pid: number | string
+  title: string
+  status?: string
+  children?: ApiCategory[]
+}
+
+interface CategoryData {
+  region_list?: ApiCategory[]
+  level_list?: ApiCategory[]
+  ich_type_list?: ApiCategory[]
+  cr_type_list?: ApiCategory[]
+}
+
+export interface ApiContent {
+  id: number | string
+  title: string
+  thumbnail?: string | null
+  image?: string | null
+  desc?: string | null
+  region?: number | string | null
+  level?: number | string | null
+  ich_type?: number | string | null
+  region_text?: string
+  level_text?: string
+  ich_type_text?: string
+  ich_name?: string | null
+  column_name?: string
+  page?: string
+  publish_at?: string | null
+}
+
+type ContentListData = ListData<ApiContent>
+
+export interface ContentDetail {
+  model_id: number
+  title: string
+  image: string
+  audio: string
+  video: string
+  flag_text: string
+  publish_at: string
+  content: string
+  images?: string[] | null
+  code?: string | null
+  age?: string | null
+  region?: string | number | null
+  level?: string | number | null
+  cr_type?: string | number | null
+  ich_type?: string | number | null
+  region_text?: string | null
+  level_text?: string | null
+  cr_type_text?: string | null
+  ich_type_text?: string | null
+  address?: string | null
+  guard?: number | string | null
+  heritage?: number | string | null
+  unit?: string | null
+  batch_text?: string | null
+  intro?: string | null
+  environment?: string | null
+  description?: string | null
+  desc?: string | null
+  value?: string | null
+  director?: string | null
+  protected_area?: string | null
+  inheritor?: string | null
+  zt_image?: string | null
+  sensor_schematic?: string | null
+  vr?: string | null
+  association_me_list?: ContentRelatedCollection
+  inheritors_list?: ContentRelatedCollection
+  ich_sites_list?: ContentRelatedCollection
+  works_list?: ContentRelatedCollection
+  other_level?: ContentRelatedCollection
+  nation?: string | null
+  gender?: number | string | null
+  gender_text?: string | null
+  date_birth?: string | null
+  prize?: string | null
+  association?: Record<string, unknown> | null
+}
+
+export type ContentRelatedCollection = Record<string, unknown>[] | Record<string, Record<string, unknown>> | null
+
+export interface CulturePlace extends ApiContent {
+  address?: string | null
+  longitude?: number | string | null
+  latitude?: number | string | null
+}
+
+export interface VillageItem {
+  id: string
+  title: string
+  image: string
+  description: string
+  location: string
+  type: string
+  date: string
+}
+
+export interface HomeBannerItem {
+  id: string
+  image: string
+  tag: string
+  title: string
+  subtitle: string
+}
+
+export interface HomeNewsItem {
+  id: string
+  image?: string
+  title: string
+  subtitle: string
+  time: string
+}
+
+export interface HomeRecommendItem {
+  id: string
+  image: string
+  imageBg: string
+  tag: string
+  tagBg: string
+  title: string
+  subtitle: string
+}
+
+export interface HomeVolunteerItem {
+  id: string
+  title: string
+  meta: string
+  actionText: string
+}
+
+export interface InheritItem extends HeritageItem {
+  id: string
+  regionId: string
+  levelId: string
+  categoryId: string
+  page: string
+}
+
+export interface InheritLists {
+  projects: InheritItem[]
+  inheritors: InheritItem[]
+  units: InheritItem[]
+  centers: InheritItem[]
+}
+
+export interface InheritResult {
+  lists: InheritLists
+  totals: Record<HeritageKey, number>
+}
+
+export interface InheritFilters {
+  keyword: string
+  categoryId: string
+  levelId: string
+  districtId: string
+}
+
+function get<T>(path: string, data: RequestData): Promise<T> {
+  return request<T>(path, { data: { main_body_id: MAIN_BODY_ID, ...data } })
+}
+
+export async function getContentDetail(id: string): Promise<ContentDetail> {
+  const data = await get<Partial<Omit<ContentDetail, 'model_id'>> & { model_id?: string | number | null }>('content/content/getContentDetail', { id })
+  if (!data || Array.isArray(data)) {
+    throw new Error('文章不存在或已下架')
+  }
+  return {
+    ...data,
+    // 文档示例使用字符串,当前接口使用数字;统一后再按模型选择展示结构。
+    model_id: Number(data.model_id) || 0,
+    title: data.title?.trim() || '',
+    image: data.image?.trim() || '',
+    audio: data.audio?.trim() || '',
+    video: data.video?.trim() || '',
+    flag_text: data.flag_text?.trim() || '',
+    publish_at: data.publish_at?.trim() || '',
+    content: data.content?.trim() || '',
+  }
+}
+
+export async function getHomeBanners(): Promise<HomeBannerItem[]> {
+  interface ApiBanner {
+    id: number | string
+    title: string
+    image?: string | null
+    intro?: string | null
+    scene_text?: string | null
+    type_text?: string | null
+  }
+  const data = await get<ApiBanner[]>('content/banner_function/getIndexBanner', {})
+  return data.map(item => ({
+    id: String(item.id),
+    image: normalizeMediaUrl(item.image),
+    tag: item.scene_text || item.type_text || '',
+    title: item.title || '',
+    subtitle: item.intro || '',
+  }))
+}
+
+export async function getHomeRecommends(): Promise<HomeRecommendItem[]> {
+  const data = await get<ContentListData>('content/content/getFlagList', {
+    flag: 'recommend',
+    pageSize: 4,
+  })
+  return normalizeList(data, 1, 4).items.slice(0, 4).map(item => ({
+    id: String(item.id),
+    image: normalizeMediaUrl(item.thumbnail || item.image),
+    imageBg: '#f2ebe3',
+    tag: item.column_name || '',
+    tagBg: 'rgba(159,55,40,0.85)',
+    title: item.title,
+    subtitle: item.desc || '',
+  }))
+}
+
+async function fetchAllCulturePlaces(): Promise<CulturePlace[]> {
+  const places: CulturePlace[] = []
+  const pageSize = 100
+  for (let page = 1; ; page++) {
+    // 栏目留空查询文化场所模型的全部栏目,分页拉全,避免只显示第一页点位。
+    const data = await get<ListData<CulturePlace>>('content/content/getContentList', {
+      model_id: 17,
+      main_body_column_id: '',
+      page,
+      pageSize,
+    })
+    const { items, total } = normalizeList(data, page, pageSize)
+    places.push(...items)
+    if (Array.isArray(data) ? items.length < pageSize : places.length >= total) {
+      return places
+    }
+    if (!items.length) {
+      throw new Error('文化场所数据未加载完整,请重试')
+    }
+  }
+}
+
+export function getCulturePlaces(force = false): Promise<CulturePlace[]> {
+  return cached('culture-places', STATIC_LIST_CACHE_TTL, fetchAllCulturePlaces, force)
+}
+
+async function fetchVillageList(): Promise<VillageItem[]> {
+  interface ApiVillage {
+    id: number | string
+    name: string
+    thumbnail?: string | null
+    images?: string[]
+    overview?: string | null
+    district?: string | null
+    township?: string | null
+    village_type_text?: string
+    enter_at?: string | null
+  }
+  // 该接口直接返回完整数组,不支持 page/pageSize,避免翻页重复同一批村落。
+  const data = await get<ApiVillage[]>('village/village/getList', {})
+  return data.map(item => ({
+    id: String(item.id),
+    title: item.name,
+    image: normalizeMediaUrl(item.thumbnail || item.images?.[0]),
+    description: item.overview || '',
+    location: [item.district, item.township].filter(Boolean).join(' · '),
+    type: item.village_type_text || '',
+    date: item.enter_at?.split(' ')[0] || '',
+  }))
+}
+
+export function getVillageList(force = false): Promise<VillageItem[]> {
+  return cached('village-list', STATIC_LIST_CACHE_TTL, fetchVillageList, force)
+}
+
+export async function getHomeVolunteers(): Promise<HomeVolunteerItem[]> {
+  // 后台主体栏目「组织介绍」ID 为 74,对应「志愿者联盟」模型 12。
+  const data = await get<ContentListData>('content/content/getContentList', {
+    model_id: 12,
+    main_body_column_id: 74,
+    page: 1,
+    pageSize: 3,
+  })
+  return normalizeList(data, 1, 3).items.slice(0, 3).map(item => ({
+    id: String(item.id),
+    title: item.title,
+    meta: item.desc || item.region_text || '',
+    actionText: '查看详情',
+  }))
+}
+
+export async function getHomeNews(): Promise<HomeNewsItem[]> {
+  // 查询宣传资讯模型的全部栏目,不按推荐标记筛选。
+  const column = HOME_CULTURE_COLUMNS.find(column => column.key === 'news')!
+  const data = await get<ContentListData>('content/content/getContentList', {
+    model_id: column.modelId,
+    main_body_column_id: column.columnId,
+    page: 1,
+    pageSize: 4,
+  })
+  return normalizeList(data, 1, 4).items.slice(0, 4).map(item => ({
+    id: String(item.id),
+    image: normalizeMediaUrl(item.thumbnail || item.image),
+    title: item.title,
+    subtitle: item.desc || '',
+    time: item.publish_at?.split(' ')[0] || '',
+  }))
+}
+
+export async function getNewsColumns(): Promise<NewsColumn[]> {
+  interface Column {
+    id: number | string
+    name: string
+    model_id: number | string
+  }
+  const data = await get<Column[]>(
+    'content/main_body_column/getColumnList',
+    { model_id: 18, main_body_column_id: 0 },
+  )
+  return data.map(item => ({ id: String(item.id), name: item.name, modelId: Number(item.model_id) }))
+}
+
+export async function getNewsList(column: NewsColumn, keyword = '', page = 1, pageSize = 20) {
+  const data = await get<ContentListData>('content/content/getContentList', {
+    model_id: column.modelId,
+    main_body_column_id: column.id,
+    keywords: keyword.trim(),
+    page,
+    pageSize,
+  })
+  const { items, hasMore } = normalizeList(data, page, pageSize)
+  return {
+    items: items.map(item => ({
+      id: String(item.id),
+      title: item.title,
+      subtitle: item.desc || '',
+      time: item.publish_at?.split(' ')[0] || '',
+    })),
+    hasMore,
+  }
+}
+
+export async function getHomeCultureList(key: HomeCultureKey, keyword = '', page = 1, pageSize = 20) {
+  const column = HOME_CULTURE_COLUMNS.find(column => column.key === key)!
+  const data = await get<ContentListData>('content/content/getContentList', {
+    model_id: column.modelId,
+    main_body_column_id: column.columnId,
+    keywords: keyword.trim(),
+    page,
+    pageSize,
+  })
+  const { items, total, hasMore } = normalizeList(data, page, pageSize)
+  return {
+    items: items.map(item => ({
+      id: String(item.id),
+      title: item.title,
+      description: item.desc || '',
+      image: normalizeMediaUrl(item.thumbnail || item.image),
+      tag: item.column_name || '',
+      date: item.publish_at?.split(' ')[0] || '',
+    })),
+    total,
+    hasMore,
+  }
+}
+
+function flattenCategories(items: ApiCategory[] = []): CategoryOption[] {
+  return items.flatMap((item) => {
+    if (item.status && item.status !== 'normal') {
+      return []
+    }
+    return [
+      { id: String(item.id), pid: String(item.pid), name: item.title.replace(/&nbsp;|[\s├└│─]/g, '').trim() },
+      ...flattenCategories(item.children),
+    ]
+  })
+}
+
+export async function getInheritCategories() {
+  const data = await get<CategoryData>('content/category/getCategoryList', { is_tree: false })
+  const regions = flattenCategories(data.region_list)
+  const regionIds = new Set(regions.map(item => item.id))
+  return {
+    // 老文档将非遗门类放在 cr_type_list;只接受 pid=4,避免混入文物类型。
+    categories: flattenCategories(data.ich_type_list ?? data.cr_type_list?.filter(item => String(item.pid) === '4')),
+    levels: flattenCategories(data.level_list),
+    districts: regions.filter(item => !regionIds.has(item.pid)),
+    regions,
+  }
+}
+
+async function getColumn(column: typeof HERITAGE_COLUMNS[number], filters: InheritFilters, page = 1, pageSize = 4) {
+  const params = {
+    model_id: column.modelId,
+    main_body_column_id: column.columnId,
+    page,
+    pageSize,
+    keywords: filters.keyword.trim(),
+    level: filters.levelId,
+    ich_type: filters.categoryId,
+    region: filters.districtId,
+  }
+  const data = await get<ContentListData>('content/content/getContentList', params)
+  return normalizeList(data, page, pageSize)
+}
+
+export function normalizeInheritItem(item: ApiContent, column: typeof HERITAGE_COLUMNS[number]): InheritItem {
+  const level = item.level_text || ''
+  const district = item.region_text || ''
+  const category = item.ich_type_text || ''
+  return {
+    id: String(item.id),
+    name: item.title,
+    meta: [level, district, category].filter(Boolean).join(' · '),
+    desc: item.desc || item.ich_name || '',
+    image: normalizeMediaUrl(item.thumbnail || item.image),
+    icon: column.icon,
+    level,
+    district,
+    category,
+    regionId: item.region == null ? '' : String(item.region),
+    levelId: item.level == null ? '' : String(item.level),
+    categoryId: item.ich_type == null ? '' : String(item.ich_type),
+    page: item.page || '',
+  }
+}
+
+export async function getInheritList(key: HeritageKey, filters: InheritFilters, page = 1, pageSize = 20) {
+  const column = HERITAGE_COLUMNS.find(column => column.key === key)!
+  const result = await getColumn(column, filters, page, pageSize)
+  return {
+    ...result,
+    items: result.items.map((item) => {
+      const normalized = normalizeInheritItem(item, column)
+      return { id: normalized.id, title: normalized.name, description: normalized.desc, image: normalized.image, tag: normalized.meta, date: item.publish_at?.split(' ')[0] || '' }
+    }),
+  }
+}
+
+export async function getInheritLists(filters: InheritFilters = { keyword: '', categoryId: '', levelId: '', districtId: '' }): Promise<InheritResult> {
+  const contents = await Promise.all(HERITAGE_COLUMNS.map(column => getColumn(column, filters)))
+  return {
+    lists: Object.fromEntries(HERITAGE_COLUMNS.map((column, index) => [
+      column.key,
+      contents[index].items.map(item => normalizeInheritItem(item, column)),
+    ])) as unknown as InheritLists,
+    totals: Object.fromEntries(HERITAGE_COLUMNS.map((column, index) => [column.key, contents[index].total])) as Record<HeritageKey, number>,
+  }
+}

+ 228 - 0
src/data/user-api.ts

@@ -0,0 +1,228 @@
+import type { ApiResponse, RequestData } from '../utils/request'
+import { normalizeMediaUrl } from '../utils/media'
+import { API_BASE_URL, LoginRequiredError, MAIN_BODY_ID, request, unwrapResponse } from '../utils/request'
+
+export { LoginRequiredError } from '../utils/request'
+
+const SESSION_KEY = 'zhangzhou-user-session'
+
+export interface UserSession {
+  token: string
+  userId: string
+  mainBodyUserId?: string
+  nickname: string
+  avatar: string
+  expiresAt: number
+}
+
+interface LoginData {
+  auth: { token: string, user_id?: string | number, expiretime?: number | string, expires_in?: number | string }
+  userinfo?: { id?: string | number, nickname?: string, avatar?: string }
+  mainBodyUserInfo?: { id?: string | number, user_id?: string | number, nickname?: string, avatar?: string }
+}
+
+export interface FavoriteItem {
+  id: string
+  title: string
+  image: string
+  category: string
+}
+
+interface CollectData {
+  total: number
+  data: { content_id: string | number, title: string, thumbnail?: string, image?: string, model_name?: string, column_name?: string }[]
+}
+
+export function getUserSession(): UserSession | null {
+  const session = wx.getStorageSync(SESSION_KEY) as UserSession | undefined
+  if (!session || typeof session.token !== 'string' || !session.token || !session.userId) {
+    return null
+  }
+  if (session.expiresAt > 0 && session.expiresAt <= Date.now()) {
+    wx.removeStorageSync(SESSION_KEY)
+    return null
+  }
+  return session
+}
+
+export function logoutUser() {
+  wx.removeStorageSync(SESSION_KEY)
+}
+
+// 令牌失效时只清除仍是该令牌的本地会话,避免误删期间重新登录得到的新会话。
+function clearSessionIfCurrent(token: string) {
+  if (getUserSession()?.token === token) {
+    logoutUser()
+  }
+}
+
+async function post<T>(path: string, data: RequestData, token = ''): Promise<T> {
+  try {
+    return await request<T>(path.includes('/') ? path : `content/main_body_user/${path}`, {
+      method: 'POST',
+      data,
+      token,
+      errorMessage: '请求失败,请稍后重试',
+    })
+  }
+  catch (error) {
+    if (error instanceof LoginRequiredError) {
+      clearSessionIfCurrent(token)
+    }
+    throw error
+  }
+}
+
+export async function loginWithWeChat(): Promise<UserSession> {
+  const code = await new Promise<string>((resolve, reject) => {
+    wx.login({
+      timeout: 10000,
+      success(result) {
+        if (result.code) {
+          resolve(result.code)
+        }
+        else {
+          reject(new Error('未获取到微信登录凭证,请重试'))
+        }
+      },
+      fail() {
+        reject(new Error('微信登录失败,请稍后重试'))
+      },
+    })
+  })
+  const appid = wx.getAccountInfoSync().miniProgram.appId
+  if (!appid) {
+    throw new Error('未获取到小程序 AppID')
+  }
+  // code 只用于本次换取后台令牌;第三方 access_token 不是业务登录令牌。
+  const data = await post<LoginData>('third', { main_body_id: MAIN_BODY_ID, appid, code })
+  const userId = data?.mainBodyUserInfo?.user_id || data?.auth?.user_id || data?.userinfo?.id
+  if (!data?.auth?.token || !userId) {
+    throw new Error('登录返回信息不完整,请稍后重试')
+  }
+  const expiretime = Number(data.auth.expiretime) || 0
+  const duration = Number(data.auth.expires_in) || 0
+  const session: UserSession = {
+    token: data.auth.token,
+    userId: String(userId),
+    mainBodyUserId: data.mainBodyUserInfo?.id ? String(data.mainBodyUserInfo.id) : '',
+    nickname: data.mainBodyUserInfo?.nickname || data.userinfo?.nickname || '微信用户',
+    avatar: normalizeMediaUrl(data.mainBodyUserInfo?.avatar || data.userinfo?.avatar || ''),
+    expiresAt: expiretime > 0 ? expiretime * 1000 : duration > 0 ? Date.now() + duration * 1000 : 0,
+  }
+  wx.setStorageSync(SESSION_KEY, session)
+  return session
+}
+
+export function needsUserProfile(session: UserSession): boolean {
+  return !session.avatar || /\/assets\/img\/avatar\.png(?:\?|$)/.test(session.avatar)
+    || /^data:image\/svg\+xml[;,]/i.test(session.avatar)
+    || !session.nickname.trim() || /^微信用户\d*$/.test(session.nickname.trim())
+}
+
+function requireSameSession(session: UserSession): UserSession {
+  const current = getUserSession()
+  if (!current || current.token !== session.token || current.userId !== session.userId) {
+    throw new LoginRequiredError()
+  }
+  return current
+}
+
+function isTemporaryAvatar(avatar: string): boolean {
+  // 微信临时文件也可能使用 HTTP 协议,tmp/usr 不能当作远程图片域名。
+  return /^(?:wxfile:\/\/|https?:\/\/(?:tmp|usr)(?=[:/?#]|$))/i.test(avatar)
+}
+
+async function uploadAvatar(filePath: string, session: UserSession): Promise<string> {
+  return new Promise((resolve, reject) => {
+    wx.uploadFile({
+      url: `${API_BASE_URL}common/upload`,
+      filePath,
+      name: 'file',
+      header: { token: session.token },
+      timeout: 15000,
+      success(response) {
+        try {
+          // uploadFile 返回的是字符串,需要先解析再走统一的响应校验。
+          const result = JSON.parse(response.data) as Partial<ApiResponse<{ url?: string, fullurl?: string } | undefined>>
+          const data = unwrapResponse(response.statusCode, result, { token: session.token, errorMessage: '头像上传失败,请重试' })
+          const avatar = normalizeMediaUrl(data?.fullurl || data?.url || '')
+          if (!/^https:\/\//i.test(avatar) || isTemporaryAvatar(avatar)) {
+            throw new Error('头像上传返回地址异常,请重试')
+          }
+          resolve(avatar)
+        }
+        catch (error) {
+          if (error instanceof LoginRequiredError) {
+            clearSessionIfCurrent(session.token)
+          }
+          reject(error instanceof SyntaxError ? new Error('头像上传返回数据异常,请重试') : error)
+        }
+      },
+      fail() {
+        reject(new Error('头像上传失败,请检查网络后重试'))
+      },
+    })
+  })
+}
+
+export async function saveUserProfile(profile: { nickname: string, avatar: string }, userId: string): Promise<UserSession> {
+  let session = getUserSession()
+  if (!session || session.userId !== userId) {
+    throw new LoginRequiredError()
+  }
+  const nickname = profile.nickname.trim()
+  if (!nickname || nickname.length > 32) {
+    throw new Error('请输入 1 至 32 个字的昵称')
+  }
+  if (!profile.avatar) {
+    throw new Error('请先选择头像')
+  }
+  if (!session.mainBodyUserId) {
+    // 旧缓存只有普通用户 ID,需刷新主体资料,不能用 userId 替代主体用户 ID。
+    const data = await post<LoginData>('minnansoul/main_body_user/refreshUser', { main_body_id: MAIN_BODY_ID }, session.token)
+    const current = requireSameSession(session)
+    const bodyUser = data?.mainBodyUserInfo
+    if (!bodyUser?.id || String(bodyUser.user_id) !== session.userId) {
+      throw new Error('登录信息不完整,请退出后重新登录再修改资料')
+    }
+    session = { ...current, mainBodyUserId: String(bodyUser.id) }
+    wx.setStorageSync(SESSION_KEY, session)
+  }
+  const temporaryAvatar = isTemporaryAvatar(profile.avatar)
+  const avatarChanged = profile.avatar !== session.avatar || temporaryAvatar
+  // 后台默认头像可能是 SVG data URI;未修改时保留它,只有新选择的临时文件需要上传。
+  const avatar = !avatarChanged || (!temporaryAvatar && /^https?:\/\//i.test(profile.avatar))
+    ? profile.avatar
+    : await uploadAvatar(profile.avatar, session)
+  requireSameSession(session)
+  await post<null>('content/main_body_user/editMainBodyUser', {
+    main_body_id: MAIN_BODY_ID,
+    main_body_user_id: session.mainBodyUserId!,
+    nickname,
+    ...(avatarChanged ? { avatar } : {}),
+  }, session.token)
+  const updated = { ...requireSameSession(session), nickname, avatar }
+  wx.setStorageSync(SESSION_KEY, updated)
+  return updated
+}
+
+export async function getUserFavorites(page = 1, pageSize = 20) {
+  const session = getUserSession()
+  if (!session) {
+    throw new LoginRequiredError()
+  }
+  const data = await post<CollectData>('getUserCollect', { main_body_id: MAIN_BODY_ID, page, pageSize }, session.token)
+  if (!data || !Array.isArray(data.data)) {
+    throw new Error('收藏数据格式异常,请稍后重试')
+  }
+  return {
+    items: data.data.map(item => ({
+      id: String(item.content_id),
+      title: item.title || '',
+      image: normalizeMediaUrl(item.thumbnail || item.image || ''),
+      category: item.column_name || item.model_name || '',
+    })),
+    hasMore: page * pageSize < Number(data.total),
+  }
+}

+ 1 - 2
src/pages/home/home.json

@@ -7,7 +7,6 @@
     "recommend-card": "/components/recommend-card/index",
     "news-item": "/components/news-item/index",
     "volunteer-card": "/components/volunteer-card/index",
-    "svg-icon": "weapp-svg-icon/index",
-    "van-toast": "@vant/weapp/toast/index"
+    "svg-icon": "weapp-svg-icon/index"
   }
 }

+ 151 - 162
src/pages/home/home.ts

@@ -1,194 +1,183 @@
-import Toast from '@vant/weapp/toast/toast'
-
-interface BannerItem {
-  image: string
-  tag: string
-  topic: string
-  enTitle: string
-  title: string
-  subtitle: string
-}
+import type { CultureCategoryKey } from '../../data/culture-content'
+import type { HomeBannerItem, HomeNewsItem, HomeRecommendItem, HomeVolunteerItem } from '../../data/inherit-api'
+import { getCultureListUrl } from '../../data/culture-content'
+import { getHomeBanners, getHomeNews, getHomeRecommends, getHomeVolunteers } from '../../data/inherit-api'
+import { runRefresh } from '../../utils/refresh'
+import { syncTabBar } from '../../utils/tab-bar'
 
 interface QuickEntry {
   icon: string
-  iconBg: string
-  iconColor: string
-  iconBorder: string
   text: string
+  category?: CultureCategoryKey
+  tabPath?: string
 }
 
 Component({
   data: {
-    banners: [
-      {
-        image: 'https://modao.cc/agent-py/media/generated_images/2026-08-06/8b37d6e9e1d74b9fb48c953f0e199c71.jpg',
-        tag: '古城实景',
-        topic: '古城慢游专题',
-        enTitle: 'Z H A N G Z H O U',
-        title: '红砖古厝里的夏日烟火',
-        subtitle: '在千年古城,遇见闽南生活美学',
-      },
-      {
-        image: 'https://modao.cc/agent-py/media/generated_images/2026-08-06/e6fa0fac0a834dcc9389dccae0c8308d.jpg',
-        tag: '国家级非遗',
-        topic: '布袋木偶非遗专题',
-        enTitle: 'LIVING HERITAGE',
-        title: '掌中乾坤 · 布袋木偶戏',
-        subtitle: '一方戏台,演尽闽南百年故事',
-      },
-      {
-        image: 'https://modao.cc/agent-py/media/generated_images/2026-08-06/e00e4cebe5254522aeb935928765429f.jpg',
-        tag: '本周推荐',
-        topic: '非遗市集专题',
-        enTitle: 'CULTURAL MARKET',
-        title: '一场热闹的非遗市集',
-        subtitle: '手作、食味与匠心,在此相逢',
-      },
-    ] as BannerItem[],
+    refreshing: false,
+
+    banners: [] as HomeBannerItem[],
+    bannersLoading: true,
+    bannersError: '',
 
     quickEntries: [
-      { icon: 'ph:mask-happy-duotone', iconBg: '#f9e7df', iconColor: '#a83f2d', iconBorder: '#edcabd', text: '非遗项目' },
-      { icon: 'ph:person-simple-tai-chi-duotone', iconBg: '#fff1d8', iconColor: '#a87a27', iconBorder: '#ead4a3', text: '非遗传承人' },
-      { icon: 'ph:shield-check-duotone', iconBg: '#e8f0e7', iconColor: '#5f795d', iconBorder: '#cbdcc8', text: '重点区域' },
-      { icon: 'ph:building-duotone', iconBg: '#f9e8e1', iconColor: '#a83f2d', iconBorder: '#ead0c8', text: '文物古迹' },
-      { icon: 'ph:map-pin-area-duotone', iconBg: '#edf2e8', iconColor: '#5f795d', iconBorder: '#cbdcc8', text: '文化地图' },
-      { icon: 'ph:hand-heart-duotone', iconBg: '#fff1d8', iconColor: '#a87a27', iconBorder: '#ead4a3', text: '传承体验' },
-      { icon: 'ph:books-duotone', iconBg: '#f2ebe3', iconColor: '#8b4935', iconBorder: '#dfcbb8', text: '理论研究' },
-      { icon: 'ph:trophy-duotone', iconBg: '#e8f0e7', iconColor: '#5f795d', iconBorder: '#cbdcc8', text: '特色成果' },
+      { icon: '/icons/home/projects.png', text: '非遗项目', category: 'projects' },
+      { icon: '/icons/home/inheritors.png', text: '非遗传承人', category: 'inheritors' },
+      { icon: '/icons/home/areas.png', text: '重点区域', category: 'areas' },
+      { icon: '/icons/home/relics.png', text: '文物古迹', category: 'relics' },
+      { icon: '/icons/home/map.png', text: '文化地图', tabPath: '/pages/travel/travel' },
+      { icon: '/icons/home/experience.png', text: '传承体验', category: 'experience' },
+      { icon: '/icons/home/research.png', text: '理论研究', category: 'research' },
+      { icon: '/icons/home/achievements.png', text: '特色成果', category: 'achievements' },
     ] as QuickEntry[],
 
-    recommends: [
-      {
-        image: 'https://modao.cc/agent-py/media/generated_images/2026-08-06/57cb448b9cad417eaff26bd1ea34fc10.jpg',
-        imageBg: '#762d25',
-        tag: '非遗体验',
-        tagBg: 'rgba(159,55,40,0.85)',
-        title: '木偶戏沉浸体验',
-        subtitle: '古城剧场 · 90分钟',
-      },
-      {
-        image: 'https://modao.cc/agent-py/media/user_assets/2026-08-20/4c62b95d09954e9dbfb8eefffa11317c.png',
-        imageBg: '#5b756a',
-        tag: '打卡点',
-        tagBg: 'rgba(89,117,93,0.9)',
-        title: '云洞岩摩崖石刻',
-        subtitle: '龙文区 · 山野清凉',
-      },
-      {
-        image: 'https://modao.cc/agent-py/media/generated_images/2026-08-06/c442391b73bf46f99a6d09d414c04306.jpg',
-        imageBg: '#a96638',
-        tag: '亲子研学',
-        tagBg: 'rgba(167,103,55,0.9)',
-        title: '土楼营造技艺研学',
-        subtitle: '南靖县 · 周末成团',
-      },
-    ],
-
-    news: [
-      {
-        icon: 'ph:microphone-stage-duotone',
-        iconBg: '#f9e5df',
-        iconColor: '#a83f2d',
-        title: '漳州古城周末非遗展演安排公布',
-        subtitle: '精彩戏曲、南音与传统技艺轮番上演',
-        time: '今天',
-      },
-      {
-        icon: 'ph:ticket-duotone',
-        iconBg: '#fff0d8',
-        iconColor: '#a87a27',
-        title: '暑期文旅惠民消费券即将发放',
-        subtitle: '覆盖景区、文创、研学等多个场景',
-        time: '08-05',
-      },
-      {
-        icon: 'ph:calendar-heart-duotone',
-        iconBg: '#e8f0e7',
-        iconColor: '#5f795d',
-        title: '中秋博饼民俗活动报名通道开启',
-        subtitle: '感受闽南传统团圆仪式与欢乐',
-        time: '08-03',
-      },
-      {
-        icon: 'ph:scroll-duotone',
-        iconBg: '#f2ebe3',
-        iconColor: '#78675a',
-        title: '闽南文化生态保护区建设政策解读',
-        subtitle: '守护文化根脉,激活传承新活力',
-        time: '08-01',
-      },
-    ],
-
-    volunteers: [
-      {
-        icon: 'ph:megaphone-duotone',
-        iconBg: '#f9e5df',
-        iconColor: '#a83f2d',
-        title: '古城文化讲解志愿队',
-        status: '招募中',
-        statusBg: '#e8f0e7',
-        statusColor: '#5f795d',
-        meta: '每周末 · 漳州古城',
-        actionText: '查看详情',
-      },
-      {
-        icon: 'ph:hand-heart-duotone',
-        iconBg: '#fff0d8',
-        iconColor: '#a87a27',
-        title: '非遗传承助力团',
-        status: '长期开放',
-        statusBg: '#fff0d8',
-        statusColor: '#a87a27',
-        meta: '灵活参与 · 线上报名',
-        actionText: '立即参与',
-      },
-      {
-        icon: 'ph:camera-duotone',
-        iconBg: '#e8f0e7',
-        iconColor: '#5f795d',
-        title: '乡村文化记录计划',
-        status: '即将开始',
-        statusBg: '#f2ebe3',
-        statusColor: '#78675a',
-        meta: '每月主题 · 南靖县',
-        actionText: '预约报名',
-      },
-    ],
+    recommends: [] as HomeRecommendItem[],
+    recommendsLoading: true,
+    recommendsError: '',
+
+    news: [] as HomeNewsItem[],
+    newsLoading: true,
+    newsError: '',
+
+    // 暂时隐藏整块志愿者组织,改为 true 可恢复展示和数据加载。
+    showVolunteers: false,
+    volunteers: [] as HomeVolunteerItem[],
+    volunteersLoading: true,
+    volunteersError: '',
+  },
+
+  lifetimes: {
+    attached() {
+      this.loadBanners()
+      this.loadRecommends()
+      this.loadNews()
+      this.loadVolunteers()
+    },
   },
 
   pageLifetimes: {
     show() {
-      if (typeof this.getTabBar === 'function' && this.getTabBar()) {
-        this.getTabBar().setData({ selected: 0 })
-      }
+      syncTabBar(this)
     },
   },
 
   methods: {
-    onBannerTap(e: WechatMiniprogram.CustomEvent) {
-      const index = e.detail.index as number
-      const banners = this.data.banners as BannerItem[]
-      const banner = banners[index]
-      if (banner) {
-        Toast(`已进入:${banner.topic}`)
+    async onPullRefresh() {
+      this.setData({ refreshing: true })
+      await runRefresh([this.loadBanners(true), this.loadRecommends(true), this.loadNews(true), this.loadVolunteers(true)])
+      this.setData({ refreshing: false })
+    },
+
+    onRetrySection(e: WechatMiniprogram.TouchEvent) {
+      const section = e.currentTarget.dataset.section as string
+      if (section === 'banners') {
+        return this.loadBanners()
+      }
+      if (section === 'recommends') {
+        return this.loadRecommends()
+      }
+      if (section === 'news') {
+        return this.loadNews()
+      }
+      if (section === 'volunteers') {
+        return this.loadVolunteers()
+      }
+    },
+
+    // refresh 为下拉刷新:不切换到加载态;已有内容时失败只抛给 runRefresh 提示,保留原内容。
+    async loadBanners(refresh = false) {
+      if (!refresh) {
+        this.setData({ bannersLoading: true, bannersError: '' })
+      }
+      try {
+        const banners = await getHomeBanners()
+        this.setData({ banners, bannersLoading: false, bannersError: '' })
+      }
+      catch (error) {
+        if (refresh && this.data.banners.length) {
+          throw error
+        }
+        this.setData({
+          bannersLoading: false,
+          bannersError: error instanceof Error ? error.message : '轮播图加载失败,请稍后重试',
+        })
+      }
+    },
+
+    async loadVolunteers(refresh = false) {
+      if (!this.data.showVolunteers) {
+        return
+      }
+      if (!refresh) {
+        this.setData({ volunteersLoading: true, volunteersError: '' })
+      }
+      try {
+        const volunteers = await getHomeVolunteers()
+        this.setData({ volunteers, volunteersLoading: false, volunteersError: '' })
+      }
+      catch (error) {
+        if (refresh && this.data.volunteers.length) {
+          throw error
+        }
+        this.setData({
+          volunteersLoading: false,
+          volunteersError: error instanceof Error ? error.message : '志愿者组织加载失败,请稍后重试',
+        })
+      }
+    },
+
+    async loadRecommends(refresh = false) {
+      if (!refresh) {
+        this.setData({ recommendsLoading: true, recommendsError: '' })
+      }
+      try {
+        const recommends = await getHomeRecommends()
+        this.setData({ recommends, recommendsLoading: false, recommendsError: '' })
+      }
+      catch (error) {
+        if (refresh && this.data.recommends.length) {
+          throw error
+        }
+        this.setData({
+          recommendsLoading: false,
+          recommendsError: error instanceof Error ? error.message : '推荐加载失败,请稍后重试',
+        })
       }
     },
+
+    async loadNews(refresh = false) {
+      if (!refresh) {
+        this.setData({ newsLoading: true, newsError: '' })
+      }
+      try {
+        const news = await getHomeNews()
+        this.setData({ news, newsLoading: false, newsError: '' })
+      }
+      catch (error) {
+        if (refresh && this.data.news.length) {
+          throw error
+        }
+        this.setData({
+          newsLoading: false,
+          newsError: error instanceof Error ? error.message : '资讯加载失败,请稍后重试',
+        })
+      }
+    },
+
     onQuickTap(e: WechatMiniprogram.TouchEvent) {
       const index = Number(e.currentTarget.dataset.index)
       const quickEntries = this.data.quickEntries as QuickEntry[]
       const item = quickEntries[index]
-      if (item) {
-        Toast(`${item.text}功能建设中`)
+      if (item?.tabPath) {
+        wx.switchTab({ url: item.tabPath })
+        return
+      }
+      if (item?.category) {
+        wx.navigateTo({ url: getCultureListUrl(item.category) })
       }
-    },
-    onMoreRecommend() {
-      Toast('更多精选内容正在加载')
     },
     onMoreNews() {
-      Toast('已切换到资讯列表')
-    },
-    onMoreVolunteer() {
-      Toast('更多志愿组织正在招募')
+      wx.switchTab({ url: '/pages/news/news' })
     },
   },
 })

+ 31 - 19
src/pages/home/home.wxml

@@ -1,13 +1,16 @@
 <view class="h-screen flex flex-col paper-pattern">
   <page-header />
 
-  <scroll-view class="flex-1 min-h-0" scroll-y>
+  <scroll-view class="flex-1 min-h-0" scroll-y refresher-enabled="{{true}}" refresher-triggered="{{refreshing}}" bindrefresherrefresh="onPullRefresh">
     <view class="tabbar-safe-bottom">
       <view class="px-4 pt-4">
-        <banner-swiper list="{{banners}}" bind:select="onBannerTap" />
+        <view wx:if="{{bannersLoading}}" class="h-[178px] flex items-center justify-center rounded-2xl border border-[#d1aa58] bg-[#fbfbfb] text-xs text-[#9a8c82]">轮播图加载中...</view>
+        <view wx:elif="{{bannersError}}" class="h-[178px] flex items-center justify-center rounded-2xl border border-[#d1aa58] bg-[#fbfbfb] text-xs text-[#9a8c82]" bindtap="onRetrySection" data-section="banners">{{bannersError}},点击重试</view>
+        <view wx:elif="{{!banners.length}}" class="h-[178px] flex items-center justify-center rounded-2xl border border-[#d1aa58] bg-[#fbfbfb] text-xs text-[#9a8c82]">暂无轮播图</view>
+        <banner-swiper wx:else list="{{banners}}" />
       </view>
 
-      <view class="mx-4 mt-4 rounded-2xl bg-white/85 border border-[#eadcc5] px-2 py-3 shadow-sm">
+      <view class="mx-4 mt-4 rounded-2xl bg-[#fbfbfb] border border-[#eadcc5] px-2 py-3 shadow-sm">
         <view class="grid grid-cols-4 gap-x-1 gap-y-3 px-1">
           <view
             wx:for="{{quickEntries}}"
@@ -16,12 +19,7 @@
             data-index="{{index}}"
             bindtap="onQuickTap"
           >
-            <view
-              class="w-11 h-11 rounded-2xl flex items-center justify-center border"
-              style="background-color: {{item.iconBg}}; border-color: {{item.iconBorder}};"
-            >
-              <svg-icon name="{{item.icon}}" size="23px" color="{{item.iconColor}}" />
-            </view>
+            <image class="block w-11 h-11 rounded-xl" src="{{item.icon}}" mode="aspectFit" />
             <text class="text-xs font-medium text-[#4d4540]">{{item.text}}</text>
           </view>
         </view>
@@ -29,32 +27,46 @@
 
       <view class="mt-5">
         <view class="px-4">
-          <section-header title="精选推荐" barColor="#b48732" moreText="更多" bind:more="onMoreRecommend" />
+          <section-header title="精选推荐" barColor="#b48732" showMore="{{false}}" />
         </view>
-        <scroll-view class="mt-3" scroll-x>
+        <view wx:if="{{recommendsLoading}}" class="mx-4 mt-3 px-3 py-5 text-center text-xs text-[#9a8c82]">推荐加载中...</view>
+        <view wx:elif="{{recommendsError}}" class="mx-4 mt-3 px-3 py-5 text-center text-xs text-[#9a8c82]" bindtap="onRetrySection" data-section="recommends">{{recommendsError}},点击重试</view>
+        <view wx:elif="{{!recommends.length}}" class="mx-4 mt-3 px-3 py-5 text-center text-xs text-[#9a8c82]">暂无推荐</view>
+        <scroll-view wx:else class="mt-3" scroll-x>
           <view class="inline-flex gap-3 pl-4 pr-4">
-            <recommend-card wx:for="{{recommends}}" wx:key="title" item="{{item}}" />
+            <recommend-card wx:for="{{recommends}}" wx:key="id" item="{{item}}" />
           </view>
         </scroll-view>
       </view>
 
       <view class="mt-5 px-4">
         <section-header title="最新资讯" barColor="#a83f2d" moreText="查看全部" bind:more="onMoreNews" />
-        <view class="mt-3 overflow-hidden rounded-2xl border border-[#eadcc5] bg-white/90 divide-y divide-[#f0e6d5]">
-          <news-item wx:for="{{news}}" wx:key="title" item="{{item}}" />
+        <view class="mt-3 overflow-hidden rounded-2xl border border-[#eadcc5] bg-white/90">
+          <view wx:if="{{newsLoading}}" class="px-3 py-5 text-center text-xs text-[#9a8c82]">资讯加载中...</view>
+          <view wx:elif="{{newsError}}" class="px-3 py-5 text-center text-xs text-[#9a8c82]" bindtap="onRetrySection" data-section="news">{{newsError}},点击重试</view>
+          <view wx:elif="{{!news.length}}" class="px-3 py-5 text-center text-xs text-[#9a8c82]">暂无资讯</view>
+          <block wx:else>
+            <block wx:for="{{news}}" wx:key="id">
+              <news-item item="{{item}}" show-icon="{{false}}" show-image="{{true}}" />
+              <view wx:if="{{index !== news.length - 1}}" class="home-news-divider"></view>
+            </block>
+          </block>
         </view>
       </view>
 
-      <view class="mt-5 px-4">
-        <section-header title="志愿者组织" barColor="#b48732" moreText="查看全部" bind:more="onMoreVolunteer" />
+      <view wx:if="{{showVolunteers}}" class="mt-5 px-4">
+        <section-header title="志愿者组织" barColor="#b48732" showMore="{{false}}" />
         <view class="flex flex-col mt-3 gap-2.5">
-          <volunteer-card wx:for="{{volunteers}}" wx:key="title" item="{{item}}" />
+          <view wx:if="{{volunteersLoading}}" class="px-3 py-5 text-center text-xs text-[#9a8c82]">志愿者组织加载中...</view>
+          <view wx:elif="{{volunteersError}}" class="px-3 py-5 text-center text-xs text-[#9a8c82]" bindtap="onRetrySection" data-section="volunteers">{{volunteersError}},点击重试</view>
+          <view wx:elif="{{!volunteers.length}}" class="px-3 py-5 text-center text-xs text-[#9a8c82]">暂无志愿者组织</view>
+          <block wx:else>
+            <volunteer-card wx:for="{{volunteers}}" wx:key="id" item="{{item}}" />
+          </block>
         </view>
       </view>
 
       <view class="tabbar-placeholder"></view>
     </view>
   </scroll-view>
-
-  <van-toast id="van-toast" />
 </view>

+ 5 - 1
src/pages/home/home.wxss

@@ -1,2 +1,6 @@
-/* home */
+.home-news-divider {
+  height: 1px;
+  margin: 0 24rpx;
+  background-color: #eadcc5;
+}
 

+ 1 - 2
src/pages/inherit/inherit.json

@@ -3,7 +3,6 @@
   "usingComponents": {
     "heritage-header": "/components/heritage-header/index",
     "heritage-card": "/components/heritage-card/index",
-    "svg-icon": "weapp-svg-icon/index",
-    "van-toast": "@vant/weapp/toast/index"
+    "svg-icon": "weapp-svg-icon/index"
   }
 }

+ 124 - 319
src/pages/inherit/inherit.ts

@@ -1,368 +1,173 @@
-import Toast from '@vant/weapp/toast/toast'
+import type { CategoryOption, InheritItem, InheritLists } from '../../data/inherit-api'
+import { getCultureListUrl } from '../../data/culture-content'
+import { getInheritCategories, getInheritLists, HERITAGE_COLUMNS } from '../../data/inherit-api'
+import { runRefresh } from '../../utils/refresh'
+import { syncTabBar } from '../../utils/tab-bar'
 
-interface Stat {
-  label: string
-  value: string
-  unit: string
-  icon?: string
-}
-
-interface HeritageItem {
-  name: string
-  meta: string
-  desc: string
-  icon: string
-  image: string
-  level: string
-  district: string
-  category: string
-}
-
-interface TagOption {
-  name: string
+interface TagOption extends CategoryOption {
   active: boolean
 }
 
-const MEDIA = 'https://modao.cc/agent-py/media'
-
-const PROJECTS: HeritageItem[] = [
-  {
-    name: '漳州布袋木偶戏',
-    meta: '国家级 · 芗城',
-    desc: '掌中乾坤,一口道尽千古事',
-    icon: 'ph:mask-happy-duotone',
-    image: `${MEDIA}/generated_images/2026-08-07/a0d729e3db234da0b8ce54c7076e4fed.jpg`,
-    level: '国家级',
-    district: '芗城',
-    category: '传统戏剧',
-  },
-  {
-    name: '漳浦剪纸',
-    meta: '国家级 · 漳浦',
-    desc: '剪刻乡土记忆与吉祥纹样',
-    icon: 'ph:scissors-duotone',
-    image: `${MEDIA}/generated_images/2026-08-07/236e78587aac4527ae84a006f6397167.jpg`,
-    level: '国家级',
-    district: '漳浦',
-    category: '传统美术',
-  },
-  {
-    name: '东山歌册',
-    meta: '省级 · 东山',
-    desc: '方言吟唱里的海岛生活',
-    icon: 'ph:music-notes-duotone',
-    image: `${MEDIA}/generated_images/2026-08-06/49d50567367248718d0d833c46ada65c.jpg`,
-    level: '省级',
-    district: '东山',
-    category: '民间文学',
-  },
-  {
-    name: '南靖土楼营造技艺',
-    meta: '市级 · 南靖',
-    desc: '夯土筑圆楼,聚族而居',
-    icon: 'ph:building-duotone',
-    image: `${MEDIA}/generated_images/2026-08-06/2a2356e6bdb74d3abff8576c1339926f.jpg`,
-    level: '市级',
-    district: '南靖',
-    category: '传统技艺',
-  },
-]
-
-const INHERITORS: HeritageItem[] = [
-  {
-    name: '陈黎晖',
-    meta: '布袋木偶戏 · 芗城',
-    desc: '四十载掌上演绎漳州故事',
-    icon: 'ph:user-focus-duotone',
-    image: `${MEDIA}/generated_images/2026-08-06/69916b535e7d4045993ee45b945a67d2.jpg`,
-    level: '国家级',
-    district: '芗城',
-    category: '传统戏剧',
-  },
-  {
-    name: '林桃',
-    meta: '剪纸 · 漳浦',
-    desc: '以剪代笔,留住花鸟人情',
-    icon: 'ph:user-focus-duotone',
-    image: `${MEDIA}/generated_images/2026-08-06/ca5ca067074747e8b76d98546b37ea6d.jpg`,
-    level: '省级',
-    district: '漳浦',
-    category: '传统美术',
-  },
-  {
-    name: '沈水仙',
-    meta: '歌册 · 东山',
-    desc: '乡音传唱海岛古韵',
-    icon: 'ph:user-focus-duotone',
-    image: `${MEDIA}/generated_images/2026-08-06/33251f5102fe4de18a2cc548b85035fc.jpg`,
-    level: '市级',
-    district: '东山',
-    category: '民间文学',
-  },
-  {
-    name: '简天佑',
-    meta: '竹编 · 平和',
-    desc: '一篾一挑编出山野风物',
-    icon: 'ph:user-focus-duotone',
-    image: `${MEDIA}/generated_images/2026-08-06/6f7e281e05064529899f0cd60dc9dbf4.jpg`,
-    level: '县级',
-    district: '平和',
-    category: '传统技艺',
-  },
-]
-
-const UNITS: HeritageItem[] = [
-  {
-    name: '漳州市木偶剧团',
-    meta: '国家级保护单位 · 芗城',
-    desc: '布袋木偶戏系统保护与展演',
-    icon: 'ph:columns-duotone',
-    image: `${MEDIA}/generated_images/2026-08-06/40f6b69d9e9a4bf7be8bb81fffa1cb7b.jpg`,
-    level: '国家级',
-    district: '芗城',
-    category: '传统戏剧',
-  },
-  {
-    name: '南靖县文化馆',
-    meta: '市级保护单位 · 南靖',
-    desc: '土楼民俗资料整理与活化',
-    icon: 'ph:bank-duotone',
-    image: `${MEDIA}/generated_images/2026-08-06/42d41037be194bdca22ced6a181d08c7.jpg`,
-    level: '市级',
-    district: '南靖',
-    category: '民俗',
-  },
-  {
-    name: '东山县文化馆',
-    meta: '省级保护单位 · 东山',
-    desc: '海洋民俗与歌册传承基地',
-    icon: 'ph:lighthouse-duotone',
-    image: `${MEDIA}/generated_images/2026-08-06/636da2f41d614f8797833a11f2967743.jpg`,
-    level: '省级',
-    district: '东山',
-    category: '民间文学',
-  },
-  {
-    name: '诏安县美术馆',
-    meta: '县级保护单位 · 诏安',
-    desc: '书画艺术与民间美术守护',
-    icon: 'ph:frame-corners-duotone',
-    image: `${MEDIA}/generated_images/2026-08-06/50b938f366134e749616ad065f1b4b32.jpg`,
-    level: '县级',
-    district: '诏安',
-    category: '传统美术',
-  },
-]
-
-const CENTERS: HeritageItem[] = [
-  {
-    name: '芗城木偶传习所',
-    meta: '芗城 · 预约开放',
-    desc: '木偶操演、唱腔与道具体验',
-    icon: 'ph:storefront-duotone',
-    image: `${MEDIA}/generated_images/2026-08-06/4f7a53eab8c8493ab98704d4d2d452fd.jpg`,
-    level: '国家级',
-    district: '芗城',
-    category: '传统戏剧',
-  },
-  {
-    name: '南靖土楼营造传习中心',
-    meta: '南靖 · 周二至周日',
-    desc: '夯筑工具与传统工序展示',
-    icon: 'ph:house-line-duotone',
-    image: `${MEDIA}/generated_images/2026-08-06/5b8c846df27049b1ba38df648280df8d.jpg`,
-    level: '市级',
-    district: '南靖',
-    category: '传统技艺',
-  },
-  {
-    name: '云霄竹塔传习所',
-    meta: '云霄 · 公益课堂',
-    desc: '竹艺制作与节庆文化传习',
-    icon: 'ph:plant-duotone',
-    image: `${MEDIA}/generated_images/2026-08-06/dd3693b6cae1420999e57a56aa10e735.jpg`,
-    level: '区级',
-    district: '云霄',
-    category: '传统技艺',
-  },
-  {
-    name: '诏安木版年画传习中心',
-    meta: '诏安 · 可现场体验',
-    desc: '刻版、拓印与年俗课堂',
-    icon: 'ph:paint-brush-broad-duotone',
-    image: `${MEDIA}/generated_images/2026-08-06/9b460a47a8f34e1dafbf29ecd5260a68.jpg`,
-    level: '县级',
-    district: '诏安',
-    category: '传统美术',
-  },
-]
-
-function matchItems(
-  items: HeritageItem[],
-  query: string,
-  category: string,
-  levels: string[],
-  district: string,
-): HeritageItem[] {
-  const q = query.trim().toLowerCase()
-  return items.filter((item) => {
-    const matchQuery = !q || `${item.name}${item.meta}${item.desc}`.toLowerCase().includes(q)
-    const matchCategory = !category || item.category === category
-    const matchLevel = levels.length === 0 || levels.includes(item.level)
-    const matchDistrict = district === '全部' || item.district === district
-    return matchQuery && matchCategory && matchLevel && matchDistrict
-  })
-}
+const ALL_OPTION: CategoryOption = { id: '', name: '全部', pid: '' }
 
 Component({
   data: {
+    refreshing: false,
     keyword: '',
-
-    stats: [
-      { label: '非遗项目总数', value: '1,286', unit: '项' },
-      { label: '传承人总量', value: '2,560', unit: '人' },
-      { label: '文保单位数量', value: '486', unit: '处', icon: 'ph:columns-duotone' },
-      { label: '传习工坊数量', value: '128', unit: '家' },
-    ] as Stat[],
-
-    categories: [
-      '民间文学',
-      '传统音乐',
-      '传统舞蹈',
-      '传统戏剧',
-      '曲艺',
-      '传统体育游艺与杂技',
-      '传统美术',
-      '传统技艺',
-      '传统医药',
-      '民俗',
-    ],
+    stats: HERITAGE_COLUMNS.map(column => ({ label: column.label, value: '—', unit: column.unit })),
+    categories: [ALL_OPTION] as CategoryOption[],
     selectedCategory: '',
-
-    levels: [
-      { name: '全部', active: true },
-      { name: '国家级', active: false },
-      { name: '省级', active: false },
-      { name: '市级', active: false },
-      { name: '区级', active: false },
-      { name: '县级', active: false },
-    ] as TagOption[],
-
-    districts: ['全部', '芗城', '龙文', '南靖', '东山', '云霄', '诏安', '漳浦', '平和', '华安', '长泰'],
-    selectedDistrict: '全部',
-
-    projects: PROJECTS as HeritageItem[],
-    inheritors: INHERITORS as HeritageItem[],
-    units: UNITS as HeritageItem[],
-    centers: CENTERS as HeritageItem[],
-
-    summary: '当前展示全部非遗内容 · 共 16 条',
-    hasResult: true,
+    levels: [{ ...ALL_OPTION, active: true }] as TagOption[],
+    districts: [ALL_OPTION] as CategoryOption[],
+    optionsLoaded: false,
+    selectedDistrict: '',
+    projects: [] as InheritItem[],
+    inheritors: [] as InheritItem[],
+    units: [] as InheritItem[],
+    centers: [] as InheritItem[],
+    hasResult: false,
+    loading: true,
+    loadError: '',
+    requestVersion: 0,
+  },
+
+  lifetimes: {
+    attached() {
+      this.loadData()
+    },
+    detached() {
+      this.data.requestVersion++
+    },
   },
 
   pageLifetimes: {
     show() {
-      if (typeof this.getTabBar === 'function' && this.getTabBar()) {
-        this.getTabBar().setData({ selected: 1 })
-      }
+      syncTabBar(this)
     },
   },
 
   methods: {
-    refresh() {
-      const { keyword, selectedCategory, selectedDistrict } = this.data as {
-        keyword: string
-        selectedCategory: string
-        selectedDistrict: string
-      }
-      const selectedLevels = (this.data.levels as TagOption[])
-        .filter(l => l.active && l.name !== '全部')
-        .map(l => l.name)
+    async onPullRefresh() {
+      this.setData({ refreshing: true })
+      await runRefresh([this.loadData(true)])
+      this.setData({ refreshing: false })
+    },
 
-      const projects = matchItems(PROJECTS, keyword, selectedCategory, selectedLevels, selectedDistrict)
-      const inheritors = matchItems(INHERITORS, keyword, selectedCategory, selectedLevels, selectedDistrict)
-      const units = matchItems(UNITS, keyword, selectedCategory, selectedLevels, selectedDistrict)
-      const centers = matchItems(CENTERS, keyword, selectedCategory, selectedLevels, selectedDistrict)
-      const total = projects.length + inheritors.length + units.length + centers.length
+    onRetry() {
+      return this.loadData()
+    },
 
-      const active = [
-        selectedCategory,
-        ...selectedLevels,
-        selectedDistrict === '全部' ? '' : selectedDistrict,
-      ].filter(Boolean)
-      const summary = active.length
-        ? `已筛选:${active.join('、')} · 共 ${total} 条内容`
-        : `当前展示全部非遗内容 · 共 ${total} 条`
+    // refresh 为下拉刷新:同时重新拉取筛选项,不切换到加载态,已有内容时失败保留原内容。
+    async loadData(refresh = false) {
+      const requestVersion = ++this.data.requestVersion
+      const { keyword, selectedCategory, selectedDistrict, levels, optionsLoaded } = this.data
+      const filters = {
+        keyword,
+        categoryId: selectedCategory,
+        levelId: levels.find(level => level.active)?.id || '',
+        districtId: selectedDistrict,
+      }
+      const unfiltered = !filters.keyword.trim() && !filters.categoryId && !filters.levelId && !filters.districtId
+      if (!refresh) {
+        this.setData({ loading: true, loadError: '' })
+      }
+      try {
+        const [options, result] = await Promise.all([
+          optionsLoaded && !refresh ? Promise.resolve(null) : getInheritCategories(),
+          getInheritLists(filters),
+        ])
+        // 连续切换筛选时只接收最后一次请求,防止旧结果覆盖当前选择。
+        if (this.data.requestVersion !== requestVersion) {
+          return
+        }
+        if (options) {
+          this.setData({
+            categories: [ALL_OPTION, ...options.categories],
+            districts: [ALL_OPTION, ...options.districts],
+            levels: [
+              { ...ALL_OPTION, active: !filters.levelId },
+              ...options.levels.map(item => ({ ...item, active: filters.levelId === item.id })),
+            ],
+            optionsLoaded: true,
+          })
+        }
+        // 顶部统计展示全部数据的总数,只用不带筛选条件的结果更新。
+        if (unfiltered) {
+          this.setData({
+            stats: HERITAGE_COLUMNS.map(column => ({ label: column.label, value: String(result.totals[column.key]), unit: column.unit })),
+          })
+        }
+        this.setData({ loading: false, loadError: '' })
+        this.refresh(result.lists)
+      }
+      catch (error) {
+        if (this.data.requestVersion !== requestVersion) {
+          return
+        }
+        if (refresh && optionsLoaded && !this.data.loadError) {
+          throw error
+        }
+        this.setData({ loading: false, loadError: error instanceof Error ? error.message : '数据加载失败,请稍后重试' })
+      }
+    },
 
+    refresh(lists: InheritLists) {
+      const total = HERITAGE_COLUMNS.reduce((count, column) => count + lists[column.key].length, 0)
       this.setData({
-        projects,
-        inheritors,
-        units,
-        centers,
-        summary,
+        ...lists,
         hasResult: total > 0,
       })
     },
 
     onSearch(e: WechatMiniprogram.CustomEvent) {
       this.setData({ keyword: e.detail.keyword as string })
-      this.refresh()
+      return this.loadData()
     },
 
     onSelectCategory(e: WechatMiniprogram.TouchEvent) {
-      const category = e.currentTarget.dataset.name as string
-      const selectedCategory = this.data.selectedCategory === category ? '' : category
-      this.setData({ selectedCategory })
-      this.refresh()
+      const id = e.currentTarget.dataset.id as string
+      if (this.data.selectedCategory === id) {
+        return
+      }
+      this.setData({ selectedCategory: id })
+      return this.loadData()
     },
 
-    onToggleLevel(e: WechatMiniprogram.TouchEvent) {
-      const name = e.currentTarget.dataset.name as string
-      let levels = this.data.levels as TagOption[]
-      if (name === '全部') {
-        levels = levels.map(l => ({ ...l, active: l.name === '全部' }))
-      }
-      else {
-        levels = levels.map((l) => {
-          if (l.name === '全部') {
-            return { ...l, active: false }
-          }
-          if (l.name === name) {
-            return { ...l, active: !l.active }
-          }
-          return l
-        })
-        const hasSpecific = levels.some(l => l.name !== '全部' && l.active)
-        if (!hasSpecific) {
-          levels = levels.map(l => ({ ...l, active: l.name === '全部' }))
-        }
+    onSelectLevel(e: WechatMiniprogram.TouchEvent) {
+      const id = e.currentTarget.dataset.id as string
+      const option = this.data.levels.find(level => level.id === id)
+      if (!option || option.active) {
+        return
       }
+      const levels = this.data.levels.map(level => ({ ...level, active: level.id === id }))
       this.setData({ levels })
-      this.refresh()
+      return this.loadData()
     },
 
     onSelectDistrict(e: WechatMiniprogram.TouchEvent) {
-      const district = e.currentTarget.dataset.name as string
-      if (!district) {
-        return
-      }
-      this.setData({ selectedDistrict: district })
-      this.refresh()
+      this.setData({ selectedDistrict: e.currentTarget.dataset.id as string })
+      return this.loadData()
     },
 
     onReset() {
-      const levels = (this.data.levels as TagOption[]).map(l => ({ ...l, active: l.name === '全部' }))
       this.setData({
         keyword: '',
         selectedCategory: '',
-        levels,
-        selectedDistrict: '全部',
+        levels: this.data.levels.map(level => ({ ...level, active: !level.id })),
+        selectedDistrict: '',
       })
-      this.refresh()
+      return this.loadData()
     },
 
-    onFilter() {
-      Toast('可使用下方门类、级别与区县进行筛选')
+    onMore(e: WechatMiniprogram.TouchEvent) {
+      const column = HERITAGE_COLUMNS.find(column => column.key === e.currentTarget.dataset.category)
+      if (!column) {
+        return
+      }
+      const { keyword, selectedCategory, selectedDistrict, levels } = this.data
+      const filters = { keyword, categoryId: selectedCategory, levelId: levels.find(level => level.active)?.id || '', districtId: selectedDistrict }
+      // 沿用当前筛选,让“更多”展示当前栏目对应的完整结果。
+      wx.navigateTo({ url: getCultureListUrl(column.key, filters) })
     },
 
     onBack() {

+ 49 - 46
src/pages/inherit/inherit.wxml

@@ -1,44 +1,31 @@
 <view class="h-screen flex flex-col bg-[#f8efe2]">
-  <heritage-header value="{{keyword}}" bind:search="onSearch" bind:filter="onFilter" bind:back="onBack" />
+  <heritage-header value="{{keyword}}" bind:search="onSearch" bind:back="onBack" />
 
-  <scroll-view class="flex-1 min-h-0" scroll-y>
-    <view class="bg-[#fffaf1] border-b border-[#eadcc5] px-4 pt-3 pb-3">
-      <view class="mb-2">
-        <text class="text-sm font-bold text-[#983726]">非遗数据</text>
-      </view>
-      <view class="grid grid-cols-2 gap-2">
-        <view
-          wx:for="{{stats}}"
-          wx:key="label"
-          class="border border-[#e5cfa9] bg-[#fff7e9] px-3 py-2"
-        >
-          <view class="flex items-center justify-between text-[#a83f2d]">
-            <text class="text-xs">{{item.label}}</text>
-            <svg-icon wx:if="{{item.icon}}" name="{{item.icon}}" size="16px" color="#a83f2d" />
-          </view>
-          <view class="mt-1 flex items-baseline">
-            <text class="text-xl leading-none font-bold text-[#803020]">{{item.value}}</text>
-            <text class="ml-1 text-xs text-[#803020]">{{item.unit}}</text>
-          </view>
+  <scroll-view class="flex-1 min-h-0" scroll-y refresher-enabled="{{true}}" refresher-triggered="{{refreshing}}" bindrefresherrefresh="onPullRefresh">
+    <view class="inherit-stats">
+      <view wx:for="{{stats}}" wx:key="label" class="inherit-stat">
+        <view class="inherit-stat__amount">
+          <text class="inherit-stat__value">{{item.value}}</text>
+          <text class="inherit-stat__unit">{{item.unit}}</text>
         </view>
+        <text class="inherit-stat__label">{{item.label}}</text>
       </view>
     </view>
 
     <view class="bg-[#fffaf1] border-b border-[#eadcc5] px-4 pt-3 pb-2">
       <view class="flex items-center justify-between">
         <text class="text-sm font-bold text-[#983726]">非遗门类</text>
-        <view class="text-sm text-[#a83f2d]" bindtap="onReset">重置</view>
       </view>
       <scroll-view class="hide-scroll mt-2" scroll-x>
         <view class="inline-flex gap-2 whitespace-nowrap pb-1">
           <view
             wx:for="{{categories}}"
-            wx:key="*this"
-            class="rounded-full border px-3 py-1.5 text-sm {{selectedCategory === item ? 'bg-[#a83f2d] border-[#a83f2d] text-white' : 'bg-white border-[#e6d4bd] text-[#806d5c]'}}"
-            data-name="{{item}}"
+            wx:key="id"
+            class="rounded-full border px-3 py-1.5 text-sm {{selectedCategory === item.id ? 'bg-[#a83f2d] border-[#a83f2d] text-white' : 'bg-white border-[#e6d4bd] text-[#806d5c]'}}"
+            data-id="{{item.id}}"
             bindtap="onSelectCategory"
           >
-            {{item}}
+            {{item.name}}
           </view>
         </view>
       </scroll-view>
@@ -47,15 +34,14 @@
     <view class="bg-[#fffaf1] border-b border-[#eadcc5] px-4 py-3">
       <view class="flex items-center justify-between">
         <text class="text-sm font-bold text-[#983726]">保护级别</text>
-        <text class="text-xs text-[#9b897a]">可多选</text>
       </view>
       <view class="mt-2 flex flex-wrap gap-2 text-sm">
         <view
           wx:for="{{levels}}"
-          wx:key="name"
+          wx:key="id"
           class="rounded-full border px-3 py-1.5 {{item.active ? 'bg-[#a83f2d] border-[#a83f2d] text-white' : 'bg-white border-[#e6d4bd] text-[#806d5c]'}}"
-          data-name="{{item.name}}"
-          bindtap="onToggleLevel"
+          data-id="{{item.id}}"
+          bindtap="onSelectLevel"
         >
           {{item.name}}
         </view>
@@ -63,60 +49,78 @@
 
       <view class="mt-3 flex items-center justify-between">
         <text class="text-sm font-bold text-[#6c5145]">漳州各区县</text>
-        <text class="text-xs text-[#9b897a]">快捷筛选</text>
       </view>
       <scroll-view class="hide-scroll mt-2" scroll-x>
         <view class="inline-flex gap-2 whitespace-nowrap pb-1">
           <view
             wx:for="{{districts}}"
-            wx:key="*this"
-            class="rounded-full border px-3 py-1.5 text-sm {{selectedDistrict === item ? 'bg-[#a83f2d] border-[#a83f2d] text-white' : 'bg-white border-[#e6d4bd] text-[#806d5c]'}}"
-            data-name="{{item}}"
+            wx:key="id"
+            class="rounded-full border px-3 py-1.5 text-sm {{selectedDistrict === item.id ? 'bg-[#a83f2d] border-[#a83f2d] text-white' : 'bg-white border-[#e6d4bd] text-[#806d5c]'}}"
+            data-id="{{item.id}}"
             bindtap="onSelectDistrict"
           >
-            {{item}}
+            {{item.name}}
           </view>
         </view>
       </scroll-view>
-
-      <text class="mt-2 block text-xs text-[#9b897a]">{{summary}}</text>
     </view>
 
-    <view wx:if="{{hasResult}}">
+    <view wx:if="{{loading}}" class="px-4 py-12 text-center text-sm text-[#806d5c]">正在加载非遗内容…</view>
+    <view wx:elif="{{loadError}}" class="px-4 py-12 text-center">
+      <text class="block text-sm text-[#7f5f50]">{{loadError}}</text>
+      <view class="mt-3 inline-block text-sm text-[#a83f2d]" bindtap="onRetry">点击重试</view>
+    </view>
+    <view wx:elif="{{hasResult}}">
       <view class="px-4 pt-4">
-        <text class="text-lg font-bold text-[#873324]">非遗项目</text>
+        <view class="flex items-center justify-between">
+          <text class="text-lg font-bold text-[#873324]">非遗项目</text>
+          <view class="py-2 pl-3 text-sm text-[#a83f2d]" data-category="projects" bindtap="onMore" aria-role="button" aria-label="更多非遗项目">更多</view>
+        </view>
         <scroll-view class="hide-scroll mt-2.5" scroll-x>
           <view class="inline-flex gap-3 pb-2">
-            <heritage-card wx:for="{{projects}}" wx:key="name" item="{{item}}" />
+            <heritage-card wx:for="{{projects}}" wx:key="id" item="{{item}}" />
           </view>
         </scroll-view>
+        <text wx:if="{{!projects.length}}" class="mt-2 block text-sm text-[#9b897a]">暂无匹配的非遗项目</text>
       </view>
 
       <view class="px-4 pt-4">
-        <text class="text-lg font-bold text-[#873324]">非遗传承人</text>
+        <view class="flex items-center justify-between">
+          <text class="text-lg font-bold text-[#873324]">非遗传承人</text>
+          <view class="py-2 pl-3 text-sm text-[#a83f2d]" data-category="inheritors" bindtap="onMore" aria-role="button" aria-label="更多非遗传承人">更多</view>
+        </view>
         <scroll-view class="hide-scroll mt-2.5" scroll-x>
           <view class="inline-flex gap-3 pb-2">
-            <heritage-card wx:for="{{inheritors}}" wx:key="name" item="{{item}}" />
+            <heritage-card wx:for="{{inheritors}}" wx:key="id" item="{{item}}" />
           </view>
         </scroll-view>
+        <text wx:if="{{!inheritors.length}}" class="mt-2 block text-sm text-[#9b897a]">暂无匹配的非遗传承人</text>
       </view>
 
       <view class="px-4 pt-4">
-        <text class="text-lg font-bold text-[#873324]">非遗保护单位</text>
+        <view class="flex items-center justify-between">
+          <text class="text-lg font-bold text-[#873324]">非遗保护单位</text>
+          <view class="py-2 pl-3 text-sm text-[#a83f2d]" data-category="units" bindtap="onMore" aria-role="button" aria-label="更多非遗保护单位">更多</view>
+        </view>
         <scroll-view class="hide-scroll mt-2.5" scroll-x>
           <view class="inline-flex gap-3 pb-2">
-            <heritage-card wx:for="{{units}}" wx:key="name" item="{{item}}" />
+            <heritage-card wx:for="{{units}}" wx:key="id" item="{{item}}" />
           </view>
         </scroll-view>
+        <text wx:if="{{!units.length}}" class="mt-2 block text-sm text-[#9b897a]">暂无匹配的非遗保护单位</text>
       </view>
 
       <view class="px-4 pt-4">
-        <text class="text-lg font-bold text-[#873324]">非遗传习中心(所)</text>
+        <view class="flex items-center justify-between">
+          <text class="text-lg font-bold text-[#873324]">非遗传习中心(所)</text>
+          <view class="py-2 pl-3 text-sm text-[#a83f2d]" data-category="centers" bindtap="onMore" aria-role="button" aria-label="更多非遗传习中心(所)">更多</view>
+        </view>
         <scroll-view class="hide-scroll mt-2.5" scroll-x>
           <view class="inline-flex gap-3 pb-2">
-            <heritage-card wx:for="{{centers}}" wx:key="name" item="{{item}}" />
+            <heritage-card wx:for="{{centers}}" wx:key="id" item="{{item}}" />
           </view>
         </scroll-view>
+        <text wx:if="{{!centers.length}}" class="mt-2 block text-sm text-[#9b897a]">暂无匹配的非遗传习中心(所)</text>
       </view>
     </view>
 
@@ -131,5 +135,4 @@
     <view class="tabbar-placeholder"></view>
   </scroll-view>
 
-  <van-toast id="van-toast" />
 </view>

+ 70 - 1
src/pages/inherit/inherit.wxss

@@ -1,4 +1,73 @@
-/* inherit */
+.inherit-stats {
+  display: flex;
+  flex-wrap: wrap;
+  row-gap: 28rpx;
+  padding: 32rpx 20rpx 24rpx;
+  background: #fffaf1;
+  border-bottom: 1rpx solid #eadcc5;
+}
+
+.inherit-stat {
+  position: relative;
+  box-sizing: border-box;
+  display: flex;
+  flex: 0 0 50%;
+  flex-direction: column;
+  align-items: center;
+  min-width: 0;
+  padding: 0 10rpx;
+  text-align: center;
+}
+
+.inherit-stat:nth-child(even)::before {
+  position: absolute;
+  top: 12rpx;
+  left: 0;
+  width: 1rpx;
+  height: 64rpx;
+  content: "";
+  background: #e8d8c2;
+}
+
+.inherit-stat:nth-child(n + 3)::after {
+  position: absolute;
+  top: -14rpx;
+  right: 0;
+  left: 0;
+  height: 1rpx;
+  content: "";
+  background: #e8d8c2;
+}
+
+.inherit-stat__amount {
+  display: flex;
+  align-items: baseline;
+  justify-content: center;
+  white-space: nowrap;
+}
+
+.inherit-stat__value {
+  font-size: 46rpx;
+  font-weight: 600;
+  font-variant-numeric: tabular-nums;
+  line-height: 1.1;
+  color: #873324;
+}
+
+.inherit-stat__unit {
+  margin-left: 4rpx;
+  font-size: 20rpx;
+  color: #a18b78;
+}
+
+.inherit-stat__label {
+  display: block;
+  margin-top: 12rpx;
+  font-size: 24rpx;
+  line-height: 32rpx;
+  color: #8d7768;
+  white-space: nowrap;
+}
 
 .hide-scroll {
   scrollbar-width: none;

+ 1 - 6
src/pages/news/news.json

@@ -2,11 +2,6 @@
   "navigationStyle": "custom",
   "usingComponents": {
     "news-header": "/components/news-header/index",
-    "news-item": "/components/news-item/index",
-    "feature-card": "/components/feature-card/index",
-    "section-header": "/components/section-header/index",
-    "svg-icon": "weapp-svg-icon/index",
-    "van-toast": "@vant/weapp/toast/index",
-    "van-dialog": "@vant/weapp/dialog/index"
+    "svg-icon": "weapp-svg-icon/index"
   }
 }

+ 93 - 204
src/pages/news/news.ts

@@ -1,239 +1,128 @@
-import Dialog from '@vant/weapp/dialog/dialog'
-import Toast from '@vant/weapp/toast/toast'
+import type { CultureItem } from '../../data/culture-content'
+import { getHomeCultureList } from '../../data/inherit-api'
+import { runRefresh } from '../../utils/refresh'
+import { getArticleDetailUrl } from '../../utils/routes'
+import { syncTabBar } from '../../utils/tab-bar'
 
-interface NewsItem {
-  icon: string
-  iconBg: string
-  iconColor: string
-  title: string
-  subtitle: string
-}
-
-interface NewsTab {
-  key: string
-  text: string
-  icon: string
-}
-
-interface FeatureItem {
-  tag: string
-  name: string
-  desc: string
-  task: string
-  icon: string
-}
-
-interface MechanismItem {
-  icon: string
-  title: string
-  desc: string
-}
-
-interface FeedbackItem {
-  icon: string
-  title: string
-  sub: string
-}
-
-interface CategoryMeta {
-  icon: string
-  iconBg: string
-  iconColor: string
-}
-
-const CATEGORY_META: Record<string, CategoryMeta> = {
-  宣传传播: { icon: 'ph:newspaper-clipping-duotone', iconBg: '#f9e5df', iconColor: '#a83f2d' },
-  非遗教育: { icon: 'ph:student-duotone', iconBg: '#fff0d8', iconColor: '#a87a27' },
-  建设动态: { icon: 'ph:house-line-duotone', iconBg: '#e8f0e7', iconColor: '#5f795d' },
-  政策法规: { icon: 'ph:scroll-duotone', iconBg: '#f2ebe3', iconColor: '#78675a' },
-}
-
-const NEWS_MAP: Record<string, [string, string][]> = {
-  宣传传播: [
-    ['专题展示:漳州非遗名录', '一览闽南文化生态保护区代表性项目'],
-    ['品牌活动持续上新', '古城灯会、南音雅集等品牌活动预告'],
-    ['闽南文化交流开启新篇', '跨区域文化交流与合作成果'],
-    ['宣传报道:守护漳州非遗', '记录传承人和保护工作一线'],
-    ['非遗宣传物料上线', '主题海报与公共文化宣传手册'],
-    ['视觉形象焕新发布', '统一保护区文化视觉识别'],
-    ['保护区标识牌更新', '古厝街巷新增文化保护指引'],
-  ],
-  非遗教育: [
-    ['“非遗在校园”工作活动开展', '传统技艺走进课堂与校园社团'],
-    ['非遗校本教材/通识读本发布', '让闽南文化成为可读的乡土教材'],
-    ['专业教育合作项目启动', '推动非遗传承与专业人才培养'],
-    ['师资队伍培训完成', '提升非遗教学与实践指导能力'],
-  ],
-  建设动态: [
-    ['古城骑楼修缮进入收尾阶段', '燕尾脊与红砖立面焕新'],
-    ['九龙江文化廊道新增三处驿站', '水岸慢行线路持续完善'],
-    ['传统村落数字档案完成更新', '新增二百余处古厝记录'],
-  ],
-  政策法规: [
-    ['文化生态保护区专项规划公示', '公众意见征集至本月底'],
-    ['非遗工坊扶持申报正式启动', '支持活态传承与创新转化'],
-    ['传统建筑保护导则发布', '明确修缮材料与工艺标准'],
-  ],
-}
-
-function buildNews(tab: string): NewsItem[] {
-  const meta = CATEGORY_META[tab] || CATEGORY_META['宣传传播']
-  return (NEWS_MAP[tab] || []).map(([title, subtitle], index) => ({
-    icon: index === 0 ? 'ph:buildings-duotone' : meta.icon,
-    iconBg: meta.iconBg,
-    iconColor: meta.iconColor,
-    title,
-    subtitle,
-  }))
-}
+const NEWS_PAGE_SIZE = 15
 
 Component({
   data: {
-    tabs: [
-      { key: '宣传传播', text: '宣传传播', icon: 'ph:megaphone-duotone' },
-      { key: '非遗教育', text: '非遗教育', icon: 'ph:student-duotone' },
-      { key: '建设动态', text: '建设动态', icon: 'ph:house-line-duotone' },
-      { key: '政策法规', text: '政策法规', icon: 'ph:scroll-duotone' },
-    ] as NewsTab[],
-
-    activeTab: '宣传传播',
+    // 暂时隐藏顶部搜索,保留开关便于恢复。
+    showHeaderActions: false,
+    refreshing: false,
     keyword: '',
-    news: buildNews('宣传传播') as NewsItem[],
-
-    festivalTitle: '古城七夕灯游会',
-    festivalCountdown: '还剩 11 天',
-
-    features: [
-      {
-        tag: '拍照出片',
-        name: '漳州古城香港路',
-        desc: '骑楼红砖与百年商铺,一步一景。',
-        task: '找到一扇燕尾脊门楼',
-        icon: 'ph:buildings-duotone',
-      },
-      {
-        tag: '亲子遛娃',
-        name: '东山南门湾',
-        desc: '沿海堤慢走,等一场橘色日落。',
-        task: '收集三种海浪声音',
-        icon: 'ph:map-pin-area-duotone',
-      },
-      {
-        tag: '小众秘境',
-        name: '埭美古村',
-        desc: '水上红砖古厝群,安静又从容。',
-        task: '辨认五种红砖纹样',
-        icon: 'ph:buildings-duotone',
-      },
-    ] as FeatureItem[],
-
-    mechanisms: [
-      {
-        icon: 'ph:buildings-duotone',
-        title: '机构建设',
-        desc: '完善保护区工作架构,明确职责边界,推动保护、传承与利用协同开展。',
-      },
-      {
-        icon: 'ph:clipboard-text-duotone',
-        title: '统筹管理',
-        desc: '建立项目清单与年度计划,统筹资源调度,持续跟进重点保护任务进度。',
-      },
-      {
-        icon: 'ph:users-three-duotone',
-        title: '专职人员',
-        desc: '配备熟悉地方文化的专职队伍,做好日常巡查、资料整理与公众服务。',
-      },
-    ] as MechanismItem[],
+    news: [] as CultureItem[],
+    failedImages: {} as Record<string, boolean>,
+    scrollTop: 0,
+    loading: false,
+    loadError: '',
+    page: 1,
+    hasMore: false,
+    requestVersion: 0,
+  },
 
-    feedback: [
-      { icon: 'ph:star-duotone', title: '我要打分', sub: '' },
-      { icon: 'ph:chat-circle-dots-duotone', title: '提个小建议', sub: '含进度查询' },
-    ] as FeedbackItem[],
+  lifetimes: {
+    attached() {
+      this.refreshNews()
+    },
+    detached() {
+      this.data.requestVersion++
+    },
   },
 
   pageLifetimes: {
     show() {
-      if (typeof this.getTabBar === 'function' && this.getTabBar()) {
-        this.getTabBar().setData({ selected: 2 })
-      }
+      syncTabBar(this)
     },
   },
 
   methods: {
     refreshNews() {
-      const activeTab = this.data.activeTab as string
-      const keyword = (this.data.keyword as string).trim()
-      let list = buildNews(activeTab)
-      if (keyword) {
-        list = list.filter(n => n.title.includes(keyword) || n.subtitle.includes(keyword))
-      }
-      this.setData({ news: list })
+      return this.loadNews(1)
     },
 
-    onSearch(e: WechatMiniprogram.CustomEvent) {
-      this.setData({ keyword: e.detail.keyword as string })
-      this.refreshNews()
+    async onPullRefresh() {
+      this.setData({ refreshing: true })
+      await runRefresh([this.loadNews(1, true)])
+      this.setData({ refreshing: false })
+    },
+
+    // refresh 为下拉刷新:保留当前列表直到新数据返回,已有内容时失败只提示不清空。
+    async loadNews(page: number, refresh = false) {
+      const requestVersion = ++this.data.requestVersion
+      const { keyword } = this.data
+      if (!refresh) {
+        if (page === 1) {
+          this.setData({ news: [], page: 1, hasMore: false, failedImages: {}, scrollTop: 0 })
+        }
+        this.setData({ loading: true, loadError: '' })
+      }
+      try {
+        // 与首页最新资讯使用相同模型和全部栏目参数。
+        const result = await getHomeCultureList('news', keyword, page, NEWS_PAGE_SIZE)
+        // 搜索后,旧请求不得覆盖新列表和分页状态。
+        if (this.data.requestVersion !== requestVersion) {
+          return
+        }
+        this.setData({
+          news: page === 1 ? result.items : [...this.data.news, ...result.items],
+          ...(refresh ? { failedImages: {} } : {}),
+          page,
+          hasMore: result.hasMore,
+          loading: false,
+          loadError: '',
+        })
+      }
+      catch (error) {
+        if (this.data.requestVersion !== requestVersion) {
+          return
+        }
+        // 刷新会作废进行中的加载更多,这里统一结束加载态。
+        if (refresh && this.data.news.length) {
+          this.setData({ loading: false })
+          throw error
+        }
+        this.setData({ loading: false, loadError: error instanceof Error ? error.message : '资讯加载失败,请稍后重试' })
+      }
     },
 
-    onTabTap(e: WechatMiniprogram.TouchEvent) {
-      const key = e.currentTarget.dataset.key as string
-      if (!key || key === this.data.activeTab) {
+    loadMoreNews() {
+      if (this.data.loading || this.data.loadError || !this.data.hasMore) {
         return
       }
-      this.setData({ activeTab: key, keyword: '' })
-      this.refreshNews()
+      return this.loadNews(this.data.page + 1)
     },
 
-    onClearSearch() {
-      this.setData({ keyword: '' })
-      this.refreshNews()
+    onRetryNews() {
+      return this.loadNews(this.data.news.length ? this.data.page + 1 : 1)
     },
 
-    onNotification() {
-      Dialog.alert({
-        title: '元宵限定推送',
-        message: '古城千盏花灯今晚亮起,猜灯谜集章可兑换限定剪纸书签。',
-        confirmButtonText: '收下灯会消息',
-      })
+    onSearch(e: WechatMiniprogram.CustomEvent) {
+      this.setData({ keyword: e.detail.keyword as string })
+      return this.refreshNews()
     },
 
-    onMoreFeature() {
-      Toast('已为你展开更多特色成果')
+    onClearSearch() {
+      this.setData({ keyword: '' })
+      return this.refreshNews()
     },
 
-    onMechanism(e: WechatMiniprogram.TouchEvent) {
-      const index = Number(e.currentTarget.dataset.index)
-      const item = (this.data.mechanisms as MechanismItem[])[index]
-      if (!item) {
-        return
+    onItemTap(e: WechatMiniprogram.TouchEvent) {
+      const id = e.currentTarget.dataset.id as string
+      if (id) {
+        wx.navigateTo({ url: getArticleDetailUrl(id) })
       }
-      Dialog.alert({
-        title: item.title,
-        message: item.desc,
-        confirmButtonText: '知道了',
-      })
     },
 
-    onFeedback(e: WechatMiniprogram.TouchEvent) {
-      const index = Number(e.currentTarget.dataset.index)
-      const item = (this.data.feedback as FeedbackItem[])[index]
-      if (!item) {
-        return
-      }
-      if (item.title === '我要打分') {
-        Dialog.alert({
-          title: '满意度问卷',
-          message: '感谢你的参与!完成问卷即可点亮“古厝守护者”徽章。',
-          confirmButtonText: '收入徽章册',
-        })
-      }
-      else {
-        Dialog.alert({
-          title: '建议反馈',
-          message: '你的建议已记录,可在“我的”页查看处理进度。',
-          confirmButtonText: '知道了',
-        })
-      }
+    onImageError(e: WechatMiniprogram.CustomEvent) {
+      const id = e.currentTarget.dataset.id as string
+      this.setData({ [`failedImages.${id}`]: true })
+    },
+
+    onListScroll(e: WechatMiniprogram.CustomEvent) {
+      // 记录实际位置,使搜索后的 scrollTop: 0 能触发滚动复位。
+      this.data.scrollTop = e.detail.scrollTop
     },
   },
 })

+ 34 - 93
src/pages/news/news.wxml

@@ -1,105 +1,46 @@
 <view class="h-screen flex flex-col paper">
-  <news-header value="{{keyword}}" bind:search="onSearch" bind:notification="onNotification" />
-
-  <scroll-view class="flex-1 min-h-0" scroll-y>
-    <view class="px-4 pt-4">
-      <scroll-view class="hide-scroll" scroll-x>
-        <view class="inline-flex gap-2 whitespace-nowrap">
-          <view
-            wx:for="{{tabs}}"
-            wx:key="key"
-            class="inline-flex items-center gap-1.5 rounded-full border px-3 py-2 text-sm {{activeTab === item.key ? 'bg-[#a83f2d] text-white border-[#a83f2d]' : 'bg-white text-[#765f52] border-[#e4d0b2]'}}"
-            data-key="{{item.key}}"
-            bindtap="onTabTap"
-          >
-            <svg-icon name="{{item.icon}}" size="14px" color="{{activeTab === item.key ? '#ffffff' : '#765f52'}}" />
-            <text>{{item.text}}</text>
+  <news-header show-actions="{{showHeaderActions}}" value="{{keyword}}" bind:search="onSearch" />
+
+  <scroll-view class="flex-1 min-h-0" scroll-y scroll-top="{{scrollTop}}" bindscroll="onListScroll" bindscrolltolower="loadMoreNews" show-scrollbar="{{false}}" refresher-enabled="{{true}}" refresher-triggered="{{refreshing}}" bindrefresherrefresh="onPullRefresh">
+    <view class="news-content">
+      <view class="news-list">
+        <view wx:for="{{news}}" wx:key="id" class="news-card" data-id="{{item.id}}" bindtap="onItemTap" hover-class="news-card--pressed" aria-role="button" aria-label="查看{{item.title}}详情">
+          <view class="news-card__cover">
+            <view class="news-card__fallback">
+              <svg-icon name="ph:newspaper-clipping-duotone" size="32px" color="#b59b77" />
+              <text wx:if="{{!item.image || failedImages[item.id]}}">资讯</text>
+            </view>
+            <image
+              wx:if="{{item.image && !failedImages[item.id]}}"
+              class="news-card__image"
+              src="{{item.image}}"
+              mode="aspectFill"
+              lazy-load
+              data-id="{{item.id}}"
+              binderror="onImageError"
+              aria-label="{{item.title}}"
+            />
           </view>
-        </view>
-      </scroll-view>
-
-      <view class="mt-3 flex items-center justify-between rounded-lg border border-[#e6c98f] bg-[#9d3829] px-3 py-2 text-white">
-        <view class="flex items-center gap-2 text-sm">
-          <svg-icon name="ph:lightbulb-duotone" size="19px" color="#f5d390" />
-          <text>{{festivalTitle}}</text>
-        </view>
-        <text class="text-sm font-bold text-[#f8dda2]">{{festivalCountdown}}</text>
-      </view>
-
-      <view class="mt-2 overflow-hidden rounded-2xl border border-[#eadcc5] bg-white divide-y divide-[#f0e6d6]">
-        <news-item wx:for="{{news}}" wx:key="title" item="{{item}}" bold="{{true}}" />
-        <view wx:if="{{!news.length}}" class="px-5 py-14 text-center">
-          <view class="mx-auto w-28 h-24 rounded-lg bg-[#f2dfc1] flex items-center justify-center text-[#a83f2d]">
-            <svg-icon name="ph:map-pin-line-duotone" size="48px" color="#a83f2d" />
+          <view class="news-card__body">
+            <text class="news-card__title">{{item.title}}</text>
+            <text class="news-card__description">{{item.description}}</text>
+            <view class="news-card__meta">
+              <text wx:if="{{item.tag}}" class="news-card__tag">{{item.tag}}</text>
+              <text wx:if="{{item.date}}" class="news-card__date">{{item.date}}</text>
+            </view>
           </view>
-          <text class="block mt-4 text-md font-bold text-[#78473b]">这条巷子暂时没有线索</text>
-          <text class="block mt-1 text-sm text-[#9a8273]">换个关键词吧,好料总在下一转角。</text>
-          <view class="mt-4 inline-block rounded bg-[#a83f2d] px-4 py-2 text-xs text-white" bindtap="onClearSearch">看看全部</view>
-        </view>
-      </view>
-    </view>
-
-    <view class="mx-4 my-5 flex items-center gap-2 text-[#b68635]">
-      <view class="h-px flex-1 bg-[#dbbd83]"></view>
-      <svg-icon name="ph:boat-duotone" size="25px" color="#b68635" />
-      <svg-icon name="ph:lightbulb-duotone" size="20px" color="#b68635" />
-      <view class="h-px flex-1 bg-[#dbbd83]"></view>
-    </view>
-
-    <view class="px-4">
-      <section-header title="特色推荐" barColor="#8f3426" moreText="查看更多" bind:more="onMoreFeature" />
-    </view>
-    <scroll-view class="mt-3" scroll-x>
-      <view class="inline-flex gap-3 pl-4 pr-4">
-        <feature-card wx:for="{{features}}" wx:key="name" item="{{item}}" />
-      </view>
-    </scroll-view>
-
-    <view class="mx-4 my-5 flex items-center gap-2 text-[#a83f2d]">
-      <view class="h-px flex-1 bg-[#dec496]"></view>
-      <svg-icon name="ph:buildings-duotone" size="25px" color="#a83f2d" />
-      <view class="h-px flex-1 bg-[#dec496]"></view>
-    </view>
-
-    <view class="mx-4 mt-2 rounded-xl border border-[#d8ba7d] bg-[#fffaf0] p-4 relative overflow-hidden">
-      <text class="block text-lg font-bold text-[#803426]">工作机制</text>
-      <text class="block mt-1 text-xs text-[#8f7564]">把文化保护落到机构、管理与人才的每一步。</text>
-      <view class="mt-3 grid grid-cols-3 gap-2">
-        <view
-          wx:for="{{mechanisms}}"
-          wx:key="title"
-          class="flex flex-col items-center rounded-lg border border-[#e0c58e] bg-[#fdf1d9] px-1 py-3 text-[#8d3829]"
-          data-index="{{index}}"
-          bindtap="onMechanism"
-        >
-          <svg-icon name="{{item.icon}}" size="22px" color="#8d3829" />
-          <text class="mt-1 block text-xs font-bold">{{item.title}}</text>
-          <text class="mt-1 block text-[8px] text-[#9b806e]">查看详情</text>
         </view>
       </view>
-    </view>
 
-    <view class="mx-4 mt-2 rounded-xl border border-[#d8ba7d] bg-[#f5e4c6] p-4 relative overflow-hidden">
-      <text class="block text-lg font-bold text-[#803426]">意见反馈</text>
-      <text class="block mt-1 text-xs text-[#8f7564]">一盏茶的时间,一起把保护区变得更好。</text>
-      <view class="mt-4 grid grid-cols-2 gap-3">
-        <view
-          wx:for="{{feedback}}"
-          wx:key="title"
-          class="flex flex-col items-center rounded-lg border border-[#caa459] bg-[#fff9ed] py-3 text-[#8d3829]"
-          data-index="{{index}}"
-          bindtap="onFeedback"
-        >
-          <svg-icon name="{{item.icon}}" size="22px" color="#8d3829" />
-          <text class="mt-1 block text-sm font-bold">{{item.title}}</text>
-          <text wx:if="{{item.sub}}" class="mt-0.5 block text-xs text-[#9b806e]">{{item.sub}}</text>
-        </view>
+      <view wx:if="{{loading}}" class="news-list-status">资讯加载中...</view>
+      <view wx:elif="{{loadError}}" class="news-list-status" bindtap="onRetryNews">{{loadError}},点击重试</view>
+      <view wx:elif="{{!news.length}}" class="news-empty">
+        <text class="news-empty__title">{{keyword ? '暂时没有找到相关资讯' : '暂无资讯,稍后再来看看。'}}</text>
+        <view wx:if="{{keyword}}" class="news-empty__action" aria-role="button" bindtap="onClearSearch">查看全部资讯</view>
       </view>
+      <view wx:else class="news-list-status" bindtap="loadMoreNews">{{hasMore ? '点击加载更多' : '已展示全部资讯'}}</view>
     </view>
 
     <view class="tabbar-placeholder"></view>
   </scroll-view>
-
-  <van-toast id="van-toast" />
-  <van-dialog id="van-dialog" />
 </view>

+ 132 - 4
src/pages/news/news.wxss

@@ -7,10 +7,138 @@
   background-size: 20px 20px, 27px 27px;
 }
 
-.hide-scroll {
-  scrollbar-width: none;
+.news-content {
+  padding: 16px 16px calc(24px + env(safe-area-inset-bottom, 0px));
 }
 
-.hide-scroll::-webkit-scrollbar {
-  display: none;
+.news-list {
+  display: flex;
+  flex-direction: column;
+  gap: 12px;
+}
+
+.news-card {
+  display: flex;
+  gap: 13px;
+  padding: 12px;
+  background: #fffdfa;
+  border: 1px solid #eadcc5;
+  border-radius: 16px;
+  box-shadow: 0 2px 8px rgb(117 60 43 / 3%);
+}
+
+.news-card__cover {
+  position: relative;
+  flex: none;
+  width: 100px;
+  height: 112px;
+  overflow: hidden;
+  background: #eee2ce;
+  border-radius: 10px;
+}
+
+.news-card--pressed {
+  background: #f6efdf;
+}
+
+.news-card__fallback {
+  display: flex;
+  flex-direction: column;
+  gap: 8px;
+  align-items: center;
+  justify-content: center;
+  height: 100%;
+  font-size: 11px;
+  color: #a48a66;
+}
+
+.news-card__image {
+  position: absolute;
+  inset: 0;
+  width: 100%;
+  height: 100%;
+}
+
+.news-card__body {
+  display: flex;
+  flex: 1;
+  flex-direction: column;
+  min-width: 0;
+}
+
+.news-card__title,
+.news-card__description {
+  display: -webkit-box;
+  overflow: hidden;
+  -webkit-box-orient: vertical;
+  -webkit-line-clamp: 2;
+}
+
+.news-card__title {
+  font-size: 15px;
+  font-weight: 600;
+  line-height: 1.5;
+  color: #593e31;
+}
+
+.news-card__description {
+  margin-top: 6px;
+  font-size: 12px;
+  line-height: 1.65;
+  color: #93816f;
+}
+
+.news-card__meta {
+  display: flex;
+  flex-wrap: wrap;
+  gap: 6px;
+  align-items: center;
+  justify-content: space-between;
+  padding-top: 10px;
+  margin-top: auto;
+}
+
+.news-card__tag {
+  padding: 2px 6px;
+  font-size: 10px;
+  line-height: 16px;
+  color: #927346;
+  background: #f6efdf;
+  border-radius: 4px;
+}
+
+.news-card__date {
+  font-size: 10px;
+  color: #a2917f;
+}
+
+.news-empty {
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  padding: 48px 12px;
+  text-align: center;
+}
+
+.news-list-status {
+  padding: 20px 12px;
+  font-size: 12px;
+  color: #93816f;
+  text-align: center;
+}
+
+.news-empty__title {
+  margin-top: 20px;
+  font-size: 16px;
+  font-weight: 600;
+  color: #78473b;
+}
+
+.news-empty__action {
+  padding: 10px 20px;
+  margin-top: 20px;
+  font-size: 12px;
+  color: #fffaf1;
+  background: #a83f2d;
+  border-radius: 20px;
 }

+ 2 - 4
src/pages/travel/travel.json

@@ -2,10 +2,8 @@
   "navigationStyle": "custom",
   "usingComponents": {
     "travel-header": "/components/travel-header/index",
-    "route-card": "/components/route-card/index",
+    "recommend-card": "/components/recommend-card/index",
     "section-header": "/components/section-header/index",
-    "svg-icon": "weapp-svg-icon/index",
-    "van-toast": "@vant/weapp/toast/index",
-    "van-dialog": "@vant/weapp/dialog/index"
+    "van-toast": "@vant/weapp/toast/index"
   }
 }

+ 158 - 203
src/pages/travel/travel.ts

@@ -1,250 +1,205 @@
-import Dialog from '@vant/weapp/dialog/dialog'
+import type { CultureMapMarker, CultureMapPoint } from '../../data/culture-map'
 import Toast from '@vant/weapp/toast/toast'
-
-interface Layer {
-  name: string
-}
-
-interface Mode {
-  name: string
-}
-
-interface Spot {
-  icon: string
-  size: string
-  label: string
-  color: string
-  left: string
-  top: string
-  type: 'spot' | 'nav'
-  name: string
-  hours?: string
-  ticket?: string
-  stamp?: string
-}
-
-interface RouteItem {
-  icon: string
+import { getCultureListUrl } from '../../data/culture-content'
+import { getCultureMapData, getCultureMapMarkers } from '../../data/culture-map'
+import { getHomeCultureList, getVillageList } from '../../data/inherit-api'
+import { runRefresh } from '../../utils/refresh'
+import { VILLAGE_LIST_PAGE } from '../../utils/routes'
+import { syncTabBar } from '../../utils/tab-bar'
+
+interface HeritagePreviewItem {
+  id: string
+  image: string
+  imageBg: string
   title: string
-  desc: string
 }
 
-interface HeritageItem {
-  icon: string
+interface HeritageSection {
+  key: 'villages' | 'workshops'
   title: string
-  desc: string
-  action: string
-}
-
-interface StayItem {
-  title: string
-  desc: string
+  path: string
+  items: HeritagePreviewItem[]
+  loading: boolean
+  loadError: string
+  requestVersion: number
 }
 
 Component({
   data: {
-    layers: [
-      { name: '古城人文' },
-      { name: '世遗土楼' },
-      { name: '东山滨海' },
-      { name: '闽南美食' },
-    ] as Layer[],
-
-    activeLayer: '古城人文',
-
-    modes: [
-      { name: '步行' },
-      { name: '自驾' },
-    ] as Mode[],
-
-    activeMode: '步行',
-
-    spots: [
+    refreshing: false,
+    mapLongitude: 117.647,
+    mapLatitude: 24.513,
+    mapScale: 11,
+    mapMarkers: [] as CultureMapMarker[],
+    mapPoints: [] as CultureMapPoint[],
+    mapIncludePoints: [] as { longitude: number, latitude: number }[],
+    selectedPoint: null as CultureMapPoint | null,
+    mapLoading: true,
+    requestVersion: 0,
+
+    heritageSections: [
       {
-        icon: 'ph:buildings-fill',
-        size: '29px',
-        label: '土楼',
-        color: '#a83f2d',
-        left: '15%',
-        top: '26%',
-        type: 'spot',
-        name: '土楼',
-        hours: '09:00-17:30',
-        ticket: '免费',
-        stamp: '土楼手绘章',
-      },
-      {
-        icon: 'ph:bank-fill',
-        size: '29px',
-        label: '文庙',
-        color: '#a83f2d',
-        left: '51%',
-        top: '27%',
-        type: 'spot',
-        name: '漳州文庙',
-        hours: '08:30-18:00',
-        ticket: '免费',
-        stamp: '文脉印记',
-      },
-      {
-        icon: 'ph:boat-fill',
-        size: '30px',
-        label: '漳船',
-        color: '#287b8e',
-        left: '68%',
-        top: '57%',
-        type: 'nav',
-        name: '漳州古城水岸',
-      },
-      {
-        icon: 'ph:bowl-food-fill',
-        size: '28px',
-        label: '卤面',
-        color: '#a65b2d',
-        left: '32%',
-        top: '64%',
-        type: 'nav',
-        name: '古城美食街',
-      },
-      {
-        icon: 'ph:leaf-fill',
-        size: '28px',
-        label: '木偶戏',
-        color: '#4c8c61',
-        left: '52%',
-        top: '64%',
-        type: 'nav',
-        name: '木偶戏馆',
-      },
-    ] as Spot[],
-
-    routes: [
-      { icon: 'ph:buildings-duotone', title: '古城逛吃一日线', desc: '文庙 + 牌坊 + 木偶戏 + 小吃老街' },
-      { icon: 'ph:camera-duotone', title: '土楼风光摄影线', desc: '田螺坑四菜一汤 + 云水谣古榕' },
-      { icon: 'ph:waves-duotone', title: '东山滨海治愈线', desc: '苏峰山环岛 + 南门湾 + 赶海沙滩' },
-      { icon: 'ph:student-duotone', title: '亲子民俗研学线', desc: '香蕉海 + 埭美古村 + 手工体验' },
-    ] as RouteItem[],
-
-    heritages: [
-      {
-        icon: 'ph:buildings-duotone',
+        key: 'villages',
         title: '特色村镇/街区',
-        desc: '古城骑楼、牌坊街与红砖古厝,边走边看闽南生活。',
-        action: '查看街区亮点',
+        path: VILLAGE_LIST_PAGE,
+        items: [],
+        loading: true,
+        loadError: '',
+        requestVersion: 0,
       },
       {
-        icon: 'ph:house-line-duotone',
+        key: 'workshops',
         title: '非遗工坊',
-        desc: '汇集各地非遗工坊资源,呈现传统技艺生产、展示与体验空间。',
-        action: '探索非遗工坊',
+        path: getCultureListUrl('workshops'),
+        items: [],
+        loading: true,
+        loadError: '',
+        requestVersion: 0,
       },
-    ] as HeritageItem[],
+    ] as HeritageSection[],
+  },
 
-    stays: [
-      { title: '古城古厝民宿', desc: '红砖墙风格·看图选房' },
-      { title: '土楼山间小院', desc: '推窗见山·看图选房' },
-      { title: '东山海景客栈', desc: '枕着海浪眠·看图选房' },
-    ] as StayItem[],
+  lifetimes: {
+    attached() {
+      // 只在首次进入时加载,之后由用户下拉刷新获取最新数据。
+      this.loadCultureMap()
+      this.data.heritageSections.forEach((_, index) => this.loadHeritageSection(index))
+    },
+    detached() {
+      this.data.requestVersion++
+      this.data.heritageSections.forEach((section) => {
+        section.requestVersion++
+      })
+    },
   },
 
   pageLifetimes: {
     show() {
-      if (typeof this.getTabBar === 'function' && this.getTabBar()) {
-        this.getTabBar().setData({ selected: 3 })
-      }
+      syncTabBar(this)
     },
   },
 
   methods: {
-    onSearch(e: WechatMiniprogram.CustomEvent) {
-      const keyword = ((e.detail.keyword as string) || '').trim()
-      if (!keyword) {
-        Toast('试试搜索:古城、土楼、卤面、木偶或海景房')
-        return
-      }
-      const types = ['景点', '美食', '民宿', '活动']
-      const type = types[Math.floor(Math.random() * types.length)]
-      Toast(`为你找到 8 个与“${keyword}”相关的${type}结果`)
+    async onPullRefresh() {
+      this.setData({ refreshing: true })
+      await runRefresh([
+        this.loadCultureMap(true, true),
+        ...this.data.heritageSections.map((_, index) => this.loadHeritageSection(index, true)),
+      ])
+      this.setData({ refreshing: false })
     },
 
-    onLocate() {
-      Toast('定位成功:漳州古城中山公园,已更新附近点位')
+    onRefreshMap() {
+      // 手动刷新跳过缓存,直接从接口重新拉取点位。
+      return this.loadCultureMap(true)
     },
 
-    onLayerTap(e: WechatMiniprogram.TouchEvent) {
-      const name = e.currentTarget.dataset.name as string
-      if (!name) {
-        return
+    // force 跳过接口缓存;refresh 为下拉刷新:保留地图视野,已有点位时失败只提示不清空。
+    async loadCultureMap(force = false, refresh = false) {
+      const requestVersion = ++this.data.requestVersion
+      if (!refresh) {
+        this.setData({ mapLoading: true, selectedPoint: null })
       }
-      this.setData({ activeLayer: name })
-      Toast(`已切换:${name}`)
-    },
-
-    onModeTap(e: WechatMiniprogram.TouchEvent) {
-      const name = e.currentTarget.dataset.name as string
-      if (!name) {
-        return
+      try {
+        const { points } = await getCultureMapData(force)
+        if (requestVersion !== this.data.requestVersion) {
+          return
+        }
+        if (refresh && this.data.mapPoints.length) {
+          // 标记 id 按顺序生成,点位变化后原选中项可能对不上,刷新后清除选中。
+          this.setData({
+            mapPoints: points,
+            mapMarkers: getCultureMapMarkers(points),
+            selectedPoint: null,
+            mapLoading: false,
+          })
+          return
+        }
+        this.setData({
+          mapPoints: points,
+          mapMarkers: getCultureMapMarkers(points),
+          mapLongitude: points[0]?.longitude ?? 117.647,
+          mapLatitude: points[0]?.latitude ?? 24.513,
+          mapScale: points.length ? 14 : 11,
+          // 多点自动适配全部坐标;单点保留街区级视野,避免自动放到最高级别。
+          mapIncludePoints: points.length > 1 ? points.map(({ longitude, latitude }) => ({ longitude, latitude })) : [],
+          mapLoading: false,
+        })
       }
-      this.setData({ activeMode: name })
-      Toast(`路线模式已切换为${name}`)
-    },
-
-    onSpotTap(e: WechatMiniprogram.TouchEvent) {
-      const index = Number(e.currentTarget.dataset.index)
-      const spot = (this.data.spots as Spot[])[index]
-      if (!spot) {
-        return
+      catch (error) {
+        if (requestVersion !== this.data.requestVersion) {
+          return
+        }
+        this.setData({ mapLoading: false })
+        if (refresh && this.data.mapPoints.length) {
+          throw error
+        }
+        Toast(error instanceof Error ? error.message : '文化场所加载失败,请稍后重试')
       }
-      if (spot.type === 'nav') {
-        Toast(`已规划前往“${spot.name}”的最佳路线`)
-        return
-      }
-      Dialog.confirm({
-        title: spot.name,
-        message: `开放时间:${spot.hours}\n门票:${spot.ticket}\n\n抵达后自动领取:${spot.stamp}`,
-        confirmButtonText: '一键导航',
-        cancelButtonText: '预约入口',
-      }).then(() => {
-        Toast(`已规划前往“${spot.name}”的最佳路线`)
-      }).catch(() => {
-        Toast(`已打开${spot.name}预约入口`)
-      })
     },
 
-    onMapNav() {
-      Toast(`已规划前往“${this.data.activeLayer}”点位的最佳路线`)
-    },
-
-    onMoreHeritage() {
-      Toast('非遗特色已为你展开')
+    onMarkerTap(e: WechatMiniprogram.CustomEvent<{ markerId: number }>) {
+      const markerId = Number(e.detail.markerId)
+      const index = this.data.mapMarkers.findIndex(marker => marker.id === markerId)
+      if (index !== -1) {
+        this.setData({ selectedPoint: this.data.mapPoints[index] })
+      }
     },
 
-    onMoreStay() {
-      Toast('更多非遗特色住宿正在加载')
+    onMapTap() {
+      this.setData({ selectedPoint: null })
     },
 
-    onHeritageAction(e: WechatMiniprogram.TouchEvent) {
-      const index = Number(e.currentTarget.dataset.index)
-      const item = (this.data.heritages as HeritageItem[])[index]
-      if (!item) {
+    // refresh 为下拉刷新:跳过村镇缓存,不切换到加载态,已有内容时失败只提示不清空。
+    async loadHeritageSection(index: number, refresh = false) {
+      const section = this.data.heritageSections[index]
+      if (!section) {
         return
       }
-      Toast(`已打开${item.title}详情`)
+      const requestVersion = ++section.requestVersion
+      const dataPath = `heritageSections[${index}]`
+      if (!refresh) {
+        this.setData({ [`${dataPath}.loading`]: true, [`${dataPath}.loadError`]: '' })
+      }
+      try {
+        // 村镇接口返回全量数组;工坊接口支持分页,两者均只展示前四条真实内容。
+        const items = section.key === 'villages'
+          ? await getVillageList(refresh)
+          : (await getHomeCultureList('workshops', '', 1, 4)).items
+        if (requestVersion !== this.data.heritageSections[index].requestVersion) {
+          return
+        }
+        this.setData({
+          [`${dataPath}.items`]: items.slice(0, 4).map(({ id, image, title }) => ({ id, image, title, imageBg: '#f2ebe3' })),
+          [`${dataPath}.loading`]: false,
+          [`${dataPath}.loadError`]: '',
+        })
+      }
+      catch (error) {
+        if (requestVersion === this.data.heritageSections[index].requestVersion) {
+          const current = this.data.heritageSections[index]
+          if (refresh && current.items.length && !current.loadError) {
+            throw error
+          }
+          this.setData({
+            [`${dataPath}.loading`]: false,
+            [`${dataPath}.loadError`]: error instanceof Error ? error.message : '内容加载失败,请稍后重试',
+          })
+        }
+      }
     },
 
-    onStayBook(e: WechatMiniprogram.TouchEvent) {
+    onRetryHeritage(e: WechatMiniprogram.TouchEvent) {
+      return this.loadHeritageSection(Number(e.currentTarget.dataset.index))
+    },
+
+    onMoreHeritage(e: WechatMiniprogram.CustomEvent) {
       const index = Number(e.currentTarget.dataset.index)
-      const item = (this.data.stays as StayItem[])[index]
-      if (!item) {
+      const section = this.data.heritageSections[index]
+      if (!section) {
         return
       }
-      Dialog.alert({
-        title: '特色住宿',
-        message: `${item.title}\n可查看庭院、房型与窗景照片,当前周末尚有余房。\n\n到店前 24 小时可免费取消`,
-        confirmButtonText: '选择房型并预订',
-      }).then(() => {
-        Toast('预订信息已提交')
-      })
+      wx.navigateTo({ url: section.path })
     },
   },
 })

+ 33 - 112
src/pages/travel/travel.wxml

@@ -1,128 +1,50 @@
 <view class="h-screen flex flex-col bg-[#f9f3e7]">
-  <travel-header bind:search="onSearch" />
+  <travel-header />
 
-  <scroll-view class="flex-1 min-h-0" scroll-y>
+  <scroll-view class="flex-1 min-h-0" scroll-y refresher-enabled="{{true}}" refresher-triggered="{{refreshing}}" bindrefresherrefresh="onPullRefresh">
     <view class="pb-5">
       <view class="mt-5 px-4">
         <view class="flex items-end justify-between">
           <text class="text-lg font-bold text-[#843428]">文化地图</text>
-          <view class="flex items-center gap-1 text-xs text-[#a83f2d]" bindtap="onLocate">
-            <svg-icon name="ph:navigation-arrow" size="14px" color="#a83f2d" />
-            <text>自动定位</text>
-          </view>
+          <text class="text-xs text-[#a83f2d]" bindtap="onRefreshMap">{{mapLoading ? '刷新中…' : '刷新'}}</text>
         </view>
 
-        <scroll-view class="hide-scroll mt-3" scroll-x>
-          <view class="inline-flex gap-2 whitespace-nowrap">
-            <view
-              wx:for="{{layers}}"
-              wx:key="name"
-              class="shrink-0 rounded-full px-3 py-1.5 text-xs {{activeLayer === item.name ? 'bg-[#a83f2d] text-white' : 'border border-[#dcc598] text-[#765c4c]'}}"
-              data-name="{{item.name}}"
-              bindtap="onLayerTap"
-            >
-              {{item.name}}
-            </view>
-          </view>
-        </scroll-view>
-
-        <view class="map-paper relative mt-3 h-[250px] overflow-hidden rounded-2xl border border-[#d7a94e] p-3">
-          <view class="flex items-center justify-between">
-            <text class="rounded-md bg-white/90 px-2 py-1 text-xs text-[#765c4c]">{{activeLayer}}图层</text>
-            <view class="flex overflow-hidden rounded-md border border-[#c08a43] bg-white/90 text-xs">
-              <view
-                wx:for="{{modes}}"
-                wx:key="name"
-                class="px-2 py-1.5 {{activeMode === item.name ? 'bg-[#a83f2d] text-white' : 'text-[#765c4c]'}}"
-                data-name="{{item.name}}"
-                bindtap="onModeTap"
-              >
-                {{item.name}}
-              </view>
-            </view>
-          </view>
-
-          <view
-            wx:for="{{spots}}"
-            wx:key="label"
-            class="absolute flex flex-col items-center"
-            style="left: {{item.left}}; top: {{item.top}};"
-            data-index="{{index}}"
-            bindtap="onSpotTap"
-          >
-            <svg-icon name="{{item.icon}}" size="{{item.size}}" color="{{item.color}}" />
-            <text class="mt-1 rounded bg-white/90 px-1 text-xs">{{item.label}}</text>
-          </view>
-
-          <view
-            class="absolute bottom-3 right-3 flex items-center gap-1 rounded-full bg-[#a83f2d] px-3 py-1.5 text-xs text-white shadow"
-            bindtap="onMapNav"
-          >
-            <svg-icon name="ph:map-pin-line" size="12px" color="#ffffff" />
-            <text>导航</text>
-          </view>
+        <view class="culture-map mt-3 overflow-hidden rounded-2xl border border-[#d7a94e]">
+          <map
+            id="culture-map"
+            class="culture-map-canvas"
+            longitude="{{mapLongitude}}"
+            latitude="{{mapLatitude}}"
+            scale="{{mapScale}}"
+            markers="{{mapMarkers}}"
+            include-points="{{mapIncludePoints}}"
+            enable-scroll="{{true}}"
+            enable-zoom="{{true}}"
+            enable-rotate="{{false}}"
+            show-scale="{{true}}"
+            bindmarkertap="onMarkerTap"
+            bindcallouttap="onMarkerTap"
+            bindtap="onMapTap"
+          />
         </view>
-      </view>
-
-      <view class="mt-6">
-        <view class="flex items-center justify-between px-4">
-          <text class="text-lg font-bold text-[#843428]">主题路线</text>
-          <text class="text-xs text-[#a47c45]">向左滑动,查看更多路线</text>
+        <view wx:if="{{selectedPoint}}" class="mt-3 rounded-xl border border-[#dec18b] bg-white p-3">
+          <text class="block text-sm font-bold text-[#673d33]">{{selectedPoint.name}}</text>
+          <text wx:if="{{selectedPoint.address}}" class="mt-1 block text-xs text-[#8d7768]">{{selectedPoint.address}}</text>
         </view>
-        <scroll-view class="hide-scroll mt-3" scroll-x>
-          <view class="inline-flex gap-3 px-4">
-            <route-card wx:for="{{routes}}" wx:key="title" item="{{item}}" />
-          </view>
-        </scroll-view>
       </view>
 
-      <view class="mt-6 px-4">
-        <section-header title="非遗特色" barColor="#843428" moreText="查看更多" bind:more="onMoreHeritage" />
-        <view class="mt-3 space-y-3">
-          <view
-            wx:for="{{heritages}}"
-            wx:key="title"
-            class="rounded-2xl border border-[#dec18b] bg-white p-3 shadow-sm"
-          >
-            <view class="flex items-center gap-3">
-              <view class="h-11 w-11 shrink-0 rounded-xl bg-[#f2dfba] flex items-center justify-center">
-                <svg-icon name="{{item.icon}}" size="25px" color="#9a3b2d" />
-              </view>
-              <view class="min-w-0 flex-1">
-                <text class="block text-sm font-bold text-[#673d33]">{{item.title}}</text>
-                <text class="mt-1 block text-xs leading-4 text-[#8d7768]">{{item.desc}}</text>
-              </view>
-            </view>
-            <view
-              class="mt-3 w-full rounded-lg bg-[#f4e4c7] py-2 text-center text-xs text-[#9a3b2d]"
-              data-index="{{index}}"
-              bindtap="onHeritageAction"
-            >
-              {{item.action}}
-            </view>
-          </view>
+      <view wx:for="{{heritageSections}}" wx:for-item="section" wx:for-index="sectionIndex" wx:key="key" class="mt-5">
+        <view class="px-4">
+          <section-header title="{{section.title}}" barColor="#843428" moreText="更多" data-index="{{sectionIndex}}" bind:more="onMoreHeritage" />
         </view>
-      </view>
-
-      <view class="mt-6 px-4">
-        <section-header title="非遗特色住宿" barColor="#843428" moreText="查看更多" bind:more="onMoreStay" />
-        <view class="mt-3 space-y-2">
-          <view
-            wx:for="{{stays}}"
-            wx:key="title"
-            class="rounded-2xl border border-[#dec18b] bg-[#f4e4c7] p-3 shadow-sm"
-          >
-            <text class="block text-sm font-bold text-[#673d33]">{{item.title}}</text>
-            <text class="mt-1 block text-xs leading-4 text-[#8d7768]">{{item.desc}}</text>
-            <view
-              class="mt-2 inline-block text-xs text-[#a83f2d]"
-              data-index="{{index}}"
-              bindtap="onStayBook"
-            >
-              在线预订
-            </view>
+        <view wx:if="{{section.loading}}" class="mx-4 mt-3 px-3 py-5 text-center text-xs text-[#9a8c82]">内容加载中...</view>
+        <view wx:elif="{{section.loadError}}" class="mx-4 mt-3 px-3 py-5 text-center text-xs text-[#9a8c82]" data-index="{{sectionIndex}}" bindtap="onRetryHeritage">{{section.loadError}},点击重试</view>
+        <view wx:elif="{{!section.items.length}}" class="mx-4 mt-3 px-3 py-5 text-center text-xs text-[#9a8c82]">暂无{{section.title}}内容</view>
+        <scroll-view wx:else class="mt-3" scroll-x>
+          <view class="inline-flex gap-3 pl-4 pr-4">
+            <recommend-card wx:for="{{section.items}}" wx:key="id" item="{{item}}" clickable="{{section.key === 'workshops'}}" />
           </view>
-        </view>
+        </scroll-view>
       </view>
 
       <view class="tabbar-placeholder"></view>
@@ -130,5 +52,4 @@
   </scroll-view>
 
   <van-toast id="van-toast" />
-  <van-dialog id="van-dialog" />
 </view>

+ 8 - 6
src/pages/travel/travel.wxss

@@ -1,10 +1,12 @@
-/* travel */
-
-.map-paper {
+.culture-map {
+  height: 500rpx;
   background-color: #f5e8c9;
-  background-image: radial-gradient(circle at 20% 25%, #b9d2ad 0 25px, transparent 26px),
-    radial-gradient(circle at 74% 66%, #b8d6df 0 39px, transparent 40px),
-    linear-gradient(28deg, transparent 47%, rgb(175 107 60 / 18%) 48% 50%, transparent 51%);
+}
+
+.culture-map-canvas {
+  display: block;
+  width: 100%;
+  height: 100%;
 }
 
 .hide-scroll {

+ 2 - 3
src/pages/user/user.json

@@ -2,10 +2,9 @@
   "navigationStyle": "custom",
   "usingComponents": {
     "profile-header": "/components/profile-header/index",
-    "favorites-panel": "/components/favorites-panel/index",
-    "menu-item": "/components/menu-item/index",
     "svg-icon": "weapp-svg-icon/index",
     "van-toast": "@vant/weapp/toast/index",
-    "van-dialog": "@vant/weapp/dialog/index"
+    "van-dialog": "@vant/weapp/dialog/index",
+    "van-popup": "@vant/weapp/popup/index"
   }
 }

+ 206 - 60
src/pages/user/user.ts

@@ -1,97 +1,243 @@
 import Dialog from '@vant/weapp/dialog/dialog'
 import Toast from '@vant/weapp/toast/toast'
+import { getUserSession, loginWithWeChat, logoutUser, needsUserProfile, saveUserProfile } from '../../data/user-api'
+import { FAVORITES_PAGE } from '../../utils/routes'
+import { syncTabBar } from '../../utils/tab-bar'
 
-interface SettingItem {
-  icon: string
-  title: string
-  subtitle: string
+function showUserToast(message: string, success = false) {
+  // 自定义 TabBar 的层级是 9999,弹窗和提示需要覆盖它。
+  Toast({ message, type: success ? 'success' : 'text', zIndex: 10002 })
 }
 
 Component({
   data: {
-    nickname: '燕尾巷游客',
-    avatarIcon: 'ph:user-circle-duotone',
-    avatarIcons: ['ph:user-circle-duotone', 'ph:smiley-duotone', 'ph:flower-lotus-duotone'],
-    avatarIndex: 0,
-
-    settings: [
-      { icon: 'ph:pen-nib-duotone', title: '我的投稿', subtitle: '记录我与闽南文化的故事' },
-      { icon: 'ph:user-plus-duotone', title: '邀请好友', subtitle: '分享闽南文化之旅' },
-      { icon: 'ph:headset-duotone', title: '在线客服', subtitle: '获取实时人工服务' },
-      { icon: 'ph:shield-check-duotone', title: '隐私设置', subtitle: '管理授权、位置与消息权限' },
-      { icon: 'ph:broom-duotone', title: '清除缓存', subtitle: '当前缓存 18.6 MB' },
-      { icon: 'ph:info-duotone', title: '关于小程序', subtitle: '漳州文旅公共服务平台' },
-    ] as SettingItem[],
+    nickname: '未登录',
+    avatar: '',
+    loggedIn: false,
+    loggingIn: false,
+    loginConfirmOpen: false,
+    profileEditorOpen: false,
+    profileFirstTime: false,
+    profileSaving: false,
+    profileUserId: '',
+    draftNickname: '',
+    draftAvatar: '',
+    draftAvatarFailed: false,
+    nicknameInvalid: false,
+    pendingFavorites: false,
   },
 
   pageLifetimes: {
     show() {
-      if (typeof this.getTabBar === 'function' && this.getTabBar()) {
-        this.getTabBar().setData({ selected: 4 })
-      }
+      syncTabBar(this)
+      this.refreshSession()
     },
   },
 
   methods: {
-    onChangeAvatar() {
-      const icons = this.data.avatarIcons as string[]
-      const next = ((this.data.avatarIndex as number) + 1) % icons.length
-      this.setData({ avatarIcon: icons[next], avatarIndex: next })
-      Toast('头像已更换')
+    refreshSession() {
+      const session = getUserSession()
+      this.setData({
+        loggedIn: !!session,
+        nickname: session?.nickname || '未登录',
+        avatar: session?.avatar || '',
+      })
+      if (!session || (this.data.profileEditorOpen && this.data.profileUserId !== session.userId)) {
+        this.resetProfileEditor()
+      }
+    },
+
+    async onRequestLogin() {
+      this.refreshSession()
+      if (this.data.loggedIn) {
+        return true
+      }
+      if (this.data.loggingIn || this.data.loginConfirmOpen) {
+        return false
+      }
+      this.setData({ loginConfirmOpen: true })
+      try {
+        // wx.login 不弹系统授权窗,用户确认后再换取后台登录令牌。
+        await Dialog.confirm({
+          zIndex: 10000,
+          title: '微信登录',
+          message: '登录后即可查看你的个人收藏。是否使用微信账号登录?',
+          confirmButtonText: '同意并登录',
+          cancelButtonText: '暂不登录',
+        })
+      }
+      catch {
+        return false
+      }
+      finally {
+        this.setData({ loginConfirmOpen: false })
+      }
+      return this.onLogin()
+    },
+
+    async onLogin() {
+      if (this.data.loggingIn || this.data.loggedIn) {
+        return false
+      }
+      this.setData({ loggingIn: true })
+      try {
+        const session = await loginWithWeChat()
+        this.refreshSession()
+        showUserToast('登录成功', true)
+        if (needsUserProfile(session)) {
+          this.openProfileEditor(true)
+        }
+        return true
+      }
+      catch (error) {
+        showUserToast(error instanceof Error ? error.message : '登录失败,请稍后重试')
+        return false
+      }
+      finally {
+        this.setData({ loggingIn: false })
+      }
+    },
+
+    async onViewFavorites() {
+      if (this.data.loggingIn || this.data.loginConfirmOpen || this.data.profileSaving) {
+        return
+      }
+      this.refreshSession()
+      if (!this.data.loggedIn && !await this.onRequestLogin()) {
+        return
+      }
+      if (this.data.profileEditorOpen) {
+        this.setData({ pendingFavorites: true })
+        return
+      }
+      wx.navigateTo({ url: FAVORITES_PAGE })
     },
 
     onEditProfile() {
-      Dialog.alert({
-        title: '编辑资料',
-        message: '昵称编辑功能建设中,敬请期待。',
-        confirmButtonText: '我知道了',
-      })
+      this.refreshSession()
+      if (this.data.loggedIn) {
+        this.openProfileEditor(false)
+      }
     },
 
-    onShowMessages() {
-      Dialog.alert({
-        title: '消息通知中心',
-        message: '08-08 木偶戏预约提醒\n08-07 古城七夕灯游会预告\n08-06 文旅惠民消费券政策公告',
-        confirmButtonText: '我知道了',
+    openProfileEditor(firstTime: boolean) {
+      const session = getUserSession()
+      if (!session || this.data.profileEditorOpen || this.data.profileSaving) {
+        return
+      }
+      if (!wx.canIUse('button.open-type.chooseAvatar') || !wx.canIUse('input.type.nickname')) {
+        showUserToast('请更新微信后设置头像和昵称')
+        return
+      }
+      this.setData({
+        profileEditorOpen: true,
+        profileFirstTime: firstTime,
+        profileUserId: session.userId,
+        draftNickname: /^微信用户\d*$/.test(session.nickname) ? '' : session.nickname,
+        draftAvatar: /\/assets\/img\/avatar\.png(?:\?|$)/.test(session.avatar)
+          || (firstTime && /^data:image\/svg\+xml[;,]/i.test(session.avatar))
+          ? ''
+          : session.avatar,
+        draftAvatarFailed: false,
+        nicknameInvalid: false,
       })
     },
 
-    onFeedbackProgress() {
-      Dialog.alert({
-        title: '意见反馈进度',
-        message: '关于景区导览标识的建议已受理,当前进度:相关部门处理中,预计 2 个工作日内答复。',
-        confirmButtonText: '我知道了',
+    resetProfileEditor() {
+      this.setData({
+        profileEditorOpen: false,
+        profileUserId: '',
+        draftNickname: '',
+        draftAvatar: '',
+        draftAvatarFailed: false,
+        nicknameInvalid: false,
+        pendingFavorites: false,
       })
     },
 
-    onGeneratePoster() {
-      Dialog.alert({
-        title: '打卡纪念海报',
-        message: '我在漳州集齐山海烟火\n7 枚印章 · 5 枚徽章 · 1,280 积分\n\n海报已生成,可长按保存并分享朋友圈。',
-        confirmButtonText: '我知道了',
+    onCloseProfile() {
+      if (this.data.profileSaving) {
+        return
+      }
+      const navigate = this.data.pendingFavorites && !!getUserSession()
+      this.resetProfileEditor()
+      if (navigate) {
+        wx.navigateTo({ url: FAVORITES_PAGE })
+      }
+    },
+
+    onChooseAvatar(event: WechatMiniprogram.CustomEvent<{ avatarUrl: string }>) {
+      if (!this.data.profileSaving && event.detail.avatarUrl) {
+        this.setData({ draftAvatar: event.detail.avatarUrl, draftAvatarFailed: false })
+      }
+    },
+
+    onDraftAvatarError() {
+      this.setData({ draftAvatarFailed: true })
+    },
+
+    onNicknameInput(event: WechatMiniprogram.CustomEvent<{ value: string }>) {
+      this.setData({
+        draftNickname: event.detail.value,
+        nicknameInvalid: event.detail.value === this.data.draftNickname ? this.data.nicknameInvalid : false,
       })
     },
 
-    onSettingTap(e: WechatMiniprogram.TouchEvent) {
-      const title = e.currentTarget.dataset.title as string
-      const map: Record<string, { toast?: string, dialog?: string }> = {
-        我的投稿: { dialog: '投稿入口已为你打开,欢迎分享你与闽南文化的故事。' },
-        邀请好友: { dialog: '邀请链接已生成,快把这份闽南文化之旅分享给好友吧。' },
-        在线客服: { dialog: '在线客服已收到你的咨询,请稍候为你接入服务。' },
-        隐私设置: { dialog: '位置权限:仅使用期间;消息通知:已开启;个性化推荐:已关闭。' },
-        清除缓存: { toast: '缓存已清除,本次释放 18.6 MB。' },
-        关于小程序: { dialog: '漳州文旅公共服务平台,为游客提供文化、出游、预约与便民服务。' },
+    onNicknameReview(event: WechatMiniprogram.CustomEvent<{ pass: boolean }>) {
+      this.setData({ nicknameInvalid: !event.detail.pass })
+    },
+
+    async onSaveProfile(event: WechatMiniprogram.CustomEvent<{ value: { nickname: string } }>) {
+      if (this.data.profileSaving || !this.data.profileEditorOpen) {
+        return
+      }
+      // form 的值包含昵称快捷填写结果,避免只读 bindinput 而漏掉微信自动填入的昵称。
+      const nickname = event.detail.value.nickname.trim()
+      this.setData({ draftNickname: nickname })
+      if (this.data.nicknameInvalid) {
+        showUserToast('昵称未通过检查,请修改后重试')
+        return
       }
-      const item = map[title]
-      if (!item) {
+      if (!nickname || !this.data.draftAvatar || this.data.draftAvatarFailed) {
+        showUserToast(!nickname ? '请填写昵称' : '请选择有效头像')
         return
       }
-      if (item.dialog) {
-        Dialog.alert({ title, message: item.dialog, confirmButtonText: '我知道了' })
+      this.setData({ profileSaving: true })
+      try {
+        await saveUserProfile({ nickname, avatar: this.data.draftAvatar }, this.data.profileUserId)
+        this.refreshSession()
+        const navigate = this.data.pendingFavorites
+        this.resetProfileEditor()
+        showUserToast('资料已保存', true)
+        if (navigate) {
+          wx.navigateTo({ url: FAVORITES_PAGE })
+        }
+      }
+      catch (error) {
+        this.refreshSession()
+        showUserToast(error instanceof Error ? error.message : '资料保存失败,请重试')
       }
-      else if (item.toast) {
-        Toast(item.toast)
+      finally {
+        this.setData({ profileSaving: false })
       }
     },
+
+    onLogout() {
+      if (!this.data.loggedIn || this.data.loggingIn || this.data.loginConfirmOpen || this.data.profileSaving) {
+        return
+      }
+      logoutUser()
+      this.refreshSession()
+      showUserToast('已退出登录', true)
+    },
+
+    onAbout() {
+      Dialog.alert({
+        zIndex: 10000,
+        title: '关于我们',
+        message: '闽南文化生态保护区(漳州市)数据库,汇集漳州非遗项目、传承人、文物古迹与文化资讯,让更多人了解漳州的闽南文化。',
+        confirmButtonText: '我知道了',
+      })
+    },
   },
 })

+ 51 - 71
src/pages/user/user.wxml

@@ -1,83 +1,63 @@
-<view class="h-screen flex flex-col paper">
-  <profile-header
-    nickname="{{nickname}}"
-    avatar-icon="{{avatarIcon}}"
-    bind:changeavatar="onChangeAvatar"
-    bind:edit="onEditProfile"
-  />
+<view class="user-page">
+  <scroll-view class="user-scroll" scroll-y show-scrollbar="{{false}}">
+    <view class="user-content">
+      <profile-header
+        nickname="{{nickname}}"
+        avatar="{{avatar}}"
+        logged-in="{{loggedIn}}"
+        logging-in="{{loggingIn}}"
+        bind:login="onRequestLogin"
+        bind:editprofile="onEditProfile"
+      />
 
-  <scroll-view class="flex-1 min-h-0" scroll-y>
-    <view class="px-4 pt-4">
-      <favorites-panel />
-    </view>
+      <button wx:if="{{loggedIn}}" class="user-edit-profile" hover-class="user-action--pressed" disabled="{{profileSaving}}" bindtap="onEditProfile">修改信息</button>
 
-    <view class="px-4 pt-5">
-      <view class="rounded-2xl bg-[#9b382c] p-5 text-center text-white" bindtap="onGeneratePoster">
-        <view class="flex justify-center">
-          <svg-icon name="ph:flower-lotus-duotone" size="45px" color="#f4d383" />
+      <view class="user-actions">
+        <view class="user-action user-action--favorites" hover-class="user-action--pressed" aria-role="button" aria-label="查看收藏" bindtap="onViewFavorites">
+          <view class="user-action__icon">
+            <svg-icon name="ph:heart" size="34px" color="#a83f2d" />
+          </view>
+          <view class="user-action__content">
+            <text class="user-action__title">查看收藏</text>
+          </view>
+          <svg-icon name="ph:caret-right-bold" size="16px" color="#a69687" />
         </view>
-        <text class="block mt-2 text-lg font-bold">我在漳州集齐山海烟火</text>
-        <text class="block mt-1 text-xs text-[#f6d99d]">7 枚印章 · 5 枚徽章 · 1,280 积分</text>
-        <view class="mt-3 inline-flex items-center gap-1 rounded-full bg-white/15 px-3 py-1.5 text-xs">
-          <text>生成打卡纪念海报</text>
-          <svg-icon name="ph:arrow-right-bold" size="11px" color="#ffffff" />
+
+        <view class="user-action user-action--about" hover-class="user-action--pressed" aria-role="button" aria-label="关于我们" bindtap="onAbout">
+          <view class="user-action__icon">
+            <svg-icon name="ph:info" size="31px" color="#493b31" />
+          </view>
+          <text class="user-action__title user-action__content">关于我们</text>
+          <svg-icon name="ph:caret-right-bold" size="16px" color="#a69687" />
         </view>
       </view>
-    </view>
 
-    <view class="px-4 pt-5">
-      <text class="text-md font-bold text-[#873428]">反馈与消息</text>
-      <view class="mt-3 overflow-hidden rounded-2xl border border-[#e5d2af] bg-white divide-y divide-[#efe5d3]">
-        <menu-item
-          icon="ph:bell-ringing-duotone"
-          icon-bg="#f7e2dc"
-          icon-color="#a83f2d"
-          title="消息通知中心"
-          subtitle="活动预告、政策公告、预约提醒"
-          right-text="3 未读"
-          right-text-bg="#a83f2d"
-          right-text-color="#ffffff"
-          badge="{{true}}"
-          bind:select="onShowMessages"
-        />
-        <menu-item
-          icon="ph:chat-circle-dots-duotone"
-          icon-bg="#f5e8c9"
-          icon-color="#b08031"
-          title="我的意见反馈"
-          subtitle="历史投诉与建议 · 查看处理进度"
-          right-text="处理中"
-          right-text-bg="transparent"
-          right-text-color="#b17d32"
-          right-text-size="9px"
-          bind:select="onFeedbackProgress"
-        />
-      </view>
+      <button wx:if="{{loggedIn}}" class="user-logout" hover-class="user-action--pressed" bindtap="onLogout">退出登录</button>
     </view>
+  </scroll-view>
 
-    <view class="px-4 pt-5">
-      <text class="text-md font-bold text-[#873428]">便民设置</text>
-      <view class="mt-3 overflow-hidden rounded-2xl border border-[#e5d2af] bg-white divide-y divide-[#efe5d3]">
-        <menu-item
-          wx:for="{{settings}}"
-          wx:key="title"
-          icon="{{item.icon}}"
-          icon-box-class="w-8 h-8"
-          icon-bg="#f7e6df"
-          icon-color="#a83f2d"
-          icon-size="19px"
-          title="{{item.title}}"
-          subtitle="{{item.subtitle}}"
-          chevron="{{true}}"
-          data-title="{{item.title}}"
-          bind:select="onSettingTap"
-        />
+  <van-popup show="{{profileEditorOpen}}" z-index="{{10000}}" round close-on-click-overlay="{{!profileSaving}}" bind:close="onCloseProfile" custom-style="background: #fffaf7; width: 86%; max-width: 420px;">
+    <form wx:if="{{profileEditorOpen}}" bindsubmit="onSaveProfile">
+      <!-- 原生 form 的内部容器不参与外层 flex,布局交给 view。 -->
+      <view class="profile-editor">
+        <text class="profile-editor__title">{{profileFirstTime ? '完善资料' : '修改资料'}}</text>
+        <button class="profile-editor__avatar" open-type="chooseAvatar" bindchooseavatar="onChooseAvatar" disabled="{{profileSaving}}" aria-label="选择头像">
+          <image wx:if="{{draftAvatar && !draftAvatarFailed}}" class="profile-editor__image" src="{{draftAvatar}}" mode="aspectFill" binderror="onDraftAvatarError" />
+          <svg-icon wx:else name="ph:user-fill" size="50px" color="#c6b7a6" />
+        </button>
+        <text class="profile-editor__avatar-label">头像</text>
+        <view class="profile-editor__field">
+          <text class="profile-editor__label">昵称</text>
+          <input class="profile-editor__input" name="nickname" type="nickname" value="{{draftNickname}}" placeholder="请输入或选择微信昵称" maxlength="32" disabled="{{profileSaving}}" bindinput="onNicknameInput" bindblur="onNicknameInput" bindnicknamereview="onNicknameReview" />
+        </view>
+        <view class="profile-editor__actions">
+          <button class="profile-editor__button profile-editor__button--cancel" disabled="{{profileSaving}}" bindtap="onCloseProfile">{{profileFirstTime ? '暂时跳过' : '取消'}}</button>
+          <button class="profile-editor__button profile-editor__button--save" form-type="submit" loading="{{profileSaving}}" disabled="{{profileSaving}}">{{profileSaving ? '保存中' : '保存资料'}}</button>
+        </view>
       </view>
-    </view>
-
-    <view class="tabbar-placeholder"></view>
-  </scroll-view>
+    </form>
+  </van-popup>
 
   <van-toast id="van-toast" />
-  <van-dialog id="van-dialog" />
+  <van-dialog id="van-dialog" confirm-button-color="#a83f2d" />
 </view>

+ 205 - 8
src/pages/user/user.wxss

@@ -1,8 +1,205 @@
-/* user */
-
-.paper {
-  background-color: #faf3e5;
-  background-image: radial-gradient(circle at 16% 8%, rgb(159 55 40 / 5.5%) 0 1px, transparent 1px),
-    radial-gradient(circle at 76% 28%, rgb(181 135 48 / 5%) 0 1px, transparent 1px);
-  background-size: 20px 20px, 27px 27px;
-}
+page {
+  background-color: #fffaf7;
+}
+
+.user-page {
+  height: 100vh;
+  color: #3e3027;
+  background-color: #fffaf7;
+}
+
+.user-scroll {
+  height: 100%;
+}
+
+.user-content {
+  box-sizing: border-box;
+  display: flex;
+  flex-direction: column;
+  min-height: 100vh;
+  padding-bottom: calc(92px + env(safe-area-inset-bottom, 0px));
+}
+
+.user-actions {
+  padding: 0 48rpx;
+}
+
+.user-edit-profile {
+  align-self: center;
+  width: auto;
+  padding: 12rpx 30rpx;
+  margin: -40rpx auto 40rpx;
+  font-size: 26rpx;
+  line-height: 1.4;
+  color: #a83f2d;
+  background-color: transparent;
+  border: 1rpx solid #dccabb;
+  border-radius: 999rpx;
+}
+
+.user-edit-profile::after {
+  border: 0;
+}
+
+.user-action {
+  box-sizing: border-box;
+  display: flex;
+  gap: 24rpx;
+  align-items: center;
+  width: 100%;
+  padding: 32rpx;
+}
+
+.user-action--favorites {
+  min-height: 164rpx;
+  background-color: #f6efe5;
+  border-radius: 28rpx;
+}
+
+.user-action--about {
+  min-height: 136rpx;
+  margin-top: 24rpx;
+}
+
+.user-action--pressed {
+  opacity: 0.7;
+}
+
+.user-action__icon {
+  display: flex;
+  flex: none;
+  align-items: center;
+  justify-content: center;
+  width: 76rpx;
+}
+
+.user-action__content {
+  flex: 1;
+  min-width: 0;
+}
+
+.user-action__title {
+  display: block;
+  font-size: 34rpx;
+  font-weight: 600;
+  line-height: 1.5;
+  color: #3e3027;
+}
+
+.user-logout {
+  width: calc(100% - 96rpx);
+  padding: 24rpx;
+  margin: 48rpx auto 0;
+  font-size: 30rpx;
+  line-height: 1.5;
+  color: #a83f2d;
+  background-color: transparent;
+  border: 0;
+  border-radius: 16rpx;
+}
+
+.user-logout::after {
+  border: 0;
+}
+
+.profile-editor {
+  box-sizing: border-box;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  padding: 48rpx 40rpx 40rpx;
+}
+
+.profile-editor__title {
+  font-size: 38rpx;
+  font-weight: 600;
+  line-height: 1.5;
+  color: #3e3027;
+}
+
+.profile-editor__avatar {
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  width: 160rpx;
+  height: 160rpx;
+  padding: 0;
+  margin: 40rpx auto 0;
+  overflow: hidden;
+  background-color: #f1eadf;
+  border: 0;
+  border-radius: 50%;
+}
+
+.profile-editor__image {
+  width: 100%;
+  height: 100%;
+}
+
+.profile-editor__avatar-label {
+  margin-top: 16rpx;
+  font-size: 28rpx;
+  color: #735f50;
+}
+
+.profile-editor__field {
+  box-sizing: border-box;
+  display: flex;
+  gap: 24rpx;
+  align-items: center;
+  width: 100%;
+  padding: 28rpx 24rpx;
+  margin-top: 36rpx;
+  background-color: #f6efe5;
+  border-radius: 18rpx;
+}
+
+.profile-editor__label {
+  flex: none;
+  font-size: 30rpx;
+  color: #3e3027;
+}
+
+.profile-editor__input {
+  flex: 1;
+  min-width: 0;
+  font-size: 30rpx;
+  color: #3e3027;
+}
+
+.profile-editor__actions {
+  display: flex;
+  gap: 20rpx;
+  width: 100%;
+  margin-top: 40rpx;
+}
+
+.profile-editor__button {
+  flex: 1;
+  padding: 24rpx 12rpx;
+  margin: 0;
+  font-size: 30rpx;
+  font-weight: 500;
+  line-height: 1.4;
+  border: 0;
+  border-radius: 18rpx;
+}
+
+.profile-editor__button--cancel {
+  color: #735f50;
+  background-color: #f1eadf;
+}
+
+.profile-editor__button--save {
+  color: #fffaf7;
+  background-color: #a83f2d;
+}
+
+.profile-editor__avatar::after,
+.profile-editor__button::after {
+  border: 0;
+}
+
+.profile-editor__button[disabled] {
+  opacity: 0.65;
+}

+ 10 - 0
src/subpackages/content/article-detail/article-detail.json

@@ -0,0 +1,10 @@
+{
+  "$schema": "https://vite.weapp.dev/page.json",
+  "navigationStyle": "custom",
+  "navigationBarTitleText": "文章详情",
+  "backgroundColor": "#f9f3e7",
+  "disableScroll": true,
+  "usingComponents": {
+    "svg-icon": "weapp-svg-icon/index"
+  }
+}

+ 426 - 0
src/subpackages/content/article-detail/article-detail.scss

@@ -0,0 +1,426 @@
+.article-page {
+  display: flex;
+  flex-direction: column;
+  height: 100vh;
+  color: #302a23;
+  background: #f7f3e8;
+}
+
+.article-header {
+  flex: none;
+  background: #f7f3e8;
+}
+
+.article-nav {
+  position: relative;
+  display: flex;
+  align-items: center;
+  padding: 0 16px;
+}
+
+.article-back {
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  width: 32px;
+  height: 36px;
+}
+
+.article-nav__title {
+  position: absolute;
+  left: 50%;
+  overflow: hidden;
+  text-overflow: ellipsis;
+  font-size: 17px;
+  font-weight: 500;
+  text-align: center;
+  white-space: nowrap;
+  transform: translateX(-50%);
+}
+
+.article-scroll {
+  flex: 1;
+  min-height: 0;
+}
+
+.article-content {
+  padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
+}
+
+.article-hero {
+  width: 100%;
+  height: 146px;
+  overflow: hidden;
+}
+
+.article-hero--inheritor {
+  height: 210px;
+}
+
+.article-hero__slide {
+  position: relative;
+  width: 100%;
+  height: 100%;
+  overflow: hidden;
+  background: #e8dfd1;
+}
+
+.article-hero__backdrop {
+  position: absolute;
+  inset: -12px;
+  width: calc(100% + 24px);
+  height: calc(100% + 24px);
+  filter: blur(12px);
+}
+
+.article-hero__image {
+  position: relative;
+  display: block;
+  width: 100%;
+  height: 100%;
+}
+
+.article-summary {
+  padding: 32px 18px 6px;
+}
+
+.article-title {
+  display: block;
+  min-width: 0;
+  max-width: 100%;
+  font-family: 'Songti SC', SimSun, serif;
+  font-size: 27px;
+  font-weight: 700;
+  line-height: 1.5;
+  color: #574329;
+  overflow-wrap: anywhere;
+}
+
+.article-title-row {
+  display: flex;
+  flex-wrap: wrap;
+  gap: 8px 12px;
+  align-items: center;
+}
+
+.article-meta {
+  display: flex;
+  flex-wrap: wrap;
+  gap: 8px 12px;
+  align-items: center;
+  margin-top: 12px;
+}
+
+.article-tag {
+  padding: 2px 7px;
+  font-size: 11px;
+  line-height: 18px;
+  color: #a45339;
+  background: #f2e7d6;
+  border-radius: 5px;
+}
+
+.article-date {
+  font-size: 11px;
+  line-height: 1.6;
+  color: #9c9286;
+}
+
+.article-facts {
+  margin-top: 26px;
+}
+
+.article-fact {
+  display: flex;
+  gap: 16px;
+  padding: 4px 0;
+  font-size: 14px;
+  line-height: 1.65;
+}
+
+.article-fact__label {
+  flex: none;
+  width: 88px;
+  color: #8e8b83;
+}
+
+.article-fact__value {
+  flex: 1;
+  min-width: 0;
+  text-align: right;
+  overflow-wrap: anywhere;
+}
+
+.article-levels {
+  margin-top: 14px;
+}
+
+.article-levels__heading {
+  display: flex;
+  justify-content: space-between;
+  margin-bottom: 16px;
+  font-size: 14px;
+  line-height: 1.6;
+  color: #8e8b83;
+}
+
+.article-level-card {
+  display: flex;
+  gap: 10px;
+  align-items: center;
+  padding: 18px 16px;
+  margin-top: 4px;
+  background: #fffdf7;
+  border-radius: 15px;
+}
+
+.article-level-card__badge {
+  flex: none;
+  max-width: 70px;
+  padding: 3px 7px;
+  font-size: 12px;
+  line-height: 18px;
+  color: #d66a50;
+  overflow-wrap: anywhere;
+  background: #ffd4c7;
+  border-radius: 16px;
+}
+
+.article-level-card__body {
+  flex: 1;
+  min-width: 0;
+}
+
+.article-level-card__title {
+  display: block;
+  font-size: 16px;
+  font-weight: 500;
+  line-height: 1.6;
+  overflow-wrap: anywhere;
+}
+
+.article-level-card__subtitle {
+  display: block;
+  margin-top: 2px;
+  font-size: 13px;
+  line-height: 1.5;
+  color: #8e8b83;
+  overflow-wrap: anywhere;
+}
+
+.article-tabs-wrap {
+  position: sticky;
+  top: 0;
+  z-index: 2;
+  padding: 0;
+  margin-top: 0;
+  background: #f7f3e8;
+}
+
+.article-tabs {
+  width: 100%;
+  white-space: nowrap;
+}
+
+.article-tabs__row {
+  box-sizing: border-box;
+  display: flex;
+  min-width: 100%;
+  padding: 0 12px;
+}
+
+.article-tab {
+  position: relative;
+  flex: 1 0 auto;
+  padding: 10px 12px 14px;
+  font-size: 15px;
+  line-height: 22px;
+  text-align: center;
+}
+
+.article-tab--active {
+  font-weight: 500;
+  color: #d66546;
+}
+
+.article-tab--active::after {
+  position: absolute;
+  bottom: 6px;
+  left: 50%;
+  width: 46px;
+  height: 2px;
+  content: '';
+  background: #d66546;
+  border-radius: 2px;
+  transform: translateX(-50%);
+}
+
+.article-panel {
+  padding: 24px 18px;
+  margin: 8px 14px 0;
+  overflow: hidden;
+  background: #fffdf8;
+  border-radius: 18px;
+}
+
+.article-reading-section + .article-reading-section {
+  padding-top: 22px;
+  margin-top: 22px;
+  border-top: 1px solid #eee5d7;
+}
+
+.article-section-title {
+  display: block;
+  margin-bottom: 14px;
+  font-family: 'Songti SC', SimSun, serif;
+  font-size: 19px;
+  font-weight: 600;
+  line-height: 1.5;
+  color: #574329;
+}
+
+.article-rich-text {
+  font-size: 15px;
+  line-height: 1.9;
+  overflow-wrap: anywhere;
+}
+
+.article-gallery {
+  display: flex;
+  flex-direction: column;
+  gap: 14px;
+}
+
+.article-gallery__image {
+  display: block;
+  width: 100%;
+  border-radius: 10px;
+}
+
+.article-video {
+  display: block;
+  width: 100%;
+  height: 190px;
+  background: #302820;
+  border-radius: 10px;
+}
+
+.article-audio {
+  padding: 14px 10px;
+  background: #f7f3e8;
+  border-radius: 10px;
+}
+
+.article-video + .article-audio {
+  margin-top: 18px;
+}
+
+.article-audio__label {
+  display: block;
+  margin-bottom: 10px;
+  font-size: 13px;
+  color: #574329;
+}
+
+.article-audio__player {
+  display: block;
+  width: 100%;
+}
+
+.article-resource {
+  display: flex;
+  gap: 12px;
+  align-items: center;
+  justify-content: space-between;
+  padding: 12px 0;
+}
+
+.article-resource + .article-resource {
+  border-top: 1px solid #eee5d7;
+}
+
+.article-resource__title {
+  font-size: 14px;
+}
+
+.article-resource__action {
+  flex: none;
+  padding: 6px 12px;
+  font-size: 12px;
+  color: #a83f2d;
+  background: #f2e7d6;
+  border-radius: 16px;
+}
+
+.article-related {
+  display: flex;
+  gap: 12px;
+  align-items: center;
+  padding: 14px 0;
+}
+
+.article-related + .article-related,
+.article-reading-section + .article-related {
+  border-top: 1px solid #eee5d7;
+}
+
+.article-reading-section + .article-related {
+  margin-top: 18px;
+}
+
+.article-card--pressed {
+  background: #f2e7d6;
+}
+
+.article-related__image {
+  flex: none;
+  width: 60px;
+  height: 68px;
+  border-radius: 8px;
+}
+
+.article-related__body {
+  flex: 1;
+  min-width: 0;
+}
+
+.article-related__title {
+  display: block;
+  font-size: 15px;
+  font-weight: 500;
+  line-height: 1.6;
+  overflow-wrap: anywhere;
+}
+
+.article-related__meta {
+  display: block;
+  margin-top: 6px;
+  font-size: 12px;
+  line-height: 1.5;
+  color: #8e8b83;
+}
+
+.article-status,
+.article-error {
+  padding: 48px 18px;
+  font-size: 13px;
+  line-height: 1.7;
+  color: #93816f;
+  text-align: center;
+}
+
+.article-error__message {
+  display: block;
+  font-size: 16px;
+  color: #78473b;
+}
+
+.article-error__retry {
+  display: inline-block;
+  padding: 10px 20px;
+  margin-top: 20px;
+  font-size: 12px;
+  color: #fffaf1;
+  background: #a83f2d;
+  border-radius: 20px;
+}

+ 155 - 0
src/subpackages/content/article-detail/article-detail.ts

@@ -0,0 +1,155 @@
+import type { ArticlePresentation } from '../../../data/article-content'
+import type { ArticleProfile } from '../../../data/article-profile'
+import type { ContentDetail } from '../../../data/inherit-api'
+import { createArticlePresentation, prepareArticleContent } from '../../../data/article-content'
+import { createArticleProfile } from '../../../data/article-profile'
+import { getContentDetail } from '../../../data/inherit-api'
+import { normalizeMediaUrl } from '../../../utils/media'
+import { getNavBarLayout } from '../../../utils/nav-bar'
+import { getArticleDetailUrl } from '../../../utils/routes'
+
+Page({
+  data: {
+    id: '',
+    detail: null as ContentDetail | null,
+    presentation: null as ArticlePresentation | null,
+    profile: null as ArticleProfile | null,
+    activeTab: '',
+    activeRelatedGroup: null as ArticlePresentation['relatedGroups'][number] | null,
+    tabScrollTarget: '',
+    pageTitle: '文章详情',
+    loading: true,
+    loadError: '',
+    statusBarHeight: 20,
+    navHeight: 44,
+    navTitleWidth: 160,
+    requestVersion: 0,
+  },
+
+  onLoad(options) {
+    const { statusBarHeight, navHeight, navTitleWidth } = getNavBarLayout()
+    this.setData({ id: options.id || '', statusBarHeight, navHeight, navTitleWidth })
+    return this.loadDetail()
+  },
+
+  async loadDetail() {
+    if (!this.data.id) {
+      this.setData({ loading: false, loadError: '文章不存在或已下架' })
+      return
+    }
+    const requestVersion = ++this.data.requestVersion
+    this.setData({ loading: true, loadError: '', detail: null, presentation: null, profile: null, activeTab: '', activeRelatedGroup: null })
+    try {
+      const detail = await getContentDetail(this.data.id)
+      if (requestVersion !== this.data.requestVersion) {
+        return
+      }
+      const presentation = createArticlePresentation(detail)
+      const profile = createArticleProfile(detail, presentation)
+      const activeTab = profile.tabs[0]?.key || ''
+      this.setData({
+        loading: false,
+        presentation,
+        profile,
+        activeTab,
+        activeRelatedGroup: presentation.relatedGroups.find(group => group.key === activeTab) || null,
+        tabScrollTarget: activeTab ? `detail-tab-${activeTab}` : '',
+        pageTitle: presentation.pageTitle,
+        detail: {
+          ...detail,
+          image: normalizeMediaUrl(detail.image),
+          audio: normalizeMediaUrl(detail.audio),
+          video: normalizeMediaUrl(detail.video),
+          content: prepareArticleContent(detail.content),
+        },
+      })
+      wx.setNavigationBarTitle({ title: detail.title || '文章详情' })
+    }
+    catch (error) {
+      if (requestVersion === this.data.requestVersion) {
+        this.setData({ loading: false, loadError: error instanceof Error ? error.message : '数据加载失败,请稍后重试' })
+      }
+    }
+  },
+
+  onUnload() {
+    this.onHide()
+    // 返回列表后丢弃未完成的详情请求,避免更新已销毁页面。
+    this.data.requestVersion++
+  },
+
+  onHide() {
+    if (this.data.activeTab !== 'media') {
+      return
+    }
+    if (this.data.detail?.audio) {
+      wx.createAudioContext('article-audio', this).pause()
+    }
+    if (this.data.detail?.video) {
+      wx.createVideoContext('article-video', this).pause()
+    }
+  },
+
+  onPreviewImage() {
+    const image = this.data.detail?.image
+    if (image) {
+      wx.previewImage({ current: image, urls: [image] })
+    }
+  },
+
+  onPreviewGallery(e: WechatMiniprogram.CustomEvent) {
+    const profile = this.data.profile
+    const image = e.currentTarget.dataset.image as string
+    if (image && profile?.images.includes(image)) {
+      wx.previewImage({ current: image, urls: profile.images })
+    }
+  },
+
+  onPreviewExhibition() {
+    const image = this.data.presentation?.exhibitionImage
+    if (image) {
+      wx.previewImage({ current: image, urls: [image] })
+    }
+  },
+
+  onTabTap(e: WechatMiniprogram.CustomEvent) {
+    const key = e.currentTarget.dataset.key as string
+    if (key === this.data.activeTab || !this.data.profile?.tabs.some(tab => tab.key === key)) {
+      return
+    }
+    // 切换到别的内容分区前停止影音,避免播放器移除后继续出声。
+    this.onHide()
+    this.setData({
+      activeTab: key,
+      activeRelatedGroup: this.data.presentation?.relatedGroups.find(group => group.key === key) || null,
+      tabScrollTarget: `detail-tab-${key}`,
+    })
+  },
+
+  onRelatedTap(e: WechatMiniprogram.CustomEvent) {
+    const id = e.currentTarget.dataset.id as string
+    if (id && id !== this.data.id) {
+      wx.navigateTo({ url: getArticleDetailUrl(id) })
+    }
+  },
+
+  onCopyResource(e: WechatMiniprogram.CustomEvent) {
+    const url = e.currentTarget.dataset.url as string
+    if (url) {
+      wx.setClipboardData({ data: url })
+    }
+  },
+
+  onRetry() {
+    return this.loadDetail()
+  },
+
+  onBack() {
+    if (getCurrentPages().length > 1) {
+      wx.navigateBack()
+    }
+    else {
+      wx.switchTab({ url: '/pages/home/home' })
+    }
+  },
+})

+ 116 - 0
src/subpackages/content/article-detail/article-detail.wxml

@@ -0,0 +1,116 @@
+<view class="article-page">
+  <view class="article-header" style="padding-top: {{statusBarHeight}}px;">
+    <view class="article-nav" style="height: {{navHeight}}px;">
+      <view class="article-back" aria-role="button" aria-label="返回" bindtap="onBack">
+        <svg-icon name="ph:caret-left-bold" size="20px" color="#302a23" />
+      </view>
+      <text class="article-nav__title" style="width: {{navTitleWidth}}px;">{{detail.title || pageTitle}}</text>
+    </view>
+  </view>
+
+  <scroll-view class="article-scroll" scroll-y show-scrollbar="{{false}}">
+    <view wx:if="{{loading}}" class="article-status">正在加载…</view>
+    <view wx:elif="{{loadError}}" class="article-error">
+      <text class="article-error__message">{{loadError}}</text>
+      <view wx:if="{{id}}" class="article-error__retry" aria-role="button" bindtap="onRetry">点击重试</view>
+    </view>
+    <view wx:elif="{{detail}}" class="article-content">
+      <view wx:if="{{detail.image}}" class="article-hero {{presentation.type === 'inheritor' ? 'article-hero--inheritor' : ''}}" bindtap="onPreviewImage" aria-label="查看封面图片">
+        <view class="article-hero__slide">
+          <image class="article-hero__backdrop" src="{{detail.image}}" mode="aspectFill" />
+          <image class="article-hero__image" src="{{detail.image}}" mode="aspectFit" />
+        </view>
+      </view>
+
+      <view wx:if="{{detail.title || detail.flag_text || detail.publish_at || profile.facts.length || presentation.otherLevels.length}}" class="article-summary">
+        <view wx:if="{{detail.title || profile.levelBadge}}" class="article-title-row">
+          <text wx:if="{{detail.title}}" class="article-title" user-select>{{detail.title}}</text>
+          <text wx:if="{{profile.levelBadge}}" class="article-level-card__badge">{{profile.levelBadge}}</text>
+        </view>
+        <view wx:if="{{detail.flag_text || detail.publish_at}}" class="article-meta">
+          <text wx:if="{{detail.flag_text}}" class="article-tag">{{detail.flag_text}}</text>
+          <text wx:if="{{detail.publish_at}}" class="article-date">{{detail.publish_at}}</text>
+        </view>
+        <view wx:if="{{profile.facts.length}}" class="article-facts">
+          <view wx:for="{{profile.facts}}" wx:key="label" class="article-fact">
+            <text class="article-fact__label">{{item.label}}</text>
+            <text class="article-fact__value" user-select>{{item.value}}</text>
+          </view>
+        </view>
+
+        <view wx:if="{{presentation.otherLevels.length}}" class="article-levels">
+          <view class="article-levels__heading">
+            <text>其他级别保护单位</text>
+            <text>{{presentation.otherLevels.length}}个</text>
+          </view>
+          <view wx:for="{{presentation.otherLevels}}" wx:key="index" class="article-level-card" data-id="{{item.id}}" bindtap="onRelatedTap" hover-class="{{item.id ? 'article-card--pressed' : 'none'}}">
+            <text wx:if="{{item.label}}" class="article-level-card__badge">{{item.label}}</text>
+            <view class="article-level-card__body">
+              <text wx:if="{{item.title || item.label}}" class="article-level-card__title">{{item.title || item.label}}</text>
+              <text wx:if="{{item.unit || (item.value && item.value !== item.title && item.value !== item.label)}}" class="article-level-card__subtitle">{{item.unit || item.value}}</text>
+            </view>
+            <svg-icon wx:if="{{item.id}}" name="ph:caret-right-bold" size="16px" color="#302a23" />
+          </view>
+        </view>
+      </view>
+
+      <view wx:if="{{profile.tabs.length > 1}}" class="article-tabs-wrap">
+        <scroll-view class="article-tabs" scroll-x scroll-into-view="{{tabScrollTarget}}" scroll-with-animation show-scrollbar="{{false}}">
+          <view class="article-tabs__row">
+            <view wx:for="{{profile.tabs}}" wx:key="key" id="detail-tab-{{item.key}}" class="article-tab {{activeTab === item.key ? 'article-tab--active' : ''}}" data-key="{{item.key}}" bindtap="onTabTap" aria-role="button" aria-label="{{item.label}},{{activeTab === item.key ? '已选中' : '未选中'}}">{{item.label}}</view>
+          </view>
+        </scroll-view>
+      </view>
+
+      <view wx:if="{{activeTab}}" class="article-panel">
+        <block wx:if="{{activeTab === 'intro'}}">
+          <view wx:for="{{profile.sections}}" wx:key="key" class="article-reading-section">
+            <text wx:if="{{item.title}}" class="article-section-title">{{item.title}}</text>
+            <rich-text class="article-rich-text" nodes="{{item.content}}" user-select />
+          </view>
+        </block>
+
+        <view wx:elif="{{activeTab === 'images'}}" class="article-gallery">
+          <image wx:for="{{profile.images}}" wx:key="*this" class="article-gallery__image" src="{{item}}" mode="widthFix" lazy-load data-image="{{item}}" bindtap="onPreviewGallery" aria-label="查看图片" />
+        </view>
+
+        <view wx:elif="{{activeTab === 'exhibition'}}" class="article-gallery">
+          <image class="article-gallery__image" src="{{presentation.exhibitionImage}}" mode="widthFix" bindtap="onPreviewExhibition" aria-label="查看展厅图片" />
+        </view>
+
+        <view wx:elif="{{activeTab === 'prize'}}" class="article-reading-section">
+          <rich-text class="article-rich-text" nodes="{{profile.prizeContent}}" user-select />
+        </view>
+
+        <block wx:elif="{{activeTab === 'media'}}">
+          <video wx:if="{{detail.video}}" id="article-video" class="article-video" src="{{detail.video}}" poster="{{detail.image}}" controls object-fit="contain" show-center-play-btn />
+          <view wx:if="{{detail.audio}}" class="article-audio">
+            <text class="article-audio__label">音频</text>
+            <audio id="article-audio" class="article-audio__player" src="{{detail.audio}}" name="{{detail.title}}" controls />
+          </view>
+        </block>
+
+        <block wx:elif="{{activeTab === 'resources'}}">
+          <view wx:for="{{presentation.resourceLinks}}" wx:key="title" class="article-resource">
+            <text class="article-resource__title">{{item.title}}</text>
+            <view class="article-resource__action" data-url="{{item.url}}" bindtap="onCopyResource" aria-role="button" aria-label="复制{{item.title}}链接">复制链接</view>
+          </view>
+        </block>
+
+        <block wx:else>
+          <view wx:if="{{activeTab === 'inheritors' && profile.inheritorContent}}" class="article-reading-section">
+            <rich-text class="article-rich-text" nodes="{{profile.inheritorContent}}" user-select />
+          </view>
+          <view wx:for="{{activeRelatedGroup.items}}" wx:key="id" class="article-related" data-id="{{item.id}}" bindtap="onRelatedTap" hover-class="article-card--pressed" aria-role="button" aria-label="查看{{item.title}}详情">
+            <image wx:if="{{item.image}}" class="article-related__image" src="{{item.image}}" mode="aspectFill" lazy-load />
+            <view class="article-related__body">
+              <text class="article-related__title">{{item.title}}</text>
+              <text wx:if="{{item.meta}}" class="article-related__meta">{{item.meta}}</text>
+            </view>
+            <svg-icon name="ph:caret-right-bold" size="16px" color="#302a23" />
+          </view>
+        </block>
+      </view>
+    </view>
+  </scroll-view>
+</view>

+ 10 - 0
src/subpackages/content/culture-list/culture-list.json

@@ -0,0 +1,10 @@
+{
+  "$schema": "https://vite.weapp.dev/page.json",
+  "navigationStyle": "custom",
+  "navigationBarTitleText": "文化列表",
+  "backgroundColor": "#f9f3e7",
+  "disableScroll": true,
+  "usingComponents": {
+    "svg-icon": "weapp-svg-icon/index"
+  }
+}

+ 259 - 0
src/subpackages/content/culture-list/culture-list.scss

@@ -0,0 +1,259 @@
+.culture-page {
+  display: flex;
+  flex-direction: column;
+  height: 100vh;
+  color: #51433e;
+  background: #f9f3e7;
+}
+
+.culture-header {
+  flex: none;
+  background: #f9f3e7;
+  border-bottom: 1px solid #eadcc5;
+}
+
+.culture-nav {
+  display: flex;
+  gap: 10px;
+  align-items: center;
+  padding-left: 16px;
+}
+
+.culture-back {
+  display: flex;
+  flex: none;
+  align-items: center;
+  justify-content: center;
+  width: 36px;
+  height: 36px;
+  background: rgb(255 255 255 / 70%);
+  border: 1px solid #eadcc5;
+  border-radius: 50%;
+}
+
+.culture-nav__title {
+  overflow: hidden;
+  text-overflow: ellipsis;
+  font-size: 15px;
+  font-weight: 600;
+  color: #753c2b;
+  white-space: nowrap;
+}
+
+.culture-search {
+  display: flex;
+  gap: 9px;
+  align-items: center;
+  min-height: 42px;
+  padding: 0 12px;
+  margin: 12px 16px 16px;
+  background: rgb(255 255 255 / 85%);
+  border: 1px solid #e6d8c3;
+  border-radius: 12px;
+}
+
+.culture-search__input {
+  flex: 1;
+  min-width: 0;
+  height: 42px;
+  font-size: 13px;
+  color: #51433e;
+}
+
+.culture-search__placeholder {
+  color: #aa9887;
+}
+
+.culture-search__clear {
+  flex: none;
+  padding: 10px 0 10px 6px;
+  font-size: 12px;
+  color: #a83f2d;
+}
+
+.culture-scroll {
+  flex: 1;
+  min-height: 0;
+}
+
+.culture-filters {
+  display: flex;
+  padding: 0 16px 10px;
+}
+
+.culture-filter {
+  flex: 1;
+  min-width: 0;
+}
+
+.culture-filter + .culture-filter {
+  border-left: 1px solid #eadcc5;
+}
+
+.culture-filter__trigger {
+  display: flex;
+  gap: 8px;
+  align-items: center;
+  justify-content: center;
+  height: 34px;
+  padding: 0 12px;
+  font-size: 13px;
+  color: #806d5c;
+}
+
+.culture-filter__trigger--selected {
+  font-weight: 600;
+  color: #a83f2d;
+}
+
+.culture-filter__label {
+  overflow: hidden;
+  text-overflow: ellipsis;
+  white-space: nowrap;
+}
+
+.culture-filter__arrow {
+  flex: none;
+  width: 5px;
+  height: 5px;
+  margin-top: -3px;
+  border-right: 1px solid currentcolor;
+  border-bottom: 1px solid currentcolor;
+  transform: rotate(45deg);
+}
+
+.culture-content {
+  padding: 16px 16px calc(24px + env(safe-area-inset-bottom, 0px));
+}
+
+.culture-list {
+  display: flex;
+  flex-direction: column;
+  gap: 12px;
+}
+
+.culture-card {
+  display: flex;
+  gap: 13px;
+  padding: 12px;
+  background: #fffdfa;
+  border: 1px solid #eadcc5;
+  border-radius: 16px;
+  box-shadow: 0 2px 8px rgb(117 60 43 / 3%);
+}
+
+.culture-card__cover {
+  position: relative;
+  flex: none;
+  width: 100px;
+  height: 112px;
+  overflow: hidden;
+  background: #eee2ce;
+  border-radius: 10px;
+}
+
+.culture-card--pressed {
+  background: #f6efdf;
+}
+
+.culture-card__fallback {
+  display: flex;
+  flex-direction: column;
+  gap: 8px;
+  align-items: center;
+  justify-content: center;
+  height: 100%;
+  font-size: 11px;
+  color: #a48a66;
+}
+
+.culture-card__image {
+  position: absolute;
+  inset: 0;
+  width: 100%;
+  height: 100%;
+}
+
+.culture-card__body {
+  display: flex;
+  flex: 1;
+  flex-direction: column;
+  min-width: 0;
+}
+
+.culture-card__title,
+.culture-card__description {
+  display: -webkit-box;
+  overflow: hidden;
+  -webkit-box-orient: vertical;
+  -webkit-line-clamp: 2;
+}
+
+.culture-card__title {
+  font-size: 15px;
+  font-weight: 600;
+  line-height: 1.5;
+  color: #593e31;
+}
+
+.culture-card__description {
+  margin-top: 6px;
+  font-size: 12px;
+  line-height: 1.65;
+  color: #93816f;
+}
+
+.culture-card__meta {
+  display: flex;
+  flex-wrap: wrap;
+  gap: 6px;
+  align-items: center;
+  justify-content: space-between;
+  padding-top: 10px;
+  margin-top: auto;
+}
+
+.culture-card__tag {
+  padding: 2px 6px;
+  font-size: 10px;
+  line-height: 16px;
+  color: #927346;
+  background: #f6efdf;
+  border-radius: 4px;
+}
+
+.culture-card__date {
+  font-size: 10px;
+  color: #a2917f;
+}
+
+.culture-empty {
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  padding: 48px 12px;
+  text-align: center;
+}
+
+.culture-list-status {
+  padding: 20px 12px;
+  font-size: 12px;
+  color: #93816f;
+  text-align: center;
+}
+
+.culture-empty__title {
+  margin-top: 20px;
+  font-size: 16px;
+  font-weight: 600;
+  color: #78473b;
+}
+
+.culture-empty__action {
+  padding: 10px 20px;
+  margin-top: 20px;
+  font-size: 12px;
+  color: #fffaf1;
+  background: #a83f2d;
+  border-radius: 20px;
+}

+ 220 - 0
src/subpackages/content/culture-list/culture-list.ts

@@ -0,0 +1,220 @@
+import type { CultureCategoryKey, CultureItem } from '../../../data/culture-content'
+import { createCultureFilterOptions, createCultureFilters, findCultureCategory, getCultureList } from '../../../data/culture-content'
+import { getInheritCategories } from '../../../data/inherit-api'
+import { getNavBarLayout } from '../../../utils/nav-bar'
+import { runRefresh } from '../../../utils/refresh'
+import { getArticleDetailUrl } from '../../../utils/routes'
+
+const initialCategory = findCultureCategory(undefined)
+// 输入停顿后再搜索,避免每输入一个字就请求一次。
+const SEARCH_DEBOUNCE = 400
+
+Page({
+  data: {
+    activeCategory: initialCategory.key,
+    title: initialCategory.title,
+    categoryIcon: initialCategory.icon,
+    items: [] as CultureItem[],
+    keyword: '',
+    supportsFilters: false,
+    filters: createCultureFilters(),
+    filterOptions: createCultureFilterOptions(),
+    failedImages: {} as Record<string, boolean>,
+    statusBarHeight: 20,
+    navHeight: 44,
+    navRightPadding: 100,
+    scrollTop: 0,
+    remoteCategory: '' as CultureCategoryKey | '',
+    optionsLoaded: false,
+    loading: false,
+    loadError: '',
+    hasMore: false,
+    nextPage: 1,
+    requestVersion: 0,
+    searchTimer: 0,
+    refreshing: false,
+  },
+
+  onLoad(options) {
+    const { statusBarHeight, navHeight, navRightPadding } = getNavBarLayout()
+    const category = findCultureCategory(options.category)
+    const remoteCategory = category.key
+    this.setData({
+      statusBarHeight,
+      navHeight,
+      navRightPadding,
+      activeCategory: category.key,
+      title: category.title,
+      categoryIcon: category.icon,
+      items: [],
+      supportsFilters: !!category.supportsFilters,
+      remoteCategory,
+      keyword: options.keyword || '',
+      filters: category.supportsFilters ? { category: options.categoryId || '', level: options.levelId || '', district: options.districtId || '' } : createCultureFilters(),
+      filterOptions: createCultureFilterOptions(),
+    })
+    wx.setNavigationBarTitle({ title: category.title })
+    return this.loadItems()
+  },
+
+  onUnload() {
+    this.cancelPendingSearch()
+    this.data.requestVersion++
+  },
+
+  cancelPendingSearch() {
+    if (this.data.searchTimer) {
+      clearTimeout(this.data.searchTimer)
+      this.data.searchTimer = 0
+    }
+  },
+
+  async onPullRefresh() {
+    this.setData({ refreshing: true })
+    await runRefresh([this.loadItems(true, true)])
+    this.setData({ refreshing: false })
+  },
+
+  // refresh 为下拉刷新:保留当前列表直到新数据返回,已有内容时失败只提示不清空。
+  async loadItems(reset = true, refresh = false) {
+    const { remoteCategory, keyword, filters, optionsLoaded, supportsFilters } = this.data
+    if (!remoteCategory) {
+      return
+    }
+    // 任何重新加载都已带上最新关键词,未触发的延迟搜索可以丢弃。
+    if (reset) {
+      this.cancelPendingSearch()
+    }
+    const requestVersion = ++this.data.requestVersion
+    const page = reset ? 1 : this.data.nextPage
+    if (!refresh) {
+      this.setData({ loading: true, loadError: '', ...(reset ? { items: [], hasMore: false, scrollTop: 0, failedImages: {} } : {}) })
+    }
+    try {
+      const [options, result] = await Promise.all([
+        !supportsFilters || optionsLoaded ? Promise.resolve(null) : getInheritCategories(),
+        getCultureList(remoteCategory, { keyword, categoryId: filters.category, levelId: filters.level, districtId: filters.district }, page),
+      ])
+      // 搜索或筛选改变后,丢弃旧请求及旧分页结果。
+      if (requestVersion !== this.data.requestVersion) {
+        return
+      }
+      if (options) {
+        const groups = { category: options.categories, level: options.levels, district: options.districts }
+        this.setData({
+          optionsLoaded: true,
+          filterOptions: createCultureFilterOptions().map((option) => {
+            const values = groups[option.key]
+            const ids = ['', ...values.map(item => item.id)]
+            const names = [option.options[0], ...values.map(item => item.name)]
+            const index = Math.max(0, ids.indexOf(filters[option.key]))
+            return { ...option, ids, options: names, index, value: index ? names[index] : '' }
+          }),
+        })
+      }
+      this.setData({
+        items: reset ? result.items : [...this.data.items, ...result.items],
+        ...(refresh ? { failedImages: {} } : {}),
+        loading: false,
+        loadError: '',
+        hasMore: result.hasMore,
+        nextPage: page + 1,
+      })
+    }
+    catch (error) {
+      if (requestVersion !== this.data.requestVersion) {
+        return
+      }
+      // 刷新会作废进行中的加载更多,这里统一结束加载态。
+      if (refresh && this.data.items.length) {
+        this.setData({ loading: false })
+        throw error
+      }
+      this.setData({ loading: false, loadError: error instanceof Error ? error.message : '数据加载失败,请稍后重试' })
+    }
+  },
+
+  onLoadMore() {
+    if (this.data.remoteCategory && this.data.hasMore && !this.data.loading && !this.data.loadError) {
+      return this.loadItems(false)
+    }
+  },
+
+  onRetry() {
+    return this.loadItems(!this.data.items.length)
+  },
+
+  onSearchInput(e: WechatMiniprogram.Input) {
+    const keyword = e.detail.value
+    this.setData({ keyword })
+    this.cancelPendingSearch()
+    this.data.searchTimer = setTimeout(() => {
+      this.data.searchTimer = 0
+      this.loadItems()
+    }, SEARCH_DEBOUNCE)
+  },
+
+  onSearchConfirm() {
+    // 点击键盘“搜索”时立即执行尚未触发的延迟搜索。
+    if (this.data.searchTimer) {
+      return this.loadItems()
+    }
+  },
+
+  onClearSearch() {
+    this.setData({ keyword: '' })
+    return this.loadItems()
+  },
+
+  onFilterChange(e: WechatMiniprogram.PickerChange) {
+    const key = e.currentTarget.dataset.key
+    const option = this.data.filterOptions.find(option => option.key === key)
+    const index = Number(e.detail.value)
+    if (!this.data.supportsFilters || (this.data.remoteCategory && !this.data.optionsLoaded) || !option || !Number.isInteger(index) || !option.options[index]) {
+      return
+    }
+    const value = option.ids ? option.ids[index] : index === 0 ? '' : option.options[index]
+    const filters = { ...this.data.filters, [option.key]: value }
+    // 三个筛选条件与搜索同时生效;清除搜索只清关键词,保留筛选选择。
+    this.setData({
+      filters,
+      filterOptions: this.data.filterOptions.map(item => item.key === option.key ? { ...item, index, value: index ? item.options[index] : '' } : item),
+    })
+    return this.loadItems()
+  },
+
+  onResetFilters() {
+    this.setData({
+      keyword: '',
+      filters: createCultureFilters(),
+      filterOptions: this.data.filterOptions.map(option => ({ ...option, index: 0, value: '' })),
+    })
+    return this.loadItems()
+  },
+
+  onItemTap(e: WechatMiniprogram.CustomEvent) {
+    const id = e.currentTarget.dataset.id as string
+    if (id) {
+      wx.navigateTo({ url: getArticleDetailUrl(id) })
+    }
+  },
+
+  onImageError(e: WechatMiniprogram.CustomEvent) {
+    const id = e.currentTarget.dataset.id as string
+    this.setData({ [`failedImages.${id}`]: true })
+  },
+
+  onListScroll(e: WechatMiniprogram.CustomEvent) {
+    // 保存实际滚动位置,搜索时设为 0 才能触发滚动复位。
+    this.data.scrollTop = e.detail.scrollTop
+  },
+
+  onBack() {
+    if (getCurrentPages().length > 1) {
+      wx.navigateBack()
+    }
+    else {
+      wx.switchTab({ url: '/pages/home/home' })
+    }
+  },
+})

+ 87 - 0
src/subpackages/content/culture-list/culture-list.wxml

@@ -0,0 +1,87 @@
+<view class="culture-page">
+  <view class="culture-header" style="padding-top: {{statusBarHeight}}px;">
+    <view class="culture-nav" style="height: {{navHeight}}px; padding-right: {{navRightPadding}}px;">
+      <view class="culture-back" aria-role="button" aria-label="返回首页" bindtap="onBack">
+        <svg-icon name="ph:caret-left-bold" size="18px" color="#753c2b" />
+      </view>
+      <text class="culture-nav__title">{{title}}</text>
+    </view>
+    <view class="culture-search">
+      <svg-icon name="ph:magnifying-glass" size="18px" color="#9c8470" />
+      <input
+        class="culture-search__input"
+        value="{{keyword}}"
+        placeholder="搜索{{title}}的标题"
+        placeholder-class="culture-search__placeholder"
+        confirm-type="search"
+        bindinput="onSearchInput"
+        bindconfirm="onSearchConfirm"
+        maxlength="100"
+        aria-label="搜索{{title}}"
+      />
+      <view wx:if="{{keyword}}" class="culture-search__clear" aria-role="button" bindtap="onClearSearch">清除</view>
+    </view>
+    <view wx:if="{{supportsFilters && (!remoteCategory || optionsLoaded)}}" class="culture-filters">
+      <picker
+        wx:for="{{filterOptions}}"
+        wx:key="key"
+        class="culture-filter"
+        mode="selector"
+        range="{{item.options}}"
+        value="{{item.index}}"
+        data-key="{{item.key}}"
+        bindchange="onFilterChange"
+        aria-label="{{item.label}}筛选,{{item.value || item.options[0]}}"
+      >
+        <view class="culture-filter__trigger {{item.value ? 'culture-filter__trigger--selected' : ''}}">
+          <text class="culture-filter__label">{{item.value || item.label}}</text>
+          <view class="culture-filter__arrow" />
+        </view>
+      </picker>
+    </view>
+  </view>
+
+  <scroll-view class="culture-scroll" scroll-y scroll-top="{{scrollTop}}" bindscroll="onListScroll" bindscrolltolower="onLoadMore" show-scrollbar="{{false}}" refresher-enabled="{{true}}" refresher-triggered="{{refreshing}}" bindrefresherrefresh="onPullRefresh">
+    <view class="culture-content">
+      <view class="culture-list">
+        <view wx:for="{{items}}" wx:key="id" class="culture-card" data-id="{{item.id}}" bindtap="onItemTap" hover-class="culture-card--pressed" aria-role="button" aria-label="查看{{item.title}}详情">
+          <view class="culture-card__cover">
+            <view class="culture-card__fallback">
+              <svg-icon name="{{categoryIcon}}" size="32px" color="#b59b77" />
+              <text wx:if="{{!item.image || failedImages[item.id]}}">{{title}}</text>
+            </view>
+            <image
+              wx:if="{{item.image && !failedImages[item.id]}}"
+              class="culture-card__image"
+              src="{{item.image}}"
+              mode="aspectFill"
+              lazy-load
+              data-id="{{item.id}}"
+              binderror="onImageError"
+              aria-label="{{item.title}}"
+            />
+          </view>
+          <view class="culture-card__body">
+            <text class="culture-card__title">{{item.title}}</text>
+            <text class="culture-card__description">{{item.description}}</text>
+            <view class="culture-card__meta">
+              <text wx:if="{{item.tag}}" class="culture-card__tag">{{item.tag}}</text>
+              <text wx:if="{{item.date}}" class="culture-card__date">{{item.date}}</text>
+            </view>
+          </view>
+        </view>
+      </view>
+
+      <view wx:if="{{loading}}" class="culture-list-status">正在加载…</view>
+      <view wx:elif="{{loadError}}" class="culture-empty">
+        <text class="culture-empty__title">{{loadError}}</text>
+        <view class="culture-empty__action" aria-role="button" bindtap="onRetry">点击重试</view>
+      </view>
+      <view wx:elif="{{!items.length}}" class="culture-empty">
+        <text class="culture-empty__title">暂时没有找到相关内容</text>
+        <view class="culture-empty__action" aria-role="button" bindtap="onResetFilters">查看全部内容</view>
+      </view>
+      <view wx:elif="{{remoteCategory}}" class="culture-list-status" bindtap="onLoadMore">{{hasMore ? '点击加载更多' : '已展示全部内容'}}</view>
+    </view>
+  </scroll-view>
+</view>

+ 0 - 0
src/subpackages/content/favorites/favorites.json


Някои файлове не бяха показани, защото твърде много файлове са промени