{extend name="default/users/base" /}
{block name="title"}购买咨询 - 用户中心 - {:WSTConf('CONF.shopName')}{__block__}{/block}
{block name="css"}
<style type="text/css">
.my_consult{padding: 4px;}
.gImg{width:100%;}
.wst-list tbody tr td{line-height: normal;}
.gc_replytit{text-align: center;}
</style>
{/block}
{block name="content"}
  <div class="wst-user-box"><div class="wst-user-info">
    <div class="wst-user-head">购买咨询</div>
    <div class='wst-user-content'>
    <table class='wst-list'>
       <thead>
	      <tr class='head'>
	         <th width="10%">咨询商品</th>
	         <th width="20%">商品名称</th>
           <th width="35%">我的咨询</th>
	         <th width="35%">咨询回复</th>
	      </tr>
	   </thead>
	   <tbody id='loadingBdy'>
	       <tr id='loading' class='empty-row' style='display:none'>
	            <td colspan='4'><img src="__STYLE__/img/loading.gif">正在加载数据...</td>
	       </tr>
       </tbody>
       <script id="tblist" type="text/html">
       {{# for(var i = 0; i < d.length; i++){ }}
       <tbody >
         <tr >
             <td width="10%" class="tc g_bd">
                 <a href="{{WST.U('home/goods/detail','goodsId='+d[i].goodsId)}}" target="_blank" class="gc_a">
                   <img class="gImg" src="__RESOURCE_PATH__/{{d[i].goodsImg}}" src="__RESOURCE_PATH__/{:WSTConf('CONF.goodsLogo')}" width="60" height="60">
                 </a>
             </td>
             <td width="20%" class="pd10 g_bd">
                <a href="{{WST.U('home/goods/detail','goodsId='+d[i].goodsId)}}" target="_blank" class="gc_a">{{d[i].goodsName}}</a>
             </td>
             <td class="pd10 g_bd" style="vertical-align:center;">
                <div class="my_consultbox">
                  <span>{{d[i].consultContent}}</span></br>
                  <span style="display:block;width:100%;text-align:right;">{{d[i].createTime}}</span>
                  <div class="wst-clear"></div>
                </div>
             </td>
             <td>
              {{# if(WST.blank(d[i].reply)!=''){  }}
                  <div>
                      {{d[i].reply}}
                  </div></br>
                  <div style="display:block;width:100%;text-align:right;">{{d[i].replyTime}}</div>
                {{# }else{  }}
                  <div class="gc_replytit">(暂无回复)</div>
                {{# }  }}
             </td>
          </tr>
       </tbody>
       {{# } }}
       </script>
       <tr class='empty-row'>
            <td colspan='4' id='pager' align="center" style='padding:5px 0px 5px 0px;border: none;'>&nbsp;</td>
       </tr>
    </table>
  </div>
  </div></div>
{/block}
{block name="js"}
<script>
$(function(){
  myConsultByPage();
  setTimeout(function(){
   var w = $('.gImg').width();
   $('.gImg').height(w);  
},150)
})
function gDetail(id){
  return WST.U('home/goods/detail',{goodsId:id});
}
function myConsultByPage(p){
  $('#loading').show();
  var params = {};
  params = WST.getParams('.s-query');
  params.key = $.trim($('#key').val());
  params.page = p;
  $.post(WST.U('home/goodsconsult/myConsultByPage'),params,function(data,textStatus){
    $('#loading').hide();
      var json = WST.toJson(data);
      $('.j-order-row').remove();
      if(json.status==1){
        json = json.data;
        if(params.page>json.TotalPage && json.TotalPage >0){
               myConsultByPage(json.TotalPage);
               return;
            }
          var gettpl = document.getElementById('tblist').innerHTML;
          laytpl(gettpl).render(json.Rows, function(html){
            $(html).insertAfter('#loadingBdy');
            $('.gImg').lazyload({ effect: "fadeIn",failurelimit : 10,skip_invisible : false,threshold: 200,placeholder:window.conf.RESOURCE_PATH+'/'+WST.conf.GOODS_LOGO});
          });
          laypage({
            cont: 'pager', 
            pages:json.TotalPage, 
            curr: json.CurrentPage,
            skin: '#e23e3d',
            groups: 3,
            jump: function(e, first){
              if(!first){
                myConsultByPage(e.curr);
              }
            } 
        });
        }  
  });
}
</script>
{/block}
