<!--packageF/storeManagement/storeMemberInfo/storeMemberInfo.wxml-->


<view class="member-header">
  <view class="member-info">
    <view class="atavar">
      <image mode="aspectFill" src="{{memberData.avatar_image}}"></image>
    </view>
    <view class="info">
      <view style="display: flex;align-items: center;">
        <view class="user-name text-overHide">{{memberData.nickname}}</view>
        <text class="user-id">ID:{{memberData.uid}} </text>
      </view>
      <view style="display: flex;margin-top: 0.6rem">
        <view class="mermber-level text-overHide" wx:if="{{memberChild.level}}">{{memberChild.level.level_name}}</view>
        <view class="end-time" wx:if="{{memberChild.validity}}">{{memberChild.validity}} 到期 <text data-text='期限' catchtap="setIsEmitLevel">></text></view>
       
      </view>
    </view>
  </view>
  <view class="integral-detail">
    <view class="li" bindtap="gotoPage" data-id="{{memberId}}" data-name="storeIntegralList">
      <view class="number textover-2">{{memberData.credit1 ? memberData.credit1 : 0}}</view>
      <view>{{integral_text}}</view>
    </view>
    <view class="li" bindtap="gotoPage" data-id="{{memberId}}" data-name="storeBalanceList">
      <view class="number textover-2">￥{{memberData.credit2 ? memberData.credit2 : 0}}</view>
      <view>{{balance_text}}</view>
    </view>
    <view class="li" bindtap="gotoPage" data-id="{{memberId}}" data-name="storeCouponList">
      <view class="number textover-2">{{memberData.coupon ? memberData.coupon : 0}}</view>
      <view>优惠券</view>
    </view>
  </view>
</view>


<view class="member-content">
  <view class="recharge-panel">
    <view data-type="integral" bindtap="showRechargePopup">
      <view class="icon jifen">
        <i class="iconfont icon-jifen"></i>
      </view>
      <view class="text">充值{{integral_text}}</view>
    </view>
    <view data-type="balance" bindtap="showRechargePopup">
      <view class="icon qian">
        <i class="iconfont icon-fontclass-qian"></i>
      </view>
      <view class="text">充值{{balance_text}}</view>
    </view>
    <view bindtap="showCouponPopup">
      <view class="icon youhuiq">
        <i class="iconfont icon-fontclass-youhuiq"></i>
      </view>
      <view class="text">赠送优惠券</view>
    </view>
  </view>

  <view class="detail">
    <view class="plane">
      <view class="plane-title">会员信息</view>
      <view class="list">
        <view class="recommend item" wx:if="{{memberChild.agent}}">
          <view class="right" style="display: flex;flex: 1;">
            <view style="flex: 1;">
              <text class="left-title">推荐人：</text>
              <text class="mermber-id">ID:{{memberChild.agent.uid}}</text>
              <text>{{memberChild.agent.nickname}}</text>
            </view>
            <view style="color: red;padding-right: 32rpx;" data-text='推荐人' catchtap="setIsEmitLevel">修改</view>
          </view>
        </view>
        <view class="current item">
          <view class="left-title">来源：</view>
          <view class="right">
            <block wx:if="{{memberData.has_one_fans}}">
              <i class="iconfont icon-all_wechat_public" wx:if="{{memberData.has_one_fans.followed == 1}}"></i>
              <i class="iconfont icon-all_wechat_public not-followed" wx:else></i>
            </block>
            <i class="iconfont icon-all_smallprogram" wx:if="{{memberData.has_one_mini_app}}"></i>
            <i class="iconfont icon-all_app" wx:if="{{memberData.has_one_wechat}}"></i>
            <i class="iconfont icon-all_wechat" wx:if="{{memberData.has_one_unique}}"></i>
            <i class="iconfont icon-all_alipay" wx:if="{{memberData.has_one_alipay}}"></i>
            <i class="iconfont icon-all_trill" wx:if="{{memberData.has_one_douyin}}"></i>
            <i class="iconfont icon-qiyeweixin01" wx:if="{{memberData.has_one_customers}}"></i>
          </view>
        </view>
        <view class="item">
          <view class="left-title">注册时间：</view>
          <text class="right">{{memberData.createtime}}</text>
        </view>
        <view class="item">
          <view class="left-title">会员分组：</view>
          <view class="right" style="display: flex;flex: 1;">
            <view style="flex: 1;">
              <text class="right" wx:if="{{memberData.yz_member && memberData.yz_member.group}}">{{memberData.yz_member.group.group_name}}</text>
              <text class="right" wx:else>无分组</text>
            </view>
            <view style="color: red;padding-right: 32rpx;" data-text='分组' catchtap="setIsEmitLevel">修改</view>
          </view>
        </view>
        <view class="item">
          <view class="left-title">会员等级：</view>
          <view class="right" style="display: flex;flex: 1;">
            <view style="flex: 1;">{{memberChild.level.level_name}}</view>
            <view style="color: red;padding-right: 32rpx;" data-text='等级' catchtap="setIsEmitLevel">修改</view>
          </view>
        </view>
        <view class="item">
          <view class="left-title">姓名：</view>
          <text class="right">{{memberData.realname}}</text>
        </view>
        <view class="item">
          <view class="left-title">性别：</view>
          <text class="right">{{memberData.gender ? (memberData.gender == 1 ? '男' : '女') : '未知'}}</text>
        </view>
        <view class="item">
          <view class="left-title">手机号：</view>
          <text class="right">{{memberData.mobile}}</text>
        </view>
        <view class="item">
          <view class="left-title">微信号：</view>
          <text class="right">{{memberChild.wechat || ''}}</text>
        </view>
        <view class="item">
          <view class="left-title">推广员： </view>
          <view class="right">
            <van-switch checked="{{memberChild.is_agent}}" active-value="{{1}}" inactive-value="{{0}}" size="18px" bindchange="changeAgent"></van-switch>
          </view>
        </view>
      </view>
    </view>
    <view class="plane">
      <view class="plane-title">支付宝</view>
      <view class="list">
        <view class="item">
          <view class="left-title">支付宝账号：</view>
          <text class="right">{{memberChild.alipay || ''}} </text>
        </view>
        <view class="item">
          <view class="left-title">账号姓名：</view>
          <text class="right">{{memberChild.alipayname || ''}}</text>
        </view>
      </view>
    </view>
    <view class="plane" wx:if="{{memberData.bank_card}}">
      <view class="plane-title">银行卡信息</view>
      <view class="list">
        <view class="item">
          <view class="left-title">开户行：</view>
          <text class="right">{{memberData.bank_card.bank_name || ''}}</text>
        </view>
        <view class="item">
          <view class="left-title">开户行省份：</view>
          <text class="right">{{memberData.bank_card.bank_province || ''}}</text>
        </view>
        <view class="item">
          <view class="left-title">开户城市：</view>
          <text class="right">{{memberData.bank_card.bank_city || ''}}</text>
        </view>
        <view class="item">
          <view class="left-title">开户支行：</view>
          <text class="right">{{memberData.bank_card.bank_branch || ''}}</text>
        </view>
        <view class="item">
          <view class="left-title">银行卡号：</view>
          <text class="right">{{memberData.bank_card.bank_card || ''}}</text>
        </view>
        <view class="item">
          <view class="left-title">姓名：</view>
          <text class="right">{{memberData.bank_card.member_name || ''}}</text>
        </view>
      </view>
    </view>
  </view>
</view>

<view class="fixed-topping" wx:if="{{titleBgMode == 'show'}}" bindtap="setTopping">
  <i class="iconfont icon-fontclass-zhiding"></i>
</view>


<!-- 充值弹框 -->
<van-popup show="{{rechargePopup}}" position="bottom" custom-class="popup" bind:click-overlay="closeRechargePop">
  <view class="popup-header">
    <text class="pop-title">充值{{popText==='积分' ? integral_text : balance_text}}</text>
    <van-icon class="close-icon" name="cross" bindtap="closeRechargePop"></van-icon>
  </view>
  <view class="popup-content">
    <view class="current-integral">当前{{popText==='积分' ? integral_text : balance_text}} <text class="integral">{{popText==='积分' ? memberData.credit1 :
        memberData.credit2}}</text></view>
    <view class="cell-title">
      <i class="iconfont icon-fontclass-xinghao"></i>
      <text class="text">充值{{popText==='积分' ? integral_text : balance_text}}</text>
    </view>
    <!-- 积分 -->
    <view wx:if="{{popText==='积分'}}">
      <input class="int-input" data-name="integral" bindinput="setRechargeContent" value="{{recharge.integral}}" type="number" placeholder="请输入充值数量" />
    </view>
    <!-- 余额 -->
    <view wx:else>
      <input class="int-input" data-name="balance" bindinput="setRechargeContent" value="{{recharge.balance}}" type="number" placeholder="请输入充值数量" />
    </view>
    <textarea cols="30" rows="10" class="int-remarks" data-name="remarks" bindinput="setRechargeContent" value="{{recharge.remarks}}" placeholder="请输入备注信息"></textarea>
    <!-- <van-field value="{{recharge.remarks}}" class="int-remarks" placeholder="请输入备注信息"></van-field> -->
  </view>
  <view class="btn-recharge" bindtap="confirmRecharge">充值</view>
</van-popup>



<!-- 赠送优惠券 -->
<van-popup show="{{couponPopup}}" position="bottom" custom-class="popup" bind:click-overlay="closeCouponPop">
  <view class="popup-header">
    <text class="pop-title">赠送优惠券</text>
    <van-icon class="close-icon" name="cross" data-type="couponPopup" bindtap="closeCouponPop"></van-icon>
  </view>
  <view class="popup-content">
    <view>
      <view class="cell-title">
        <i class="iconfont icon-fontclass-xinghao"></i>
        <text class="text">优惠券</text>
      </view>
      <van-cell title="{{info.name || '请选择优惠劵'}}" is-link catchtap="showChooseCoupon" />
    </view>

    <view class="cell-title">
      <i class="iconfont icon-fontclass-xinghao"></i>
      <text class="text">优惠券张数</text>
    </view>
    <input value="{{coupons.number}}" data-name="number" bindinput="setCouponsContent" class="int-input" type="number" placeholder="请输入赠送优惠券张数" />
  </view>
  <view class="btn-recharge" bindtap="confirmGive">确定</view>
</van-popup>

<!-- 选择优惠劵 -->
<van-popup  custom-style="height: 55%;" show="{{ChooseCouponPopup}}" position="bottom" custom-class="popup" bind:click-overlay="closeCouponPop">
  <view class="popup-header">
    <text class="pop-title">选择优惠券</text>
    <van-icon class="close-icon" name="cross" data-type="ChooseCouponPopup" bindtap="closeCouponPop"></van-icon>
  </view>
  <view class="popup-content">
    <view>
      <input value="{{couponsName}}" class="int-input"  bindinput="setCouponsName"  placeholder="请输入优惠券名称" />
    </view>
    <van-radio-group value="{{ chooseCouponValue }}" bind:change="onChangeCoupon">
      <van-cell-group>
        <van-cell wx:for="{{CouponAll}}" wx:key="unique" title="{{item.name}}" bind:click="onClick" clickable  data-info="{{item}}" data-name="{{item.id}}">
          <van-radio slot="right-icon" name="{{item.id}}" />
        </van-cell>
      </van-cell-group>
    </van-radio-group>
  </view>
</van-popup>


<!-- 修改会员信息 -->
<van-popup show="{{isEmitLevel}}" position="bottom" custom-class="popup" bind:click-overlay="setIsEmitLevel" custom-style="height: 55%;">
  <view style="display:flex;">
    <view style="color:#B6B6B6;" catchtap="setIsEmitLevel">取消</view>
    <view style="flex:1;text-align:center;color: #333;">修改会员{{typeText}}</view>
    <view style="color: #ee0a24;" catchtap="emitLevel">确认</view>
  </view>

  <!-- 会员等级 -->
  <view class="van-radio-group-box">
    <block wx:if="{{typeText=='等级'}}">
      <van-radio-group value="{{memberChild.level_id}}" style="margin:2rem 0;" bind:change="changeLevel_id">
        <van-radio name="{{item.id}}" wx:for="{{level_list}}" style="margin:30rpx 0;" wx:key="index">
          {{item.level_name}}
        </van-radio>
      </van-radio-group>
    </block>
    <block wx:elif="{{typeText=='分组'}}">
      <van-radio-group value="{{memberChild.group_id}}" style="margin:2rem 0;" bind:change="changeMember_groupId">
        <van-radio name="{{item.id}}" wx:for="{{member_list}}" style="margin:30rpx 0;" wx:key="index">
          {{item.group_name}}
        </van-radio>
      </van-radio-group>
    </block>
    <block wx:elif="{{typeText=='推荐人'}}">
      <view style="margin-top:45rpx;">会员推荐人</view>
      <input value="{{recommendId}}"  bindinput="SearchRecommend" class="int-input" type="number" placeholder="请输入会员推荐人ID" />
      <view wx:if="{{recommendInfo && recommendInfo.nickname}}">
        会员昵称：{{recommendInfo.nickname}}
      </view>
      <view wx:if="{{!memberFlag}}"  class="tips error">
          未找到会员
      </view>
    </block>
    <block wx:else="{{typeText=='限期'}}">
      <van-datetime-picker confirm-button-text='' cancel-button-text='' type="date" value="{{ currentDate }}" bind:input="onInput" min-date="{{ minDate }}" formatter="{{ formatter }}" />
    </block>

  </view>
</van-popup>