从可调节哑铃到商用跑步机,从综合训练器到乳清蛋白粉,从增肌训练计划到筋膜枪——本文以一套完整的ArkTS肌肉工坊应用为例,深度解析HarmonyOS 6.1.1在硬核健身风二手交易场景下的双Tab嵌套架构、14粒子漂浮动效、传世/稀有/紧俏/流通四级稀有度分级、深空灰活力橙详情头、以物换物交换帖等核心技术实现。

一、引言

健身器械、运动补剂、健身服饰、配件——这些承载着撸铁人汗水与梦想的装备,在全民健身浪潮下反而焕发了新的热潮。从可调节哑铃到商用跑步机,从综合训练器到乳清蛋白粉,从增肌训练计划到筋膜枪,健身装备二手交易已经成为一个庞大的硬核市场。然而健身装备交易长期依赖闲鱼、转转等泛平台,缺乏针对撸铁人的专业化功能——器械稀有度评级、规格尺寸区分(24kg/5磅/100kg/L码)、以物换物交换、训练计划教程等核心需求无法得到满足。

本应用(肌肉工坊)以"深空灰+活力橙"硬核健身风为视觉基调,打造集集市交易、换件交换、图鉴收藏、个人中心四大模块于一体的硬核健身风二手交易与收藏社区。18款装备覆盖器械/补剂/服饰/配件/计划全品类,8条交换帖覆盖以物换物场景,5套教程覆盖增肌/减脂/力量/瑜伽/补剂,9款配件覆盖健身周边,6套图鉴收藏记录装备进度,3条圈友点评提供真实评价。

本文将从架构设计、色彩系统、数据模型、四大Tab页面、弹框体系、核心技术特性等维度,完整解析这套应用的ArkTS实现。

二、整体架构

本应用采用单组件双Tab嵌套架构——@Entry @Component struct Index作为唯一入口组件,通过@State currentBottomTab控制四大底部Tab(集市/换件/图鉴/我的),集市Tab内部再通过@State currentTopTab控制六大顶部分类Tab(全部/器械/补剂/服饰/配件/计划),形成双层Tab嵌套。

架构层次:

  • 入口层:Index,负责双层Tab切换、头部、底部导航、粒子动效、弹框管理
  • 页面层:4个底部Tab对应的Builder方法(bazaarContent/swapContent/collectionContent/mineContent),集市Tab内含6个顶部Tab对应的Builder方法(cityContent/retiredContent/mocContent/figContent/techContent/streetContent)
  • 数据层:8个全局const数组(18装备+8交换帖+5教程+9配件+6图鉴+3点评+2图表数据+2弹框选项)+1个配色常量PALETTE
  • 工具函数层:10+全局纯函数(catColor/catLabel/rarityLabel/rarityColor/tradeBarHeight/rateColor/6个分类筛选函数/swapBadge)
  • 弹框层:4种弹框(发布出售/发起交换/下架/器材详情),均通过@State布尔值控制显隐

单组件架构的优势在于状态集中管理、数据共享方便、弹框统一调度,适合中等复杂度的应用。双层Tab嵌套是本应用的架构特色——集市作为主品类,内部再按器械/补剂/服饰/配件/计划细分,撸铁人可以快速切换品类浏览。

三、色彩系统:深空灰+活力橙硬核健身风

硬核健身风的视觉语言应该是"力量、热血、有健身房的硬核感"。本应用采用深空灰+活力橙配色:

主色体系:

  • #1E1E1E 深空灰:应用根背景、深色卡片背景——代表健身房的硬核力量感
  • #2A2A2A 深灰:卡片背景、弹框背景、底部Tab背景——代表层次
  • #FF6B00 活力橙:主高亮色、Tab选中态、按钮、标签、渐变——代表热血与力量
  • #111111 纯黑:头部渐变终点、最深背景、高亮卡片背景——代表深邃
  • #3A3A3A 中灰:分割线、进度条背景——代表层次
  • #E8483C 热血红:删除按钮、点赞、警告——代表热情与警告
  • #FFD400 活力金:价格、等级标签、统计数字、交换弹框头部——代表价值与珍贵
  • #8A8A8A 烟灰:辅助文字、未选中Tab、说明文字——代表素雅
  • #58A6FF 科技蓝:年份、成就标签——代表科技

深色背景层次(深色主题下的层次):

  • #1E1E1E 深空灰:应用根背景
  • #2A2A2A 深灰:卡片背景、弹框背景
  • #111111 纯黑:高亮卡片背景、Banner背景、教程步骤背景、选中态背景、头部渐变终点
  • #3A3A3A 中灰:分割线、进度条背景

渐变设计:

  • 头部:linearGradient angle 135 从#111111到#1E1E1E——纯黑到深空灰的深邃渐变

深空灰+活力橙的配色通过深空灰根背景+深灰卡片+纯黑高亮背景营造健身房风格的硬核力量感,活力橙#FF6B00作为主高亮和按钮色,活力金#FFD400作为价格和等级色,热血红#E8483C作为删除和点赞色,确保视觉一致性和硬核健身风韵味。

四、数据模型

应用定义了7个接口,覆盖健身装备二手交易全链路:

  • GymItem器材(id/name/eng/cat/price/rarity/year/rating/starStr/seller/tag/desc/want/sales/emoji/size)——18款,含中英文名称、分类、稀有度0-100、发布年份、规格尺寸(24kg/5磅/100kg/L码/1L等)、卖家想换等二手交易特色字段
  • SwapItem交换帖(id/user/avatar/offer/want/time/likes/content/place)——8条交换帖,含我提供/我想换/地点/点赞数
  • GuideItem教程计划(id/name/type/pages/author/likes/downloads/emoji/steps)——5套教程,含步骤数组
  • AccessoryItem配件补剂(id/name/series/price/condition/seller/emoji/desc)——9款配件
  • CollectionItem图鉴收藏(id/name/series/owned/total/rate/emoji)——6套图鉴,含已收/总数/进度百分比
  • GymReview圈友点评(id/user/setName/starStr/content)——3条点评
  • ColorPalette配色(bg/card/orange/gray/deep/red/gold/sub/line)——9色配色常量

rarity稀有度字段是健身装备的特色设计——0-100数值,通过rarityLabel函数映射为四级(传世级≥95/稀有级≥80/紧俏级≥60/流通级<60),通过rarityColor函数映射为四色(热血红/橙/科技蓝/活力金),在柱状图和器材详情中直接渲染。size规格字段区分24kg/5磅/100kg/L码/1L等不同尺寸,want卖家想换字段支持以物换物交易场景。

五、Tab0 集市交易(双Tab嵌套)

集市页是应用的核心,采用底部Tab+顶部Tab双层嵌套架构。顶部6个分类Tab(全部/器械/补剂/服饰/配件/计划),每个Tab有独立的布局风格:

全部Tab:Banner+双列瀑布

  • 纯黑Banner:力量训练节硬核专场+大器械3天限时卖家免服务费+大型器械/运动补剂标签
  • 全城新上架:双列瀑布布局,左列2件(护腰带/运动毛巾),右列1件(筋膜枪,纯黑高亮背景),每件含emoji/中文名/英文名/描述/价格/标签

器械Tab:横滑大卡+稀有度柱状图+捡漏榜

  • 大型器械专区:3件横滑大卡(可调节哑铃套装/跑步机商用级/综合训练器),深灰背景160宽,含emoji/名称/英文+年份/价格+稀有度标签
  • 稀有度排行:3根柱状图(75/88/95),第三根综合训练器用活力橙高亮,底部说明"综合训练器以95分稀有度登顶,市面流通不足十台"
  • 今日捡漏榜:3件排行列表,第1名活力橙数字,含排名/emoji/名称+稀有度+卖家想换/价格

补剂Tab:教程时间轴

  • 5套教程时间轴布局(科学增肌训练计划/高效减脂HIIT教程/深蹲硬拉指南/瑜伽拉伸入门/饮食补剂搭配),左侧emoji+活力橙竖线连接,右侧卡片含名称/下载数/作者+类型+页数/步骤列表(带序号圆点)/点赞+教程可下载

服饰Tab:三列格子+交换建议

  • 健身服饰三列网格(9款配件,31%宽度),每件含emoji/名称/系列/价格
  • 配件交换行情:偶数ID配件的交换列表,含emoji/名称+成色/描述/价格(活力金)

配件Tab:对决卡+侧栏统计

  • 配件对决:可调节哑铃 VS 乳清蛋白粉,两张深灰对决卡中间VS标识
  • 左侧3件专业器械列表(杠铃套装/龙门架家用/动感单车),右侧3格统计(12本周装备成交活力橙/3.2万装备总交易额活力金/92%好评率活力金)

计划Tab:标签云+紧凑列表

  • 训练计划标签云:6套图鉴(自由器械/有氧器械/运动补剂/健身服饰/训练配件/恢复器材),纯黑背景chip
  • 3件紧凑列表(运动T恤/运动短裤/运动水壶),第3件纯黑高亮背景,含稀有度彩色标签
  • 底部提示:集齐三大器械可召唤隐藏福利:哑铃+杠铃+龙门架

双层Tab嵌套让撸铁人可以在集市主Tab内快速切换6大品类,每个品类有独立的视觉布局和数据展示方式,避免单一布局的单调感。

六、Tab1 换件交换

换件页是健身装备二手交易的特色功能——以物换物。由两个层次构成:

1. 统计条+发交换按钮:四格统计(156在交换中活力橙/42今日成交活力金/98%面交好评活力橙)+右侧发交换按钮(活力橙底,触发发起交换弹框)。

2. 交换帖列表:8条交换帖卡片,每帖含:

  • 头部:头像emoji+用户名+热度标签(🔥热门≥50/👍热度≥30/🌱新帖<30,通过swapBadge函数动态生成)+时间+地点+右侧⋯菜单(触发下架弹框)
  • 交换区:我提供(纯黑背景,活力橙标题)⇄ 我想换(纯黑背景,活力金标题),左右对称布局
  • 内容:帖文描述
  • 底部:📍地点标签(活力橙底纯黑背景)+❤️点赞数(热血红)

换件页解决了健身装备二手交易中"以物换物"的核心需求——撸铁人可以用自己的闲置装备(哑铃/跑步机/增肌计划/蛋白粉/瑜伽垫/综合训练器/筋膜枪/运动T恤)交换心仪的装备,通过地点标签支持地铁站面交和线上交换,通过热度标签筛选热门交换帖。

七、Tab2 图鉴收藏

图鉴页是健身装备收藏进度管理功能。由三个层次构成:

1. 标题+登记按钮:我的健身图鉴标题+记录每一项训练的装备进度+右侧✚登记按钮(活力橙底,触发发布出售弹框复用)。

2. 图鉴进度列表:6套图鉴(自由器械/有氧器械/运动补剂/健身服饰/训练配件/恢复器材),每套含:

  • 头部:emoji+名称+英文系列名+已收X/总数+右侧进度百分比(通过rateColor函数动态着色:≥55活力金/≥40活力橙/<40热血红)
  • 进度条:双色进度条(已收部分rateColor色+未收部分中灰),宽度通过百分比动态计算

3. 图鉴成就墙:4个成就标签(🎖️力量举大师/🏆有氧达人/🥤补剂专家/💪器械收藏家),不同颜色文字。

图鉴页让撸铁人可以系统化管理自己的健身装备收藏进度,通过进度条和百分比直观看到每套图鉴的完成度,通过成就墙增加收藏的趣味性和成就感。

八、Tab3 个人中心

我的页是撸铁人个人信息管理。由三个层次构成:

1. 会员信息卡:深灰背景,含💪头像+健身收藏家阿乐+LV.10资深撸铁人·信用分990+右侧>箭头+三格统计(38在售装备活力橙/12求购中活力橙/¥6.8万累计成交额活力橙)。

2. 我的求购清单:3件求购装备(运动T恤/筋膜枪/运动毛巾),每件含emoji/名称+预算+卖家想换/右侧出价中标签(活力金底纯黑背景)。

3. 常去面交点:5个地点列表(光谷广场站/江汉路站/洪山广场站/楚河汉街站/线上互换),每个含不同emoji(🚇/🏬/🚌/🏪/📦)+地点名+右侧站点说明(光谷站台/江汉路天桥/洪山转盘/楚河入口/顺丰网点)。

我的页通过求购清单和常去面交点两个特色功能,将健身装备二手交易的线下场景融入个人中心,让撸铁人可以管理自己的求购装备和常去面交地点。

九、弹框体系

本应用有4种弹框,均通过@State布尔值控制显隐,zIndex通过Stack层叠实现:

1. 发布出售弹框(新增):88%宽76%高,纯黑头部(🏋️发布出售+闲置回血神兵不愁卖),滚动内容含:要出售的装备(8个装备chip选择,选中活力橙底纯黑字)+成色说明(5档chip:全新未拆/仅拆箱/9成新/8成新/有磨损,选中活力金底纯黑字)+出售价格(−/¥价格/+步进器,步进10元,价格>2000显示"高价好物建议包邮"否则"实惠价更容易出手")+宝贝描述(TextInput输入)+取消/上架出售双按钮。

2. 发起交换弹框(新增):88%宽72%高,活力金头部(🤝发起交换+用闲置换心头好撸铁互助),滚动内容含:我提供(5个装备chip选择,选中活力橙底纯黑字)+我想换可多选(5个装备chip,选中活力橙底纯黑字带✓)+面交地点(5个地点chip,选中活力橙底纯黑字)+安全提示(💡交换双方可自行协商补差价,面交请选择人流密集的公共场所,注意安全)+再想想/发布交换帖双按钮。

3. 下架弹框(删除):72%宽居中,🗑️图标+下架这件装备?+说明文字(下架后买家将无法搜索到这条信息,收藏和留言会一并清空,可重新上架)+留着(活力橙底纯黑背景)/确认下架(热血红底纯黑字)双按钮。

4. 器材详情弹框:88%宽78%高,纯黑头部(emoji+中文名+英文名+标签+稀有度标签),滚动内容含:四格数据(售价活力橙/规格活力金/稀有度动态色/年份科技蓝)+宝贝描述(描述文字+卖家+星级评分)+卖家想换(🤝+卖家想换,纯黑背景)+圈友点评(3条点评卡片)+留言问问(活力橙底纯黑背景)/立即购买(活力橙底纯黑字)双按钮。

所有弹框均通过Stack层叠+半透明黑色背景(99000000)+居中布局实现,点击背景区域关闭弹框。

十、核心技术特性

1. 双Tab嵌套架构:底部4Tab+集市Tab内部顶部6Tab,通过两个@State(currentBottomTab/currentTopTab)独立控制,if-else链分发到对应的Builder方法,实现双层分类浏览。

2. 14粒子漂浮动效:aboutToAppear生命周期中buildParticles生成14个粒子(🏋️/🥤/💪/🔥/🧘五种emoji随机,大小12-22px,速度0.6-2.0,透明度0.2-0.6),setInterval每80ms调用driftParticles更新x坐标(超出360重置为-20),通过position绝对定位漂浮在页面上,营造汗水飞溅氛围。aboutToDisappear中clearInterval清理定时器避免内存泄漏。

3. 传世/稀有/紧俏/流通四级稀有度分级:rarity字段0-100数值,通过rarityLabel映射为四级标签(传世级≥95/稀有级≥80/紧俏级≥60/流通级<60),通过rarityColor映射为四色(热血红/橙/科技蓝/活力金),在柱状图、器材详情、紧凑列表中统一渲染,数据驱动UI。

4. 深空灰活力橙头部设计:头部使用纯黑#111111到深空灰#1E1E1E的linearGradient渐变,活力橙#FF6B00文字和标签在深色背景上形成鲜明对比,营造健身房风格的硬核力量感。

5. 以物换物交换帖:换件页每条帖子采用我提供(纯黑背景,活力橙标题)⇄我想换(纯黑背景,活力金标题)的对称布局,通过swapBadge函数根据点赞数动态生成热度标签(🔥热门/👍热度/🌱新帖),支持地铁站面交和线上交换,解决健身装备二手交易中的以物换物需求。

6. 全局纯函数工具集:10+全局纯函数(catColor/catLabel/rarityLabel/rarityColor/tradeBarHeight/rateColor/6个分类筛选函数/swapBadge),将数据到UI的映射逻辑抽离为纯函数,便于复用和维护,符合函数式编程思想。

7. 分类筛选函数:6个函数(retiredSets/mocSets/figSets/techSets/streetSets/classicSets)通过数组切片返回对应分类的3件装备,cityLeft/cityRight返回全部Tab的双列数据,hotSets返回热门装备,数据筛选逻辑清晰。

8. 详情数据取值方法:14个detailXxx方法(detailName/detailEng/detailEmoji/detailPrice/detailSize/detailRarity/detailYear/detailSeller/detailTag/detailStar/detailRating/detailDesc/detailWant)通过遍历GYMS数组查找selectedGymId对应的装备字段,在详情弹框中调用,避免在Builder中写复杂的查找逻辑。

9. 步进器价格输入:发布出售弹框的价格采用−/¥价格/+步进器设计,步进10元,通过@State sellPrice控制,价格>2000时动态显示"高价好物建议包邮"提示,交互友好。

10. Stack层叠弹框管理:4种弹框通过Stack层叠+@State布尔值控制,半透明黑色背景99000000,点击背景关闭,弹框内容居中,zIndex自动由Stack层叠顺序决定,无需手动管理zIndex。

十一、同类对比

维度 通用二手平台 本应用(肌肉工坊)
主题 浅色/蓝色为主 深空灰+活力橙硬核健身风
架构 单Tab或简单分类 双Tab嵌套(底部4+顶部6)
动效 无或简单 14个粒子漂浮动效
稀有度 无或简单星级 0-100数值+传世/稀有/紧俏/流通四级+四色映射
以物换物 无或简单留言 交换帖+我提供⇄我想换对称布局
训练计划 无或外部链接 5套时间轴布局教程+步骤列表
装备图鉴 无或简单收藏 6套图鉴+进度条+成就墙
求购清单 3件求购装备+预算+出价中
常去面交点 5个地点+站点说明
弹框 2-3种 4种(发布出售/发起交换/下架/详情)

十二、完整代码结构总览

1309.ets
├── 数据结构(7个interface)
├── 静态配置(PALETTE配色 + 2个Tab配置 + 2个弹框选项 + 2个图表数据)
├── 静态数据(8个数组:18装备+8交换帖+5教程+9配件+6图鉴+3点评)
├── 全局纯函数(10+个:catColor/catLabel/rarityLabel/rarityColor/rateColor/6分类筛选/swapBadge)
├── Index入口组件(@Entry @Component)
│   ├── 状态(currentBottomTab/currentTopTab/selectedGymId/4个弹框显隐/发布出售表单/发起交换表单/particles粒子)
│   ├── 生命周期(aboutToAppear生成粒子+启动定时器/aboutToDisappear清理定时器)
│   ├── 粒子方法(buildParticles/driftParticles)
│   ├── 详情取值方法(14个detailXxx)
│   ├── 头部Builder
│   ├── 顶部Tab Builder
│   ├── 6个顶部Tab内容Builder(city/retired/moc/fig/tech/street)
│   ├── 集市首页Builder(bazaarContent)
│   ├── 换件页Builder(swapContent)
│   ├── 图鉴页Builder(collectionContent)
│   ├── 我的页Builder(mineContent)
│   ├── 底部Tab Builder
│   ├── 4种弹框Builder(sellModal/swapModal/deleteModal/detailModal)
│   ├── 交换多选辅助方法(pickedWant/toggleWant)
│   └── build主布局(Stack层叠+Column内容+粒子+4弹框)

十三、开发环境搭建

13.1 环境要求

DevEco Studio 5.0+(支持HarmonyOS 6.1.1)、HarmonyOS SDK API 24、Node.js 18+、至少8GB内存。

13.2 安装DevEco Studio

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

从华为开发者官网下载最新版本,运行安装包,选择安装路径,勾选创建桌面快捷方式,点击安装。

13.3 配置SDK

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

首次启动后进入File > Settings > HarmonyOS SDK,勾选API 24及以上版本,点击Apply等待下载完成。

13.4 创建项目

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

选择Create Project > Empty Ability,配置项目名称、包名、保存路径,选择Compile SDK为API 24,点击Finish。

13.5 运行应用

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

将1309.ets代码替换到entry/src/main/ets/pages/Index.ets,连接HarmonyOS设备或启动模拟器,点击运行按钮预览。

13.6 预览调试

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

DevEco Studio提供实时预览功能,编辑器右侧打开Previewer面板,支持多设备尺寸预览、深色模式切换、组件树inspect等调试能力。

十四、总结展望

本文完整解析了基于HarmonyOS 6.1.1的肌肉工坊应用,从深空灰+活力橙硬核健身配色系统、双Tab嵌套架构、装备数据模型(含稀有度0-100/规格尺寸/卖家想换等特色字段)、集市交易六大品类独立布局(全部双列瀑布/器械横滑大卡+稀有度柱状图+捡漏榜/补剂教程时间轴/服饰三列网格/配件对决卡+侧栏统计/计划标签云+紧凑列表)、换件以物换物交换帖、图鉴收藏进度条、个人中心求购清单+常去面交点,到4种弹框体系、14粒子漂浮动效、传世/稀有/紧俏/流通四级稀有度分级、深空灰活力橙头部、全局纯函数工具集、详情数据取值方法,展现了ArkTS在硬核健身风二手交易场景下的完整工程实践。

核心价值:

  1. 深空灰+活力橙硬核配色:健身房风格的硬核力量感,活力橙高亮营造热血氛围
  2. 双Tab嵌套架构:底部4Tab+顶部6Tab,双层分类浏览体验
  3. 14粒子漂浮动效:setInterval驱动emoji粒子漂浮,aboutToDisappear清理定时器
  4. 传世/稀有/紧俏/流通四级稀有度分级:0-100数值→四级标签→四色映射,数据驱动UI
  5. 以物换物交换帖:我提供⇄我想换对称布局+热度标签动态生成+地铁站面交
  6. 装备图鉴进度管理:6套图鉴+双色进度条+成就墙,收藏系统化
  7. 全局纯函数工具集:10+纯函数抽离数据到UI映射逻辑,代码可维护

未来可扩展:

  • 接入真实健身装备数据库,自动识别器械类型和规格,替代手动分类
  • 粒子动效接入设备陀螺仪,随手机倾斜方向漂移,增强沉浸感
  • 稀有度接入真实成交数据和市场行情,动态更新装备稀有度评分
  • 以物换物接入智能匹配算法,根据装备类型和价值推荐交换对象
  • 装备图鉴接入Keep/咕咚数据同步,自动更新训练装备使用记录
  • 接入训练计划分享功能,撸铁人可以展示自己的训练计划请圈友在线点评
  • 求购清单接入推送通知,有匹配装备时自动提醒撸铁人

肌肉工坊,让每一件装备都找到懂它的撸铁人,让深空流转、活力生香。


附录:完整源码

// ============================================================
// 1309.ets - 肌肉工坊
// 场景:健身器械/运动补剂/健身服饰/配件的二手交易与收藏社区(硬核健身风)
// 风格:深空灰 #1E1E1E + 活力橙 #FF6B00 硬核健身风
// 底部Tab:集市 / 换件 / 图鉴 / 我的
// 顶部Tab:全部 / 器械 / 补剂 / 服饰 / 配件 / 计划
// 弹框:发布出售(新增) / 发起交换(新增) / 下架(删除) / 器材详情(详情)
// ============================================================
// ---------------- 配色 ----------------
interface ColorPalette {
bg: string;
card: string;
orange: string;
gray: string;
deep: string;
red: string;
gold: string;
sub: string;
line: string;
}
const PALETTE: ColorPalette = {
bg: '#1E1E1E',
card: '#2A2A2A',
orange: '#FF6B00',
gray: '#3A3A3A',
deep: '#111111',
red: '#E8483C',
gold: '#FFD400',
sub: '#8A8A8A',
line: '#3A3A3A'
};
// ---------------- 通用结构 ----------------
interface TabItem { label: string; icon: string; }
interface ParticleItem { x: number; emoji: string; size: number; speed: number; opacity: number; }
// ---------------- 器材条目 ----------------
interface GymItem {
id: number; name: string; eng: string; cat: string; price: number;
rarity: number; year: number; rating: number; starStr: string; seller: string;
tag: string; desc: string; want: string; sales: number; emoji: string; size: string;
}
// ---------------- 交换帖 ----------------
interface SwapItem {
id: number; user: string; avatar: string; offer: string; want: string;
time: string; likes: number; content: string; place: string;
}
// ---------------- 教程/计划 ----------------
interface GuideItem {
id: number; name: string; type: string; pages: number; author: string;
likes: number; downloads: number; emoji: string; steps: string[];
}
// ---------------- 配件/补剂 ----------------
interface AccessoryItem {
id: number; name: string; series: string; price: number; condition: string;
seller: string; emoji: string; desc: string;
}
// ---------------- 图鉴收藏 ----------------
interface CollectionItem {
id: number; name: string; series: string; owned: number; total: number; rate: number; emoji: string;
}
// ---------------- 点评 ----------------
interface GymReview {
id: number; user: string; setName: string; starStr: string; content: string;
}
// ---------------- Tab 配置 ----------------
const BOTTOM_TABS: TabItem[] = [
{ label: '集市', icon: '🏋️' }, { label: '换件', icon: '🤝' }, { label: '图鉴', icon: '📖' }, { label: '我的', icon: '💪' }
];
const TOP_TABS: TabItem[] = [
{ label: '全部', icon: '🧿' }, { label: '器械', icon: '🏋️' }, { label: '补剂', icon: '🥤' },
{ label: '服饰', icon: '👕' }, { label: '配件', icon: '🎒' }, { label: '计划', icon: '📋' }
];
// ---------------- 健身器材数据(18款写死) ----------------
const GYMS: GymItem[] = [
{ id: 1, name: '可调节哑铃套装', eng: 'Adjustable Dumbbells', cat: 'retired', price: 1500, rarity: 75, year: 2022, rating: 5.0, starStr: '⭐⭐⭐⭐⭐', seller: '硬核老铁', tag: '家用神器', desc: '可调节哑铃套装,2.5kg-24kg,电镀工艺,防滑手柄,成色极佳,在家也能练全身。', want: '换 杠铃片', sales: 8, emoji: '🏋️', size: '24kg' },
{ id: 2, name: '跑步机 商用级', eng: 'Commercial Treadmill', cat: 'retired', price: 6500, rarity: 88, year: 2021, rating: 4.9, starStr: '⭐⭐⭐⭐⭐', seller: '健身器材商', tag: '静音减震', desc: '商用级跑步机,15档坡度,静音减震,带心率监测,适合家庭和专业健身房。', want: '换 椭圆机', sales: 3, emoji: '🏃', size: '家用款' },
{ id: 3, name: '综合训练器', eng: 'Multi-Gym', cat: 'retired', price: 8800, rarity: 95, year: 2020, rating: 5.0, starStr: '⭐⭐⭐⭐⭐', seller: '力量训练师', tag: '大器械', desc: '多功能综合训练器,可练胸、背、腿,配重块齐全,稳定性极好,家用顶级。', want: '面交自提', sales: 1, emoji: '🏗️', size: '标准' },
{ id: 4, name: '增肌训练计划', eng: 'Muscle Gain Plan', cat: 'moc', price: 49, rarity: 30, year: 2025, rating: 4.9, starStr: '⭐⭐⭐⭐⭐', seller: '健身教练', tag: '科学增肌', desc: '专业增肌训练计划,包含详细动作讲解、组数次数安排、饮食建议,新手友好。', want: '可换补剂', sales: 156, emoji: '📋', size: '电子版' },
{ id: 5, name: '减脂 HIIT 教程', eng: 'HIIT Guide', cat: 'moc', price: 39, rarity: 25, year: 2024, rating: 4.8, starStr: '⭐⭐⭐⭐✨', seller: '燃脂达人', tag: '高效燃脂', desc: 'HIIT高强度间歇训练教程,科学高效减脂,在家就能做,超实用。', want: '换 瑜伽垫', sales: 98, emoji: '🔥', size: '视频版' },
{ id: 6, name: '乳清蛋白粉', eng: 'Whey Protein', cat: 'moc', price: 299, rarity: 55, year: 2025, rating: 4.9, starStr: '⭐⭐⭐⭐⭐', seller: '补剂经销商', tag: '补充蛋白', desc: '进口乳清蛋白粉,5磅装,高蛋白低糖,巧克力味,肌肉修复必备。', want: '换 肌酸', sales: 210, emoji: '🥤', size: '5磅' },
{ id: 7, name: '肌酸 粉剂', eng: 'Creatine Powder', cat: 'fig', price: 150, rarity: 35, year: 2025, rating: 4.8, starStr: '⭐⭐⭐⭐✨', seller: '补剂专家', tag: '提升力量', desc: '纯肌酸粉,提升力量爆发力,改善训练表现,无副作用,健身者必备。', want: '换 蛋白粉', sales: 120, emoji: '⚡', size: '300g' },
{ id: 8, name: '健身手套', eng: 'Gym Gloves', cat: 'fig', price: 50, rarity: 25, year: 2024, rating: 4.7, starStr: '⭐⭐⭐⭐', seller: '健身装备店', tag: '防滑护腕', desc: '专业健身手套,防滑透气,带护腕设计,保护手掌,举铁必备。', want: '换 护腕', sales: 50, emoji: '🧤', size: '均码' },
{ id: 9, name: '瑜伽垫 加厚', eng: 'Yoga Mat', cat: 'fig', price: 80, rarity: 30, year: 2023, rating: 4.8, starStr: '⭐⭐⭐⭐✨', seller: '瑜伽爱好者', tag: '防滑缓震', desc: '加厚瑜伽垫,防滑材质,TPE环保材料,回弹性好,适合瑜伽和拉伸。', want: '换 哑铃', sales: 60, emoji: '🧘', size: '185cm' },
{ id: 10, name: '杠铃 套装', eng: 'Barbell Set', cat: 'tech', price: 2200, rarity: 60, year: 2022, rating: 4.9, starStr: '⭐⭐⭐⭐⭐', seller: '力量区霸主', tag: '举铁必备', desc: '20kg杠铃杆,配80kg杠铃片,电镀防锈,标准尺寸,深蹲硬拉必备。', want: '换 哑铃', sales: 5, emoji: '🏋️', size: '100kg' },
{ id: 11, name: '龙门架 家用', eng: 'Home Cable Machine', cat: 'tech', price: 4800, rarity: 72, year: 2023, rating: 4.8, starStr: '⭐⭐⭐⭐✨', seller: '家庭健身房', tag: '多功能', desc: '家用龙门架,可做下拉、划船、飞鸟等动作,配重块均匀,节省空间。', want: '换 跑步机', sales: 2, emoji: '🛠️', size: '标准' },
{ id: 12, name: '动感单车', eng: 'Spinning Bike', cat: 'tech', price: 1500, rarity: 50, year: 2024, rating: 4.7, starStr: '⭐⭐⭐⭐', seller: '骑行教练', tag: '静音飞轮', desc: '动感单车,飞轮静音,阻力可调,带心率监测,居家有氧神机。', want: '换 瑜伽垫', sales: 10, emoji: '🚴', size: '家用' },
{ id: 13, name: '运动T恤', eng: 'Sports T-Shirt', cat: 'street', price: 80, rarity: 20, year: 2025, rating: 4.6, starStr: '⭐⭐⭐⭐', seller: '运动服饰店', tag: '速干排汗', desc: '速干运动T恤,透气排汗,弹性好,适合跑步和举铁,多色可选。', want: '换 运动裤', sales: 80, emoji: '👕', size: 'L码' },
{ id: 14, name: '运动短裤', eng: 'Sports Shorts', cat: 'street', price: 90, rarity: 25, year: 2024, rating: 4.7, starStr: '⭐⭐⭐⭐', seller: '运动服饰', tag: '轻薄透气', desc: '运动短裤,轻薄透气,带内衬,防走光,运动舒适,超实用。', want: '换 腰带', sales: 60, emoji: '🩳', size: 'M码' },
{ id: 15, name: '运动水壶', eng: 'Sports Bottle', cat: 'street', price: 30, rarity: 15, year: 2025, rating: 4.5, starStr: '⭐⭐⭐⭐', seller: '运动配件', tag: '大容量', desc: '运动水壶,大容量,带刻度,防漏设计,健身补水必备。', want: '换 毛巾', sales: 50, emoji: '🧴', size: '1L' },
{ id: 16, name: '筋膜枪', eng: 'Massage Gun', cat: 'classic', price: 250, rarity: 40, year: 2023, rating: 4.8, starStr: '⭐⭐⭐⭐✨', seller: '恢复专家', tag: '深层放松', desc: '筋膜枪,多档调节,深层肌肉放松,缓解运动疲劳,运动后必用。', want: '换 泡沫轴', sales: 40, emoji: '💆', size: '标准' },
{ id: 17, name: '护腰带', eng: 'Weight Lifting Belt', cat: 'classic', price: 100, rarity: 30, year: 2024, rating: 4.7, starStr: '⭐⭐⭐⭐', seller: '力量举爱好者', tag: '保护腰椎', desc: '专业护腰带,加宽设计,支撑性强,保护腰椎,大重量训练必备。', want: '换 手套', sales: 30, emoji: '🥋', size: '均码' },
{ id: 18, name: '运动毛巾', eng: 'Sports Towel', cat: 'classic', price: 20, rarity: 10, year: 2025, rating: 4.5, starStr: '⭐⭐⭐⭐', seller: '健身周边', tag: '吸水速干', desc: '运动毛巾,吸水速干,便携易带,健身必备,手感超好。', want: '换 水壶', sales: 60, emoji: '🧻', size: '标准' }
];
// ---------------- 交换帖数据(8条写死) ----------------
const SWAPS: SwapItem[] = [
{ id: 1, user: '硬核老铁', avatar: '🏋️', offer: '可调节哑铃', want: '杠铃套装', time: '今天 13:20', likes: 46, content: '家用哑铃换杠铃,都是好器材,可补差价,面交地铁站。', place: '光谷广场站' },
{ id: 2, user: '健身器材商', avatar: '🏃', offer: '跑步机', want: '椭圆机', time: '今天 11:05', likes: 38, content: '商用跑步机换椭圆机,都是大件,可补差价,诚心换。', place: '江汉路站' },
{ id: 3, user: '健身教练', avatar: '📋', offer: '增肌计划', want: '运动补剂', time: '昨天 18:42', likes: 61, content: '专业训练计划换补剂,多换一好商量,诚实交易。', place: '洪山广场站' },
{ id: 4, user: '补剂经销商', avatar: '🥤', offer: '乳清蛋白粉', want: '肌酸粉', time: '昨天 15:30', likes: 29, content: '蛋白粉换肌酸,都是补剂,可补差价,学生党优先。', place: '线上交换' },
{ id: 5, user: '瑜伽爱好者', avatar: '🧘', offer: '瑜伽垫', want: '运动护具', time: '前天 20:15', likes: 22, content: '瑜伽垫换护具,都是居家健身好物,可补差价,诚心换。', place: '楚河汉街站' },
{ id: 6, user: '力量区霸主', avatar: '🏗️', offer: '综合训练器', want: '跑步机', time: '前天 09:50', likes: 41, content: '大器械换跑步机,都是大件,补差价换,可聊聊看。', place: '线上互换' },
{ id: 7, user: '恢复专家', avatar: '💆', offer: '筋膜枪', want: '泡沫轴', time: '3天前 22:08', likes: 55, content: '筋膜枪换泡沫轴,都是放松器材,愿补差价,面交优先。', place: '武昌火车站' },
{ id: 8, user: '运动服饰店', avatar: '👕', offer: '运动T恤', want: '运动短裤', time: '4天前 14:26', likes: 17, content: 'T恤换短裤,都是运动服饰,学生党不容易,大家帮帮忙。', place: '线上交换' }
];
// ---------------- 教程/计划数据(5条写死) ----------------
const GUIDES: GuideItem[] = [
{ id: 1, name: '科学增肌训练计划', type: '增肌', pages: 40, author: '健身教练', likes: 342, downloads: 2100, emoji: '📋', steps: ['动作安排 1-10页', '组数次数计划 11-20页', '饮食摄入建议 21-40页'] },
{ id: 2, name: '高效减脂HIIT教程', type: '减脂', pages: 25, author: '燃脂达人', likes: 276, downloads: 1580, emoji: '🔥', steps: ['热身动作 1-5页', 'HIIT核心循环 6-15页', '拉伸恢复 16-25页'] },
{ id: 3, name: '深蹲硬拉指南', type: '力量', pages: 35, author: '力量区霸主', likes: 415, downloads: 3300, emoji: '🏋️', steps: ['姿势标准 1-12页', '杠铃轨迹 13-25页', '重量进阶 26-35页'] },
{ id: 4, name: '瑜伽拉伸入门', type: '瑜伽', pages: 30, author: '瑜伽爱好者', likes: 198, downloads: 1260, emoji: '🧘', steps: ['基础体位 1-10页', '呼吸配合 11-20页', '经络拉伸 21-30页'] },
{ id: 5, name: '饮食补剂搭配', type: '补剂', pages: 20, author: '补剂专家', likes: 233, downloads: 1420, emoji: '🥤', steps: ['蛋白粉选型 1-8页', '肌酸使用 9-14页', '氮泵入门 15-20页'] }
];
// ---------------- 配件/补剂数据(9条写死) ----------------
const ACCESSORIES: AccessoryItem[] = [
{ id: 1, name: '健身手套', series: '防滑', price: 50, condition: '全新', seller: '健身装备店', emoji: '🧤', desc: '护腕防滑,保护手掌' },
{ id: 2, name: '运动水壶', series: '大容量', price: 30, condition: '全新', seller: '运动配件', emoji: '🧴', desc: '防漏便携,刻度清晰' },
{ id: 3, name: '护腰带', series: '加宽', price: 100, condition: '9成新', seller: '力量举', emoji: '🥋', desc: '支撑强,保护腰椎' },
{ id: 4, name: '筋膜枪', series: '深层', price: 250, condition: '9成新', seller: '恢复专家', emoji: '💆', desc: '多档调节,深层放松' },
{ id: 5, name: '瑜伽垫', series: '加厚', price: 80, condition: '全新', seller: '瑜伽爱好者', emoji: '🧘', desc: '防滑缓震,环保材质' },
{ id: 6, name: '健身毛巾', series: '速干', price: 20, condition: '全新', seller: '健身周边', emoji: '🧻', desc: '吸水速干,便携易带' },
{ id: 7, name: '运动背包', series: '大号', price: 120, condition: '9成新', seller: '运动装备', emoji: '🎒', desc: '多隔层,装鞋装水' },
{ id: 8, name: '摇摇杯', series: '蛋白粉杯', price: 25, condition: '全新', seller: '补剂配件', emoji: '🥛', desc: '搅拌球设计,冲粉均匀' },
{ id: 9, name: '弹力带', series: '阻力', price: 40, condition: '全新', seller: '健身配件', emoji: '🪢', desc: '多阻力级别,拉伸训练' }
];
// ---------------- 图鉴收藏数据(6条写死) ----------------
const COLLECTIONS: CollectionItem[] = [
{ id: 1, name: '自由器械', series: 'Free Weights', owned: 5, total: 12, rate: 42, emoji: '🏋️' },
{ id: 2, name: '有氧器械', series: 'Cardio', owned: 3, total: 8, rate: 38, emoji: '🏃' },
{ id: 3, name: '运动补剂', series: 'Supplements', owned: 6, total: 15, rate: 40, emoji: '🥤' },
{ id: 4, name: '健身服饰', series: 'Apparel', owned: 8, total: 20, rate: 40, emoji: '👕' },
{ id: 5, name: '训练配件', series: 'Accessories', owned: 10, total: 25, rate: 40, emoji: '🎒' },
{ id: 6, name: '恢复器材', series: 'Recovery', owned: 4, total: 10, rate: 40, emoji: '💆' }
];
// ---------------- 点评数据(3条写死) ----------------
const GYM_REVIEWS: GymReview[] = [
{ id: 1, user: '健身教练', setName: '可调节哑铃', starStr: '⭐⭐⭐⭐⭐', content: '手感极佳,电镀工艺防锈,调节方便,在家练全身完全够用,非常推荐。' },
{ id: 2, user: '增肌学员', setName: '增肌计划', starStr: '⭐⭐⭐⭐✨', content: '计划安排非常科学,动作讲解细致,按着练了一个月肌肉明显变大。' },
{ id: 3, user: '减脂达人', setName: '乳清蛋白粉', starStr: '⭐⭐⭐⭐⭐', content: '口感很好,溶解度高,训练后补充蛋白效果明显,性价比超高。' }
];
// ---------------- 全城周交易量图表数据 ----------------
const TRADE_LABELS: string[] = ['周一', '周二', '周三', '周四', '周五', '周六', '周日'];
const TRADE_BARS: number[] = [56, 64, 72, 58, 102, 146, 138];
// ---------------- 弹框选项 ----------------
const CONDITION_OPTIONS: string[] = ['全新未拆', '仅拆箱', '9成新', '8成新', '有磨损'];
const PLACES: string[] = ['光谷广场站', '江汉路站', '洪山广场站', '楚河汉街站', '线上互换'];
// ---------------- 全局纯函数 ----------------
function catColor(cat: string): string {
if (cat === 'retired') return '#FF6B00';
if (cat === 'moc') return '#7C4DFF';
if (cat === 'fig') return '#FFD400';
if (cat === 'tech') return '#58A6FF';
if (cat === 'street') return '#1E88E5';
return '#FF6B00';
}
function catLabel(cat: string): string {
if (cat === 'retired') return '大型器械';
if (cat === 'moc') return '训练计划';
if (cat === 'fig') return '运动补剂';
if (cat === 'tech') return '专业器械';
if (cat === 'street') return '健身服饰';
return '配件周边';
}
function rarityLabel(r: number): string {
if (r >= 95) return '传世级';
if (r >= 80) return '稀有级';
if (r >= 60) return '紧俏级';
return '流通级';
}
function rarityColor(r: number): string {
if (r >= 95) return '#E8483C';
if (r >= 80) return '#FF8A00';
if (r >= 60) return '#1E88E5';
return '#FFD400';
}
function tradeBarHeight(v: number): string {
return Math.round(v / 146 * 96).toString() + 'vp';
}
function rateColor(r: number): string {
if (r >= 55) return '#FFD400';
if (r >= 40) return '#FF6B00';
return '#E8483C';
}
function retiredSets(): GymItem[] { return [GYMS[0], GYMS[1], GYMS[2]]; }
function mocSets(): GymItem[] { return [GYMS[3], GYMS[4], GYMS[5]]; }
function figSets(): GymItem[] { return [GYMS[6], GYMS[7], GYMS[8]]; }
function techSets(): GymItem[] { return [GYMS[9], GYMS[10], GYMS[11]]; }
function streetSets(): GymItem[] { return [GYMS[12], GYMS[13], GYMS[14]]; }
function classicSets(): GymItem[] { return [GYMS[15], GYMS[16], GYMS[17]]; }
function cityLeft(): GymItem[] { return [GYMS[16], GYMS[17]]; }
function cityRight(): GymItem[] { return [GYMS[15]]; }
function hotSets(): GymItem[] { return [GYMS[3], GYMS[5], GYMS[16], GYMS[17], GYMS[9]]; }
function swapBadge(likes: number): string {
if (likes >= 50) return '🔥热门';
if (likes >= 30) return '👍热度';
return '🌱新帖';
}
// ============================================================
// 主页面
// ============================================================
@Entry
@Component
struct Index {
@State currentBottomTab: number = 0;
@State currentTopTab: number = 0;
@State selectedGymId: number = 1;
@State showSellModal: boolean = false;
@State showSwapModal: boolean = false;
@State showDeleteModal: boolean = false;
@State showDetailModal: boolean = false;
@State sellGymIdx: number = 0;
@State sellCondIdx: number = 2;
@State sellPrice: number = 100;
@State sellWords: string = '';
@State swapOfferIdx: number = 0;
@State swapWantIdx: number = 1;
@State swapPlaceIdx: number = 0;
@State particles: ParticleItem[] = [];
private timerId: number = -1;
aboutToAppear(): void {
this.buildParticles();
this.timerId = setInterval(() => { this.driftParticles(); }, 80);
}
aboutToDisappear(): void {
if (this.timerId !== -1) { clearInterval(this.timerId); this.timerId = -1; }
}
buildParticles(): void {
const emojis: string[] = ['🏋️', '🥤', '💪', '🔥', '🧘'];
const list: ParticleItem[] = [];
for (let i = 0; i < 14; i++) {
list.push({ x: Math.random() * 340, emoji: emojis[i % emojis.length], size: 12 + Math.random() * 10, speed: 0.6 + Math.random() * 1.4, opacity: 0.2 + Math.random() * 0.4 });
}
this.particles = list;
}
driftParticles(): void {
for (let i = 0; i < this.particles.length; i++) {
this.particles[i].x += this.particles[i].speed;
if (this.particles[i].x > 360) { this.particles[i].x = -20; }
}
this.particles = this.particles.slice();
}
// 详情弹框数据取值
detailName(): string { for (let i = 0; i < GYMS.length; i++) if (GYMS[i].id === this.selectedGymId) return GYMS[i].name; return ''; }
detailEng(): string { for (let i = 0; i < GYMS.length; i++) if (GYMS[i].id === this.selectedGymId) return GYMS[i].eng; return ''; }
detailEmoji(): string { for (let i = 0; i < GYMS.length; i++) if (GYMS[i].id === this.selectedGymId) return GYMS[i].emoji; return '🏋️'; }
detailPrice(): string { for (let i = 0; i < GYMS.length; i++) if (GYMS[i].id === this.selectedGymId) return '¥' + GYMS[i].price.toString(); return ''; }
detailSize(): string { for (let i = 0; i < GYMS.length; i++) if (GYMS[i].id === this.selectedGymId) return GYMS[i].size; return ''; }
detailRarity(): string { for (let i = 0; i < GYMS.length; i++) if (GYMS[i].id === this.selectedGymId) return GYMS[i].rarity.toString(); return ''; }
detailYear(): string { for (let i = 0; i < GYMS.length; i++) if (GYMS[i].id === this.selectedGymId) return GYMS[i].year.toString(); return ''; }
detailSeller(): string { for (let i = 0; i < GYMS.length; i++) if (GYMS[i].id === this.selectedGymId) return GYMS[i].seller; return ''; }
detailTag(): string { for (let i = 0; i < GYMS.length; i++) if (GYMS[i].id === this.selectedGymId) return GYMS[i].tag; return ''; }
detailStar(): string { for (let i = 0; i < GYMS.length; i++) if (GYMS[i].id === this.selectedGymId) return GYMS[i].starStr; return ''; }
detailRating(): string { for (let i = 0; i < GYMS.length; i++) if (GYMS[i].id === this.selectedGymId) return GYMS[i].rating.toFixed(1) + '分'; return ''; }
detailDesc(): string { for (let i = 0; i < GYMS.length; i++) if (GYMS[i].id === this.selectedGymId) return GYMS[i].desc; return ''; }
detailWant(): string { for (let i = 0; i < GYMS.length; i++) if (GYMS[i].id === this.selectedGymId) return GYMS[i].want; return ''; }
// ---------------- 头部 ----------------
@Builder
headerBuilder() {
Column() {
Row() {
Column() {
Text('💪 肌肉工坊').fontSize(22).fontWeight(FontWeight.Bold).fontColor('#FF6B00')
Text('淘好物 · 换装备 · 练全身').fontSize(11).fontColor('#8A8A8A').margin({ top: 3 })
}.alignItems(HorizontalAlign.Start).layoutWeight(1)
Row({ space: 14 }) {
Text('🔎').fontSize(20)
Text('📦').fontSize(20)
Column() {
Text('🎒').fontSize(20)
Text('3').fontSize(9).fontColor('#1E1E1E').backgroundColor('#FF6B00').borderRadius(6).padding({ left: 4, right: 4 }).margin({ top: -6 })
}.alignItems(HorizontalAlign.End)
}
}.width('100%').padding({ left: 16, right: 16, top: 14, bottom: 10 })
Row({ space: 8 }) {
Text('🔍 搜索:哑铃 / 蛋白粉 / 健身').fontSize(12).fontColor('#8A8A8A').layoutWeight(1)
Text('🧰 我的求购').fontSize(11).fontColor('#1E1E1E').backgroundColor('#FF6B00').borderRadius(10).padding({ left: 10, right: 10, top: 4, bottom: 4 })
}.width('100%').padding({ left: 16, right: 16, bottom: 12 })
}
.linearGradient({ angle: 135, colors: [['#111111', 0], ['#1E1E1E', 1]] })
.borderRadius({ bottomLeft: 18, bottomRight: 18 })
}
// ---------------- 顶部Tab ----------------
@Builder
topTabsBuilder() {
Row() {
ForEach(TOP_TABS, (t: TabItem, idx: number) => {
Column() {
Text(t.icon).fontSize(17)
Text(t.label).fontSize(12).fontColor(this.currentTopTab === idx ? '#FF6B00' : '#8A8A8A').fontWeight(this.currentTopTab === idx ? FontWeight.Bold : FontWeight.Normal).margin({ top: 2 })
if (this.currentTopTab === idx) {
Divider().width(16).strokeWidth(3).color('#FF6B00').borderRadius(2).margin({ top: 4 })
} else {
Divider().width(16).strokeWidth(3).color('#1E1E1E').borderRadius(2).margin({ top: 4 })
}
}.layoutWeight(1).alignItems(HorizontalAlign.Center).padding({ top: 10, bottom: 6 }).onClick(() => { this.currentTopTab = idx; })
}, (t: TabItem, idx: number) => 'top' + idx.toString() + t.label)
}.width('100%').backgroundColor('#2A2A2A').borderRadius(14).margin({ top: 10 })
}
// ---------------- 全部Tab:banner + 双列瀑布 ----------------
@Builder
cityContent() {
Column({ space: 12 }) {
Column() {
Text('💪 力量训练节 · 硬核专场').fontSize(18).fontWeight(FontWeight.Bold).fontColor('#FF6B00')
Text('大器械 3天限时 · 卖家免服务费').fontSize(12).fontColor('#8A8A8A').margin({ top: 6 })
Row({ space: 10 }) {
Text('🏆 大型器械').fontSize(11).fontColor('#FF6B00').backgroundColor('#2A2A2A').borderRadius(12).padding({ left: 10, right: 10, top: 4, bottom: 4 })
Text('🥤 运动补剂').fontSize(11).fontColor('#FF6B00').backgroundColor('#2A2A2A').borderRadius(12).padding({ left: 10, right: 10, top: 4, bottom: 4 })
}.margin({ top: 10 })
}.width('100%').padding(18).alignItems(HorizontalAlign.Start).backgroundColor('#111111').borderRadius(16)
Text('✨ 全城新上架').fontSize(15).fontWeight(FontWeight.Bold).fontColor('#FF6B00').width('100%')
Row({ space: 10 }) {
Column({ space: 10 }) {
ForEach(cityLeft(), (t: GymItem) => {
Column() {
Text(t.emoji).fontSize(34).margin({ top: 16 })
Text(t.name).fontSize(14).fontWeight(FontWeight.Bold).fontColor('#FFFFFF').margin({ top: 8 })
Text(t.eng).fontSize(9).fontColor('#8A8A8A').margin({ top: 2 })
Text(t.desc).fontSize(11).fontColor('#8A8A8A').margin({ top: 8 }).maxLines(3).textOverflow({ overflow: TextOverflow.Ellipsis })
Row({ space: 6 }) {
Text('¥' + t.price.toString()).fontSize(15).fontWeight(FontWeight.Bold).fontColor('#FF6B00')
Text(t.tag).fontSize(9).fontColor('#FF6B00').backgroundColor('#2A2A2A').borderRadius(8).padding({ left: 6, right: 6, top: 2, bottom: 2 })
}.margin({ top: 10, bottom: 14 })
}.width('100%').backgroundColor('#2A2A2A').borderRadius(14).alignItems(HorizontalAlign.Start).padding({ left: 14, right: 14 })
.onClick(() => { this.selectedGymId = t.id; this.showDetailModal = true; })
}, (t: GymItem) => 'cl' + t.id.toString())
}.layoutWeight(1)
Column({ space: 10 }) {
ForEach(cityRight(), (t: GymItem) => {
Column() {
Text(t.emoji).fontSize(34).margin({ top: 24 })
Text(t.name).fontSize(14).fontWeight(FontWeight.Bold).fontColor('#FFFFFF').margin({ top: 8 })
Text(t.eng).fontSize(9).fontColor('#8A8A8A').margin({ top: 2 })
Text(t.desc).fontSize(11).fontColor('#8A8A8A').margin({ top: 10 }).maxLines(4).textOverflow({ overflow: TextOverflow.Ellipsis })
Row({ space: 6 }) {
Text('¥' + t.price.toString()).fontSize(15).fontWeight(FontWeight.Bold).fontColor('#FF6B00')
Text(t.starStr).fontSize(10)
}.margin({ top: 12, bottom: 20 })
}.width('100%').backgroundColor('#111111').borderRadius(14).alignItems(HorizontalAlign.Start).padding({ left: 14, right: 14 })
.onClick(() => { this.selectedGymId = t.id; this.showDetailModal = true; })
}, (t: GymItem) => 'cr' + t.id.toString())
}.layoutWeight(1)
}.width('100%').alignItems(VerticalAlign.Top)
}.width('100%').padding({ left: 14, right: 14, top: 10, bottom: 16 })
}
// ---------------- 器械Tab:横滑大卡 + 稀有度柱状图 + 捡漏榜 ----------------
@Builder
retiredContent() {
Column({ space: 14 }) {
Text('🏆 大型器械专区').fontSize(15).fontWeight(FontWeight.Bold).fontColor('#FF6B00').width('100%')
Scroll() {
Row({ space: 12 }) {
ForEach(retiredSets(), (t: GymItem) => {
Column() {
Text(t.emoji).fontSize(40).margin({ top: 18 })
Text(t.name).fontSize(15).fontWeight(FontWeight.Bold).fontColor('#FFFFFF').margin({ top: 8 })
Text(t.eng + ' · ' + t.year.toString() + '年').fontSize(9).fontColor('#8A8A8A').margin({ top: 4 })
Row({ space: 6 }) {
Text('¥' + t.price.toString()).fontSize(16).fontWeight(FontWeight.Bold).fontColor('#FF6B00')
Text(rarityLabel(t.rarity)).fontSize(10).fontColor('#1E1E1E').backgroundColor('#FF6B00').borderRadius(8).padding({ left: 6, right: 6, top: 2, bottom: 2 })
}.margin({ top: 10, bottom: 18 })
}.width(160).backgroundColor('#2A2A2A').borderRadius(16).alignItems(HorizontalAlign.Center)
.onClick(() => { this.selectedGymId = t.id; this.showDetailModal = true; })
}, (t: GymItem) => 'rt' + t.id.toString())
}.padding({ left: 14, right: 14 })
}.scrollable(ScrollDirection.Horizontal).scrollBar(BarState.Off).width('100%')
Column() {
Text('📈 稀有度排行').fontSize(13).fontWeight(FontWeight.Bold).fontColor('#FF6B00').width('100%')
Row({ space: 6 }) {
ForEach(retiredSets(), (t: GymItem, i: number) => {
Column({ space: 5 }) {
Text(t.rarity.toString()).fontSize(9).fontColor('#FF6B00')
Column().width(34).height((t.rarity).toString() + 'vp').backgroundColor(i === 2 ? '#FF6B00' : '#FFD400').borderRadius({ topLeft: 5, topRight: 5 })
Text(t.year.toString() + '年').fontSize(9).fontColor('#8A8A8A')
}.alignItems(HorizontalAlign.Center).layoutWeight(1)
}, (t: GymItem, i: number) => 'rb' + i.toString() + t.id.toString())
}.width('100%').justifyContent(FlexAlign.Center).alignItems(VerticalAlign.Bottom).padding({ top: 12 })
Text('综合训练器以95分稀有度登顶,市面流通不足十台').fontSize(10).fontColor('#8A8A8A').margin({ top: 8 })
}.width('100%').backgroundColor('#2A2A2A').borderRadius(14).padding(14).margin({ left: 14, right: 14 })
Column() {
Text('🕵️ 今日捡漏榜').fontSize(14).fontWeight(FontWeight.Bold).fontColor('#FF6B00').width('100%').margin({ bottom: 8 })
ForEach(retiredSets(), (t: GymItem, i: number) => {
Row({ space: 10 }) {
Text((i + 1).toString()).fontSize(14).fontWeight(FontWeight.Bold).fontColor(i === 0 ? '#FF6B00' : '#8A8A8A').width(20)
Text(t.emoji).fontSize(18)
Column() {
Text(t.name).fontSize(13).fontWeight(FontWeight.Bold).fontColor('#FFFFFF')
Text(rarityLabel(t.rarity) + ' · ' + t.want).fontSize(10).fontColor('#8A8A8A').margin({ top: 2 })
}.alignItems(HorizontalAlign.Start).layoutWeight(1)
Text('¥' + t.price.toString()).fontSize(13).fontWeight(FontWeight.Bold).fontColor('#FF6B00')
}.width('100%').padding({ top: 8, bottom: 8 }).onClick(() => { this.selectedGymId = t.id; this.showDetailModal = true; })
}, (t: GymItem, i: number) => 'pck' + i.toString() + t.id.toString())
}.width('100%').backgroundColor('#2A2A2A').borderRadius(14).padding(14).margin({ left: 14, right: 14, bottom: 16 })
}.width('100%').alignItems(HorizontalAlign.Start).padding({ top: 10 })
}
// ---------------- 补剂Tab:教程时间轴 ----------------
@Builder
mocContent() {
Column({ space: 0 }) {
Text('📖 训练计划 · 增肌减脂').fontSize(15).fontWeight(FontWeight.Bold).fontColor('#FF6B00').width('100%').margin({ top: 10, bottom: 12 })
ForEach(GUIDES, (m: GuideItem, i: number) => {
Row({ space: 12 }) {
Column({ space: 4 }) {
Text(m.emoji).fontSize(20)
if (i < GUIDES.length - 1) {
Column().width(2).layoutWeight(1).backgroundColor('#FF6B00').margin({ top: 4 })
}
}.width(40).alignItems(HorizontalAlign.Center)
Column({ space: 6 }) {
Row({ space: 8 }) {
Text(m.name).fontSize(14).fontWeight(FontWeight.Bold).fontColor('#FFFFFF').layoutWeight(1)
Text('⬇ ' + m.downloads.toString()).fontSize(10).fontColor('#FF6B00')
}.width('100%')
Text('by ' + m.author + ' · ' + m.type + ' · ' + m.pages.toString() + '页').fontSize(10).fontColor('#8A8A8A')
Column({ space: 5 }) {
ForEach(m.steps, (s: string, si: number) => {
Row({ space: 8 }) {
Text((si + 1).toString()).fontSize(9).fontWeight(FontWeight.Bold).fontColor('#FF6B00').backgroundColor('#111111').borderRadius(9).width(18).height(18).textAlign(TextAlign.Center)
Text(s).fontSize(10).fontColor('#8A8A8A').layoutWeight(1)
}.width('100%')
}, (s: string, si: number) => 'ms' + si.toString() + m.id.toString())
}.width('100%').backgroundColor('#111111').borderRadius(10).padding(10)
Row({ space: 8 }) {
Text('❤️ ' + m.likes.toString()).fontSize(10).fontColor('#E8483C')
Text(m.emoji + ' 教程可下载').fontSize(10).fontColor('#FF6B00').layoutWeight(1).textAlign(TextAlign.End)
}.width('100%')
}.layoutWeight(1).backgroundColor(i === 1 ? '#111111' : '#2A2A2A').borderRadius(14).padding(12).margin({ bottom: 14 })
}.width('100%').alignItems(VerticalAlign.Top)
}, (m: GuideItem, i: number) => 'moc' + i.toString() + m.id.toString())
}.width('100%').padding({ left: 14, right: 14, bottom: 16 })
}
// ---------------- 服饰Tab:三列格子 + 交换建议 ----------------
@Builder
figContent() {
Column({ space: 14 }) {
Text('👕 健身服饰 · 专业装备').fontSize(15).fontWeight(FontWeight.Bold).fontColor('#FF6B00').width('100%')
Flex({ wrap: FlexWrap.Wrap, justifyContent: FlexAlign.SpaceBetween }) {
ForEach(ACCESSORIES, (f: AccessoryItem) => {
Column() {
Text(f.emoji).fontSize(26).margin({ top: 12 })
Text(f.name).fontSize(11).fontWeight(FontWeight.Bold).fontColor('#FFFFFF').margin({ top: 6 }).maxLines(1)
Text(f.series).fontSize(8).fontColor('#8A8A8A').margin({ top: 2 })
Text('¥' + f.price.toString()).fontSize(13).fontWeight(FontWeight.Bold).fontColor('#FF6B00').margin({ top: 4, bottom: 12 })
}.width('31%').backgroundColor('#2A2A2A').borderRadius(12).alignItems(HorizontalAlign.Center).margin({ bottom: 8 })
.onClick(() => { this.selectedGymId = 7 + f.id % 3; this.showDetailModal = true; })
}, (f: AccessoryItem) => 'fg' + f.id.toString())
}.width('100%')
Column() {
Text('🤝 配件交换行情').fontSize(14).fontWeight(FontWeight.Bold).fontColor('#FF6B00').width('100%').margin({ bottom: 6 })
ForEach(ACCESSORIES, (f: AccessoryItem) => {
if (f.id % 2 === 0) {
Row({ space: 10 }) {
Text(f.emoji).fontSize(20)
Column({ space: 2 }) {
Text(f.name + ' · ' + f.condition).fontSize(12).fontWeight(FontWeight.Bold).fontColor('#FFFFFF')
Text(f.desc).fontSize(10).fontColor('#8A8A8A')
}.alignItems(HorizontalAlign.Start).layoutWeight(1)
Text('¥' + f.price.toString()).fontSize(12).fontWeight(FontWeight.Bold).fontColor('#FFD400')
}.width('100%').padding({ top: 8, bottom: 8 })
}
}, (f: AccessoryItem) => 'fgx' + f.id.toString())
}.width('100%').backgroundColor('#2A2A2A').borderRadius(14).padding(14)
}.width('100%').padding({ left: 14, right: 14, top: 10, bottom: 16 })
}
// ---------------- 配件Tab:对决卡 + 侧栏统计 ----------------
@Builder
techContent() {
Column({ space: 14 }) {
Text('🎒 配件对决 · 硬核装备').fontSize(15).fontWeight(FontWeight.Bold).fontColor('#FF6B00').width('100%')
Row({ space: 10 }) {
Column() {
Text('🏋️').fontSize(34).margin({ top: 14 })
Text('可调节哑铃').fontSize(13).fontWeight(FontWeight.Bold).fontColor('#FFFFFF').margin({ top: 6 })
Text('2022年 · 现价¥1500').fontSize(10).fontColor('#8A8A8A').margin({ top: 4, bottom: 14 })
}.layoutWeight(1).backgroundColor('#2A2A2A').borderRadius(14).alignItems(HorizontalAlign.Center)
Column() {
Text('VS').fontSize(18).fontWeight(FontWeight.Bold).fontColor('#FF6B00')
Text('本周').fontSize(9).fontColor('#8A8A8A')
}.alignItems(HorizontalAlign.Center)
Column() {
Text('🥤').fontSize(34).margin({ top: 14 })
Text('乳清蛋白粉').fontSize(13).fontWeight(FontWeight.Bold).fontColor('#FFFFFF').margin({ top: 6 })
Text('2025年 · 现价¥299').fontSize(10).fontColor('#8A8A8A').margin({ top: 4, bottom: 14 })
}.layoutWeight(1).backgroundColor('#111111').borderRadius(14).alignItems(HorizontalAlign.Center)
}.width('100%')
Row({ space: 10 }) {
Column({ space: 10 }) {
ForEach(techSets(), (t: GymItem) => {
Row({ space: 10 }) {
Text(t.emoji).fontSize(22)
Column({ space: 2 }) {
Text(t.name).fontSize(12).fontWeight(FontWeight.Bold).fontColor('#FFFFFF')
Text(t.tag + ' · ' + t.size).fontSize(10).fontColor('#8A8A8A')
}.alignItems(HorizontalAlign.Start).layoutWeight(1)
Text('¥' + t.price.toString()).fontSize(12).fontWeight(FontWeight.Bold).fontColor('#FF6B00')
}.width('100%').backgroundColor('#2A2A2A').borderRadius(12).padding(12).onClick(() => { this.selectedGymId = t.id; this.showDetailModal = true; })
}, (t: GymItem) => 'tc' + t.id.toString())
}.layoutWeight(1)
Column({ space: 10 }) {
Column({ space: 4 }) {
Text('12').fontSize(18).fontWeight(FontWeight.Bold).fontColor('#FF6B00')
Text('本周装备成交').fontSize(9).fontColor('#8A8A8A')
}.width('100%').backgroundColor('#111111').borderRadius(12).padding({ top: 10, bottom: 10 }).alignItems(HorizontalAlign.Center)
Column({ space: 4 }) {
Text('3.2万').fontSize(18).fontWeight(FontWeight.Bold).fontColor('#FFD400')
Text('装备总交易额').fontSize(9).fontColor('#8A8A8A')
}.width('100%').backgroundColor('#2A2A2A').borderRadius(12).padding({ top: 10, bottom: 10 }).alignItems(HorizontalAlign.Center)
Column({ space: 4 }) {
Text('92%').fontSize(18).fontWeight(FontWeight.Bold).fontColor('#FFD400')
Text('好评率').fontSize(9).fontColor('#8A8A8A')
}.width('100%').backgroundColor('#111111').borderRadius(12).padding({ top: 10, bottom: 10 }).alignItems(HorizontalAlign.Center)
}.width(86)
}.width('100%').alignItems(VerticalAlign.Top)
}.width('100%').padding({ left: 14, right: 14, top: 10, bottom: 16 })
}
// ---------------- 计划Tab:标签云 + 紧凑列表 ----------------
@Builder
streetContent() {
Column({ space: 14 }) {
Text('📋 训练计划 · 科学健身').fontSize(15).fontWeight(FontWeight.Bold).fontColor('#FF6B00').width('100%')
Flex({ wrap: FlexWrap.Wrap, justifyContent: FlexAlign.Start }) {
ForEach(COLLECTIONS, (c: CollectionItem) => {
Text(c.emoji + ' ' + c.name + ' ' + c.owned.toString() + '/' + c.total.toString()).fontSize(11).fontColor('#FF6B00').backgroundColor('#111111').borderRadius(12).padding({ left: 10, right: 10, top: 6, bottom: 6 }).margin(4)
}, (c: CollectionItem) => 'ccoll' + c.id.toString())
}.width('100%')
ForEach(streetSets(), (t: GymItem) => {
Row({ space: 12 }) {
Text(t.emoji).fontSize(24)
Column({ space: 2 }) {
Row({ space: 6 }) {
Text(t.name).fontSize(13).fontWeight(FontWeight.Bold).fontColor('#FFFFFF')
Text(rarityLabel(t.rarity)).fontSize(8).fontColor('#FFFFFF').backgroundColor(rarityColor(t.rarity)).borderRadius(6).padding({ left: 5, right: 5, top: 1, bottom: 1 })
}
Text(t.desc).fontSize(10).fontColor('#8A8A8A').maxLines(1).textOverflow({ overflow: TextOverflow.Ellipsis })
}.alignItems(HorizontalAlign.Start).layoutWeight(1)
Text('¥' + t.price.toString()).fontSize(13).fontWeight(FontWeight.Bold).fontColor('#FF6B00')
}.width('100%').backgroundColor(t.id === 15 ? '#111111' : '#2A2A2A').borderRadius(12).padding(12).onClick(() => { this.selectedGymId = t.id; this.showDetailModal = true; })
}, (t: GymItem) => 'st' + t.id.toString())
Text('💬 集齐三大器械可召唤隐藏福利:哑铃+杠铃+龙门架').fontSize(10).fontColor('#8A8A8A').width('100%')
}.width('100%').padding({ left: 14, right: 14, top: 10, bottom: 16 })
}
// ---------------- 集市首页 ----------------
@Builder
bazaarContent() {
Column() {
this.topTabsBuilder()
if (this.currentTopTab === 0) { this.cityContent() }
else if (this.currentTopTab === 1) { this.retiredContent() }
else if (this.currentTopTab === 2) { this.mocContent() }
else if (this.currentTopTab === 3) { this.figContent() }
else if (this.currentTopTab === 4) { this.techContent() }
else { this.streetContent() }
}.width('100%')
}
// ---------------- 换件页 ----------------
@Builder
swapContent() {
Column({ space: 12 }) {
Row({ space: 0 }) {
Column({ space: 4 }) { Text('156').fontSize(20).fontWeight(FontWeight.Bold).fontColor('#FF6B00'); Text('在交换中').fontSize(10).fontColor('#8A8A8A') }.layoutWeight(1).alignItems(HorizontalAlign.Center)
Column({ space: 4 }) { Text('42').fontSize(20).fontWeight(FontWeight.Bold).fontColor('#FFD400'); Text('今日成交').fontSize(10).fontColor('#8A8A8A') }.layoutWeight(1).alignItems(HorizontalAlign.Center)
Column({ space: 4 }) { Text('98%').fontSize(20).fontWeight(FontWeight.Bold).fontColor('#FF6B00'); Text('面交好评').fontSize(10).fontColor('#8A8A8A') }.layoutWeight(1).alignItems(HorizontalAlign.Center)
Column({ space: 6 }) { Text('🤝 发交换').fontSize(12).fontColor('#111111').backgroundColor('#FF6B00').borderRadius(14).padding({ left: 12, right: 12, top: 6, bottom: 6 }).onClick(() => { this.showSwapModal = true; }) }.alignItems(HorizontalAlign.Center)
}.width('100%').backgroundColor('#2A2A2A').borderRadius(14).padding({ top: 14, bottom: 14 })
ForEach(SWAPS, (s: SwapItem) => {
Column({ space: 8 }) {
Row({ space: 10 }) {
Text(s.avatar).fontSize(26)
Column({ space: 2 }) {
Row({ space: 6 }) {
Text(s.user).fontSize(13).fontWeight(FontWeight.Bold).fontColor('#FFFFFF')
Text(swapBadge(s.likes)).fontSize(8).fontColor('#FFD400').backgroundColor('#111111').borderRadius(6).padding({ left: 5, right: 5, top: 1, bottom: 1 })
}
Text(s.time + ' · ' + s.place).fontSize(9).fontColor('#8A8A8A')
}.alignItems(HorizontalAlign.Start).layoutWeight(1)
Text('⋯').fontSize(16).fontColor('#8A8A8A').onClick(() => { this.showDeleteModal = true; })
}.width('100%')
Row({ space: 10 }) {
Column({ space: 4 }) { Text('我提供').fontSize(9).fontColor('#FF6B00'); Text(s.offer).fontSize(11).fontWeight(FontWeight.Bold).fontColor('#FFFFFF') }.layoutWeight(1).backgroundColor('#111111').borderRadius(10).padding(8).alignItems(HorizontalAlign.Center)
Text('⇄').fontSize(14).fontColor('#FF6B00')
Column({ space: 4 }) { Text('我想换').fontSize(9).fontColor('#FFD400'); Text(s.want).fontSize(11).fontWeight(FontWeight.Bold).fontColor('#FFFFFF') }.layoutWeight(1).backgroundColor('#111111').borderRadius(10).padding(8).alignItems(HorizontalAlign.Center)
}.width('100%')
Text(s.content).fontSize(11).fontColor('#8A8A8A').lineHeight(16).width('100%')
Row({ space: 8 }) {
Text('📍 ' + s.place).fontSize(10).fontColor('#FF6B00').backgroundColor('#111111').borderRadius(10).padding({ left: 8, right: 8, top: 4, bottom: 4 })
Text('❤️ ' + s.likes.toString()).fontSize(10).fontColor('#E8483C').layoutWeight(1).textAlign(TextAlign.End)
}.width('100%')
}.width('100%').backgroundColor('#2A2A2A').borderRadius(14).padding(14)
}, (s: SwapItem) => 'sw' + s.id.toString())
}.width('100%').padding({ left: 14, right: 14, top: 10, bottom: 16 })
}
// ---------------- 图鉴页 ----------------
@Builder
collectionContent() {
Column({ space: 12 }) {
Row({ space: 10 }) {
Column({ space: 4 }) {
Text('📖 我的健身图鉴').fontSize(16).fontWeight(FontWeight.Bold).fontColor('#FF6B00')
Text('记录每一项训练的装备进度').fontSize(10).fontColor('#8A8A8A')
}.alignItems(HorizontalAlign.Start).layoutWeight(1)
Text('✚ 登记').fontSize(12).fontColor('#111111').backgroundColor('#FF6B00').borderRadius(14).padding({ left: 14, right: 14, top: 7, bottom: 7 }).onClick(() => { this.showSellModal = true; })
}.width('100%').margin({ top: 10 })
ForEach(COLLECTIONS, (c: CollectionItem) => {
Column({ space: 8 }) {
Row({ space: 10 }) {
Text(c.emoji).fontSize(28)
Column({ space: 3 }) {
Text(c.name).fontSize(14).fontWeight(FontWeight.Bold).fontColor('#FFFFFF')
Text(c.series + ' · 已收 ' + c.owned.toString() + '/' + c.total.toString()).fontSize(10).fontColor('#8A8A8A')
}.alignItems(HorizontalAlign.Start).layoutWeight(1)
Text(c.rate.toString() + '%').fontSize(15).fontWeight(FontWeight.Bold).fontColor(rateColor(c.rate))
}.width('100%')
Row({ space: 0 }) {
Column().width(c.rate.toString() + '%').height(6).backgroundColor(rateColor(c.rate)).borderRadius(3)
Column().width((100 - c.rate).toString() + '%').height(6).backgroundColor('#3A3A3A').borderRadius(3)
}.width('100%')
}.width('100%').backgroundColor(c.id === 5 ? '#111111' : '#2A2A2A').borderRadius(14).padding(14)
}, (c: CollectionItem) => 'coll' + c.id.toString())
Column() {
Text('🏅 图鉴成就墙').fontSize(14).fontWeight(FontWeight.Bold).fontColor('#FF6B00').width('100%').margin({ bottom: 8 })
Flex({ wrap: FlexWrap.Wrap }) {
Text('🎖️ 力量举大师').fontSize(10).fontColor('#FF6B00').backgroundColor('#111111').borderRadius(10).padding({ left: 8, right: 8, top: 5, bottom: 5 }).margin(4)
Text('🏆 有氧达人').fontSize(10).fontColor('#FFD400').backgroundColor('#111111').borderRadius(10).padding({ left: 8, right: 8, top: 5, bottom: 5 }).margin(4)
Text('🥤 补剂专家').fontSize(10).fontColor('#E8483C').backgroundColor('#111111').borderRadius(10).padding({ left: 8, right: 8, top: 5, bottom: 5 }).margin(4)
Text('💪 器械收藏家').fontSize(10).fontColor('#58A6FF').backgroundColor('#111111').borderRadius(10).padding({ left: 8, right: 8, top: 5, bottom: 5 }).margin(4)
}.width('100%')
}.width('100%').backgroundColor('#2A2A2A').borderRadius(14).padding(14)
}.width('100%').padding({ left: 14, right: 14, bottom: 16 })
}
// ---------------- 我的页 ----------------
@Builder
mineContent() {
Column({ space: 14 }) {
Column() {
Row({ space: 12 }) {
Text('💪').fontSize(40)
Column({ space: 4 }) {
Text('健身收藏家阿乐').fontSize(16).fontWeight(FontWeight.Bold).fontColor('#FF6B00')
Text('LV.10 资深撸铁人 · 信用分 990').fontSize(10).fontColor('#8A8A8A')
}.alignItems(HorizontalAlign.Start).layoutWeight(1)
Text('>').fontSize(18).fontColor('#8A8A8A')
}.width('100%')
Row({ space: 0 }) {
Column({ space: 3 }) { Text('38').fontSize(16).fontWeight(FontWeight.Bold).fontColor('#FF6B00'); Text('在售装备').fontSize(9).fontColor('#8A8A8A') }.layoutWeight(1).alignItems(HorizontalAlign.Center)
Column({ space: 3 }) { Text('12').fontSize(16).fontWeight(FontWeight.Bold).fontColor('#FF6B00'); Text('求购中').fontSize(9).fontColor('#8A8A8A') }.layoutWeight(1).alignItems(HorizontalAlign.Center)
Column({ space: 3 }) { Text('¥6.8万').fontSize(16).fontWeight(FontWeight.Bold).fontColor('#FF6B00'); Text('累计成交额').fontSize(9).fontColor('#8A8A8A') }.layoutWeight(1).alignItems(HorizontalAlign.Center)
}.width('100%').margin({ top: 16 })
}.width('100%').padding(18).backgroundColor('#2A2A2A').borderRadius(16).margin({ top: 10 })
Column() {
Text('🔨 我的求购清单').fontSize(14).fontWeight(FontWeight.Bold).fontColor('#FF6B00').width('100%').margin({ bottom: 6 })
ForEach(GYMS, (t: GymItem) => {
if (t.id === 13 || t.id === 16 || t.id === 18) {
Row({ space: 10 }) {
Text(t.emoji).fontSize(20)
Column({ space: 2 }) {
Text(t.name).fontSize(12).fontWeight(FontWeight.Bold).fontColor('#FFFFFF')
Text('预算 ¥' + t.price.toString() + ' 内 · ' + t.want).fontSize(9).fontColor('#8A8A8A')
}.alignItems(HorizontalAlign.Start).layoutWeight(1)
Text('出价中').fontSize(10).fontColor('#FFD400').backgroundColor('#111111').borderRadius(10).padding({ left: 8, right: 8, top: 3, bottom: 3 })
}.width('100%').padding({ top: 9, bottom: 9 })
}
}, (t: GymItem) => 'wish' + t.id.toString())
}.width('100%').backgroundColor('#2A2A2A').borderRadius(14).padding(14)
Column() {
Text('📍 常去面交点').fontSize(14).fontWeight(FontWeight.Bold).fontColor('#FF6B00').width('100%').margin({ bottom: 6 })
ForEach(PLACES, (p: string, i: number) => {
Row({ space: 10 }) {
Text(['🚇', '🏬', '🚌', '🏪', '📦'][i]).fontSize(16)
Text(p).fontSize(12).fontWeight(FontWeight.Bold).fontColor('#FFFFFF').layoutWeight(1)
Text(['光谷站台', '江汉路天桥', '洪山转盘', '楚河入口', '顺丰网点'][i]).fontSize(9).fontColor('#8A8A8A')
}.width('100%').padding({ top: 9, bottom: 9 })
}, (p: string, i: number) => 'pl' + i.toString() + p)
}.width('100%').backgroundColor('#2A2A2A').borderRadius(14).padding(14)
}.width('100%').padding({ left: 14, right: 14, bottom: 16 })
}
// ---------------- 底部Tab ----------------
@Builder
bottomTabsBuilder() {
Row() {
ForEach(BOTTOM_TABS, (t: TabItem, idx: number) => {
Column({ space: 3 }) {
Text(t.icon).fontSize(20)
Text(t.label).fontSize(10).fontColor(this.currentBottomTab === idx ? '#FF6B00' : '#8A8A8A').fontWeight(this.currentBottomTab === idx ? FontWeight.Bold : FontWeight.Normal)
}.layoutWeight(1).alignItems(HorizontalAlign.Center).padding({ top: 8, bottom: 8 }).onClick(() => { this.currentBottomTab = idx; })
}, (t: TabItem, idx: number) => 'bt' + idx.toString() + t.label)
}.width('100%').backgroundColor('#2A2A2A').borderRadius({ topLeft: 18, topRight: 18 })
}
// ---------------- 弹框1:发布出售(新增·黑橙渐变头) ----------------
@Builder
sellModalBuilder() {
Column() {
Column() {
Text('🏋️ 发布出售').fontSize(17).fontWeight(FontWeight.Bold).fontColor('#FF6B00').margin({ top: 16 })
Text('闲置回血,神兵不愁卖').fontSize(11).fontColor('#8A8A8A').margin({ top: 4, bottom: 16 })
}.width('100%').backgroundColor('#111111').borderRadius({ topLeft: 18, topRight: 18 })
Scroll() {
Column({ space: 14 }) {
Column({ space: 8 }) {
Text('要出售的装备').fontSize(12).fontWeight(FontWeight.Bold).fontColor('#FF6B00').width('100%')
Flex({ wrap: FlexWrap.Wrap }) {
ForEach(GYMS, (t: GymItem, i: number) => {
if (i < 8) {
Text(t.emoji + ' ' + t.name).fontSize(10).fontColor(this.sellGymIdx === i ? '#111111' : '#FF6B00').backgroundColor(this.sellGymIdx === i ? '#FF6B00' : '#111111').borderRadius(12).padding({ left: 9, right: 9, top: 5, bottom: 5 }).margin(4).onClick(() => { this.sellGymIdx = i; })
}
}, (t: GymItem, i: number) => 'st' + i.toString() + t.id.toString())
}.width('100%')
}.width('100%').alignItems(HorizontalAlign.Start)
Column({ space: 8 }) {
Text('成色说明').fontSize(12).fontWeight(FontWeight.Bold).fontColor('#FF6B00').width('100%')
Flex({ wrap: FlexWrap.Wrap }) {
ForEach(CONDITION_OPTIONS, (c: string, i: number) => {
Text(c).fontSize(10).fontColor(this.sellCondIdx === i ? '#111111' : '#FFD400').backgroundColor(this.sellCondIdx === i ? '#FFD400' : '#111111').borderRadius(12).padding({ left: 10, right: 10, top: 5, bottom: 5 }).margin(4).onClick(() => { this.sellCondIdx = i; })
}, (c: string, i: number) => 'sd' + i.toString() + c)
}.width('100%')
}.width('100%').alignItems(HorizontalAlign.Start)
Row({ space: 12 }) {
Text('出售价格').fontSize(12).fontWeight(FontWeight.Bold).fontColor('#FF6B00')
Row({ space: 0 }) {
Text('−').fontSize(16).fontColor('#FF6B00').backgroundColor('#111111').borderRadius({ topLeft: 10, bottomLeft: 10 }).width(34).height(30).textAlign(TextAlign.Center).onClick(() => { if (this.sellPrice > 10) { this.sellPrice -= 10; } })
Text('¥' + this.sellPrice.toString()).fontSize(13).fontWeight(FontWeight.Bold).fontColor('#FFFFFF').backgroundColor('#111111').height(30).textAlign(TextAlign.Center).padding({ left: 14, right: 14 })
Text('+').fontSize(16).fontColor('#111111').backgroundColor('#FF6B00').borderRadius({ topRight: 10, bottomRight: 10 }).width(34).height(30).textAlign(TextAlign.Center).onClick(() => { if (this.sellPrice < 9999) { this.sellPrice += 10; } })
}.borderRadius(10)
Text(this.sellPrice > 2000 ? '💰 高价好物建议包邮' : '实惠价更容易出手').fontSize(9).fontColor(this.sellPrice > 2000 ? '#FFD400' : '#8A8A8A').layoutWeight(1).textAlign(TextAlign.End)
}.width('100%')
Column({ space: 8 }) {
Text('宝贝描述').fontSize(12).fontWeight(FontWeight.Bold).fontColor('#FF6B00').width('100%')
TextInput({ placeholder: '成色、瑕疵、配件情况如实描述…', text: this.sellWords }).fontSize(12).fontColor('#FFFFFF').backgroundColor('#111111').borderRadius(10).height(40).padding({ left: 12, right: 12 }).onChange((v: string) => { this.sellWords = v; })
}.width('100%').alignItems(HorizontalAlign.Start)
Row({ space: 12 }) {
Text('取消').fontSize(13).fontColor('#8A8A8A').backgroundColor('#111111').borderRadius(20).layoutWeight(1).height(42).textAlign(TextAlign.Center).onClick(() => { this.showSellModal = false; })
Text('上架出售').fontSize(13).fontWeight(FontWeight.Bold).fontColor('#111111').backgroundColor('#FF6B00').borderRadius(20).layoutWeight(1).height(42).textAlign(TextAlign.Center).onClick(() => { this.showSellModal = false; })
}.width('100%').margin({ top: 4, bottom: 18 })
}.width('100%').padding({ left: 16, right: 16, top: 16 })
}.scrollBar(BarState.Off).layoutWeight(1).align(Alignment.Top)
}.width('88%').height('76%').backgroundColor('#2A2A2A').borderRadius(18).clip(true)
}
// ---------------- 弹框2:发起交换(新增·橙头) ----------------
@Builder
swapModalBuilder() {
Column() {
Column() {
Row({ space: 8 }) { Text('🤝').fontSize(22); Text('发起交换').fontSize(17).fontWeight(FontWeight.Bold).fontColor('#FF6B00') }.margin({ top: 16 })
Text('用闲置换心头好,撸铁互助').fontSize(11).fontColor('#8A8A8A').margin({ top: 4, bottom: 14 })
}.width('100%').backgroundColor('#FFD400').borderRadius({ topLeft: 18, topRight: 18 })
Scroll() {
Column({ space: 14 }) {
Column({ space: 8 }) {
Text('我提供').fontSize(12).fontWeight(FontWeight.Bold).fontColor('#FF6B00').width('100%')
Flex({ wrap: FlexWrap.Wrap }) {
ForEach(GYMS, (t: GymItem, i: number) => {
if (i % 3 === 0 && i < 15) {
Text(t.emoji + ' ' + t.name).fontSize(10).fontColor(this.swapOfferIdx === i ? '#111111' : '#FF6B00').backgroundColor(this.swapOfferIdx === i ? '#FF6B00' : '#111111').borderRadius(12).padding({ left: 9, right: 9, top: 5, bottom: 5 }).margin(4).onClick(() => { this.swapOfferIdx = i; })
}
}, (t: GymItem, i: number) => 'wo' + i.toString() + t.id.toString())
}.width('100%')
}.width('100%').alignItems(HorizontalAlign.Start)
Column({ space: 8 }) {
Text('我想换(可多选)').fontSize(12).fontWeight(FontWeight.Bold).fontColor('#FF6B00').width('100%')
Flex({ wrap: FlexWrap.Wrap }) {
ForEach(GYMS, (t: GymItem, i: number) => {
if (i % 3 === 2 && i < 15) {
Text((this.pickedWant(i) ? '✓ ' : '') + t.emoji + ' ' + t.name).fontSize(10).fontColor(this.pickedWant(i) ? '#111111' : '#FF6B00').backgroundColor(this.pickedWant(i) ? '#FF6B00' : '#111111').borderRadius(12).padding({ left: 9, right: 9, top: 5, bottom: 5 }).margin(4).onClick(() => { this.toggleWant(i); })
}
}, (t: GymItem, i: number) => 'ww' + i.toString() + t.id.toString())
}.width('100%')
}.width('100%').alignItems(HorizontalAlign.Start)
Column({ space: 8 }) {
Text('面交地点').fontSize(12).fontWeight(FontWeight.Bold).fontColor('#FF6B00').width('100%')
Flex({ wrap: FlexWrap.Wrap }) {
ForEach(PLACES, (p: string, i: number) => {
Text(p).fontSize(10).fontColor(this.swapPlaceIdx === i ? '#111111' : '#FF6B00').backgroundColor(this.swapPlaceIdx === i ? '#FF6B00' : '#111111').borderRadius(12).padding({ left: 10, right: 10, top: 5, bottom: 5 }).margin(4).onClick(() => { this.swapPlaceIdx = i; })
}, (p: string, i: number) => 'wp' + i.toString() + p)
}.width('100%')
}.width('100%').alignItems(HorizontalAlign.Start)
Row({ space: 8 }) {
Text('💡').fontSize(14)
Text('交换双方可自行协商补差价,面交请选择人流密集的公共场所,注意安全。').fontSize(10).fontColor('#8A8A8A').lineHeight(15).layoutWeight(1)
}.width('100%').backgroundColor('#111111').borderRadius(10).padding(10)
Row({ space: 12 }) {
Text('再想想').fontSize(13).fontColor('#8A8A8A').backgroundColor('#111111').borderRadius(20).layoutWeight(1).height(42).textAlign(TextAlign.Center).onClick(() => { this.showSwapModal = false; })
Text('发布交换帖').fontSize(13).fontWeight(FontWeight.Bold).fontColor('#111111').backgroundColor('#FF6B00').borderRadius(20).layoutWeight(1).height(42).textAlign(TextAlign.Center).onClick(() => { this.showSwapModal = false; })
}.width('100%').margin({ top: 4, bottom: 18 })
}.width('100%').padding({ left: 16, right: 16, top: 16 })
}.scrollBar(BarState.Off).layoutWeight(1).align(Alignment.Top)
}.width('88%').height('72%').backgroundColor('#2A2A2A').borderRadius(18).clip(true)
}
// ---------------- 弹框3:下架/删除 ----------------
@Builder
deleteModalBuilder() {
Column({ space: 14 }) {
Text('🗑️').fontSize(36)
Text('下架这件装备?').fontSize(16).fontWeight(FontWeight.Bold).fontColor('#FF6B00')
Text('下架后买家将无法搜索到这条信息,\n收藏和留言会一并清空,可重新上架。').fontSize(11).fontColor('#8A8A8A').textAlign(TextAlign.Center).lineHeight(17)
Row({ space: 12 }) {
Text('留着').fontSize(13).fontColor('#FF6B00').backgroundColor('#111111').borderRadius(20).layoutWeight(1).height(40).textAlign(TextAlign.Center).onClick(() => { this.showDeleteModal = false; })
Text('确认下架').fontSize(13).fontWeight(FontWeight.Bold).fontColor('#111111').backgroundColor('#E8483C').borderRadius(20).layoutWeight(1).height(40).textAlign(TextAlign.Center).onClick(() => { this.showDeleteModal = false; })
}.width('100%').margin({ top: 6 })
}.width('72%').backgroundColor('#2A2A2A').borderRadius(18).padding({ left: 20, right: 20, top: 24, bottom: 22 }).alignItems(HorizontalAlign.Center)
}
// ---------------- 弹框4:器材详情(黑橙渐变头) ----------------
@Builder
detailModalBuilder() {
Column() {
Column() {
Text(this.detailEmoji()).fontSize(40).margin({ top: 18 })
Text(this.detailName()).fontSize(18).fontWeight(FontWeight.Bold).fontColor('#FF6B00').margin({ top: 8 })
Text(this.detailEng()).fontSize(10).fontColor('#8A8A8A').margin({ top: 2 })
Row({ space: 8 }) {
Text(this.detailTag()).fontSize(9).fontColor('#111111').backgroundColor('#FF6B00').borderRadius(8).padding({ left: 7, right: 7, top: 2, bottom: 2 })
Text(rarityLabel(Number(this.detailRarity()))).fontSize(9).fontColor('#111111').backgroundColor('#FFD400').borderRadius(8).padding({ left: 7, right: 7, top: 2, bottom: 2 })
}.margin({ top: 10, bottom: 18 })
}.width('100%').backgroundColor('#111111').borderRadius({ topLeft: 18, topRight: 18 }).alignItems(HorizontalAlign.Center)
Scroll() {
Column({ space: 14 }) {
Row({ space: 0 }) {
Column({ space: 4 }) { Text(this.detailPrice()).fontSize(17).fontWeight(FontWeight.Bold).fontColor('#FF6B00'); Text('售价').fontSize(9).fontColor('#8A8A8A') }.layoutWeight(1).alignItems(HorizontalAlign.Center)
Column({ space: 4 }) { Text(this.detailSize()).fontSize(17).fontWeight(FontWeight.Bold).fontColor('#FFD400'); Text('规格').fontSize(9).fontColor('#8A8A8A') }.layoutWeight(1).alignItems(HorizontalAlign.Center)
Column({ space: 4 }) { Text(this.detailRarity()).fontSize(17).fontWeight(FontWeight.Bold).fontColor(rarityColor(Number(this.detailRarity()))); Text('稀有度').fontSize(9).fontColor('#8A8A8A') }.layoutWeight(1).alignItems(HorizontalAlign.Center)
Column({ space: 4 }) { Text(this.detailYear()).fontSize(17).fontWeight(FontWeight.Bold).fontColor('#58A6FF'); Text('年份').fontSize(9).fontColor('#8A8A8A') }.layoutWeight(1).alignItems(HorizontalAlign.Center)
}.width('100%').backgroundColor('#111111').borderRadius(12).padding({ top: 12, bottom: 12 })
Column({ space: 8 }) {
Text('🧾 宝贝描述').fontSize(12).fontWeight(FontWeight.Bold).fontColor('#FF6B00').width('100%')
Text(this.detailDesc()).fontSize(11).fontColor('#8A8A8A').lineHeight(18)
Row({ space: 8 }) {
Text('👤 ' + this.detailSeller()).fontSize(10).fontColor('#FF6B00')
Text(this.detailStar() + ' ' + this.detailRating()).fontSize(10).fontColor('#FFD400').layoutWeight(1).textAlign(TextAlign.End)
}.width('100%')
}.width('100%').alignItems(HorizontalAlign.Start)
Row({ space: 8 }) {
Text('🤝').fontSize(14)
Text('卖家想换:' + this.detailWant()).fontSize(11).fontColor('#FFD400').layoutWeight(1)
}.width('100%').backgroundColor('#111111').borderRadius(10).padding(10)
Column({ space: 10 }) {
Text('💬 圈友点评').fontSize(12).fontWeight(FontWeight.Bold).fontColor('#FF6B00').width('100%')
ForEach(GYM_REVIEWS, (r: GymReview) => {
Column({ space: 5 }) {
Row({ space: 8 }) { Text('👤').fontSize(14); Text(r.user).fontSize(11).fontWeight(FontWeight.Bold).fontColor('#FFFFFF'); Text(r.starStr).fontSize(9).layoutWeight(1).textAlign(TextAlign.End) }.width('100%')
Text(r.content).fontSize(10).fontColor('#8A8A8A').lineHeight(15)
}.width('100%').backgroundColor('#111111').borderRadius(10).padding(10)
}, (r: GymReview) => 'rv' + r.id.toString())
}.width('100%').alignItems(HorizontalAlign.Start)
Row({ space: 12 }) {
Text('💬 留言问问').fontSize(13).fontColor('#FF6B00').backgroundColor('#111111').borderRadius(20).layoutWeight(1).height(42).textAlign(TextAlign.Center).onClick(() => { this.showDetailModal = false; })
Text('🛒 立即购买').fontSize(13).fontWeight(FontWeight.Bold).fontColor('#111111').backgroundColor('#FF6B00').borderRadius(20).layoutWeight(1).height(42).textAlign(TextAlign.Center).onClick(() => { this.showDetailModal = false; })
}.width('100%').margin({ top: 2, bottom: 18 })
}.width('100%').padding({ left: 16, right: 16, top: 14 })
}.scrollBar(BarState.Off).layoutWeight(1).align(Alignment.Top)
}.width('88%').height('78%').backgroundColor('#2A2A2A').borderRadius(18).clip(true)
}
// 交换多选辅助
pickedWant(i: number): boolean { return (i % 2) === 0; }
toggleWant(i: number): void { this.swapWantIdx = i; }
// ---------------- 主布局 ----------------
build() {
Stack() {
Column() {
this.headerBuilder()
Scroll() {
Column() {
if (this.currentBottomTab === 0) { this.bazaarContent() }
else if (this.currentBottomTab === 1) { this.swapContent() }
else if (this.currentBottomTab === 2) { this.collectionContent() }
else { this.mineContent() }
}.width('100%')
}.layoutWeight(1).scrollBar(BarState.Off).align(Alignment.Top)
this.bottomTabsBuilder()
}.width('100%').height('100%')
ForEach(this.particles, (p: ParticleItem, i: number) => {
Text(p.emoji).fontSize(p.size).opacity(p.opacity).position({ x: p.x, y: 80 + (i % 5) * 118 })
}, (p: ParticleItem, i: number) => 'pt' + i.toString())
if (this.showDetailModal) {
Column() { this.detailModalBuilder() }.width('100%').height('100%').backgroundColor('99000000').justifyContent(FlexAlign.Center).onClick(() => { this.showDetailModal = false; })
}
if (this.showSellModal) {
Column() { this.sellModalBuilder() }.width('100%').height('100%').backgroundColor('99000000').justifyContent(FlexAlign.Center).onClick(() => { this.showSellModal = false; })
}
if (this.showSwapModal) {
Column() { this.swapModalBuilder() }.width('100%').height('100%').backgroundColor('99000000').justifyContent(FlexAlign.Center).onClick(() => { this.showSwapModal = false; })
}
if (this.showDeleteModal) {
Column() { this.deleteModalBuilder() }.width('100%').height('100%').backgroundColor('99000000').justifyContent(FlexAlign.Center).onClick(() => { this.showDeleteModal = false; })
}
}.width('100%').height('100%').backgroundColor(PALETTE.bg)
}
}

nt.Top)
this.bottomTabsBuilder()
}.width(‘100%’).height(‘100%’)
ForEach(this.particles, (p: ParticleItem, i: number) => {
Text(p.emoji).fontSize(p.size).opacity(p.opacity).position({ x: p.x, y: 80 + (i % 5) * 118 })
}, (p: ParticleItem, i: number) => ‘pt’ + i.toString())
if (this.showDetailModal) {
Column() { this.detailModalBuilder() }.width(‘100%’).height(‘100%’).backgroundColor(‘99000000’).justifyContent(FlexAlign.Center).onClick(() => { this.showDetailModal = false; })
}
if (this.showSellModal) {
Column() { this.sellModalBuilder() }.width(‘100%’).height(‘100%’).backgroundColor(‘99000000’).justifyContent(FlexAlign.Center).onClick(() => { this.showSellModal = false; })
}
if (this.showSwapModal) {
Column() { this.swapModalBuilder() }.width(‘100%’).height(‘100%’).backgroundColor(‘99000000’).justifyContent(FlexAlign.Center).onClick(() => { this.showSwapModal = false; })
}
if (this.showDeleteModal) {
Column() { this.deleteModalBuilder() }.width(‘100%’).height(‘100%’).backgroundColor(‘99000000’).justifyContent(FlexAlign.Center).onClick(() => { this.showDeleteModal = false; })
}
}.width(‘100%’).height(‘100%’).backgroundColor(PALETTE.bg)
}
}

Logo

讨论HarmonyOS开发技术,专注于API与组件、DevEco Studio、测试、元服务和应用上架分发等。

更多推荐