<drawer id="withdrawDrawer" needCancel="{{false}}" bind:myCancel="closeWithdrawModal">
  <view class="withdraw-content">
    <mp-icon icon="close" size="{{18}}" color="#fff" class="close-icon" bindtap="closeWithdrawModal" />
    <view class="cover"></view>
    <view class="wrapper">
      
      <!-- WIN and Step 0 -->
      <block wx:if="{{mergedCurrent.result === 1 && luckymoney.withdrawStep === 0}}">
         <view class="congrat">{{mergedCurrent.ClaimText || (isPoint ? '恭喜你，抢到积分红包' : '恭喜你，抢到现金红包')}}</view>
         <view class="amount">
           {{isPoint ? mergedCurrent.Amount : mergedCurrent.Amount / 100}}
           <text class="unit">{{isPoint ? mergedCurrent.RewardsPointsUnit : '元'}}</text>
         </view>
      </block>

      <!-- LOSE or ATTENDED -->
      <block wx:if="{{mergedCurrent.result === 2 || mergedCurrent.result === 4}}">
         <view class="congrat">{{mergedCurrent.ClaimText || '很遗憾，未抢到红包'}}</view>
      </block>

      <!-- UNATTENDED -->
      <block wx:if="{{mergedCurrent.result === 3}}">
         <view class="congrat">很遗憾，你未提前报名参加</view>
      </block>

      <!-- ERROR (< 0) -->
      <block wx:if="{{mergedCurrent.result < 0}}">
         <image src="./assets/fail.svg" class="fail-svg" />
         <view class="congrat" style="margin-bottom: 0">抢红包的人太多了</view>
         <view class="small-text">努力计算中...</view>
         <button class="refresh-btn" type="warn" bindtap="refreshResult">刷新</button>
      </block>

      <!-- Step 0 List -->
      <block wx:if="{{mergedCurrent.result > 0 && luckymoney.withdrawStep === 0}}">
         <view class="splitter"></view>
         <view class="header">红包手气榜</view>
         <scroll-view scroll-y class="withdraw-list">
            <view class="list-inner">
                <view wx:for="{{mergedCurrent.RedPacketWinner}}" wx:key="index" class="item">
                   <view class="item-name">{{item.UserName}}</view>
                   <view class="item-count">
                     <block wx:if="{{isPoint}}">{{item.Amount || '0'}} {{mergedCurrent.RewardsPointsUnit}}</block>
                     <block wx:else>{{item.Amount / 100}} 元</block>
                   </view>
                </view>
            </view>
         </scroll-view>
      </block>

      <!-- Step 1 Input -->
      <block wx:if="{{luckymoney.withdrawStep === 1}}">
         <block wx:if="{{unableToWithdraw}}">
            <image src="./assets/fail.svg" class="fail-svg" />
            <view class="congrat" style="margin-bottom: 0; padding: 24rpx; font-weight: normal; font-size: 28rpx;">
              当前页未在微信中打开，无法进行到账微信授权。请在微信中打开，登录后再进行提现操作
            </view>
         </block>
         <block wx:else>
            <view class="congrat">绑定相关信息进行提现</view>
            <block wx:if="{{luckymoney.hasWechatAppInfo && IsOpenWeChatWithdraw}}">
               <view class="wechat-wrapper">
                 <view class="wechat-info">
                   <block wx:if="{{!luckymoney.wechat}}">暂未绑定微信账号</block>
                   <block wx:elif="{{luckymoney.wechat.UserId == '0'}}">授权失败，请重试或联系主办方</block>
                   <block wx:else>{{luckymoney.wechat.WechatName}}</block>
                 </view>
                 <view class="auth-btn" bindtap="onHandleWechatRedirect">
                    {{!luckymoney.wechat ? '立即授权' : '重新授权'}}
                 </view>
               </view>
            </block>
            
            <view class="cell-wrapper input-group">
               <input class="input" placeholder="请输入手机号" value="{{phoneNumber}}" bindinput="onPhoneInput" />
            </view>
            <view class="cell-wrapper input-group" style="display: flex; align-items: center;">
               <input class="input" placeholder="请输入验证码" value="{{verifyCode}}" bindinput="onVerifyCodeInput" style="flex: 1;" />
               <view class="suffix-btn {{cellCountdown > 0 ? 'disabled' : ''}}" bindtap="sendVerifyCode">
                 {{cellCountdown > 0 ? '重新发送' + cellCountdown + '秒' : '获取验证码'}}
               </view>
            </view>
            <view class="error-notice">{{cellError}}</view>
         </block>
      </block>

      <!-- Withdraw Button -->
      <block wx:if="{{mergedCurrent.result === 1 && !isPoint && canWithdraw}}">
         <button class="withdraw-button" hover-class="withdraw-button-hover" bindtap="onWithdrawClick">
           立即提现
         </button>
      </block>
    </view>
  </view>
</drawer>
