基本成型

This commit is contained in:
JACKYMYPERSON
2025-09-27 17:24:52 +08:00
parent 578d49826b
commit eae49c76bd
502 changed files with 15238 additions and 708 deletions

View File

@@ -1,6 +1,10 @@
import envConfig from "../../env";
Component({
data: {
processedCardsData: [] as any[]
processedCardsData: [] as any[],
refresherTriggered: false,
url:""
},
lifetimes: {
attached() {
@@ -11,6 +15,10 @@ Component({
}).catch(err => {
wx.showToast({ title: '加载失败', icon: 'none' });
});
const apiBaseUrl = `${envConfig.apiBaseUrl}`;
this.setData({
url:apiBaseUrl
})
},
},
methods: {
@@ -119,13 +127,47 @@ Component({
icon: 'success',
duration: 2000
});
},
goToDetail(e: { currentTarget: { dataset: { id: any; }; }; }) {
},
goToDetail(e: { currentTarget: { dataset: { id: any; }; }; }) {
const id = e.currentTarget.dataset.id;
console.log(id)
wx.navigateTo({
url: `/pages/articledetail/articledetail?id=${id}`,
});
}
},
onRefresherPulling() {
console.log("正在下拉...");
},
onRefresherRestore() {
console.log("刷新完成,已恢复原位");
},
onRefresherRefresh() {
console.log("用户文评刷新")
this.setData({
refresherTriggered: true
});
const app = getApp();
setTimeout(()=>{
app.fetchRawCardData().then(cards => {
this.setData({ processedCardsData: cards });
this.setData({
refresherTriggered: false
});
}).catch(err => {
wx.showToast({ title: '加载失败', icon: 'none' });
this.setData({
refresherTriggered: false
});
});
},2000)
}
}
});

View File

@@ -1,4 +1,5 @@
<view style="height: 80vh; padding-bottom: 100rpx;">
<a>{{url}}</a>
<scroll-view
class="scroll-container"
scroll-y="true"
@@ -6,83 +7,91 @@
show-scrollbar="true"
enhanced="true"
scroll-with-animation="true"
refresher-enabled="true"
refresher-triggered="{{refresherTriggered}}"
refresher-threshold="80"
refresher-default-style="black"
refresher-background="#f5f5f5"
bindrefresherpulling="onRefresherPulling"
bindrefresherrefresh="onRefresherRefresh"
bindrefresherrestore="onRefresherRestore"
>
<view class="cards-container">
<block wx:for="{{processedCardsData}}" wx:for-item="card" wx:key="article_id">
<view class="voting-card"
>
<view class="card-header"
bindtap="goToDetail"
data-id="{{card.article_id}}"
>
<view class="voting-card">
<!-- 卡片头部 -->
<view class="card-header" bindtap="goToDetail" data-id="{{card.article_id}}">
<view class="user-info">
<image src="https://picsum.photos/id/100/200/200" mode="widthFix" class="avatar" alt="用户头像"></image>
<view class="user-details">
<text class="username">{{card.publisher_id}}</text>
<text class="user-status">发起人</text>
<text class="user-status">({{card.vote_type === 'single' ? '单选' : '多选'}})</text>
</view>
</view>
<view class="vote-status">{{card.is_ended ? '已结束' : '进行中'}}</view>
<view class="vote-status">{{card.user_has_voted ? '已投票' : (card.is_ended ? '已结束' : '进行中')}}</view>
</view>
<view class="divider"></view>
<view class="vote-title-section" bindtap="goToDetail"
data-id="{{card.article_id}}">
<text class="vote-title">{{card.article_title}} ({{card.vote_type === 'single' ? '单选' : '多选'}})</text>
<!-- 投票标题与已投票提示 -->
<view class="vote-title-section" bindtap="goToDetail" data-id="{{card.article_id}}">
<text class="vote-title">{{card.article_title}} </text>
<text class="voted-tip" wx:if="{{card.user_has_voted}}">• 您已投票</text>
<text class="vote-desc"></text>
</view>
<!-- 投票选项列表合并class表达式避免多{{}}拆分 -->
<view class="options-container">
<block wx:for="{{card.options}}" wx:for-item="option" wx:key="id">
<view
class="option-item {{option.isSelected ? 'selected' : ''}} {{card.is_ended ? 'disabled-option' : ''}}"
bindtap="selectOption"
class="option-item {{(card.user_has_voted && option.is_voted) ? 'selected voted-option' : (option.isSelected ? 'selected' : '')}} {{(card.is_ended || card.user_has_voted) ? 'disabled-option' : ''}}"
bindtap="{{(card.is_ended || card.user_has_voted) ? '' : 'selectOption'}}"
data-card-id="{{card.article_id}}"
data-option-id="{{option.id}}">
data-option-id="{{option.id}}"
>
<view class="option-info">
<view class="option-icon bg-gray">
<text class="iconfont icon-default"></text>
<text class="iconfont">{{(card.user_has_voted && option.is_voted) ? '✓' : (option.isSelected ? '✓' : '○')}}</text>
</view>
<view class="option-details">
<text class="option-name">{{option.name}}</text>
<text class="option-name">
{{option.name}}
<text class="your-selection" wx:if="{{card.user_has_voted && option.is_voted}}">(您的选择)</text>
</text>
<text class="option-desc"></text>
</view>
</view>
<view class="option-action-btn">
AI
</view>
<view class="option-action-btn">AI</view>
<text class="option-percent">{{option.percentage}}%</text>
<text class="option-percent">{{option.percentage || 0}}%</text>
<view class="progress-bar">
<view class="progress-value" style="width: {{option.percentage + '%'}}"></view>
<view class="progress-value" style="width: {{(option.percentage || 0) + '%'}}"></view>
</view>
<view class="vote-indicator {{option.isSelected ? 'show' : ''}}">
<view class="vote-indicator {{(card.user_has_voted && option.is_voted) || option.isSelected ? 'show' : ''}}">
<text class="iconfont icon-check-circle"></text>
</view>
</view>
</block>
</view>
<view class="vote-stats"
bindtap="goToDetail"
data-id="{{card.article_id}}"
>
<text class="stats-text">已有 {{card.total_voters}} 人参与投票</text>
<!-- 投票统计信息 -->
<view class="vote-stats" bindtap="goToDetail" data-id="{{card.article_id}}">
<text class="stats-text">已有 {{card.total_voters || 0}} 人参与投票</text>
<text class="stats-text">{{card.is_ended ? '已结束' : '剩余 ' + card.end_time}}</text>
</view>
<!-- 投票提交按钮 -->
<button
class="vote-btn {{card.is_ended ? 'vote-btn-ended' : ''}}"
disabled="{{card.is_ended}}"
class="vote-btn {{(card.is_ended || card.user_has_voted) ? 'vote-btn-disabled' : ''}}"
disabled="{{card.is_ended || card.user_has_voted}}"
bindtap="submitVote"
data-card-id="{{card.article_id}}">
data-card-id="{{card.article_id}}"
>
<text class="iconfont icon-thumbs-up"></text>
<text class="btn-text">{{card.is_ended ? '投票结束' : '投我一票'}}</text>
<text class="btn-text">{{card.user_has_voted ? '已提交投票' : (card.is_ended ? '投票结束' : '投我一票')}}</text>
</button>
</view>
</block>

View File

@@ -1,32 +1,31 @@
/* 引入通用样式 */
.container {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color: #f5f7fa;
::-webkit-scrollbar {
width: 0;
height: 0;
color: transparent;
}
/* 滚动容器样式 */
.scroll-container {
width: 100%;
height: 100vh;
box-sizing: border-box;
padding: 20rpx;
padding-bottom: 13vh;
}
/* 卡片容器使用纵向布局 */
/* 卡片容器样式 */
.cards-container {
display: flex;
margin-bottom: 150rpx;
flex-direction: column; /* 纵向排列卡片 */
gap: 15px; /* 卡片之间的间距 */
padding: 15px;
box-sizing: border-box;
flex-direction: column;
gap: 20rpx;
}
/* 投票卡片样式 */
/* 投票卡片基础样式 */
.voting-card {
width: 100%;
min-height: 400px; /* 卡片最小高度,可根据内容调整 */
background: #fff;
border-radius: 10px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
padding: 15px;
box-sizing: border-box;
background-color: #fff;
border-radius: 24rpx;
padding: 24rpx;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
}
/* 卡片头部样式 */
@@ -34,169 +33,213 @@
display: flex;
justify-content: space-between;
align-items: center;
padding: 30rpx;
margin-bottom: 20rpx;
}
.user-info {
display: flex;
align-items: center;
gap: 16rpx;
}
.avatar {
width: 80rpx;
height: 80rpx;
width: 56rpx;
height: 56rpx;
border-radius: 50%;
margin-right: 20rpx;
}
.user-details {
display: flex;
flex-direction: column;
gap: 4rpx;
}
.username {
display: block;
font-size: 32rpx;
font-weight: 600;
color: #333333;
margin-bottom: 4rpx;
font-size: 24rpx;
font-weight: 500;
color: #333;
}
.user-status {
display: block;
font-size: 24rpx;
color: #888888;
font-size: 20rpx;
color: #666;
}
.vote-status {
background-color: rgba(79, 70, 229, 0.1);
color: #4F46E5;
font-size: 24rpx;
padding: 8rpx 16rpx;
font-size: 22rpx;
padding: 6rpx 16rpx;
border-radius: 20rpx;
background-color: #f5f5f5;
color: #666;
}
.vote-status:empty {
display: none;
}
/* 分割线样式 */
.divider {
width: 100%;
height: 2rpx;
background-color: #f5f5f5;
margin-bottom: 24rpx;
}
/* 投票标题区域 */
/* 标题区域样式 */
.vote-title-section {
padding: 0 30rpx 30rpx;
margin-bottom: 24rpx;
}
.vote-title {
display: block;
font-size: 36rpx;
font-weight: 700;
color: #333333;
margin-bottom: 16rpx;
font-size: 28rpx;
font-weight: 600;
color: #333;
line-height: 40rpx;
}
.voted-tip {
color: #51bdb6;
font-size: 24rpx;
margin-left: 10rpx;
font-weight: 500;
}
.vote-desc {
font-size: 26rpx;
color: #888888;
font-size: 22rpx;
color: #666;
margin-top: 8rpx;
line-height: 32rpx;
}
/* 选项区域样式 */
/* 选项容器样式 */
.options-container {
padding: 0 30rpx 20rpx;
display: flex;
flex-direction: column;
gap: 16rpx;
margin-bottom: 28rpx;
}
/* 选项项样式 */
.option-item {
position: relative;
padding: 24rpx;
border: 2rpx solid #f0f0f0;
display: flex;
align-items: center;
justify-content: space-between;
padding: 20rpx;
border: 2rpx solid #eee;
border-radius: 16rpx;
margin-bottom: 20rpx;
transition: all 0.3s;
position: relative;
transition: all 0.2s;
}
/* 移除 :hover 样式,以避免颜色冲突 */
/*
.option-item:hover {
border-color: rgba(79, 70, 229, 0.3);
background-color: rgba(79, 70, 229, 0.03);
}
*/
.option-item.selected {
border-color: #4F46E5;
background-color: rgba(79, 70, 229, 0.05);
border-color: #409EFF;
background-color: rgba(64, 158, 255, 0.05);
}
.option-item.voted-option {
border-color: #51bdb6;
background-color: rgba(46, 125, 50, 0.05);
}
.option-item.disabled-option {
opacity: 0.8;
pointer-events: none;
}
/* 选项信息样式 */
.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 {
gap: 16rpx;
flex: 1;
}
.option-icon {
width: 40rpx;
height: 40rpx;
border-radius: 50%;
background-color: #f5f5f5;
display: flex;
align-items: center;
justify-content: center;
font-size: 24rpx;
color: #666;
}
.option-item.voted-option .option-icon {
background-color: rgba(46, 125, 50, 0.1);
color: #51bdb6;
}
.option-details {
display: flex;
flex-direction: column;
gap: 4rpx;
}
.option-name {
display: block;
font-size: 30rpx;
font-weight: 600;
color: #333333;
margin-bottom: 4rpx;
font-size: 24rpx;
color: #333;
font-weight: 500;
}
.your-selection {
color: #51bdb6;
font-size: 22rpx;
margin-left: 10rpx;
}
.option-desc {
font-size: 24rpx;
color: #888888;
font-size: 20rpx;
color: #999;
}
/* 选项操作按钮样式 */
.option-action-btn {
font-size: 20rpx;
color: #666;
padding: 4rpx 12rpx;
border: 2rpx solid #eee;
border-radius: 8rpx;
margin-right: 16rpx;
}
/* 选项百分比样式 */
.option-percent {
font-size: 28rpx;
font-weight: 600;
color: #333333;
font-size: 22rpx;
color: #666;
margin-right: 16rpx;
min-width: 60rpx;
text-align: right;
}
/* 进度条样式 */
.progress-bar {
height: 12rpx;
background-color: #f0f0f0;
border-radius: 6rpx;
width: 160rpx;
height: 8rpx;
background-color: #f5f5f5;
border-radius: 4rpx;
overflow: hidden;
}
.progress-value {
height: 100%;
background-color: #4F46E5;
border-radius: 6rpx;
transition: width 0.5s ease-out;
background-color: #409EFF;
transition: width 0.3s;
}
/* 选中指示器 */
.option-item.voted-option .progress-value {
background-color: #51bdb6;
}
/* 选中指示器样式 */
.vote-indicator {
position: absolute;
top: 24rpx;
right: 24rpx;
color: #4F46E5;
font-size: 36rpx;
right: 20rpx;
top: 50%;
transform: translateY(-50%);
font-size: 32rpx;
color: #409EFF;
display: none;
}
@@ -204,116 +247,61 @@
display: block;
}
/* 投票统计信息 */
.option-item.voted-option .vote-indicator {
color: #51bdb6;
}
/* 统计信息样式 */
.vote-stats {
display: flex;
justify-content: space-between;
padding: 0 30rpx 20rpx;
font-size: 20rpx;
color: #999;
margin-bottom: 28rpx;
}
.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;
width: 100%;
height: 80rpx;
background-color: #51bdb6;
color: #fff;
border-radius: 40rpx;
font-size: 24rpx;
font-weight: 500;
display: flex;
justify-content: center;
align-items: center;
transition: all 0.3s;
}
.vote-btn .iconfont {
margin-right: 12rpx;
font-size: 32rpx;
justify-content: center;
gap: 12rpx;
}
.vote-btn::after {
border: none;
}
.vote-btn:hover {
background-color: rgba(79, 70, 229, 0.9);
.vote-btn.vote-btn-disabled {
background-color: #E0E0E0 !important;
color: #9E9E9E !important;
border-color: #E0E0E0 !important;
}
.vote-btn:active {
transform: scale(0.98);
.btn-text {
font-size: 24rpx;
}
/* 成功提示 */
.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;
/* 图标字体基础样式需确保项目已引入iconfont */
.iconfont {
font-family: "iconfont" !important;
font-size: inherit;
font-style: normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.success-toast.show {
opacity: 1;
pointer-events: auto;
.icon-thumbs-up:before {
content: "\e60a";
}
.success-toast .iconfont {
margin-right: 12rpx;
font-size: 32rpx;
.icon-check-circle:before {
content: "\e610";
}
.toast-text {
font-size: 28rpx;
}
/* AI 操作按钮 */
.option-action-btn {
position: absolute;
top: 8px; /* 调整距离顶部 */
right: 8px; /* 调整距离右侧 */
width: 32px;
height: 32px;
display: flex;
align-items: center;
justify-content: center;
background-color: #e0e0e0;
border-radius: 8px;
color: #333;
font-weight: bold;
font-size: 14px;
z-index: 10;
}
.option-action-btn .iconfont {
font-size: 18px;
}
/* 投票按钮 - 已结束状态 */
.vote-btn-ended {
background-color: #ccc; /* 灰色背景 */
color: #888; /* 灰色文字 */
cursor: not-allowed; /* 禁用光标样式 */
}
/* 禁用选项状态 */
.disabled-option {
opacity: 0.6; /* 降低透明度表示禁用 */
pointer-events: none; /* 禁止鼠标事件 */
cursor: not-allowed; /* 禁用光标样式 */
}