<%
'**************************************
'* 最后更新 2013-05-04 by 56770.kingdge
'* Copyright www.56770.com
'**************************************
'..................................
'读取品牌目录页品牌列表
'..................................
Public Function Brandlist()
		Dim strFile,strLoad,loadstr(4),Brandlist_name_pic,rs,Charstr,A_Charstr,A_Charstr_i,Brandlist_num,tstr
		strFile = Eshop_url& Style_Folder &"Lebi.Brandlist."
		Brandlist  = LoadStyle(strFile&"0.style")
		ReplaceStyle "linenum",linenum,Brandlist
		loadstr(0) = LoadStyle(strFile&"1.style")
		loadstr(1) = LoadStyle(strFile&"2.style")
		loadstr(2) = LoadStyle(strFile&"3.style")
		loadstr(3) = LoadStyle(strFile&"4.style")
		loadstr(4) = LoadStyle(strFile&"5.style")
		b_width = checknum(b_width,80) : b_height = checknum(b_height,30) : linenum = checknum(linenum,1)
		Charstr = "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z"
		A_Charstr = split(Charstr,",")
		for A_Charstr_i = 0 to ubound(A_Charstr)
                set rs = conn.execute("select brand_pic,brand"& LangTxt &",b_pronum from [Lebi_brand] where brand_w='"&A_Charstr(A_Charstr_i)&"' order by paixu desc")
				tstr = ""
		        If not (rs.eof And rs.bof) Then
						tstr = loadstr(0)
		                Brandlist_num=1
						ReplaceStyle "bookmark",A_Charstr(A_Charstr_i),tstr
						Brandlist = Brandlist & tstr
                        do while not rs.EOF
						If Not IsNull(Trim(rs(1))) And Trim(rs(1)) <> "" Then 
							tstr = loadstr(1)
							Brandlist_name_pic = ""
							If trim(rs("brand_pic"))<>"" Then
									Brandlist_name_pic = loadstr(2)
									ReplaceStyle "pic_src",Eshop_url&rs(0),Brandlist_name_pic
									ReplaceStyle "alt",rs(1),Brandlist_name_pic
							Else
									Brandlist_name_pic = rs(1)
							End If
							ReplaceStyle "pic",Brandlist_name_pic,tstr
							ReplaceStyle "name",rs(1),tstr
							Select Case ISAPI_Rewrite
								   Case "0" ReplaceStyle "url",Eshop_url & PagePath(4) &"?brand="&Urlencode(rs(1)),tstr
								   Case "1" ReplaceStyle "url",Eshop_url & LangPath &"brand-"&Urlencode(rs(1)) &".html",tstr
							End Select
							ReplaceStyle "num",rs(2),tstr
							ReplaceStyle "loop_num",A_Charstr_i + 1,tstr
							Brandlist = Brandlist & tstr
						End If 
						rs.MoveNext
						Brandlist_num=Brandlist_num+1
    		            Loop
						Brandlist=Brandlist & loadstr(3)
    		    End if
                rs.Close:Set rs=Nothing
		next
        Brandlist=Brandlist & loadstr(4)
End function

'..................................
'读取品牌分类 商品列表
'动态页调用模块
'..................................
Function BrandProductList(showheadpage,showfootpage)
        Dim showsort_price,sql_c,DataCount,DataList,List_num,Filename,i,showpic_width,showpic_height,pic_url, div_width,div_height,briefed,j,RLoadStyle(5),LoadListStr,strFile,skin_ys,tmpstr,loopstr,stock
        showheadpage = checknum(showheadpage,0) : showfootpage = checknum(showfootpage,0)
        skin_ys = top17
        If listtype="pic" Then skin_ys = 1
	    If listtype="word" Then skin_ys = 0
	    If listtype="listpic" Then skin_ys = 2
	    Dim ors
	    Set ors=new Cls_vbsPage
	    Set ors.Conn=conn
	    With ors
		    .PageSize=top15
		    .PageName="Page"
			If IsSqlDataBase = 0 Then
		            .DbType="AC"
			Else
			        .DbType="MSSQL"
			End If
		    .RecType=-1
		    .Pkey="p.id"
    	    .Field="p.id,p.product_name"& LangTxt &",p.pic,p.sprice,p.cprice,p.cx,p.stj,p.ytj,p.p_jifen,p.briefed"& LangTxt &",p.views,p.kucun,p.p_cx_sj,p.p_stj_sj,p.p_ytj_sj,p.sj,p.pic_size,p.cpic,g.price,p.IsNew,p.p_filename,bianhao"
		    .Table="[Lebi_product] as p,[Lebi_product_price] as g"
		    sql_c = "p.zhuangtai=1 and g.product_id=p.id and g.grade_id="&Lebi_UserGrade
            if sort_id<>0 And IsSqlDataBase ="1" then sql_c=sql_c+" and CharIndex(',"& sort_id &",',p.categoryid)>0"
	        if sort_id<>0 And IsSqlDataBase ="0" then sql_c=sql_c+" and instr(p.categoryid,',"& sort_id &",')>0"
            if brand<>"" And IsSqlDataBase ="1" then sql_c=sql_c+" and CharIndex('"&brand&"',brand"& LangTxt &")>0"
	        if brand<>"" And IsSqlDataBase ="0" then sql_c=sql_c+" and instr(brand"& LangTxt &",'"&brand&"')>0"
			rem	<-{  价格差联合搜索  2008-2-29 by 56770.WangLei
            if price1<>"" and price2<>"" Then
				sql_c=sql_c + " and g.price >"&price1&" and g.price <"&price2&" "
			End If
			rem	}->
	        rem 增加商品类型选择 2006-1-22 Lebi.kingdge
	        If sle_type="1" Then sql_c=sql_c+" And p.IsNew=1"
	        If sle_type="2" Then sql_c=sql_c+" And p.views>"&Config_Lebi_Eshop(6)&""
	        If sle_type="3" Then sql_c=sql_c+" And p.ytj=1"
	        If sle_type="4" Then sql_c=sql_c+" And p.cx=1"
	        rem 结束
	        If gongxiao<>"" And IsSqlDataBase =1 Then sql_c=sql_c+" and charindex(',"&gongxiao&",',p.p_gongxiao)>0"
	        If gongxiao<>"" And IsSqlDataBase =0 Then sql_c=sql_c+" and instr(p.p_gongxiao,',"&gongxiao&",')>0"
	        If person<>"" And IsSqlDataBase =1 Then sql_c=sql_c+" and charindex(',"&person&",',p.p_person)>0"
	        If person<>"" And IsSqlDataBase =0 Then sql_c=sql_c+" and instr(p.p_person,',"&person&",')>0"
	        .Condition=sql_c		'条件,不需要where
	        If listprice="up" Then .OrderBy="g.price DESC"
	        If listprice="down" Then .OrderBy="g.price ASC"
	        If listtime="up" Or (listprice="" And listtime="") Then .OrderBy="p.sj DESC"
	        If listtime="down" Then .OrderBy="p.sj ASC"
	        If listview="up" Then .OrderBy="p.views DESC"
	        If listview="down" Then .OrderBy="p.views ASC"
	        If listbuy="up" Then .OrderBy="p.buys DESC"
	        If listbuy="down" Then .OrderBy="p.buys ASC"
			If listprice="" And listtime="" And listview="" And listbuy="" Then .OrderBy="p.p_order desc,p.id desc"
	    End With
	    DataCount=ors.RecCount()
	    DataList=ors.ResultSet()
		List_num = 1
		strFile = Eshop_url& Style_Folder &"Lebi.BrandProductList."
		RLoadStyle(0) = splits(LoadStyle(strFile&"11.style"))	'购买按钮
		RLoadStyle(2) = splits(LoadStyle(strFile&"12.style"))	'预订按钮
		RLoadStyle(3) = splits(LoadStyle(strFile&"13.style"))	'零库存
		RLoadStyle(1) = splits(LoadStyle(strFile&"14.style"))	'收藏按钮
		LoadListStr = "<form action="""" method=""post"" name=""LEBI_FORMBUY_0001"" id=""LEBI_FORMBUY_0001"">"
		LoadListStr = LoadListStr & LoadStyle(strFile&"0.style")
		Select Case show_html
			   Case "0" : Filename = Eshop_url & PagePath(4)
			   Case "1"
						Select Case sle_type
							   Case "0" : Filename = Eshop_url & Folder(2) & sort_id
							   Case Else
									Filename = Eshop_url & Folder(2) & sort_id &"-"& sle_type
						End Select
		End Select
		If showheadpage = 1 Then
				tmpstr = LoadStyle(strFile&"1.style")
				ReplaceStyle "headpage",ors.ShowPageHead(Filename),tmpstr
				LoadListStr = LoadListStr & tmpstr
		End If
	    If DataCount > 0 Then
				If skin_ys <> 2 Then
						LoadListStr = LoadListStr & splits(LoadStyle(strFile&"3.style"))
				End If
				Select Case skin_ys
				       Case "0" : RLoadStyle(4) = splits(LoadStyle(strFile&"7.style")) '文字显示
				       Case "1" : RLoadStyle(4) = splits(LoadStyle(strFile&"5.style")) '图片显示
				       Case "2" : RLoadStyle(4) = splits(LoadStyle(strFile&"6.style")) '图片多列显示
				End Select
				LoadListStr = LoadListStr & LoadStyle(strFile&"4.style")
		        For i = 0 To Ubound(DataList,2)
						Dim PList_url,icostr
						loopstr = RLoadStyle(4)
						stock=DataList(11,i)
						tmpstr = "":icostr = ""
						briefed = DataList(9,i)
						Select Case show_html
                                Case "0"
									Select Case ISAPI_Rewrite
										   Case "0" PList_url=PagePath(10) &"?id="& DataList(0,i)
										   Case "1" PList_url=LangPath &"product-"& DataList(0,i) &".html"
									End Select
				                Case "1" : PList_url=LangPath & Folder(0) & DataList(20,i) &".1."& Sys_Ext
				        End Select
						icostr=""
						If Config_Lebi_Eshop(7)=1 And DataList(19,i)=1 Then
								icostr=icostr&" <img src='"& Eshop_url &"images/icons/pro_3.gif' align='absmiddle'> "
						End if
						If Config_Lebi_Eshop(5)=1 And Int(DataList(10,i))>Int(Config_Lebi_Eshop(6)) Then
								icostr=icostr&" <img src='"& Eshop_url &"images/icons/pro_2.gif' align='absmiddle'> "
						End if
						If Config_Lebi_Eshop(3)=1 And DataList(5,i)=1 Then
								icostr=icostr&" <img src='"& Eshop_url &"images/icons/pro_1.gif' align='absmiddle'> "
						End If
						If Config_Lebi_Eshop(4)=1 And (DataList(6,i)=1 Or DataList(7,i)=1) Then
								icostr=icostr&" <img src='"& Eshop_url &"images/icons/pro_4.gif' align='absmiddle'> "
						End If
						ReplaceStyle "ico",icostr,loopstr
						If Trim(DataList(2,i))<>"" Then
								tmpstr = ""
								ReplaceStyle "pic_url",PicturePath & DataList(2,i),loopstr
								ReplaceStyle "lazyload_pic_url",Eshop_url & PicturePath & DataList(2,i),loopstr
								If show_mouse = "0" Then
										If InStr(DataList(17,i),"@@") > 0 Then
												pic_url = Split(DataList(17,i),"@@")(0)
												If pic_url = "" Then pic_url = Split(DataList(17,i),"@@")(1)
										Else
												pic_url = DataList(17,i)
										End If
										tmpstr = " onMouseover=""javascript:ddrivetip('<img src="& Eshop_url & PicturePath & pic_url &" width="& pic_dw &">', '#ffffff', '"& pic_dw + 10 &"')"" onMouseout=""hideddrivetip()"""
								Else
										tmpstr = ""
								End If
								ReplaceStyle "onmouse",tmpstr,loopstr
						End If
						ReplaceStyle "url",PList_url,loopstr
						ReplaceStyle "target",Config_Lebi_Eshop(9),loopstr
						ReplaceStyle "id",DataList(0,i),loopstr
						ReplaceStyle "name",DataList(1,i),loopstr
						rem	  会员组价格显示 2008-2-28 by 56770.WangLei
						If checkPricePurview(Lebi_UserGrade) Then
								Select Case DataList(5,i)
									   Case "0" : ReplaceStyle "buy_price",Formatnumber2(DataList(18,i)/moneyhl),loopstr
									   Case "1" : ReplaceStyle "buy_price",Formatnumber2(DataList(4,i)/moneyhl),loopstr
								End Select
						Else
								ReplaceStyle "buy_price",Lebi_word(66),loopstr
						End If
						ReplaceStyle "market_price",Formatnumber2(DataList(3,i)/moneyhl),loopstr
						ReplaceStyle "sale_price",Formatnumber2(DataList(4,i)/moneyhl),loopstr
						ReplaceStyle "point",DataList(8,i),loopstr
						ReplaceStyle "content",cutchar(briefed,100),loopstr
						ReplaceStyle "stock",stock,loopstr
						ReplaceStyle "bianhao",DataList(21,i),loopstr
						rem	 购买、预订、零库存 样式 by 56770.WangLei
						If InStr(loopstr,"{@btn_buy}") > 0 Then
							tmpstr = ""
							if stock <= 0 then
								if CInt(getGradePurview(17)) = 1 Then
									tmpstr=tmpstr & RLoadStyle(2)	'预定
								else
									tmpstr=tmpstr & RLoadStyle(3)	'零库存
								end if
							else
								tmpstr=tmpstr & RLoadStyle(0)	'购买
							end If
							ReplaceStyle "listcode","0001",tmpstr
							ReplaceStyle "type","",tmpstr
							ReplaceStyle "isValid",getGradePurview(0),tmpstr
							ReplaceStyle "id",DataList(0,i),tmpstr
							ReplaceStyle "btn_buy",tmpstr,loopstr
						End If
						rem	}->
						rem	 收藏按钮 by 56770.WangLei
						If InStr(loopstr,"{@btn_fav}") > 0 Then
							tmpstr = ""
							tmpstr = RLoadStyle(1)	'收藏按钮
							ReplaceStyle "id",DataList(0,i),tmpstr
							ReplaceStyle "name",DataList(1,i),tmpstr
							ReplaceStyle "backurl",Urlencode(geturl()),tmpstr
							ReplaceStyle "type","",tmpstr
							ReplaceStyle "btn_fav",tmpstr,loopstr
						End If
						rem	}->
						ReplaceStyle "loop_num",i + 1,loopstr
						LoadListStr = LoadListStr & loopstr
						List_num = List_num + 1
                Next
		Else
			LoadListStr = LoadListStr & splits(LoadStyle(strFile&"2.style"))
		End If
		LoadListStr = LoadListStr & LoadStyle(strFile&"8.style")
		If showfootpage = 1 Then
				tmpstr = LoadStyle(strFile&"9.style")
				ReplaceStyle "footpage",ors.ShowPageFoot(Filename),tmpstr
				LoadListStr = LoadListStr & tmpstr
		End If
		LoadListStr = LoadListStr & LoadStyle(strFile&"10.style")
		LoadListStr = LoadListStr & "</form>"
		BrandProductList = LoadListStr
End Function

Function brandContent(num)
	If brand_content <> "" Then brandContent = cutchar(brand_content,num)
End Function

Function Get_showsort_sortname(a)
		Dim Rs_s
	    set Rs_s = conn.execute("select c_id,c_name"& LangTxt &",c_parentid,c_foldername,c_filename from [Lebi_category] where is_hide = 0 and c_id = "& CLng(a) &"")
	    do while not rs_s.eof
		Get_showsort_sortname = Get_showsort_sortname & Get_showsort_sortname(rs_s("c_parentid"))
		Select Case show_html
			   Case "0"
					Select Case ISAPI_Rewrite
						   Case "0"
								Select Case Config_Lebi_Eshop(16)
									   Case "0" : Get_showsort_sortname = Get_showsort_sortname &"<a href="""& Eshop_url & LangPath &"showsort.asp?sort_id="& rs_s(0) &""">"& rs_s(1) &"</a> → "
									   Case "1" : Get_showsort_sortname = Get_showsort_sortname &"<a href="""& Eshop_url & LangPath &"category/"& rs_s(3) &"/"">"& rs_s(1) &"</a> → "
									   Case "2" : Get_showsort_sortname = Get_showsort_sortname &"<a href="""& Eshop_url & LangPath &"category/"& rs_s(3) &"/default.asp"">"& rs_s(1) &"</a> → "
								End Select
						   Case "1" Get_showsort_sortname = Get_showsort_sortname &"<a href="""& Eshop_url & LangPath &"category-"& rs_s(3) &".html"">"& rs_s(1) &"</a> → "
					End Select
			   Case "1" : Get_showsort_sortname = Get_showsort_sortname &"<a href="""& Eshop_url & LangPath & Folder(2) & rs_s(4) &".1."& Sys_Ext &""">"& rs_s(1) &"</a> → "
		End Select
	    rs_s.movenext
	    Loop
	    rs_s.Close : set Rs_s = nothing
End Function
%>