【正文】
首頁設(shè)計(jì) 一般的電子商務(wù)網(wǎng)站,首頁所含的信息量是非常大的,為了方便維護(hù),對(duì)首頁進(jìn)行分塊處理,然后用包含的方式,把各個(gè)塊組裝起來,這樣不僅使頁面結(jié)構(gòu)清晰,而且維護(hù)方便。例程 35 為首頁的參考代碼。 例程 35 用戶首頁代碼 % dim productid productid=Request(id) if (productid=) then end if dim strUrlGo strUrlGo=/?id=amp。productid % 產(chǎn)品瀏覽 頁面 和頁面 的實(shí)現(xiàn)類試,這里只介紹 頁面實(shí)現(xiàn)的核心部分。例程 36 為頁面 的開始部分代碼。 圖 319 鮮花分類的目錄式檢索瀏覽頁面 例程 36 頁面開始部分代碼 % dim pagenum pagenum=16 % 在例程 36 中 pagenum 定義每頁顯示的產(chǎn)品數(shù)量,默認(rèn)顯示 16 個(gè)鮮花產(chǎn)品?!?! _ _includefile=””_ _引入 公用文件。 從例程 36 可以看出當(dāng)產(chǎn)品個(gè)數(shù)大于 16 的時(shí)候,就需要顯示在下一頁,因此需要實(shí)現(xiàn)產(chǎn)品的分頁顯示,例程 37 為 產(chǎn)品分 頁顯示的代碼。 例程 37 產(chǎn)品分野顯示的代碼 % dim dir,strPage,nPage dir=Request(dir) strPage=Request(Page) if (strPage=) then nPage=1 else nPage=CInt(strPage) end if dim MyValue,property MyValue=Request(MyValue) property=Request(property) if (property=) then property=0 end if if (MyValue=) then MyValue=0 end if dim result result=GetListFlower(property,MyValue) dim aryReturn,i aryReturn = Split(result,) dim startelment,endelment startelment=(nPage1)*pagenum endelment=nPage*pagenum1 if (endelment UBound(aryReturn)) then endelment=UBound(aryReturn) end if dim strSplitPage,allpage allpage=CInt((UBound(aryReturn)LBound(aryReturn))/) +1 strSplitPage= bfont color=redamp。nPageamp。/amp。allpageamp。/font 頁/b dim startShow,endShow,nextShow if ((nPage5)=0) then startShow=1 else startShow=nPage5 end if if ((nPage+5)allpage) then endShow=allpage else endShow=nPage+5 end if dim k For k=startShow To endShow dim showone showone=a href=39。?property=amp。propertyamp。amp。MyValue=amp。MyValueamp。amp。Page=amp。kamp。39。amp。kamp。/a strSplitPage=strSplitPageamp。showone Next if (nPage1) then nextShow=a href=39。?property=amp。propertyamp。amp。MyValue=amp。MyValueamp。amp。Page=amp。(nPage1)amp。39。上一頁 /a end if nextShow=nextShowamp。 if (nPageallpage) then nextShow=nextShowamp。a href=39。?property=amp。propertyamp。amp。MyValue=amp。MyValueamp。amp。Page=amp。(nPage+1)amp。39。下一頁 /a end if % !include file=inc//td td width=10 /td td valign=top table border=0 cellspacing=0 cellpadding=0 width=99% tr bgcolor=ddFFFFtd colspan=3 height=10 %=strSplitPage% /tdtd align=right %=nextShow% /td/tr % dim n n=0 For i = startelment To endelment dim one one=GetProduct(aryReturn(i)) if one(FIELDAUTOID)0 Then if ((n mod 4)=0) then tr end if % td width=20% align=center !include file=inc/ /td % if ((n mod 4)=3) then /tr end if n=n+1 end if Next % 例程 38 為 顯示產(chǎn)品的代碼。 例程 38 顯示 產(chǎn)品的代碼 % dim n n=0 For i = startelment To endelment dim one one=GetProduct(aryReturn(i)) if one(FIELDAUTOID)0 Then if ((n mod 4)=0) then tr end if % td width=20% align=center !include file=inc/ /td % if ((n mod 4)=3) then /tr end if n=n+1 end if Next % 例程 39 為頁面 的參考代碼。 例程 39 頁面 的參考代碼 a href=?id=%=one(FIELDAUTOID)% target=_blank img alt=鮮花 border=0 height=80 src=%=one(FIELDNETIMAGEMID) % width=80 /a br %=one(FIELDNAME)%br 銷售價(jià)格: %=one(FIELDSALEPRICE)%元 br a href=javascript:add2cart(39。%=one(FIELDAUTOID)%39。)img src=images/ width=40 height=17 border=0/a 例程 39 中 one 是在例程 38 中調(diào)用 Getproduct()方法得到的一個(gè)產(chǎn)品對(duì)象( one=Getproduct(aryreturn(i)),one(FIELDNAME)等是獲得產(chǎn)品的名稱等屬性。 產(chǎn)品詳細(xì)信息 用戶在產(chǎn)品瀏覽頁面中單擊某個(gè)產(chǎn)品,就會(huì)進(jìn)入產(chǎn)品的詳細(xì)信息頁面,產(chǎn)品詳細(xì)頁面主要包含兩部分內(nèi)容:一部分是產(chǎn)品信息顯示:另一部分是針對(duì)該產(chǎn)品的用戶評(píng)論。圖 320 為產(chǎn)品詳細(xì)信息頁面。 圖 320 產(chǎn)品信息頁面 產(chǎn)品信息頁面的實(shí)現(xiàn)文件問 ,例程 310 為 頁面的參考代碼。 例程 310 頁面的參考代碼 % dim productid productid=Request(id) if (productid=) then end if dim strUrlGo strUrlGo=?id=amp。productid % !include file=inc/ % dim MyListUse,MyListFlower,MyListObject,MyListPrice MyListUse=0 MyListFlower=0 MyListObject=0 MyListPrice=0 % !include file=inc//td td width=10 /td td valign=top !include file=inc/ br !include file=inc/ /td /tr /table !include file=inc/ /body /html 例程 310 中利用包含文件 !include file=來顯示單個(gè)產(chǎn)品的纖細(xì)信息;利用包含 !include file=來顯示針對(duì)該產(chǎn)品的所有評(píng)論信息。 在頁面中 先調(diào)用 Getproduct 方法得到產(chǎn)品對(duì)象,如例程 311所示 / 例程 311 調(diào)用 Getproduct 方法得到產(chǎn)品對(duì)象 〈 % Dim one One=Getproduct (productid) If one(FIELDAYTOID)0 Then ”該商品不存在 !” Else %