<%
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,myOrdersCount,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)
	myOrdersCount = OW.DB.getFieldValueBySQL("SELECT count(*) FROM "& DB_PRE &"orders WHERE uid="& UID &" AND "& OW.DB.auxSQL &"")
	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 class=""all""><a href=""?ctl=orders""><i class=""all""></i><span>我的订单</span></a></li>"
		sb.append "<li class=""unpay""><a href=""?ctl=orders&ordertype=1""><i class=""unpay"">"& OW.iif(orderUnpayCount>0,"<em>"& orderUnpayCount &"</em>","") &"</i><span>待付款</span></a></li>"
		sb.append "<li class=""unreceived""><a href=""?ctl=orders&ordertype=3""><i class=""unreceived"">"& OW.iif(orderUnReceivedCount>0,"<em>"& orderUnReceivedCount &"</em>","") &"</i><span>待收货</span></a></li>"
		sb.append "<li class=""uncomment""><a href=""?ctl=orders&ordertype=4""><i class=""uncomment"">"& OW.iif(orderUnCommentCount>0,"<em>"& orderUnCommentCount &"</em>","") &"</i><span>待评价</span></a></li>"
		sb.append "<li class=""service""><a href=""?ctl=orders&ordertype=5""><i class=""service"">"& OW.iif(orderServiceCount>0,"<em>"& orderServiceCount &"</em>","") &"</i><span>退款/售后</span></a></li>"
		sb.append "</ul>"
		orderStr = sb.toString() : set sb = nothing
	end if
%>
    <section id="mbody">
    <div class="om-ucenter">
        <div class="ow-member-card">
            <div class="ow-myheader">
                <div class="ow-myheader-in">
                    <div class="avatar"><a href="<%=UCENTER_HURL%>ctl=setting&act=avatar"><img class="avatar" src="<%=AVATAR%>?ran=<%=OW.random(5)%>" /></a></div>
                    <div class="member-name"><span class="username"><%=USERNAME%></span><%=OW.iif(OW.rs(USERNAME)=OW.rs(NICKNAME),"","<span class=""nickname"">"& NICKNAME &"</span>")%></div>
                    <div class="member-group"><span class="mgroup"><%=myMGroupName%></span><%=OW.iif(OW.isNul(mySMGroupName),"","<span class=""sgroup"">"& mySMGroupName &"</span>")%></div>
                </div>
            </div>
            <div class="ow-account-info">
                <% if OS.versionType="x" then %>
                <dl>
                    <a href="<%=UCENTER_HURL%>ctl=finance">
                    <dt><%=UC.lang(114)%></dt>
                    <dd><b><%=OW.iif(myDeposit>0,"<em>"& myDeposit &"</em>",myDeposit)%></b><span><%=UC.lang(115)%></span></dd>
                    </a>
                </dl>
                <% end if %>
                <dl>
                    <a href="<%=UCENTER_HURL%>ctl=point">
                    <dt><%=OS.lang(200)%></dt>
                    <dd><b><%=OW.iif(myPoint>0,"<em>"& myPoint &"</em>",myPoint)%></b><span>分</span></dd>
                    </a>
                </dl>
                <% if OS.versionType="x" then %>
                <dl>
                    <a href="<%=UCENTER_HURL%>ctl=coupon">
                    <dt><%=UC.lang(117)%></dt>
                    <dd><b><%=OW.iif(myCoupons>0,"<em>"& myCoupons &"</em>",myCoupons)%></b><span>张</span></dd>
                    </a>
                </dl>
                <% end if %>
                <dl>
                    <a href="<%=UCENTER_HURL%>ctl=system_msg">
                    <dt><%=UC.lang(120)%></dt>
                    <dd><b><%=OW.iif(myMsgs>0,"<em>"& myMsgs &"</em>",myMsgs)%></b><span>条</span></dd>
                    </a>
                </dl>
            </div>
        </div>
        <% if OS.versionType="x" then %>
        <div class="ow-my-order"><%=orderStr%></div>
        <% end if %>
        <div class="ow-apios-index-destop"><%=APIOS.ucenterMobIndexDestop()%></div>
        <div class="menulist">
            <ul>
                <% if OS.versionType="x" then %>
                <% if OW.config("is_fenxiao_open")=1 then %>
                <li><a href="<%=UCENTER_HURL%>ctl=fenxiao"><i class="icon-fenxiao"></i><b><%=UC.lang(10)%></b></a></li>
                <% end if %>
                <li><a href="<%=UCENTER_HURL%>ctl=favorite"><i class="icon-favorite"></i><b><%=UC.lang(8)%></b></a></li>
                <li><a href="<%=UCENTER_HURL%>ctl=address"><i class="icon-address"></i><b><%=UC.lang(9)%></b></a></li>
                <% end if %>
                <% if OS.isVersionSenior and OW.int(OW.config("is_member_sign"))=1 then %>
                <li class="member-sign"><a href="<%=UCENTER_HURL%>ctl=member_sign"><i class="icon-member-sign"></i><b>签到领积分</b></a></li>
                <% end if %>
                <li class="setting"><a href="<%=UCENTER_HURL%>ctl=setting"><i class="icon-setting"></i><b><%=UC.lang(4)%></b></a></li>
                <li class="password"><a href="<%=UCENTER_HURL%>ctl=password"><i class="icon-password"></i><b><%=UC.lang(11)%></b></a></li>
                <% if OS.isVersionSenior and IS_STAFF then %>
                 <li class="staff"><a href="<%=UCENTER_HURL%>ctl=staff"><i class="icon-password"></i><b>员工业绩统计</b></a></li>
				<% end if %>
            </ul>
        </div>
        <div class="ow-formlist">
			<%=formList()%>
        </div>
        <div class="ow-apios-aux-menu"><%=APIOS.ucenterMobAuxMenu()%></div>
        <div class="ow-logout">
            <a href="<%=OW.urlRewrite("l2")%>"><%=UC.lang(12)%></a>
        </div>
    </div>
    </section>
    <script type="text/javascript">
	$(document).ready(function(){
	});
    </script>
	<%=UC.htmlFooter()%>
<%
	call UC.echoFooter()
	end function
	
	private function formList()
		dim rs
		dim sb,str : set sb = OW.stringBuilder()
		set rs = OW.DB.getRecordBySQL("SELECT form_id,name,[table] FROM "& DB_PRE &"form WHERE is_ucenter_show=1 AND status=0 AND "& OW.DB.auxSQL &" ORDER BY sequence ASC")
		do while not rs.eof
			sb.append "<li><a href="""& UCENTER_HURL &"ctl=form&act=list&form_id="& rs("form_id") &"""""><i class=""icon-form""></i><b>"& rs("name") &"</b></a></li>"
			rs.movenext
		loop
		OW.DB.closeRs rs
		str = sb.toString() : set sb = nothing
		if str<>"" then
			str = "<ul>"& str &"</ul>"
		end if
		formList = str
	end function
end class
%>

