<%
dim UC_INDEX
class UC_INDEX_CLASS
	
	private oRs,sSQL,sString
	
	private sub class_initialize()
	end sub
	
	public sub init()
		select case ACT
		case "do"
		case else
			call main()
		end select
	end sub
	
	private sub class_terminate()
	end sub
	
	private function main()
		dim myDeposit,myPoint,myCoupons,myMsgs,myMGroupName,mySMGroupName,myMGroupColor,mySMGroupColor,lastLoginTime
		dim orderUnpayCount,orderUnReceivedCount,orderUnCommentCount,orderServiceCount
		dim sb,orderStr : set sb = OW.stringBuilder()
		call UC.echoHeader()
		myDeposit = OS.getMemberDeposit(UID)(0)
		myPoint   = OS.getMemberPoint(UID)(0)
		if OS.versionType="x" then
		myCoupons = OS.getMemberValidCoupon(UID)
		end if
		myMsgs    = OS.getMemberUnReadMsg(UID)
		myMGroupName  = OS.getGroupName(GROUP_ID)
		mySMGroupName = OS.getGroupName(SPECIAL_GROUP_ID)
		myMGroupColor = OW.DB.getFieldValueBySQL("SELECT group_color FROM "& DB_PRE &"member_group WHERE group_id="& GROUP_ID &"")
		mySMGroupColor= OW.DB.getFieldValueBySQL("SELECT group_color FROM "& DB_PRE &"member_group WHERE group_id="& SPECIAL_GROUP_ID &"")
		lastLoginTime = OW.DB.getFieldValueBySQL("SELECT last_login_time FROM "& DB_PRE &"member WHERE uid="& UID &"")
		'****
		if OS.versionType="x" then
		orderUnpayCount      = OW.int(OW.DB.getFieldValueBySQL("SELECT count(*) FROM "& OW.DB.Table.orders &" WHERE uid="& UID &" AND is_recycle<>1 AND is_user_delete<>1 AND status=0 AND is_paid=0 AND "& OW.DB.auxSQL &""))
		orderUnReceivedCount = OW.int(OW.DB.getFieldValueBySQL("SELECT count(*) FROM "& OW.DB.Table.orders &" WHERE uid="& UID &" AND is_recycle<>1 AND is_user_delete<>1 AND status=0 AND is_shipped=1 AND ship_status<>3 AND "& OW.DB.auxSQL &""))
		orderUnCommentCount  = OW.int(OW.DB.getFieldValueBySQL("SELECT count(*) FROM "& OW.DB.Table.orders &" WHERE uid="& UID &" AND is_recycle<>1 AND is_user_delete<>1 AND status=0 AND ship_status=3 AND is_comment<>1 AND "& OW.DB.auxSQL &""))
		orderServiceCount    = OW.int(OW.DB.getFieldValueBySQL("SELECT count(*) FROM "& OW.DB.Table.orders &" WHERE uid="& UID &" AND is_recycle<>1 AND is_user_delete<>1 AND status=0 AND (pay_refund_status=1 OR pay_refund_status=2 OR ship_refund_status=1 OR ship_refund_status=2) AND "& OW.DB.auxSQL &""))
		sb.append "<ul>"
		sb.append "<li><a href=""?ctl=orders&ordertype=1"">待付款"& OW.iif(orderUnpayCount>0,"<em>"& orderUnpayCount &"</em>","") &"</a></li>"
		sb.append "<li><a href=""?ctl=orders&ordertype=3"">待收货"& OW.iif(orderUnReceivedCount>0,"<em>"& orderUnReceivedCount &"</em>","") &"</a></li>"
		sb.append "<li><a href=""?ctl=orders&ordertype=4"">待评价"& OW.iif(orderUnCommentCount>0,"<em>"& orderUnCommentCount &"</em>","") &"</a></li>"
		sb.append "<li><a href=""?ctl=orders&ordertype=5"">退款/售后"& OW.iif(orderServiceCount>0,"<em>"& orderServiceCount &"</em>","") &"</a></li>"
		sb.append "<li><a href=""?ctl=orders"">全部订单<i class=""glyphicon glyphicon-menu-right""></i></a></li>"
		sb.append "</ul>"
		orderStr = sb.toString() : set sb = nothing
		end if
%>
	<%=UC.htmlHeader()%>
    <div id="mbody">
		<%=UC.htmlSider()%>
        <div id="container" class="container-section">
            <div class="uc-userinfo">
              <div class="avatar" id="uc_avatar"><img class="avatar" src="<%=AVATAR%>"><a class="upload" href="<%=UCENTER_HURL%>ctl=setting&act=avatar" style="display:none;"><%=UC.lang(110)%></a></div>
              <div class="baseinfo"><span class="nickname"><%=OW.iif(NICKNAME="",USERNAME,NICKNAME)%></span><span class="mobile"><%=MOBILE%></span></div>
              <div class="account">
                  <span class="username"><%=UC.lang(111)%><b><%=USERNAME%></b></span><span class="email"><%=EMAIL%></span><span class="last-login-time"><%=UC.lang(112)%><%=lastLoginTime%></span>
              </div>
              <div class="auxinfo">
                  <span class="group"><%=UC.lang(113)%><a href="javascript:;" style="color:<%=myMGroupColor%>"><%=myMGroupName%></a></span><span class="sep">|</span><span class="special-group" style="color:<%=mySMGroupColor%>"><%=mySMGroupName%></span>
              </div>
            </div>
            <div class="account-info">
              <% if OS.versionType="x" then %>
              <dl>
                <dt><%=UC.lang(114)%></dt>
                <dd><a href="<%=UCENTER_HURL%>ctl=finance"><strong><%=OW.iif(myDeposit>0,"<em>"& myDeposit &"</em>",myDeposit)%></strong><span><%=UC.lang(115)%></span></a><a class="btn btn-primary btn-charge" href="<%=UCENTER_HURL%>ctl=finance&act=charge"><%=UC.lang(116)%></a></dd>
              </dl>
              <% end if %>
              <dl>
                <dt><%=OS.lang(200)%></dt>
                <dd><a href="<%=UCENTER_HURL%>ctl=point"><strong><%=OW.iif(myPoint>0,"<em>"& myPoint &"</em>",myPoint)%></strong><span><%=OS.lang(200)%></span></a>
                    <% if OS.isVersionSenior and OW.int(OW.config("is_member_sign"))=1 then %>
                    <a class="btn btn-primary btn-charge" href="<%=UCENTER_HURL%>ctl=member_sign">积分签到</a>
                    <% end if %>
                </dd>
              </dl>
              <% if OS.versionType="x" then %>
              <dl>
                <dt><%=UC.lang(117)%></dt>
                <dd><a href="<%=UCENTER_HURL%>ctl=coupon"><strong><%=OW.iif(myCoupons>0,"<em>"& myCoupons &"</em>",myCoupons)%></strong><span><%=UC.lang(118)%></span></a></dd>
              </dl>
              <% end if %>
              <dl>
                <dt><%=UC.lang(120)%></dt>
                <dd><a href="<%=UCENTER_HURL%>ctl=system_msg"><strong><%=OW.iif(myMsgs>0,"<em>"& myMsgs &"</em>",myMsgs)%></strong><span><%=UC.lang(121)%></span></a></dd>
              </dl>
            </div>
            <% if OS.versionType="x" then %>
            <div class="order-latest">
                <div class="hd"><a href="?ctl=orders">我的订单</a></div>
                <div class="bd"><%=orderStr%></div>
            </div>
            <div class="goods-latest-view">
                <div class="hd">浏览记录</div>
                <div class="bd"><ul><%=goodslatestView()%></ul></div>
            </div>
            <% end if %>
            <!--api{-->
            <%=APIOS.ucenterPCIndexDestop()%>
            <!--}-->
        </div>
    </div>
    <script type="text/javascript">
	$(document).ready(function(){
		$("#uc_avatar").hover(function(){$(this).find(".upload").show();},function(){$(this).find(".upload").hide();});
	});
    </script>
	<%=UC.htmlFooter()%>
<%
	call UC.echoFooter()
	end function
	
	private function goodslatestView()
		dim rs,sql,gids,link,title
		dim sb,str : set sb = OW.stringBuilder()
		gids = OS.SHOP.getLatestViewGids()
		if OW.DB.dbType=0 then
			sql = "SELECT top 20 * FROM "& DB_PRE &"goods WHERE status=0 AND gid IN("& gids &") ORDER BY instr(',"& gids &",',',gid,')"
		else
			sql = "SELECT top 20 * FROM "& DB_PRE &"goods WHERE status=0 AND gid IN("& gids &") ORDER BY charindex(','+rtrim(gid)+',',',"& gids &",')"
		end if
		set rs = OW.DB.getRecordBySQL(sql)
		do while not rs.eof
			link  = OS.createGoodsLink(rs("rootpath"),rs("urlpath"),rs("url"))
			title = rs("title")
			sb.append "<li><div class=""thumb""><a href="""& link &""" target=""_blank""><img src="""& rs("thumbnail") &"""/></a></div><h3 class=""title""><a href="""& link &""" target=""_blank"">"& title &"</a></h3></li>"
			rs.movenext
		loop
		OW.DB.closeRs rs
		str = sb.toString() : set sb = nothing
		goodslatestView = str
	end function
	
end class
%>

