<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> 
<jsp:include page="../../common.jsp" />
  <head>
        <meta charset="utf-8">
        <title></title>
        <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
        <title>会员卡充值</title>
        <style>
            .h40{
                height:40px;
                line-height:40px;
            }
        </style>
    </head>
<!doctype html>
    <body class="">
        <div class="bluebg pt20 pb15 positionr mt20 ml20 mr20 pl10 pr10 positionr radius5" style="min-height:150px;">
            <div class="weui-flex">
                   <div class="weui-flex__item white">
                       <div class="f14 mb10">${merchantMenber.nickName }</div>
                        <div class="f14">${merchantMenber.memberCode }</div>
                  </div>
                  <div class="weui-flex__item white tright">
                      要收银用快银
                  </div>  
            </div>
            <div class="f14 pt20 white">
            
            
            <c:if test="${not empty activityRechargeList }">
            <div class="mb10">
                <span class="icon icon-18 f14 vm"></span><span class="vm ml10">
                <c:forEach var="activityRecharge" items="${activityRechargeList }">
                    充<fmt:formatNumber type="number" value="${activityRecharge.rechargeMoney }" pattern="0.00" maxFractionDigits="2"/> 送<fmt:formatNumber type="number" value="${activityRecharge.giveMoney}" pattern="0.00" maxFractionDigits="2"/>；
                </c:forEach>
                </span>
            </div>
        </c:if>
       
            
            
                <!--   <div class="mb10"><span class="icon icon-18 f14 vm"></span><span class="vm ml10">充100送1；充200送2；充300送3</span></div>
                  <div class="mb10"><span class="icon icon-18 f14 vm"></span><span class="vm ml10">消费2返2</span></div>
                  <div class="mb10"><span class="icon icon-18 f14 vm"></span><span class="vm ml10">激活会员送100</span></div> -->
                
                <div class="tright positiona bottom0 right0 pr20 pb15 pr10">
                        <span class="vm"><img src="https://www.shouyinbei.net/resources/wap/images/wollet.png" width="20"></span>
                        <span class="vm">钱包</span>
                        <span class="f28 vm"><fmt:formatNumber type="number" value="${merchantMenber.usableRechargeFee + merchantMenber.usableGiveFee }" pattern="0.00" maxFractionDigits="2"/></span>
                </div> 
            </div>
        </div>
        <div class="weui-cells weui-cells_form bdbe ml20 mr20">
            <div class="weui-cell weui-cell_warn">
                <div class="weui-cell__hd"><label for="" class="weui-label f-black f22">¥</label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input tright" type="number" pattern="[0-9]*" id="rechargeMoney" value="weui input error" placeholder="请输入充值金额(元)">
                </div>
            </div>
        </div>
       <div class="weui-cells weui-cells_form bdbe pb20">
            <div class="tcenter clearfix payTab">
                <div class="f16 fl tcenter pt20 wp33 current">
                    <a href="javascript:void(0);" class="dblock radius5 pt10 pb10 ml10 mr10">200元</a>
                </div>
                <div class="f16 fl tcenter pt20 wp33">
                    <a href="javascript:void(0);" class="dblock radius5 pt10 pb10 ml10 mr10">150元</a>
                </div>
                <div class="f16 fl tcenter pt20 wp33">
                    <a href="javascript:void(0);" class="dblock radius5 pt10 pb10 ml10 mr10">50元</a>
                </div>
                <c:forEach items="${activityRechargeList }" var="activityRecharge">
                     <div class="f16 fl tcenter pt20 wp33">
                    <a href="javascript:void(0);" class="dblock radius5 pt10 pb10 ml10 mr10">${activityRecharge.rechargeMoney }元送${activityRecharge.giveMoney }元</a>
                </div>
                </c:forEach>
            </div>
        </div>
        <div class="btn mt20 ml20 mr20">
            <a href="javascript:void(0);onclick=memberPay()" class="weui-btn weui-btn_primary radius10 f14 pt15 pb15">立即充值</a>
        </div>
        <script>
             $(function(){
                 $(".payTab>div").click(function(){
                     $(this).addClass("current").siblings("div").removeClass("current");
                     var a=$(".current a").text();
                     var money=a.split('元');
                     var rechargeMoney=money[0];
                     $("#rechargeMoney").val(rechargeMoney);
                 })
             })
             
             function memberPay(){
            	 var rechargeMoney=$("#rechargeMoney").val();
            	 if(StringUtil.isNotTwo(rechargeMoney)){
                     if(StringUtil.isBlank(rechargeMoney)){
                     alert("请输入金额");
                     return;
                     }
                     alert('请输入正确的金额格式(正整数或小数)');
                     return;
                 }
                 if(StringUtil.isNotBlank(rechargeMoney)){
                     if(rechargeMoney<0.01){
                         alert('充值金额必须大于0.01');
                         return;
                     }
                 }
            	 $.ajax({
            		 url:ctx+'/merchant/memberPay',
            		 data:{
            			 "consumeMoney":rechargeMoney,
            			 'openId':'${merchantMenber.openid}',
            			 'merchantCode':'${merchantMenber.merchantCode}',
            			 'storeId':'${merchantMenber.storeId}',
            		 },
            		 dataType:"json",
            		 type:"post",
            		 success:function(res){
            			if(res.code=='1'){
            				window.location = res.jspay_url;
            			}else{
            				$.toast(res.msg,"text");
            			}
            		 }
            	 })
             }
        </script>
    </body>

</html>