{load(fhead)}
<style type="text/css">
	.tableleft input{
	border: 1px solid #E1B48E;
	padding:2px;
	background-color: #FFFCF7;
	font-family: Arial, Helvetica, sans-serif;
	font-size: 18px;
	font-weight: bold;
	color: #DB0000;
	width:217px
	}
	.tableleft .checkbox{background:none;border:none;width:16px}
	#cztpl table{border-collapse: collapse;}
</style>
<!--$item = $vd['item'];-->
<body class="mainbg">
<div id="mainhearder"><span>您的位置：<a href="{$vd['root']}index.php?m=mod_b2b&a=Home">直销商管理系统</a> >> 积分管理 >> 积分兑换</span></div>
<div id="hearder"><span>购买订单</span></div>
  <form method="post" action="{$vd['root']}index.php?m=mod_b2b&c=Scored&a=pay" onsubmit="return checksubmit()">
  <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr>
	<td class="tableleft">
	  <table border="0" width="100%" style="border-collapse: collapse;" bordercolor="#CFDCF2">
    <tr>
      <td class="buylt">商品名称：</td>
      <td class="buyrt"><a href="javascript:toggle('0','0','cp');"><b>{$item['pname']}</b><img src="{$vd['content']}images/icon_pkf.gif" border=0></a></td>
    </tr>
    
    <tr>
      <td class="buylt">购买数量：</td>
      <td class="buyrt">
        <select name="ubzqty" id="ubzqty" onchange="ChangeNum()"><option value="1">1张</option><option value="2">2张</option><option value="3">3张</option></select>
        <div id="cp0" style="display:none;" class="cpxx">
        <div id="cpinfo"><div class="cp"><span><a href="javascript:toggle('0','0','cp');"><img src="{$vd['content']}images/destroy.gif" border="0" align="absmiddle"/></a></span><img src="{$vd['content']}images/icon_p.gif" align="absmiddle"> 商品信息</div>
        <p><b>简介：</b>{#ubbcode($item['pdesc'], $vd)}<br/>
        </div></div>
      </td>
    </tr>
    <tr>
      <td class="buylt">剩余数量：</td>
      <td class="buyrt">{$item['stocks']} {$item['unit']}</td>
    </tr>
    <!--if($item['method'] == 2){-->
    <tr>
      <td class="buylt">可兑余额：</td>
      <td class="buyrt"><input id="ubzcprice" name="oneprice" type="hidden" value="{$item['param']}" /><input type="text" readonly id="ubzdollars" name="ubzdollars" value="{$item['param']}" style="width:100px"/> {$vd['lang']['moneyunit']}</td>
    </tr>
    <!--}-->
    <!--if($item['method'] == 1){-->
    <tr>
    <td class="buylt">联系姓名：</td>
    <td class="buyrt">
      <input id="ubzdollars" name="ubzdollars" type="hidden" value="1" />
      <input id="ubzcprice" name="oneprice" type="hidden" value="1" />
      <input id="realname" name="realname" type="text" size="20"/> *
    </td>
    </tr>
    <tr>
    <td class="buylt">地址：</td>
    <td class="buyrt"><input id="addr" name="addr" type="text" size="20"/> *</td>
    </tr>
    <tr>
    <td class="buylt">联系电话：</td>
    <td class="buyrt"><input id="tel" name="tel" type="text" size="20"/> *</td>
    </tr>
    <tr>
    <td class="buylt">邮编：</td>
    <td class="buyrt"><input id="zip" name="zip" type="text" size="20"/> *</td>
    </tr>
    <!--}-->
    <tr id="tradepwdtr" style="display:none">
      <td class="buylt">交易密码：</td>
      <td class="buyrt"><input type="password" id="tradepwd" name="tradepwd" size="16"/></td>
    </tr>
    <tr style="display:none">
      <td class="buylt">所需积分：</td>
      <td class="buyrt"><input type="text" readonly id="priceforplayer" name="priceforplayer" value="{$item['scored']}" style="width:100px" onkeyup="ChangeNum()"/> 点</td>
    </tr>
    <tr>
      <td class="buylt">应扣积分：</td>
      <td class="buyrt"><input type="text" readonly id="dollarsforplayer"  name="dollarsforplayer" value="{$item['scored']}" style="width:100px"/> 点</td>
    </tr>
    <tr>
      <td class="buylt">用户当前积分：</td>
      <td class="buyrt"><b>{$vd['ainfo']['scored']}</b> 点</td>
    </tr>
  </table>
  </td>
  </tr>
  </table>
  <input id="myscored" name="myscored" type="hidden" value="{$vd['ainfo']['scored']}" />
  <input id="pid" name="pid" type="hidden" value="{$item['pid']}"/>
<br>
<input name="Submit" type="Submit" class="button" value="积分兑换" id="btnsubmit">　<input name="goback" type="button" class="button" value="兑换其他" onclick="javascript:self.close();">
<br><br>
</form>
<script type="text/javascript">
  function $(id){
    return document.getElementById(id);
  }
  function showcprice(flag){
    $("cprice").style.display = (flag == 1)? "" : "none";
  }
  
  firstclick = 0;
  
  function checksubmit()
  {
    
    if(parseInt($("myscored").value) < parseInt($("dollarsforplayer").value))
    {
      alert("积分点不足");
      return false;
    }
    
    if(firstclick > 0)
    {
      $("btnsubmit").disabled = true;
      alert("为了避免重复扣点，请到兑换记录中查看是否已经扣点\n\n如果已经扣点，您可以联系管理员退点后重新下单");
      return false;
    }
    
    qty = $("ubzqty").options[$("ubzqty").selectedIndex].value;
    if (qty>0)
    {
      var str = "确认兑换 {$item["pname"]} "+ qty +" 个吗？并请注意以下购买注意事项：\n\n\n1、本商品一经兑换无法退换货，请注意不要选择错误；";
      $("btnsubmit").disabled = true;
      if(confirm(str))
      {
        firstclick = firstclick + 1;
        return true;
      }
      else
      {
        $("btnsubmit").disabled = false;
        return false;
      }
    }
    else
    {
      alert("请先选择数量！");
    }
  }
  
  function getCookie(c_name)
  {
    if (document.cookie.length>0)
    {
      c_start=document.cookie.indexOf(c_name + "=");
      if (c_start!=-1)
      {
        c_start=c_start + c_name.length+1;
        c_end=document.cookie.indexOf(";",c_start);
        if (c_end==-1) c_end=document.cookie.length;
        return unescape(document.cookie.substring(c_start,c_end));
      }
    }
    return "";
  }

  if(getCookie('umebiz_com_8') == "1")
  {
    obj = $("tradepwdtr");
    obj.style.display = "";
  }

  function toggle(id,allid,name)
  {
    if (document.getElementById)
    {
      target=document.getElementById(name + id);
      if (target.style.display=="block")
      {
        target.style.display="none";
      }
      else
      {
        target.style.display="block";
        for(var i = 1;i<=allid;i++)
        {
          if (id!=i)
          {
            target=document.getElementById(name + i);
            if (target.style.display=="block")
            {
              target.style.display="none";
            }
          }
        }
      }
    }
  }
</script>
<input type="hidden" id="webdir" name="webdir" value="{$vd['root']}"/>
<script src="{$vd['content']}js/buyscored.js"></script>
</body>
</html>

