using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using xabaraCOM;

public partial class member_Default : System.Web.UI.Page
{
    user u = new user();
    sqlServer sql = new sqlServer();
    javasrcipt js = new javasrcipt();
    xabara x = new xabara();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            advertisement ad = new advertisement();
            ad950.Text = ad.read("", 950, 90, 1, false, true, "");

            string returnUrl = Server.UrlDecode(Request.QueryString["url"]);

            string errorStr = Request.QueryString["errorTitle"];
            if (!string.IsNullOrEmpty(errorStr as string))
            {
                if (errorStr.Equals("exit"))
                {
                    //执行同步平台

                }
                else
                {
                    Session.Abandon();
                    js.div(false, "", "text", Server.UrlDecode(errorStr), 350, 0, "/member/", "top");
                }
            }

            string userID = u.autoLogin(returnUrl);
            if (string.IsNullOrEmpty(userID as string))
            {
                userID = "用户名/邮箱/手机号码";
            }
            uID.Text = userID;

            //QQ快捷登录检查
            if (string.IsNullOrEmpty(xml.read("xabara.config", "qqAppID", 180) as string))
            {
                qq.Visible = false;
            }

            //aliPay快捷登录检查
            if (string.IsNullOrEmpty(xml.read("xabara.config", "aliPayID", 180) as string))
            {
                alipay.Visible = false;
            }

            regExpression reg = new regExpression();
            uIDRegularExpressionValidator.ValidationExpression = reg.CHAR(2, 20);
            uIDRegularExpressionValidator.ErrorMessage = reg.charError(2, 20);
            PWRegularExpressionValidator.ValidationExpression = reg.passWord(6, 20);
            PWRegularExpressionValidator.ErrorMessage = reg.passWordError(6, 20);
            RndNumReg.ValidationExpression = reg.rndNums(6, 20);
            RndNumReg.ErrorMessage = reg.rndNumsError(6, 20);
        }

        Page.Title = "会员中心　" + xml.read("xabara.config", "webName", 180) + xml.read("xabara.config", "titleMeta", 180);
    }

    protected void loginEnter_Click(object sender, ImageClickEventArgs e)
    {
        bool isLogin = false;
        if (checkLogin.Checked)
        {
            isLogin = true;
        }

        if (x.checkValidateCode(true, RndNum.Text.Trim()))
        {
            u.login("", uID.Text, uPW.Text, "", true, isLogin);
        }
    }
}