<?php include mayi_tpl('inc_header');?>
<link rel="Stylesheet" type="text/css" href="template/css/new.dialog.css" />
<link rel="stylesheet" type="text/css" href="template/css/new.my.css" />
<script language="javascript" src="template/javascript.js"></script>
<script language="javascript" src="template/jquery.172.min.js"></script>
</head>
<body class="<?php echo $mymps_global['cfg_tpl_dir']; ?>" <?php if($box == 1){?>style="background:none"<?php }?>>
<div class="container">
    
    <div id="main" class="main section-setting">
            <div class="clearfix main-inner" >
                <div class="content">
                    <div class="clearfix content-inner" <?php if($box == 1) echo 'style="margin:0!important;"';?>>
                        <?php if($box != 1){?><?php if($m!='subStore'){?><div class='location'><?=$location?></div><?php }?><?php }?>
                        <div class="content-main" <?php if($box == 1) echo 'style="margin:0!important;"';?>>
                            <div class="content-main-inner">
                                
                                <div class="pwrap">
                                    
                                    <div class="pbody">
                                        <?php if($box != 1){?>
                                        <div class="clearfix pagetab-wrap">
                                            <ul class="pagetab">
                                                <li><a href="?m=pay&ac=pay" <?php if($ac == 'pay') echo 'class="current"'; ?>><span>金币充值</span></a></li>
												<?php if($box != 1){?>
                                                <li><a href="?m=pay&ac=record" <?php if($ac == 'record') echo 'class="current"'; ?>><span>充值明细</span></a></li>
                                                <li><a href="?m=pay&ac=use" <?php if($ac == 'user') echo 'class="current"'; ?>><span>消费记录</span></a></li>
												<?php }?>
                                            </ul>
                                        </div>
										
    									<div id="msg_success"></div>
										<div id="msg_error"></div>
										<div id="msg_alert"></div>
                                        <?php }?>
										<?php if(empty($money) || $money == $mymps_global['cfg_pay_min']){?>
                                        <div id="yhlist">
                                        <ul>
                                        <li class="yl" onClick="yhclick(<?php echo ceil($mymps_global['cfg_pay_min']/$mymps_global['cfg_coin_fee'])?>,<?=$mymps_global['cfg_pay_min']?>)">
                                        <div class="lmoney"><?=$mymps_global['cfg_pay_min']?>金币</div>
                                        <div class="ljinbi"><?=$moneymark?><?php echo ceil($mymps_global['cfg_pay_min']/$mymps_global['cfg_coin_fee'])?></div>
                                        </li>
                                        <?php foreach($payChoose as $k=>$v){?>
                                        <li onClick="yhclick(<?=$k?>,<?=$v*$mymps_global['cfg_coin_fee']?>)">
                                        <div class="lmoney"><?=$v*$mymps_global['cfg_coin_fee']?>金币</div>
                                        <div class="ljinbi"><?=$moneymark?><?=$k?>(<font color=red>送<?=$v-$k?>金币</font>)</div>
                                        </li>
                                        <?php }?>
                                        </ul>
                                        </div>
                                        <?php }?>
                                        <form action="?m=pay&ac=pay" method="post" target="_blank">
                                        <input name="back" type="hidden" value="<?=$back;?>">
                                        <div class="formgroup topupform">
                                            
                                            <div class="errormsg" id="error" style="display:none"></div>
                                          
                                            <div class="formrow">
                                                <div class="formrow-enter">
                                                    <ul class="clearfix paymentlist">
                                                    <?php $kami=mymps_count("kami")?>
                                                    <?php if($kami>0){?>
                                                    <li id="likami">
                                                        <label for="payment_kami" class="image">
                                                            <img src="template/images/kami.png" alt="kami" width="160" height="40" onClick="$obj('payment_kami').checked = true;kamiPayment();" />
                                                        </label>
                                                        <input id="payment_kami" class="radio" type="radio" name="payid" onClick="selPayment()" value="10000"  />
                                                        <label for="payment_kami" class="title">卡密兑换</label>
                                                    </li>
                                                    <?php }?>
                                                     <?php 
                                                     if(is_array($opened_pay_api)){
                                                     foreach($opened_pay_api as $k => $v){?>
                                                     <?php if($v['paytype']!='chinabank' && $v['paytype']!='tenpay' && $v['paytype']!='wxapp'){?>
                                                        <li id="li<?=$v['paytype']?>" <?php if($v['payid'] == 3){?>class="selected"<?php }?>>
                                                            <label for="payment_<?=$v['paytype']?>" class="image">
                                                                <img src="template/images/<?=$v['paytype']?>.png" alt="<?=$v['payname']?>" width="160" height="40" onClick="$obj('payment_<?=$v['paytype']?>').checked = true;selPayment();" />
                                                            </label>
                                                            <input id="payment_<?=$v['paytype']?>" class="radio" type="radio" name="payid" onClick="selPayment()" value="<?=$v['payid']?>"  <?php if($v['payid'] == 3) echo 'checked="checked"'; ?> />
                                                            <label for="payment_<?=$v['paytype']?>" class="title"><?=$v['payname']?></label>
                                                        </li>
                                                        <?php }?>
                                                     <?php
                                                     	}}else{
                                                        ?>
                                                        <font color="red">请联系网站客服为您充值</font>
                                                     <?php
                                                     }
                                                     ?>
                                                    </ul>
                                                </div>
                                            </div>
                                            
                                            <div id="kamipay" style="display:none;">
                                                <div class="formrow">
                                                    <h3 class="label" style="text-align:left"><label for="value" id="realfont">请输入卡密号码</label></h3>
                                                    <div class="formrow-enter">
                                                        <input type="hidden" name="currentPointType" id="currentPointType" value="Point8" />
                                                        <input type="text" class="txt number" name="keycode" />
                                                        <span id="pointunit"></span>
                                                    </div>
                                                </div>
                                            </div>
                                            
                                            <div id="realpay">
                                                <div class="formrow">
                                                    <h3 class="label" style="text-align:left"><label for="value" id="realfont">请输入要充值的<span id="pointname">金币</span>数 <span class="note">(当前金币为: <img src="template/images/coins.gif" align="absmiddle"><font color="red"><?=$money_own?></font>，一次最少需要充值<span id="minvalue" style="color:red">0</span>个金币)</span></label></h3>
                                                    <div class="formrow-enter">
                                                        <input type="hidden" name="currentPointType" id="currentPointType" value="Point8" />
                                                        <input type="text" class="txt number" name="money" id="payvalue" value="<?php echo $money?$money:$mymps_global['cfg_pay_min']?>" onKeyUp="setMustPay()" />
                                                        <span id="pointunit"></span>
                                                    </div>
                                                </div>
                                                <?php if($box!=1){?>
                                                <div class="formrow">
                                                    <h3 class="label" style="text-align:left">实际应付</h3>
                                                    <div class="formrow-enter">
                                                        <span class="pay" id="mustpay">0</span> <?php echo $moneytype; ?>
                                                        <span class="note" id="paytype"></span>
                                                    </div>
                                                </div>
                                                <?php }?>
                                            </div>
                                            <script type="text/javascript">
												function kamiPayment() {
                                                    var varPayment = document.getElementsByName("payid");
                                                    for (i = 0; i < varPayment.length; i++) {
                                                        if (varPayment[i].checked) {
															setCssClass("liwxnative", "");
															setCssClass("lialipay","");
															setCssClass("litenpay", "");
															setCssClass("lichinabank", "");
															setCssClass("likami", "");
															$obj('realpay').style.display='none';
															$obj('kamipay').style.display='';
															$obj('paytype').innerHTML = '(你选择了卡密支付)';
                                                        }
                                                    }
                                                }
                                                function selPayment() {
                                                    var varPayment = document.getElementsByName("payid");
                                                    for (i = 0; i < varPayment.length; i++) {
                                                        if (varPayment[i].checked) {
                                                            switch (varPayment[i].value) {
                                                                case "8":
																	setCssClass("likami", "");
                                                                    setCssClass("liwxnative", "");
                                                                    setCssClass("lialipay","");
                                                                    setCssClass("litenpay", "");
                                                                    setCssClass("lichinabank", "");
																	setCssClass("lierweima_pay", "selected");
																	//$obj('realpay').style.display='';
																	$obj('kamipay').style.display='none';
                                                                    $obj('paytype').innerHTML = '(你选择了微信扫码支付)';
                                                                    break;
																case "6":
																	setCssClass("likami", "");
                                                                    setCssClass("liwxnative", "selected");
                                                                    setCssClass("lialipay","");
                                                                    setCssClass("litenpay", "");
                                                                    setCssClass("lichinabank", "");
																	setCssClass("lierweima_pay", "");
																	//$obj('realpay').style.display='';
																	$obj('kamipay').style.display='none';
                                                                    $obj('paytype').innerHTML = '(你选择了微信扫码支付)';
                                                                    break;
                                                                case "3":
																	setCssClass("likami", "");
                                                                    setCssClass("lialipay", "selected");
                                                                    setCssClass("litenpay", "");
                                                                    setCssClass("lichinabank", "");
                                                                    setCssClass("liwxnative", "");
																	setCssClass("lierweima_pay", "");
																	//$obj('realpay').style.display='';
																	$obj('kamipay').style.display='none';
                                                                    $obj('paytype').innerHTML = '(你选择了支付宝支付)';
                                                                    break;
                                                                case "1":
																	setCssClass("likami", "");
                                                                    setCssClass("lialipay", "");
                                                                    setCssClass("litenpay", "selected");
                                                                    setCssClass("lichinabank", "");
                                                                    setCssClass("liwxnative", "");
																	setCssClass("lierweima_pay", "");
																	//$obj('realpay').style.display='';
																	$obj('kamipay').style.display='none';
                                                                    $obj('paytype').innerHTML = '(你选择了财付通支付)';
                                                                    break;
                                                                case "2":
																	setCssClass("likami", "");
                                                                    setCssClass("lialipay", "");
                                                                    setCssClass("litenpay", "");
                                                                    setCssClass("liwxnative", "");
                                                                    setCssClass("lichinabank", "selected");
																	setCssClass("lierweima_pay", "");
																	//$obj('realpay').style.display='';
																	$obj('kamipay').style.display='none';
                                                                    $obj('paytype').innerHTML = '(你选择了网银在线支付)';
                                                                    break;
																case "10000":
                                                                    setCssClass("lialipay", "");
                                                                    setCssClass("litenpay", "");
                                                                    setCssClass("liwxnative", "");
                                                                    setCssClass("lichinabank", "");
																	setCssClass("lierweima_pay", "");
																	setCssClass("likami", "selected");
                                                                    $obj('paytype').innerHTML = '(你选择了卡密兑换支付)';
                                                                    break;
                                                                default:
                                                                    break;
                                                            }
                                                        }
                                                    }
                                                }
    
                                                function setCssClass(id, className) {
                                                    var element = document.getElementById(id);
                                                    if (element != null)
                                                        element.className = className;
                                                }
                                             
												$(document).ready(function(){
												$("#yhlist ul li").click(function(){
												$(this).addClass("yl").siblings().removeClass("yl");
												});
												});
												
												function yhclick(num,num2)
												{
												$("#payvalue").val(num2);
												$("#mustpay").html(num);
												}
                                            </script>
                                            <div class="formrow formrow-action"> 
                                                <span class="minbtn-wrap"><span class="btn">
                                                <input class="button" type="submit" name="pay_submit" id="confirmResult" onClick="return checkInput();" value="点我确认充值" <?php if(!is_array($opened_pay_api)){?>disabled<?php }?>/>
                                                </span>
                                                <?php if($box==1 && $money>$mymps_global['cfg_pay_min']){?><font style="color:white; margin-left:10px;">(实际应付：<span id="mustpay">0</span> <?php echo $moneytype; ?>)</font><?php }?>
                                                </span>
                                                
                                            </div>
                                        </div>
                                        </form>
                                		<?php if($box != 1){?>
                                        <div class="alertmsg" style="padding-left:35px;">
                                            <p>1、充值费用与金币比例为1:<?php echo $mymps_global['cfg_coin_fee']; ?>，即充值1<?php echo $moneytype; ?>可购买<?php echo $mymps_global['cfg_coin_fee']; ?>个金币</p>
											<p>2、若出现已成功充值的提示，但金额未到帐，可能是网络或系统繁忙导致，我们会在2个工作日内核对后为您充值。 </p>
                                            <p> 3、在充值时请仔细确认充值的金额和账户，以免为充值错误；</p>
                                            <p>4、在充值过程中如出现网页错误或打开缓慢时，请先查询银行或者相关支付方式的交易记录，检查扣款是否成功；然后查看帐户是否已成功充值。若没有确认，请不要反复刷新页面，以防止重复购买； </p>
                                            <p>5、如有任何疑问也可直接联系客服：<strong><?=$mymps_global['SiteTel']?></strong></p>
                                        </div>
										<?php }?>
                                    
                                    </div>
                                    <div class="pfoot"><p><b>-</b></p></div>
                                </div>
                                    
                            </div>
                        </div>
                    </div>
                </div>
                
            </div>
        </div>
        
    <?php include mayi_tpl('inc_foot');?>
    
</div>
<script type="text/javascript">
    function checkInput() {
        var messages = {
            //
            'Point1': ['一次最少需要充值0经验'],
            //
            'Point2': ['一次最少需要充值0魅力'],
            //
            'Point4': ['一次最少需要充值0金币'],
            //
            'Point8': ['一次最少需要充值<?=$mymps_global['cfg_pay_min']?>金币'],
            //
            '-1': ['', '']
        };
        var pointType = $obj('currentPointType').value;
        var pavValue = $obj('payvalue').value;
        if (pavValue == '' || minvalues['Point8'] > pavValue) {
            $obj('error').style.display = '';
            $obj('error').innerHTML = messages[pointType][0];
            return false;
            //location.href = '#error';
            //setButtonDisable('confirmResult', false);
        }
        else {
            $obj('error').style.display = 'none';
            return true;
        }
    }

    var moneys = {};
    var points = {};
    var minvalues = {};
    //
    moneys['Point8'] = 1;
    points['Point8'] = 10;
    minvalues['Point8'] = <?php echo $mymps_global['cfg_pay_min'] ? $mymps_global['cfg_pay_min'] : 1 ;?>;
    //
    //
    function setMustPay() {
        var type = $obj('currentPointType').value;
        var payvalue = $obj('payvalue').value;
        $obj('minvalue').innerHTML = minvalues[type];
        if (payvalue == '') {
            $obj('mustpay').value = '0';
            return;
        }
        var pay = moneys[type] * payvalue;
        var payStr = pay + '';
        var dotIndex = payStr.indexOf('.');
        if (dotIndex > 0) {
            var temp = payStr.substring(dotIndex + 1);
            if (temp.length > 2) {
                var t = parseInt(temp.substring(0, 2)) + 1;
                pay = parseInt(payStr.substring(0, dotIndex)) + t / 100;
            }
        }
        $obj('mustpay').innerHTML = Math.ceil(pay/<?php echo $mymps_global["cfg_coin_fee"];?>);
    }
    setMustPay();
    //
</script>
</body>
</html>