From 940fb884c604619f299730f1b6ddf8e9e8bc96f9 Mon Sep 17 00:00:00 2001 From: JACKYMYPERSON Date: Wed, 24 Sep 2025 21:10:29 +0800 Subject: [PATCH] 2025-9-24-21:10 --- miniprogram/pages/chat/chat.wxml | 91 ----------- miniprogram/pages/home/home.ts | 61 +++++++- miniprogram/pages/home/home.wxml | 261 +++++++++++++++++++------------ miniprogram/pages/home/home.wxss | 28 +--- project.private.config.json | 4 +- 5 files changed, 226 insertions(+), 219 deletions(-) diff --git a/miniprogram/pages/chat/chat.wxml b/miniprogram/pages/chat/chat.wxml index 027dff1..cc1e3a7 100644 --- a/miniprogram/pages/chat/chat.wxml +++ b/miniprogram/pages/chat/chat.wxml @@ -1,95 +1,4 @@ - - - - - - - - - - - - - - - - - - 王小明 - 10:23 - - - 我们明天上午9点在公司楼下集合吧 - - - - - - - - - - - - 产品研发群 - 昨天 - - - 李设计:新的UI稿已经上传到群文件了 - - - - - - - - - 3 - - - - 系统通知 - 周一 - - - 您有3条新的系统通知待查看 - - - - - - - - - - - - 张小红 - 09-12 - - - 上次你说的那个电影资源能发我一下吗? - - - - - - - - - - - - 生活服务号 - 09-10 - - - 您订阅的服务已更新,点击查看详情 - - - - \ No newline at end of file diff --git a/miniprogram/pages/home/home.ts b/miniprogram/pages/home/home.ts index 56987ac..78d0c68 100644 --- a/miniprogram/pages/home/home.ts +++ b/miniprogram/pages/home/home.ts @@ -1,8 +1,55 @@ Component({ - data: { - - }, - methods: { - - }, -}) + data: { + // 用对象存储多个卡片的选中状态,键为卡片ID,值为选中的选项ID + selectedOptions: {} as Record + }, + methods: { + /** + * 选择选项 + * @param e 事件对象,包含卡片ID和选项ID + */ + selectOption(e: WechatMiniprogram.TouchEvent) { + const { card, id } = e.currentTarget.dataset as { card: string; id: string }; + + // 更新选中状态(使用对象展开语法保持响应式) + this.setData({ + selectedOptions: { + ...this.data.selectedOptions, + [card]: id + } + }); + }, + + /** + * 提交投票 + * @param e 事件对象,包含卡片ID + */ + submitVote(e: WechatMiniprogram.TouchEvent) { + const { card } = e.currentTarget.dataset as { card: string }; + const selected = this.data.selectedOptions[card]; + + if (!selected) { + wx.showToast({ + title: '请先选择一个选项', + icon: 'none', + duration: 2000 + }); + return; + } + + // 可以通过triggerEvent向父组件传递投票结果 + this.triggerEvent('voteSuccess', { + cardId: card, + selectedOption: selected, + timestamp: Date.now() + }); + + wx.showToast({ + title: '投票成功', + icon: 'success', + duration: 2000 + }); + } + } + }); + \ No newline at end of file diff --git a/miniprogram/pages/home/home.wxml b/miniprogram/pages/home/home.wxml index f155a51..1095c05 100644 --- a/miniprogram/pages/home/home.wxml +++ b/miniprogram/pages/home/home.wxml @@ -1,112 +1,177 @@ - - - - + + + + + + + + + + 进行中 + + + + + + 午餐该选哪个?好纠结啊! + 大家帮我投个票吧,选择困难症又犯了... + + + + + + + + + + + + 麻辣烫 + 鲜香麻辣,越吃越开胃 + + + 42% + + + + + + + + + + + + + + + + + + 汉堡套餐 + 快捷方便,配冰可乐 + + + 28% + + + + + + + + + + + + + + + + + + 沙拉轻食 + 健康低卡,适合减脂 + + + 30% + + + + + + + + + + + + + 已有 126 人参与投票 + 剩余 23 小时结束 + + + + - - - - - - - 进行中 - - - - - - 午餐该选哪个?好纠结啊! - 大家帮我投个票吧,选择困难症又犯了... - - - - - - - - - - - - 麻辣烫 - 鲜香麻辣,越吃越开胃 + + + + + - 42% - - - - - - - - + 进行中 - - - - - - - - 汉堡套餐 - 快捷方便,配冰可乐 + + + + 周末团建活动选哪个? + 大家踊跃投票,少数服从多数~ + + + + 已有 38 人参与投票 + 剩余 45 小时结束 + + + + + + + + + - 28% - - - - - - - - + 进行中 - - - - - - - - 沙拉轻食 - 健康低卡,适合减脂 - - - 30% - - - - - - - - + + + + 买哪个牌子的笔记本电脑? + 主要用于办公和轻度设计 + + + 已有 76 人参与投票 + 剩余 12 小时结束 + + - - - 已有 126 人参与投票 - 剩余 23 小时结束 - - - - + - - - \ No newline at end of file diff --git a/miniprogram/pages/home/home.wxss b/miniprogram/pages/home/home.wxss index 3d7adcf..9fad924 100644 --- a/miniprogram/pages/home/home.wxss +++ b/miniprogram/pages/home/home.wxss @@ -7,28 +7,14 @@ background-color: #f5f7fa; padding: 20rpx; } +.scroll-container { + width: 100%; -.search-bar { - padding: 16rpx 24rpx; - background-color: #f5f5f7; -} - -.search-input { - display: flex; - align-items: center; - background-color: #eaeaea; - border-radius: 30rpx; - padding: 14rpx 24rpx; -} - -.search-input input { - margin-left: 12rpx; - font-size: 28rpx; - flex: 1; - color: #333; - height: 40rpx; - line-height: 40rpx; -} + } + .voting-card { + min-width: calc(100% - 30px); /* 确保在手机上卡片占满宽度 */ + /* 其他原有样式保持不变 */ + } /* 投票卡片卡片样式 */ .voting-card { diff --git a/project.private.config.json b/project.private.config.json index 7a3bb3c..bf7ca8d 100644 --- a/project.private.config.json +++ b/project.private.config.json @@ -1,6 +1,6 @@ { "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", - "projectname": "toutoukan", + "projectname": "%E6%8A%95%E6%8A%95%E7%9C%8B%E5%B0%8F%E7%A8%8B%E5%BA%8F", "setting": { "compileHotReLoad": true, "urlCheck": false, @@ -19,5 +19,5 @@ "checkInvalidKey": true, "ignoreDevUnusedFiles": true }, - "libVersion": "3.9.0" + "libVersion": "3.10.1" } \ No newline at end of file