Files

100 lines
4.7 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<view style="height: 80vh; padding-bottom: 100rpx;">
<a>{{url}}</a>
<scroll-view
class="scroll-container"
scroll-y="true"
enable-flex="true"
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="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_name}}</text>
<text class="user-status">({{card.vote_type === 'single' ? '单选' : '多选'}})</text>
</view>
</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}} </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 {{(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}}"
>
<view class="option-info">
<view class="option-icon bg-gray">
<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 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>
<text class="option-percent">{{option.percentage || 0}}%</text>
<view class="progress-bar">
<view class="progress-value" style="width: {{(option.percentage || 0) + '%'}}"></view>
</view>
<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 || 0}} 人参与投票</text>
<text class="stats-text">{{card.is_ended ? '已结束' : '剩余 ' + card.end_time}}</text>
</view>
<!-- 投票提交按钮 -->
<button
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}}"
>
<text class="iconfont icon-thumbs-up"></text>
<text class="btn-text">{{card.user_has_voted ? '已提交投票' : (card.is_ended ? '投票结束' : '投我一票')}}</text>
</button>
</view>
</block>
</view>
</scroll-view>
</view>