<!-- #Include File="../Include/Channel_Shop.asp" -->
<!-- #Include File="Common.asp" -->
<%
'=======================================================
' 欢迎使用《阿赛大型门户网站系统V3.0》，简称“AsaiMHV3”
' 技术支持、商业版咨询、官方唯一指定联系QQ“4941172”
' 官方网站：http://77ya.com      程序负责人：阿赛
'=======================================================

dim id,shop_session,BagMsg
shop_session=trim(request.cookies(Cls.web_cookies)("bag"))
id=trim(request.querystring("id"))
id=Cls.code_id("id")
'response.cookies(Cls.web_cookies)("bag")=""
tit="我的购物车"

call DoWebHead(0,0)
Call Channel_Load(0)
tit_fir=Cls.ChannelName

if isnumeric(id) And id<>0 then
  call shop_bag_add(id)
end if

select case action
case "chk"
  call shop_bag_chk()
case "clear"
  call shop_bag_clear()
end select

call shop_bag_type()
Call Channel_End(0)
call DoWebEnd()

sub shop_bag_chk()
  dim sdim,sel_id,nnum
  sel_id=trim(request.form("sel_id"))
  sel_id=replace(sel_id,", ",",")
  sdim=split(sel_id,",")
  shop_session=""
  for i=0 to ubound(sdim)
    if Cls.Is_Int(sdim(i)) then
      nnum=trim(request.form("sel_num"&sdim(i)))
      if Cls.Is_Int(nnum)=false then nnum=1
      shop_session=shop_session&","&sdim(i)&"$"&nnum
    end if
  next
  erase sdim
  if left(shop_session,1)="," then shop_session=right(shop_session,len(shop_session)-1)
  response.cookies(Cls.web_cookies)("bag")=shop_session
  BagMsg = vbcrlf&Cls.js_put("alert(""成功更改了"&tit&"内所选的"&Cls.ChannelTit&"！"");",1)
end sub

sub shop_bag_clear()
  shop_session=""
  response.cookies(Cls.web_cookies)("bag")=shop_session
  BagMsg = vbcrlf&Cls.js_put("alert(""成功清空了"&tit&"内所选的"&Cls.ChannelTit&"！"");",1)
end sub

sub shop_bag_add(aid)
  sql="select top 1 name from AsaiMHShop where hidden=1 and id="&aid
  set rs=Cls.exec(sql,1)
  if rs.eof then
    BagMsg = vbcrlf&Cls.js_put("alert("""&Cls.ChannelTit&"（ID："&aid&"）不存在！"");",1)
  else
    if instr(","&shop_session&"$",","&aid&"$")<1 then
      shop_session=shop_session&","&aid&"$1"
      if left(shop_session,1)="," then shop_session=right(shop_session,len(shop_session)-1)
      response.cookies(Cls.web_cookies)("bag")=shop_session
      BagMsg = vbcrlf&Cls.js_put("alert(""成功添加"&Cls.ChannelTit&"（名称："&rs("name")&"，ID："&aid&"）到"&tit&"内！"");",1)
    end if
  end if
end sub

sub shop_bag_type()
  dim sTmp,sdim,ssum,nid,nnum,price,price_now,discount,name,ds,dss
  ssum=0
  ds=" disabled"
  dss=" disabled"
  sdim=split(shop_session,",")
sTmp="<table cellspacing=1 cellpadding=4 class=table>" & _
vbcrlf&"<tr class=trb><td colspan=7 height=30 align=center><font class=red>以下是您所选购的"&Cls.ChannelTit&"清单</font></td></tr>" & _
vbcrlf&"<tr height=22 align=center> " & _
vbcrlf&"<td width='6%' class=td>选</td>" & _
vbcrlf&"<td width='38%' class=td>"&Cls.ChannelTit&"名称</td>" & _
vbcrlf&"<td width='10%' class=td>数量</td>" & _
vbcrlf&"<td width='13%' class=td>原价("&val_unit&")</td>" & _
vbcrlf&"<td width='8%' class=td>折扣</td>" & _
vbcrlf&"<td width='13%' class=td>现价("&val_unit&")</td>" & _
vbcrlf&"<td width='12%' class=td>"&web_dim(8)&"支付</td>" & _
vbcrlf&"</tr>" & _
vbcrlf&"<form name=shop_bag_frm action='Bag.asp?action=chk' method=post>"
  for i=0 to ubound(sdim)
    nid=left(sdim(i),instr(sdim(i),"$")-1)
    nnum=right(sdim(i),len(sdim(i))-instr(sdim(i),"$"))
    if isnumeric(nid) and Cls.Is_Int(nnum) then
      sql="select top 1 name,serial,Price_Original,discount,is_emoney,emoney from AsaiMHShop where hidden=1 and id="&nid
      set rs=Cls.exec(sql,1)
      if not rs.eof then
        name=Cls.Code_Html(rs("name"),1,0)
        price=fm_price(rs("Price_Original"),1)
        discount=rs("discount")
        price_now=fm_price(price*(discount/100),1)
        discount=Cls.FM_Discount(discount)
        ssum=ssum+price_now*nnum
sTmp=sTmp&"<tr class=tr align=center>" & _
vbcrlf&"<td><input type=checkbox name=sel_id value='"&nid&"' checked ></td>" & _
vbcrlf&"<td align=left><a href='#' title="&Cls.ChannelTit&"编号："&rs("serial")&vbcrlf&"点击浏览"&Cls.ChannelTit&"详细信息' onclick=""javascript:open_view('View.asp?id="&nid&"',1);"">"&name&"</a></td>" & _
vbcrlf&"<input type=hidden name=tmp_num"&nid&" value='"&nnum&"'>" & _
vbcrlf&"<td><input type=text name=sel_num"&nid&" size=4 value='"&nnum&"' onKeyUp=""javascript:shop_checknum(sel_num"&nid&",tmp_num"&nid&");"" style=""text-align: right""></td>" & _
vbcrlf&"<td align=right>"&price&"</td>" & _
vbcrlf&"<td>"
        if discount=Cls.FM_Discount(100) then
          sTmp=sTmp&"<font class=Gys>"&discount&"</font>"
        else
          sTmp=sTmp&"<font class=red2>"&discount&"</font>"
        end if
sTmp=sTmp&"</td>" & _
vbcrlf&"<td align=right><font class=blue>"&price_now&"</font></td>" & _
vbcrlf&"<td>"
        if rs("is_emoney") then
           sTmp=sTmp&"<a href='Emoney_Pay.asp?ChannelIDs="&ChannelIDs&"&id="&nid&"' title='点击"&web_dim(8)&"使用金币购买此"&Cls.ChannelTit&"'>"&rs("emoney")&"</a>"
           dss=""
        else
           sTmp=sTmp&"<font class=Gys>不可用</font>"
        end if
sTmp=sTmp&"</td>" & _
vbcrlf&"</tr>"
        ds=""
      end if
      rs.close
    end if
  next
sTmp=sTmp&"<tr  class=tr><td colspan=7 height=30 align=right>"
  if ds="" then
    sTmp=sTmp&"您所选购的"&Cls.ChannelTit&"总的有效金额：<font class=red>"&fm_price(ssum,1)&"</font>&nbsp;"&val_unit
  else
    sTmp=sTmp&"<font class=blue>您目前还没有选购"&Cls.ChannelTit&"</font>"
  end if
sTmp=sTmp&"&nbsp;</td></tr>" & _
vbcrlf&"<tr class=trs><td colspan=7 align=center height=40>" & _
vbcrlf&"<table border=0>" & _
vbcrlf&"<tr>" & _
vbcrlf&"<td><input class=btn type=submit value='确认更改'"&ds&"></td>" & _
vbcrlf&"<td width=5></td>" & _
vbcrlf&"<td><input class=btn type=button value='继续购物' onclick=""javascript:location.href='Index.asp';""></td>" & _
vbcrlf&"<td width=5></td>" & _
vbcrlf&"<td><input class=btn type=button value='清空购物车' onclick=""javascript:shop_clear();"""&ds&"></td>" & _
vbcrlf&"<td width=5></td>" & _
vbcrlf&"<td><input class=btn type=button value='去收银台' onclick=""javascript:location.href='Pay.asp';"""&ds&"></td>" & _
vbcrlf&"<td width=5></td>" & _
vbcrlf&"<td><input class=btn type=button value='去"&web_dim(8)&"收银台' onclick=""javascript:location.href='Emoney_Pay.asp';"""&dss&" title='使用网站"&web_dim(8)&"支付，需要"&Cls.ChannelTit&"支持！'></td>" & _
vbcrlf&"</tr>" & _
vbcrlf&"</table>" & _
vbcrlf&"</td></tr>" & _
vbcrlf&"<tr class=tr><td colspan=7 align=center><font class=red>注意：改变商品数量和减少商品种类需按“确认更改”按钮</font></td></tr>" & _
vbcrlf&"</form>" & _
vbcrlf&"</table>"
  erase sdim
    Call ShowMsg(tit,sTmp&vbcrlf&BagMsg)
end sub
%>
