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

public partial class member_user_my : System.Web.UI.Page
{
    user u = new user();
    sqlServer sql = new sqlServer();
    xabara x = new xabara();
    ipAddress ip = new ipAddress();
    javasrcipt js = new javasrcipt();
    fileDocument f = new fileDocument();
    webPublic wp = new webPublic();

    public string gradeImg = "00";

    protected void Page_Load(object sender, EventArgs e)
    {
        u.check("", url.before);
        //wp.checkUserInfo();

        Page.Title = "我的帐户　" + xml.read("xabara.config", "webName", 180) + xml.read("xabara.config", "titleMeta", 180);

        if (!IsPostBack)
        {
            DataTable dt;

            if (Request.Cookies["XabaraUser"] != null)  //cookies检查
            {
                userName.Text = HttpUtility.UrlDecode(Request.Cookies["XabaraUser"]["userName"].ToString().Trim());
                if (string.IsNullOrEmpty(userName.Text as string))
                {
                    userName.Text = u.userCardID;
                }
                string uID = HttpUtility.UrlDecode(Request.Cookies["XabaraUser"]["userID"].ToString().Trim());
                if (string.IsNullOrEmpty(uID as string))
                {
                    uID = u.userCardID;
                    //js.div(false, "绑定主站ID号", "text", "请设置一个简易ID号！", 350, 0, "id.aspx", "top");
                }
                else
                {
                    setID.Visible = false;
                }
                userLoginID.Text = uID;
                vipTxt.Text = u.level(u.classID.ToString(),"text");
                userLoginTime.Text = Convert.ToDateTime(Request.Cookies["XabaraUser"]["userLgDate"]).ToString("yyyy年MM月dd日 HH:mm:ss");
                userLoginWhere.Text = ip.addressCN(Request.Cookies["XabaraUser"]["userLgIP"].ToString().Trim());
                userLoginNums.Text = Request.Cookies["XabaraUser"]["userLgNums"].ToString().Trim();
                gradeImg = u.classID.ToString();

                dt = sql.getDataTable("select * from XabaraUser where userCardID='" + u.userCardID + "'");  //会员基本信息
                if (dt.Rows.Count > 0)
                {
                    myImg.ImageUrl = f.picDisplay(dt.Rows[0]["userImg"].ToString().Trim());
                    string mailDate = dt.Rows[0]["userEmailDate"].ToString().Trim();
                    if (!string.IsNullOrEmpty(mailDate as string))
                    {
                        mailTxt.Text = "<span style='color:green;'>已认证</span>";
                        mailLink.Text = "修改";
                    }
                    else
                    {
                        mailTxt.Text = "<span style='color:#ff5a00;'>待认证</span>";
                        mailLink.Text = "立即认证";
                    }

                    //api接口判断
                    string qqID = dt.Rows[0]["qqID"].ToString().Trim();
                    if (!string.IsNullOrEmpty(qqID as string))
                    {
                        qqLogin.Text = "<span style='color:green;'>[已绑定]</span>";
                    }
                    else
                    {
                        qqLogin.Text = "<a href=\"../api/qqLogin.aspx\" target=\"_blank\" class=\"member\">[立即绑定]</a>";
                    }

                    string alipayID = dt.Rows[0]["alipayID"].ToString().Trim();
                    if (!string.IsNullOrEmpty(alipayID as string))
                    {
                        alipayLogin.Text = "<span style='color:green;'>[已绑定]</span>";
                    }
                    else
                    {
                        alipayLogin.Text = "<a href=\"../api/alipayLogin.aspx\" target=\"_blank\" class=\"member\">[立即绑定]</a>";
                    }
                }
                dt.Dispose();
            }
        }
    }
}