项目初始化

This commit is contained in:
2025-08-09 17:41:14 +08:00
parent a35ecb09f3
commit 7e60227aa6
24 changed files with 1103 additions and 60 deletions

View File

@@ -0,0 +1,7 @@
{
"component": true,
"usingComponents": {
"t-divider": "tdesign-miniprogram/divider/divider",
"t-search": "tdesign-miniprogram/search/search"
}
}

View File

@@ -0,0 +1,8 @@
Component({
data: {
},
methods: {
},
})

View File

@@ -0,0 +1,112 @@
<view class="search-bar">
<view class="search-input">
<icon type="search" size="16" color="#999"></icon>
<input placeholder="搜索聊天记录" placeholder-class="placeholder-style"/>
</view>
</view>
<view style="width: 100vw;display: flex;justify-content: center;">
<view class="voting-card">
<!-- 卡片头部 -->
<view class="card-header">
<view class="user-info">
<image src="https://picsum.photos/id/64/200/200" mode="widthFix" class="avatar" alt="发起者头像"></image>
<view class="user-details">
<text class="username">张小萌</text>
<text class="user-status">需要你的帮助</text>
</view>
</view>
<view class="vote-status">进行中</view>
</view>
<view class="divider"></view>
<view class="vote-title-section">
<text class="vote-title">午餐该选哪个?好纠结啊!</text>
<text class="vote-desc">大家帮我投个票吧,选择困难症又犯了...</text>
</view>
<!-- 选项区域 -->
<view class="options-container">
<!-- 选项1 -->
<view class="option-item {{selectedOption === '1' ? 'selected' : ''}}" bindtap="selectOption" data-id="1">
<view class="option-info">
<view class="option-icon bg-red">
<text class="iconfont icon-cutlery"></text>
</view>
<view class="option-details">
<text class="option-name">麻辣烫</text>
<text class="option-desc">鲜香麻辣,越吃越开胃</text>
</view>
</view>
<text class="option-percent">42%</text>
<view class="progress-bar">
<view class="progress-value" style="width: 42%"></view>
</view>
<view class="vote-indicator {{selectedOption === '1' ? 'show' : ''}}">
<text class="iconfont icon-check-circle"></text>
</view>
</view>
<!-- 选项2 -->
<view class="option-item {{selectedOption === '2' ? 'selected' : ''}}" bindtap="selectOption" data-id="2">
<view class="option-info">
<view class="option-icon bg-yellow">
<text class="iconfont icon-coffee"></text>
</view>
<view class="option-details">
<text class="option-name">汉堡套餐</text>
<text class="option-desc">快捷方便,配冰可乐</text>
</view>
</view>
<text class="option-percent">28%</text>
<view class="progress-bar">
<view class="progress-value" style="width: 28%"></view>
</view>
<view class="vote-indicator {{selectedOption === '2' ? 'show' : ''}}">
<text class="iconfont icon-check-circle"></text>
</view>
</view>
<!-- 选项3 -->
<view class="option-item {{selectedOption === '3' ? 'selected' : ''}}" bindtap="selectOption" data-id="3">
<view class="option-info">
<view class="option-icon bg-green">
<text class="iconfont icon-leaf"></text>
</view>
<view class="option-details">
<text class="option-name">沙拉轻食</text>
<text class="option-desc">健康低卡,适合减脂</text>
</view>
</view>
<text class="option-percent">30%</text>
<view class="progress-bar">
<view class="progress-value" style="width: 30%"></view>
</view>
<view class="vote-indicator {{selectedOption === '3' ? 'show' : ''}}">
<text class="iconfont icon-check-circle"></text>
</view>
</view>
</view>
<view class="vote-stats">
<text class="stats-text">已有 126 人参与投票</text>
<text class="stats-text">剩余 23 小时结束</text>
</view>
<!-- 投票按钮 -->
<button class="vote-btn" bindtap="submitVote">
<text class="iconfont icon-thumbs-up"></text>
<text class="btn-text">投我一票</text>
</button>
</view>
</view>

View File

@@ -0,0 +1,291 @@
/* 引入通用样式 */
.container {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color: #f5f7fa;
padding: 20rpx;
}
.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 {
width: 90%;
background-color: #ffffff;
border-radius: 24rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.05);
overflow: hidden;
}
/* 卡片头部样式 */
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 30rpx;
}
.user-info {
display: flex;
align-items: center;
}
.avatar {
width: 80rpx;
height: 80rpx;
border-radius: 50%;
margin-right: 20rpx;
}
.username {
display: block;
font-size: 32rpx;
font-weight: 600;
color: #333333;
margin-bottom: 4rpx;
}
.user-status {
display: block;
font-size: 24rpx;
color: #888888;
}
.vote-status {
background-color: rgba(79, 70, 229, 0.1);
color: #4F46E5;
font-size: 24rpx;
padding: 8rpx 16rpx;
border-radius: 20rpx;
}
.divider {
height: 2rpx;
background-color: #f5f5f5;
}
/* 投票标题区域 */
.vote-title-section {
padding: 0 30rpx 30rpx;
}
.vote-title {
display: block;
font-size: 36rpx;
font-weight: 700;
color: #333333;
margin-bottom: 16rpx;
}
.vote-desc {
font-size: 26rpx;
color: #888888;
}
/* 选项区域样式 */
.options-container {
padding: 0 30rpx 20rpx;
}
.option-item {
position: relative;
padding: 24rpx;
border: 2rpx solid #f0f0f0;
border-radius: 16rpx;
margin-bottom: 20rpx;
transition: all 0.3s;
}
.option-item.selected {
border-color: #4F46E5;
background-color: rgba(79, 70, 229, 0.05);
}
.option-item:hover {
border-color: rgba(79, 70, 229, 0.3);
background-color: rgba(79, 70, 229, 0.03);
}
.option-info {
display: flex;
align-items: center;
margin-bottom: 16rpx;
}
.option-icon {
width: 64rpx;
height: 64rpx;
border-radius: 12rpx;
display: flex;
justify-content: center;
align-items: center;
margin-right: 20rpx;
}
.bg-red {
background-color: rgba(248, 113, 113, 0.1);
color: #ef4444;
}
.bg-yellow {
background-color: rgba(251, 191, 36, 0.1);
color: #f59e0b;
}
.bg-green {
background-color: rgba(34, 197, 94, 0.1);
color: #10b981;
}
.option-details {
flex: 1;
}
.option-name {
display: block;
font-size: 30rpx;
font-weight: 600;
color: #333333;
margin-bottom: 4rpx;
}
.option-desc {
font-size: 24rpx;
color: #888888;
}
.option-percent {
font-size: 28rpx;
font-weight: 600;
color: #333333;
}
/* 进度条样式 */
.progress-bar {
height: 12rpx;
background-color: #f0f0f0;
border-radius: 6rpx;
overflow: hidden;
}
.progress-value {
height: 100%;
background-color: #4F46E5;
border-radius: 6rpx;
transition: width 0.5s ease-out;
}
/* 选中指示器 */
.vote-indicator {
position: absolute;
top: 24rpx;
right: 24rpx;
color: #4F46E5;
font-size: 36rpx;
display: none;
}
.vote-indicator.show {
display: block;
}
/* 投票统计信息 */
.vote-stats {
display: flex;
justify-content: space-between;
padding: 0 30rpx 20rpx;
}
.stats-text {
font-size: 24rpx;
color: #888888;
}
/* 投票按钮 */
.vote-btn {
width: calc(100% - 60rpx);
margin: 0 30rpx 30rpx;
padding: 24rpx 0;
background-color: #4F46E5;
color: #ffffff;
border-radius: 16rpx;
font-size: 30rpx;
font-weight: 600;
display: flex;
justify-content: center;
align-items: center;
transition: all 0.3s;
}
.vote-btn .iconfont {
margin-right: 12rpx;
font-size: 32rpx;
}
.vote-btn::after {
border: none;
}
.vote-btn:hover {
background-color: rgba(79, 70, 229, 0.9);
}
.vote-btn:active {
transform: scale(0.98);
}
/* 成功提示 */
.success-toast {
position: fixed;
top: 50rpx;
left: 50%;
transform: translateX(-50%);
background-color: #10b981;
color: #ffffff;
padding: 16rpx 32rpx;
border-radius: 8rpx;
display: flex;
align-items: center;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
z-index: 999;
opacity: 0;
pointer-events: none;
transition: opacity 0.3s;
}
.success-toast.show {
opacity: 1;
pointer-events: auto;
}
.success-toast .iconfont {
margin-right: 12rpx;
font-size: 32rpx;
}
.toast-text {
font-size: 28rpx;
}