<%

sub shop_list()
  dim price,price_now,discount,name,li
  response.write vbcrlf&shop_bar_top(n_name,1,1) & _
		 vbcrlf&"<table border=0 width='100%'>"
  li=0
  sql="select top 6 id,name,smallimg,brand,price,discount,is_emoney,emoney from shop_product where hidden=1"&sql_var&" order by id desc"
  set rs=joekoe_cms.exec(sql,1)
  do while not rs.eof
    if (li mod 2)=0 then response.write vbcrlf&"<tr valign=top>"
    name=joekoe_cms.code_html(rs("name"),1,0)
    price=fm_price(rs("price"),0)
    discount=rs("discount")
    price_now=fm_price(price*(discount/100),0)
    discount=fm_discount(discount)
    response.write vbcrlf&shop_list_type(rs("id"),name,rs("smallimg"),rs("brand"),price,price_now,discount,rs("is_emoney"),rs("emoney"))
    if (li mod 2)>0 then response.write vbcrlf&"</tr>"
    rs.movenext
    li=li+1
  loop
  rs.close
  response.write vbcrlf&"<tr><td colspan=2 bgcolor=999999 height=1></td></tr><tr><td colspan=2 align=right><a href='?action=more&c_id="&cid&"&s_id="&sid&"&taxis='><b>浏览更多产品...</b></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></tr><tr><td colspan=2 bgcolor=999999 height=1></td></tr>" & _
		 vbcrlf&"</table>" & _
		 vbcrlf&shop_bar_end("",0)
end sub

function shop_list_taxis_sql(n_taxis)
  dim temp1
  select case n_taxis
  case "tim"
    temp1="tim desc,id desc"
  case "buy"
    temp1="buy_counter desc,id desc"
  case "price_high"
    temp1="price desc,id desc"
  case "price_low"
    temp1="price,id desc"
  case "counter"
    temp1="counter desc,id desc"
  case else
    temp1="id desc"
  end select
  shop_list_taxis_sql=temp1
end function

sub shop_list_more()
  dim pageurl,sql_add,li,price,price_now,discount,name
  if taxis="good" then sql_var=sql_var&" and isgood=1 "
  if taxis="special" then sql_var=sql_var&" and discount<100 "
  if taxis="isemoney" then sql_var=sql_var&" and is_emoney=1 "
  response.write vbcrlf&shop_bar_top("产品列表"&n_name,1,1) & _
		 vbcrlf&"<table border=0 width='100%'>"
  li=0
  pageurl="?action="&action&"&c_id="&cid&"&s_id="&sid&"&"
  sql="select count(id) from shop_product where hidden=1"&sql_var
  set rs=joekoe_cms.exec(sql,1)
  rssum=rs(0)
  rs.close
  call format_pagecute()
  sql="select top "&nummer*viewpage&" id,name,smallimg,brand,price,discount,is_emoney,emoney from shop_product where hidden=1"&sql_var&" order by "&shop_list_taxis_sql(taxis)
  call joekoe_cms.exec("",-1)
  rs.open sql,conn,1,1
  if int(viewpage)>1 then
    rs.move (viewpage-1)*nummer
  end if
  if int(viewpage*nummer)>int(rssum) then nums=nummer-(viewpage*nummer-rssum)
  for i=1 to nums
    if (li mod 2)=0 then response.write vbcrlf&"<tr valign=top>"
    name=joekoe_cms.code_html(rs("name"),1,0)
    price=fm_price(rs("price"),0)
    discount=rs("discount")
    price_now=fm_price(price*(discount/100),0)
    discount=fm_discount(discount)
    response.write vbcrlf&shop_list_type(rs("id"),name,rs("smallimg"),rs("brand"),price,price_now,discount,rs("is_emoney"),rs("emoney"))
    if (li mod 2)>0 then response.write vbcrlf&"</tr>"
    rs.movenext
    li=li+1
  next
  rs.close
  if (li mod 2)>0 then
    response.write vbcrlf&"<td width='50%'></td></tr>"
  end if
  response.write vbcrlf&"</table>" & _
		 vbcrlf&shop_bar_end("",0)
  call shop_pagecute(rssum,viewpage,thepages,pageurl,taxis)
end sub

sub shop_pagecute(n_rssum,n_viewpage,n_thepages,n_pageurl,n_taxis)
  response.write vbcrlf&"<table border=0 cellspacing=0 cellpadding=2 width='98%'>" & _
		 vbcrlf&"<tr>" & _
		 vbcrlf&"<td>&nbsp;共有<font class=red>"&n_rssum&"</font>个产品，<font class=red>"&n_viewpage&"</font>/<font class=red>"&n_thepages&"</font>页&nbsp;分页："&jk_pagecute(nummer,n_thepages,n_viewpage,n_pageurl&"taxis="&n_taxis&"&",5,"#ff0000")&"</td>" & _
		 vbcrlf&"<td align=right><select name=taxis size=1 onchange=""javascript:shop_sel_taxis(this.options[this.selectedIndex].value);"">" & _
		 vbcrlf&"<option value=''>－请选择显示方式－</option>" & _
		 vbcrlf&"<option value='tim'>按上架时间排序</option>" & _
		 vbcrlf&"<option value='buy'>按订购次数排序</option>" & _
		 vbcrlf&"<option value='price_high'>按价格由高到低排序</option>" & _
		 vbcrlf&"<option value='price_low'>按价格由低到高排序</option>" & _
		 vbcrlf&"<option value='counter'>按点击次数排序</option>" & _
		 vbcrlf&"</select>&nbsp;</td>" & _
		 vbcrlf&"</tr>" & _
		 vbcrlf&"</table>"&ukong & _
		 vbcrlf&"<script language=javascript>" & _
		 vbcrlf&"function shop_sel_taxis(tvar)" & _
		 vbcrlf&"{" & _
		 vbcrlf&"  if (tvar=="""" || tvar==null) {return;}" & _
		 vbcrlf&"  location.href="""&n_pageurl&"taxis=""+tvar;" & _
		 vbcrlf&"}" & _
		 vbcrlf&"</script>"
end sub
%>