<%@page contentType="text/html;charset=GBK" %>
<html:form  method="post" action="/fg/product/fgproductSearch">
<jsp:useBean id="pager" class="com.keyshop.pub.util.Pager" scope="request"/>
<input type="hidden" name="maxRecNoPerPage" value="<%=pager.getRowsPerPage()%>"/>
<input type="hidden" name="recordNumber" value="<%=pager.getTotalRow()%>"/>
<%
parentCategoryList = (List)request.getAttribute("categoryList");
if(parentCategoryList != null && parentCategoryList.size()  >0 ) {
%>
<table width="640" border="0" cellpadding="0" cellspacing="0">
  <tr> 
    <td height="25" colspan="2">
			<table width="95%" height="25" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td align="left">
					<!--商品类型导航开始-->
          <%
					for(int i=parentCategoryList.size()-1; i>=0; i--) {
					  String[] cs = (String[])parentCategoryList.get(i);
					if(i != parentCategoryList.size()-1) {
					  %>
						&gt;
						<%
						}		
						if(i == 0 && !StringUtil.isEmpty(cs[1]) && !StringUtil.isEmpty(cs[0])) {		
						%>
						<a  class="leftIndex_txt01" href="<%=PRODUCTLIST%>&categoryId=<%=cs[0]%>"> <%=cs[1]%> </a>
						<%
						} else if(!StringUtil.isEmpty(cs[1]) && !StringUtil.isEmpty(cs[0])){
							String url = PRODUCTLIST + "&categoryId=" + cs[0];
							
							if (!StringUtil.isEmpty(cs[2])) {
								url = CONTEXT + "/" + cs[2];
							}
						%>
						<a class="leftIndex_txt01" href="<%=url%>"> <%=cs[1]%> </a>
						<%
							    }
								}
						%>
					<!--商品类型导航结束-->
          </td>
        </tr>
      </table>
<!--子分类列表开始-->
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
			  <tr>
			    <td align="center" >
				  <table width="100%" align="center" border="0" cellspacing="0" cellpadding="0">
			    <%
			    //显示子分类
			    int cols=7;
			    int widthnumber=1/cols*100;
			    String subcategoryId = request.getParameter("categoryId");
					String parentCategoryId = request.getParameter("parentCategoryId");
					if(StringUtil.isEmpty(parentCategoryId)) {
						parentCategoryId = subcategoryId;
					}
					List subCategorys = ProductHelper.getSubProductCategorys(parentCategoryId);
					if(subCategorys != null && subCategorys.size() > 0 ) {
					double treeRows = subCategorys.size() /7.0;
					for(int i=0; i<Math.ceil(subCategorys.size()/7.0); i++) {				
						%>
					<tr align="center">
					<%
						for(int j=0; j< cols && (i * cols + j) < subCategorys.size();j++){
							ProductCategory subCategory =  (ProductCategory)subCategorys.get(i * cols + j);
			        String url = PRODUCTLIST + "&categoryId=" + subCategory.getId();
							url = url + "&init=true";
							Channel subChannel = subCategory.getChannel();
						    if(subChannel != null) {
							    if(ChannelConst.CHANNEL_HTML_PAGE.equals(subChannel.getPageType()) && subChannel.isStatus()) {
										url = CONTEXT + "/" + subChannel.getPageName()  + "?channelId=" + subChannel.getId();
									}else if(ChannelConst.CHANNEL_LINK_PAGE.equals(subChannel.getPageType())){
									  url = subChannel.getLinkUrl();
									} else {
										url = CONTEXT + "/" + subChannel.getJspModel().getFileName() + "?channelId=" + subChannel.getId();
									}
								}
								if(subCategory.getChannel() != null) {
									  url = url + "&channelId=" + subCategory.getChannel().getId();
									 }
								url = url + "&parentCategoryId=" + parentCategoryId;
			    %>
			     	<td width="<%=widthnumber%>%" height="30" align="center" >
							<TABLE  BORDER=0 CELLPADDING=0 CELLSPACING=0>
								<TR>
									<TD>
										<IMG SRC="<%=CONTEXT%>/img/taobao_1.gif" WIDTH=3 HEIGHT=3 ALT=""></TD>
									<TD background="<%=CONTEXT%>/img/taobao_2.gif"></TD>
									<TD >
										<IMG SRC="<%=CONTEXT%>/img/taobao_3.gif" WIDTH=3 HEIGHT=3 ALT=""></TD>
								</TR>
								<TR>
									<TD  WIDTH=3 background="<%=CONTEXT%>/img/taobao_4.gif">
										<IMG SRC="<%=CONTEXT%>/img/taobao_4.gif" WIDTH=3 HEIGHT=15 ALT=""></TD>
									<TD algin=center >
											  <a href="<%=url%>" class=Category_sub_css>
											  	<%=subCategory.getCategoryName()%>
											  </a>
									</TD>
									<TD  WIDTH=3  background="<%=CONTEXT%>/img/taobao_6.gif">
									</TD>
								</TR>
								<TR>
									<TD>
										<IMG SRC="<%=CONTEXT%>/img/taobao_7.gif" WIDTH=3 HEIGHT=3 ALT=""></TD>
									<TD  HEIGHT=3 background="<%=CONTEXT%>/img/taobao_8.gif">
										</TD>
									<TD>
										<IMG SRC="<%=CONTEXT%>/img/taobao_9.gif" WIDTH=3 HEIGHT=3 ALT=""></TD>
								</TR>
							</TABLE> 
			  	 	</td>
				  <%
					  }
				  %>
			    </tr>
			    <tr>
			  <%if(i<treeRows){
				  for(int j=0; j<cols;j++){
				%>
				  <td class=Catalogue_product01_line></td>
			  <%
						}		
					}
				%>
			    </tr>
						<%
							}
						 }
						%>
				   </table>
				 </td>
				</tr>
			</table> 
			 	
    </td>
  </tr>
</table>
<%
}
%>
<table border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="10" height="10"><img src="<%=CONTEXT%>/img/QQ/i01.gif" width="10" height="10"></td>
    <td  background="<%=CONTEXT%>/img/QQ/i03.gif"></td>
    <td width="10" height="10"><img src="<%=CONTEXT%>/img/QQ/i02.gif" width="10" height="10"></td>
  </tr>
  <tr>
    <td  background="<%=CONTEXT%>/img/QQ/i04.gif">&nbsp;</td>
    <td>
			<table width="620" border="0" cellpadding="0" cellspacing="0">
			  <tr > 
			    <td height="25" colspan="2">
						<table width="100%" height="41" border="0" cellpadding="0" cellspacing="0" >
			        <tr>
			          <td align="right">
			          	<table width="95%" border="0" cellspacing="0" cellpadding="0">
			              <tr> 
			                <td>共<%=pager.getTotalPage()%>页 当前位于第 <%=fgProductSearchForm.getCurrentPageNo()%> 页
										<a  class="Category_sub_css" href="javascript:jump('1')">首页</a>&nbsp;
										<% if(pager.getCurrentPage()>1){%>
										<a  class="Category_sub_css" href="javascript:select('prev')">上 一 页</a>
										<%
										} else {
										%>上一页
										<%
										} 
										%>&nbsp;
										<% if(pager.getTotalPage()>pager.getCurrentPage()){
										%>
										<a  class="Category_sub_css" href="javascript:select('next')">下 一 页</a>
										<%
										} else {
										%> 下一 页
										<%
										} 
										%> &nbsp;
										<a  class="Category_sub_css" href="javascript:jump('<%=pager.getTotalPage()%>')">末页</a>&nbsp;&nbsp;
			              第<input name="toPage" type="text" size="2" value="<%=fgProductSearchForm.getCurrentPageNo()%>" maxlength="5"/> 页
										<input type="button" onclick="javascript:jump(document.all['toPage'].value)"  value="GO">
			               </td>
										 <td  align="right"> 
					  <select name="orderby1" onChange='javascript:orderby(this.value)'>
						  <option value='1' <%="1".equals(fgProductSearchForm.getOrderbyType()) ? "selected":""%>>按价格由低至高</option>
						  <option value='2' <%="2".equals(fgProductSearchForm.getOrderbyType()) ? "selected":""%>>按价格由高至低</option>
						  <option value='3' <%="3".equals(fgProductSearchForm.getOrderbyType()) ? "selected":""%>>按名称正向</option>
						  <option value='4' <%="4".equals(fgProductSearchForm.getOrderbyType()) ? "selected":""%>>按名称逆向</option>
					  </select>
					            </td>
			              </tr>
			            </table>
			          </td>
			        </tr>
			      </table>
			    </td>
			  </tr>
			</table>
			
			<table width="100%"  border="0" cellspacing="0" cellpadding="0">
			<input type="hidden" name="recordNumber" value="<%=pager.getTotalRow()%>"/>
			<%
				 categoryId = request.getParameter("categoryId");
				if(categoryId == null) {
					categoryId = "";
				}
			%>
			<input type="hidden" name="actionType" value="qiantailist"/>
			<html:hidden property="categoryId" value="<%=categoryId%>"/>
			<html:hidden property="orderbyType"/>	
			<html:hidden property="channelId" value="<%=currentChannel.getId()%>"/>
			<html:hidden property="key"/>
			<html:hidden property="currentPageNo"/>				
			<%
				String startUnitPrice = request.getParameter("startUnitPrice");
				String endUnitPrice = request.getParameter("endUnitPrice");
				if(endUnitPrice == null) {
					endUnitPrice = "";
				}%>
				<html:hidden property="startUnitPrice" value="<%=startUnitPrice%>"/>
				<html:hidden property="endUnitPrice" value="<%=endUnitPrice%>"/>
			<%
			List searchResult = (List)request.getAttribute("searchresult");
			if(searchResult != null && searchResult.size() > 0 ) {
			%>
<!--商品列表开始-->
			<table width="640"  border="0" cellpadding="0" cellspacing="0">
			 <%
				java.text.DecimalFormat formatter = new java.text.DecimalFormat("0.00");
			      double maxRow = Math.ceil((double)searchResult.size() / 4.0);
			  %>
			  <%
			    for(int i=0; i<maxRow; i++) {
			  %>
			  <tr> 
					<%
			  		for(int j=0; j<4 ; j++) {
							Product p = null;
							if(i * 4 + j < searchResult.size()) {
			      		p = (Product)searchResult.get(i * 4 + j);
			  	%>	
			    <td width="180" height="138" valign="top">
			    	<table width="100%" border="0" cellspacing="0" cellpadding="0">
			        <tr>
			          <td width="100%">
			          	<table width="100%" border="0" cellspacing="0" cellpadding="0">
			              <tr>
			                <td height=8></td>
			              </tr>
			              <tr>
			                <td align="center">
			                	<a href="<%=PRODUCTVIEW%>&bean.id=<%=p.getId()%>"
			                		 class=" ">
			                  <%
				            			String pic = p.getSmallPicture();
				            			if(StringUtil.isEmpty(pic)) {
				            				pic = p.getPopPicture();
				            			}
				              		if(!StringUtil.isEmpty(pic)) {
				              	%>
				                <img src="<%=CONTEXT%>/<%=pic%>" border="0" width="100" hight="100" />
				                <%
				              		} else {
				              	%>
				                <img src="<%=CONTEXT%>/img/emptyls.gif" border="0" width="100" hight="100"/>
				                <%
				              		}
				              	%>
				                </a> 
						          </td>
						        </tr>
				    		  </table>
				        </td>
						  </tr>
						  <tr>
						    <td valign="top">
						    	<table width="100%" border="0" cellpadding="0" cellspacing="0">
						        <tr>
					            <td width="14%">&nbsp;</td>
					            <td width="86%" valign="top" align="center"><font color="#000CBB">
					            <a href="<%=PRODUCTVIEW%>&bean.id=<%=p.getId()%>" class="leftIndex_txt00001">
					            <%=p.getName()%></a><br></font><span class=" ">
					              市场价￥：
					              <%=formatter.format(p.getListPrice())%>元</span><font color="#000CBB">&nbsp; </font><br>
					              <font color="#000CBB">
					              现　价</font>
					              <font color="#F14A00">￥：
					              <%=formatter.format(p.getUnitPrice())%>元
					              </font>
					            </td>
					          </tr>
					        </table>
					      </td>
					    </tr>
					    <tr>
					      <td>
					        <table width="100%" border="0" cellspacing="0" cellpadding="0">
					          <tr>
					            <td width="16%">&nbsp;</td>
					            <td width="84%" valign="top"><a href="<%=CART%>&actionType=addproduct&productId=<%=p.getId()%>"><img src="<%=CONTEXT%>/img/gm.gif"  width="53" height="22"border="0"/></a>
											<jsp:useBean id="myAlipayObj" scope="page" class="com.keyshop.pub.util.alipay.myAlipay"/>
											<%
												String goodsBid,sellerEmail,goodsTitle,securityCode,Cmd,Subject,Body,sDate;
												String ResponseTxt;
												Cmd	= "0001";//命令编号
												Subject	= p.getName();//商品名称
												Body =p.getName();//商品描述
												goodsTitle= DateUtil.getSysDateTimestamp().toString();//订单编号
												goodsBid = String.valueOf(p.getUnitPrice());//商品价格
												
												PayConfig alipayInfoConfig = (PayConfig)SystemManager.getAlipayInfoConfig(request);//系统中的支付宝机制，参考自OrderAction.java
										 		String alipaySellerEmail=alipayInfoConfig.getSellerEmail();
											  String alipaySecurityCode=alipayInfoConfig.getSecurityCode();
											  
												sellerEmail	=alipaySellerEmail;//merchanttool@alipay.com 您的支付宝认证Email,必须通过支付宝认证才可以
												securityCode =alipaySecurityCode;//wnqrsxq4n91x7ny637vdgtuutkt5n65h安全校验码,在支付宝网站“商家工具”那里可以获得
												
												ResponseTxt= myAlipayObj.generatePaytoURL(Cmd,Subject,Body,goodsTitle,goodsBid,sellerEmail,securityCode);
												%>
												<a href="<%=ResponseTxt%>"><img src="<%=CONTEXT%>/img/zhifu.gif"  width="53" height="22"border="0"/>
					            </td>
					          </tr>
					          <tr>
					            <td height=5></td>
					            <td valign="top" height=5></td>
					          </tr>
					        </table>
					      </td>
					    </tr>
					  </table>
					</td>
				<%
					}
				}
			  %>
			  </tr>
				<%
				if(i < maxRow-1) {
				%>
				<tr> 
				 <td colspan="4" valign="top" bgcolor="#CCCCCC"　height=1  ></td>
				</tr>
				<%
					}
				}
				%>
			</table>
<!--商品列表结束-->
			<%
			}
			%>
<!--底部页面导航--><br>
			<table width="620" border="0" cellpadding="0" cellspacing="0">
			  <tr > 
			    <td height="25" colspan="2">
						<table width="100%" height="25" border="0" cellpadding="0" cellspacing="0" >
			        <tr>
			          <td align="right">
			          	<table width="95%" border="0" cellspacing="0" cellpadding="0">
			              <tr> 
			                <td>共<%=pager.getTotalPage()%>页:
										<a  class="Category_sub_css" href="javascript:jump('1')">首页</a>&nbsp;
										<% if(pager.getCurrentPage()>1){%>
										<a  class="Category_sub_css" href="javascript:select('prev')">上 一 页</a>
										<%
										} else {
										%>上一页
										<%
										} 
										%>&nbsp;
										<% if(pager.getTotalPage()>pager.getCurrentPage()){
										%>
										<a  class="Category_sub_css" href="javascript:select('next')">下 一 页</a>
										<%
										} else {
										%> 下一 页
										<%
										} 
										%> &nbsp;
										<a  class="Category_sub_css" href="javascript:jump('<%=pager.getTotalPage()%>')">末页</a>&nbsp;&nbsp;
			              第<input name="toPage" type="text" size="2" value="<%=fgProductSearchForm.getCurrentPageNo()%>" maxlength="5"/> 页
										<input type="button" onclick="javascript:jump(document.all['toPage'].value)"  value="GO">
			               </td>
										 <td  align="right"> 
										  <select name="orderby1" onChange='javascript:orderby(this.value)'>
											  <option value='1' <%="1".equals(fgProductSearchForm.getOrderbyType()) ? "selected":""%>>按价格由低至高
											  	</option>
											  <option value='2' <%="2".equals(fgProductSearchForm.getOrderbyType()) ? "selected":""%>>按价格由高至低
											  	</option>
											  <option value='3' <%="3".equals(fgProductSearchForm.getOrderbyType()) ? "selected":""%>>按名称正向
											  	</option>
											  <option value='4' <%="4".equals(fgProductSearchForm.getOrderbyType()) ? "selected":""%>>按名称逆向
											  	</option>
										  </select>
					            </td>
			              </tr>
			            </table>
			          </td>
			        </tr>
			      </table>
			    </td>
			  </tr>
			</table>
			</html:form>      
			</td>
    <td background="<%=CONTEXT%>/img/QQ/i05.gif"></td>
  </tr>
  <tr>
    <td width="10" height="10"><img src="<%=CONTEXT%>/img/QQ/i06.gif" width="10" height="10"></td>
    <td background="<%=CONTEXT%>/img/QQ/i08.gif"></td>
    <td width="10" height="10"><img src="<%=CONTEXT%>/img/QQ/i07.gif" width="10" height="10"></td>
  </tr>
</table>