<!--{include file="<!--{$oetplpath}-->widget_header.tpl"}-->
<div class="oemarry_main">
  <!--{include file="<!--{$oetplpath}-->widget_menu.tpl"}-->
  <div class="oem_uright">
	
	<div class="oe_balance">
	  帐户余额：<strong>¥<!--{doubleval($login.user.money)}--></strong>&nbsp;&nbsp;&nbsp;
 	  <font style="display:none;">冻结资金：<strong>¥<!--{doubleval($login.user.freeze)}--></strong>&nbsp;&nbsp;&nbsp;</font>
	  <a href="<!--{$oefile}-->&c=recharge">充值</a>
	  <a href="<!--{$oefile}-->&c=withdraw">提现</a>
	</div>

	<div class="oe_mine_box">
	  <ul>
	    <li><a href="<!--{$oefile}-->&c=withdraw"<!--{if $a == "run"}--> class="_current"<!--{/if}-->>申请提现</a></li>
		<li><a href="<!--{$oefile}-->&c=withdraw&a=log"<!--{if $a == "log"}--> class="_current"<!--{/if}-->>提现记录</a></li>
	  </ul>
	  <div class="clear"></div>
	</div>

	<div class="oe_widget_center">
	  

	  <!--{if $a == "run"}-->
	  <h3 class="oe_f_title _bottom_border _margin_bottom">
	    申请提现<span>（填写最小提现金额，点击“提交申请”等待网站打款）</span>
	  </h3>

	  <table class="oe_table_info">
	   <tr>
		  <th width="15%" align="left">提现金额：</th>
		  <td width="85%">
		   <input type="text" name="money" id="money" class="input-80" onkeyup="clearNoNum(this);" /> 元
			&nbsp;&nbsp;
			手续费：¥ <span id="tips_fee"></span>&nbsp;&nbsp;实际到账：¥ <span id="tips_total"></span>
		  </td>
		</tr>
		<tr>
		  <th align="left"><font class="f_red"></font> 收款银行：</th>
		  <td><input type="text" name="bankname" id="bankname" class="input-200" value="<!--{$login.shop.bankname}-->" /></td>
		</tr>
		<tr>
		  <th align="left"><font class="f_red"></font> 收款帐号：</th>
		  <td><input type="text" name="bankaccount" id="bankaccount" class="input-200" value="<!--{$login.shop.bankaccount}-->" /></td>
		</tr>
		<tr>
		  <th align="left"><font class="f_red"></font> 	收款人姓名：</th>
		  <td><input type="text" name="bankcontact" id="bankcontact" class="input-200" value="<!--{$login.shop.bankcontact}-->" /></td>
		</tr>
		<tr>
		  <th></th>
		  <td>
			<input type="button" id="btn_post" class="submit_btn1" value="提交申请" /> 
		  </td>
		</tr>
	  </table>
	  
	  <script type="text/javascript">
	  $(function(){
		
		$("#money").bind("blur", function(){ //资金变化
			$money = $("#money").val();
			if ($money.length > 0) {
				$money = parseFloat($money);//
				//$fee = <!--{floatval($config['withdrawpercent'])/100}-->*$money;

				$fee = parseFloat(<!--{floatval($config.withdrawpercent)/100}-->*$money);
				$fee = parseFloat($fee.toFixed(2));

                $minfee = <!--{floatval($config['withdraw_minfee'])}-->;
                $maxfee = <!--{floatval($config['withdraw_maxfee'])}-->;

                if($minfee>0 && $fee<$minfee){
                    $fee =$minfee;
                }else{
                    if($maxfee>0 && $fee>$maxfee){
                        $fee =$maxfee;
                    }
                }
                $("#tips_fee").html($fee);
				$("#tips_total").html(parseFloat($money-$fee))
			}

		});

		$("#btn_post").bind("click", function(){ //提现
			$money = $("#money").val();
			$money = parseFloat($money);
			if (isNaN($money) || $money<=0) {
				ToastShow("请填写提现金额", "money");
				return false;
			}
			
			$_bankname = $("#bankname").val();
			$_bankaccount = $("#bankaccount").val();
			$_bankcontact = $("#bankcontact").val();

			if ($_bankname.length == 0) {
				ToastShow("请填写收款银行", "bankname");
				return false;
			}
			if ($_bankaccount.length == 0) {
				ToastShow("请填写收款帐号", "bankaccount");
				return false;
			}
			if ($_bankcontact.length == 0) {
				ToastShow("请填写收款人姓名", "bankcontact");
				return false;
			}

			$.ajax({
				type: "POST",
				url: "<!--{$oefile}-->",
				cache: false,
				data: {c:"withdraw", a:"savewith", money:$money, bankname:$_bankname, bankaccount:$_bankaccount, bankcontact:$_bankcontact, r:get_rndnum(8)},
				dataType: "json",
				success: function($data) {
					$json = eval($data);
					$response = $json.response;
					$result = $json.result;
					if ($response == "1") {//申请成功
						ToastShow("提现申请成功");
						setTimeout(function(){
							window.location.href="<!--{$oefile}-->&c=withdraw&a=log";
						}, 600);
					}
					else {
						if ($result.length > 0) {
							ToastShow($result);
						}
						else {
							ToastShow("提现失败");
						}
					}
				},
				error: function() {
					ToastShow("提现失败，请检查网络！");
				}
			});

		});
	  });
	  function clearNoNum(obj) {
		obj.value = obj.value.replace(/[^\d]/g,"");
		obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
	  }

	  </script>
	  <!--{/if}-->


	  <!--{if $a == "log"}-->
	  <h3 class="oe_f_title">提现记录<span><i>|</i>记录您帐户提现的情况，提现还没完成之前提现资金将处于冻结状态</span></h3>
	  <table class="oe_table_list_2 table_cs">
		<tr>
	      <th>提现单</th>
		  <th width="18%">提现时间</th>
		  <th width="13%">提现金额(元)</th>
		  <th width="13%">手续费(元)</th>
		  <th width="13%">实际到账(元)</th>
		  <th width="13%">状态</th>
	    </tr>
		<!--{if empty($withdraw)}-->
		<tr>
		  <td class="text_center" colspan="6">没有找到符合条件的信息</td>
		</tr>
		<!--{else}-->
		<!--{foreach $withdraw as $volist}-->
		<tr>
		  <td><!--{$volist.withno}--></td>
		  <td><!--{$volist.addtime|date_format:"%Y-%m-%d %H:%M:%S"}--></td>
		  <td  class="text_center"><font color="red">¥ <!--{doubleval($volist.amount)}--></font></td>
		  <td  class="text_center"><font color="green">¥ <!--{doubleval($volist.poundage)}--></font></td>
		  <td  class="text_center"><font color="blue">¥ <!--{doubleval($volist.amount-$volist.poundage)}--></font></td>
		  <td class="text_center">
			<!--{if $volist.flag == '1'}-->
			<font color="green">成功</font>
			<!--{elseif $volist.flag == '2'}-->
			<font color="red">失败</font>
			<!--{else}-->
			<font color="gray">待处理</font>
			<!--{/if}-->	  
		  </td>
		  
		</tr>
		<!--{/foreach}-->
		<!--{/if}-->
	  </table>
	  <div class="oe_page_layout">
	  <!--{$showpage}-->
	  </div>
	  <!--{/if}-->

	</div>
	<!--//oe_widget_center End-->

  </div>
  <!--//oem_uright End-->
  <div class="clear"></div>

</div>
<!--{include file="<!--{$oetplpath}-->widget_footer.tpl"}-->
</body>
</html>