<Drawer id="vote-drawer" custom-drawer="vote-drawer-shell" needCancel="{{false}}" bind:myCancel="onVoteDrawerCancel">
  <view wx:if="{{visible}}" class="vote-drawer {{useDarkTheme ? 'vote-drawer-dark' : ''}}">
    <view class="vote-header">
      <view class="vote-title-row">
        <view class="vote-type">[{{data.IsMultiple ? '多选' : '单选'}}]</view>
        <mp-icon bindtap="closeVoteDrawer" icon="close" color="#939aa3" size="{{20}}" class="vote-close-icon drawer-close-shadow" />
      </view>
    </view>
    <view wx:if="{{loading}}" class="vote-empty">加载中...</view>
    <view wx:elif="{{errMsg && !data}}" class="vote-empty">{{errMsg}}</view>
    <view wx:else class="vote-main">
      <view class="vote-title">{{data.Title}}</view>
      <scroll-view scroll-y class="vote-options-scroll">
        <radio-group wx:if="{{!data.IsMultiple}}" bindchange="valueChange" class="vote-options">
          <label
            wx:for="{{data.Options}}"
            wx:key="OptionSite"
            class="vote-option"
          >
            <radio
              class="vote-native-control"
              value="{{item.OptionSite}}"
              checked="{{item.checked}}"
              disabled="{{isVoted || isVoteClosed}}"
              color="#3370ff"
            />
            <view class="vote-option-body">
              <view class="vote-option-row">
                <view class="vote-option-check {{item.checked ? 'vote-option-check-checked' : ''}}">
                  <view wx:if="{{item.checked}}" class="vote-option-check-mark"></view>
                </view>
                <view class="vote-option-content">{{item.OptionName}}</view>
              </view>
              <view wx:if="{{isShowResult}}" class="vote-progress">
                <view class="vote-progress-text">{{item.OptionCount || 0}} 票, {{item.OptionPercent || 0}}%</view>
                <progress percent="{{item.OptionPercent || 0}}" border-radius="6" stroke-width="6" activeColor="#3370ff" backgroundColor="{{useDarkTheme ? '#37383a' : '#f1f2f5'}}" />
              </view>
            </view>
          </label>
        </radio-group>
        <checkbox-group wx:else bindchange="valueChange" class="vote-options">
          <label
            wx:for="{{data.Options}}"
            wx:key="OptionSite"
            class="vote-option"
          >
            <checkbox
              class="vote-native-control"
              value="{{item.OptionSite}}"
              checked="{{item.checked}}"
              disabled="{{isVoted || isVoteClosed}}"
              color="#3370ff"
            />
            <view class="vote-option-body">
              <view class="vote-option-row">
                <view class="vote-option-check vote-option-check-multiple {{item.checked ? 'vote-option-check-checked' : ''}}">
                  <view wx:if="{{item.checked}}" class="vote-option-check-mark"></view>
                </view>
                <view class="vote-option-content">{{item.OptionName}}</view>
              </view>
              <view wx:if="{{isShowResult}}" class="vote-progress">
                <view class="vote-progress-text">{{item.OptionCount || 0}} 票, {{item.OptionPercent || 0}}%</view>
                <progress percent="{{item.OptionPercent || 0}}" border-radius="6" stroke-width="6" activeColor="#3370ff" backgroundColor="{{useDarkTheme ? '#37383a' : '#f1f2f5'}}" />
              </view>
            </view>
          </label>
        </checkbox-group>
      </scroll-view>
      <view wx:if="{{data.TotalCount > -1}}" class="vote-total">实际参与人数：{{data.TotalCount || 0}}人</view>
      <view class="vote-footer">
        <button
          class="vote-submit {{isVoted || isVoteClosed ? 'vote-submit-disabled' : ''}}"
          disabled="{{isVoted || isVoteClosed}}"
          loading="{{submitting}}"
          bindtap="formSubmit"
        >{{isVoted ? '已投票' : (isVoteClosed ? '投票已截止' : '提交投票')}}</button>
      </view>
    </view>
  </view>
</Drawer>
