小米抢购(简单版v0.1)-登录并验证抢购权限,以及获取真实抢购地址

小米(简单版)-登录并验证抢购权限,以及获取真实抢购地址!
并不是复制到浏览器就行了的   还得传递所需要的参数 这里只是前部分  后面的自己发挥了

小米抢购代码




{
    "stime": 1389672157, 
    "d22a51": 5, 
    "login": true, 
    "pmstart": false, 
    "status": {
        "miphone": {
            "hdstart": true, 
            "hdstop": false, 
            "hdurl": "?_a=20140114_phone&_op=choose&_s=fcea663b58", 
            "duration": null, 
            "reg": true
        }, 
        "mitv": {
            "hdstart": true, 
            "hdstop": false, 
            "hdurl": "", 
            "duration": null, 
            "reg": false
        }
    }
}

 

 

说明:(抢购前1-2个钟才开放此链接,正式开始时才返回真实地址)

      console.log([])

 可用正则  也可以用json
"(allow|hdstart|hdurl)":("(.+?)"|(.+?))(,)
"hdstart":(?<hdstart>.+?,)
"hdurl":(?<hdurl>"(.+?)",)

 json实体类:

using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using xiaomi.xiaomiEntityJsonTypes;

namespace xiaomi.xiaomiEntityJsonTypes
{
public class Miphone
{
    public bool hdstart { get; set; }
    public bool hdstop { get; set; }
    public string hdurl { get; set; }
    public object duration { get; set; }
    public bool reg { get; set; }
}

public class Mitv
{
    public bool hdstart { get; set; }
    public bool hdstop { get; set; }
    public string hdurl { get; set; }
    public object duration { get; set; }
    public bool reg { get; set; }
}

public class Status
{
    public Miphone miphone { get; set; }
    public Mitv mitv { get; set; }
}

public class RootObject
{
    public int stime { get; set; }
    public int d22a51 { get; set; }
    public bool login { get; set; }
    public bool pmstart { get; set; }
    public Status status { get; set; }
}

 

public class loginObject
{
    public string passToken { get; set; }
    public string ssecurity { get; set; }
    public string desc { get; set; }
    public long nonce { get; set; }
    public string location { get; set; }
    public int userId { get; set; }
    public object captchaUrl { get; set; }
    public string psecurity { get; set; }
    public int code { get; set; }
}

 

 

抢购:

        public void QiangGou()
        {
            try
            {
                HttpHelper http = new HttpHelper();
                HttpItem item = new HttpItem()
                {
                    //_=13896722773701389672369818
                    URL = "http://tc.hd.xiaomi.com/hdget?product=phone&_=" + ConvertDateTimeInt(DateTime.Now),
                    UserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36",
                    Host = "tc.hd.xiaomi.com",
                    CookieCollection = allCookie
                };
                HttpResult result = http.GetHtml(item);
                string strJson = result.Html;


                if (strJson.Contains("hdcontrol"))
                {
                    strJson = strJson.Replace("hdcontrol(", "").Replace(")", "");
                    txtHtml.Text = strJson;
                    RootObject xm = JsonConvert.DeserializeObject<RootObject>(strJson);
                    bool reg = xm.status.miphone.reg;
                    lblreg.Invoke(new Action(delegate() { lblreg.Text = reg.ToString(); }));
                    if (xm.status.miphone.hdstart)
                    {
                        string Hdurl = xm.status.miphone.hdurl;
                        if (!string.IsNullOrEmpty(Hdurl))
                        {
                            CookieCollection midataCookie = result.CookieCollection;

                            if (midataCookie.Count == 0)
                            {
                                lblAllow.Invoke(new Action(delegate() { lblAllow.Text = "有链接无cookie"; }));
                            }
                            else
                            {
                                TimerStop();
                                btnStart.Invoke(new Action(delegate() { btnStart.Enabled = true; }));
                                btnStop.Invoke(new Action(delegate() { btnStop.Enabled = false; }));

                                allCookie.Add(midataCookie);
                                lblAllow.Invoke(new Action(delegate() { lblAllow.Text = "有链接也有cookie"; }));

                                string chooseurl = "http://t.hd.xiaomi.com/s/" + xm.status.miphone.hdurl.Replace("\u0026", "&");
                                txtUrl.Invoke(new Action(delegate() { txtUrl.Text = chooseurl; }));

                                //带上cookie 进入抢购

 

                                //1.真实地址 返回 mi_dota
                               //2.GET请求真实地址 返回 location 继续验证 获取cookie 再次请求location
                              //3.解析页面重要四个hidden元素并带其中一个参数获取验证码
                             //4.POST四个参数 提交 ok

 


                            }


                        }
                        else
                        {
                            lblAllow.Invoke(new Action(delegate() { lblAllow.Text = "无链接"; }));
                            txtUrl.Invoke(new Action(delegate() { txtUrl.Text = ""; }));
                        }
                    }
                    else
                    {
                        lblAllow.Invoke(new Action(delegate() { lblAllow.Text = "还没开始"; }));
                        TimerStop();
                        btnStart.Invoke(new Action(delegate() { btnStart.Enabled = true; }));
                        btnStop.Invoke(new Action(delegate() { btnStop.Enabled = false; }));

                    }
                }
                else
                {
                    lblAllow.Invoke(new Action(delegate() { lblAllow.Text = "尚未开放"; }));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

        }

 

登录:

 allCookie = new CookieCollection();
            string username = txtUserName.Text;
            string password = txtPwd.Text;
            //获取 Sign令牌
            HttpItem itemSign = new HttpItem()
            {
                URL = "https://account.xiaomi.com/pass/serviceLogin",
                ResultCookieType = ResultCookieType.CookieCollection,
                CerPath = CerPath,
                Host = "account.xiaomi.com",
                UserAgent = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36",
                ContentType = "application/x-www-form-urlencoded"
            };
            HttpHelper helperSign = new HttpHelper();
            HttpResult resultSign = helperSign.GetHtml(itemSign);
            string signHtml = resultSign.Html;
            Cookie u = new Cookie() { Name = "userName", Value = Regex.Escape(username), Domain = ".xiaomi.com", Path = "/", Expires = DateTime.Now.AddDays(15) };
            CookieCollection cookieSign = resultSign.CookieCollection;
            cookieSign.Add(u);
            allCookie.Add(cookieSign);

            string[] s = myhelper.GetRegexStrings(@"Component[(](.+?)""", signHtml);
            string callback = HttpUtility.UrlEncode(s[0].Replace("\"", ""));
            string sid = HttpUtility.UrlEncode(s[1].Replace("\"", ""));
            string qs = HttpUtility.UrlEncode(s[2].Replace("\"", ""));
            string hidden = HttpUtility.UrlEncode(s[3].Replace("\"", ""));
            string sign = HttpUtility.UrlEncode(s[4].Replace("\"", ""));



            string url = @"https://account.xiaomi.com/pass/static/v5login.html?inframe=true&onetimeEncode=true&callback=" + callback + "&sid=" + sid + "&qs=" + qs + "&sign=" + sign + "&hidden=" + hidden;
            HttpItem itemv5login = new HttpItem()
            {
                URL = url,
                Referer = "https://account.xiaomi.com/pass/serviceLogin",
                ResultCookieType = ResultCookieType.CookieCollection,
                CerPath = CerPath,
                Host = "account.xiaomi.com",
                UserAgent = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36",
                ContentType = "application/x-www-form-urlencoded"
            };
            HttpHelper helperv5login = new HttpHelper();
            HttpResult resultv5login = helperSign.GetHtml(itemv5login);
            string v5loginHtml = resultv5login.Html;

            CookieCollection cookiev5login = resultv5login.CookieCollection;

            allCookie.Add(cookieSign);


            HttpItem itemPost = new HttpItem()         //登陆Post
            {
                ResultCookieType = ResultCookieType.CookieCollection,
                URL = "https://account.xiaomi.com/pass/serviceLoginAuth2",
                Method = "POST",
                CerPath = CerPath,
                CookieCollection = allCookie,
                // Cookie =   cookies,
                Referer = url,
                Host = "account.xiaomi.com",
                UserAgent = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36",
                ContentType = "application/x-www-form-urlencoded",
                Postdata = string.Format("user={0}&_json=true&pwd={1}&sid={2}&_sign={3}&callback={4}&qs={5}", username, password, sid, sign, callback, qs, hidden)
            };


            HttpHelper helperPost = new HttpHelper();
            HttpResult resultPost = helperPost.GetHtml(itemPost);

            CookieCollection cookiePost = resultPost.CookieCollection;
            if (cookiePost != null)
            {
                allCookie.Add(cookiePost);
            }

            //跳转1 http://account.xiaomi.com/sts?sid=passport&followup
            string html1 = resultPost.Html;
            if (html1.Contains("小米帐户 - 登录"))
            {
                AppendText(username + "登陆失败\n"); return;
            }
            if (html1.Contains("温馨提示"))
            {
                AppendText("签名方法不对\n"); return;
            }

            string json = html1.Replace("&&&START&&&", "");

            loginObject loginjson = JsonConvert.DeserializeObject<loginObject>(json);

            if (string.IsNullOrEmpty(loginjson.location))
            {
                AppendText("出错\n"); return;
            }

            HttpItem itemsts = new HttpItem()
            {
                URL = loginjson.location,
                Referer = url,
                ResultCookieType = ResultCookieType.CookieCollection,
                CerPath = CerPath,
                Host = "account.xiaomi.com",
                UserAgent = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36",
                ContentType = "application/x-www-form-urlencoded"
            };
            HttpHelper helpersts = new HttpHelper();
            HttpResult resultsts = helpersts.GetHtml(itemsts);
            string stsHtml = resultsts.Html;
            CookieCollection cookiests = resultsts.CookieCollection;
            if (cookiests != null)
            {
                allCookie.Add(cookiests);
            }
            string okurl = resultsts.Header["Location"];



            if (okurl.Contains("userId"))
            {
                HttpItem item3 = new HttpItem()
                {
                    ResultCookieType = ResultCookieType.CookieCollection,
                    URL = okurl,
                    Method = "GET",
                    // Cookie = cookies,
                    CookieCollection = allCookie,
                    Host = "account.xiaomi.com",
                    UserAgent = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36"
                };
                HttpHelper helper3 = new HttpHelper();
                HttpResult result3 = helper3.GetHtml(item3);

                CookieCollection c3 = result3.CookieCollection;
                if (c3 != null)
                { allCookie.Add(c3); }

                //  https://account.xiaomi.com/pass/userInfo?userId
                string href4 = result3.Header["Location"];
                HttpItem item4 = new HttpItem()
                {
                    ResultCookieType = ResultCookieType.CookieCollection,
                    URL = href4,
                    Method = "GET",

                    CookieCollection = allCookie,
                    CerPath = CerPath,
                    Host = "account.xiaomi.com",
                    UserAgent = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36"

                };
                HttpHelper helper4 = new HttpHelper();
                HttpResult result4 = helper3.GetHtml(item4);

                CookieCollection c4 = result4.CookieCollection;
                if (c4 != null)
                { allCookie.Add(c4); }

                if (result4.Header["Location"] == null)
                {
                    AppendText(username + "登陆成功");
                    StartIE(allCookie, "http://p.www.xiaomi.com/open/index.html");
                }

                else
                {
                    AppendText(username + "登陆失败");//http://account.xiaomi.com/

                }





            }

 

 

 

private void btnCopy_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtUrl.Text))
            {
                Clipboard.SetDataObject(txtUrl.Text, true);
            }
        }


        protected void AppendText(string info)
        {
            txtInfo.Invoke((MethodInvoker)delegate
            {
                txtInfo.AppendText(info + Environment.NewLine);

                txtInfo.SelectionStart = txtInfo.Text.Length;
                txtInfo.ScrollToCaret();
            });
        }




    

    /// <summary>
    /// Cookie对象
    /// </summary>
    public class CookieItem
    {
        /// <summary>
        ////// </summary>
        public string Key { get; set; }
        /// <summary>
        ////// </summary>
        public string Value { get; set; }
    }
}

 

附:20140121 js

function forNum(e) {
    return e < 10 ? "0" + e : e
}
function countdown(e, t) {
    var n = (new Date(t)).getTime() / 1e3, r = n - e, i = parseInt(r % 60), s = parseInt(r / 60 % 60), o = parseInt(r / 3600 % 24), u = parseInt(r / 3600 / 24), a = [i.toString(), s.toString(), o.toString()];
    if (r <= 0)
        return ["00小时00分00秒", !0];
    if (u > 0) {
        window._timestr = u + "天" + forNum(a[2]) + "时" + forNum(a[1]) + "分" + forNum(a[0]) + "秒";
        return [u + "<span>天</span>" + forNum(a[2]) + "<span>时</span>" + forNum(a[1]) + "<span>分</span>" + forNum(a[0]) + "<span>秒</span>", !1]
    }
    window._timestr = forNum(a[2]) + "时" + forNum(a[1]) + "分" + forNum(a[0]) + "秒";
    return [forNum(a[2]) + "<span>时</span>" + forNum(a[1]) + "<span>分</span>" + forNum(a[0]) + "<span>秒</span>", !1]
}
function isApp() {
    try {
        if (!!WE)
            return !0
    } catch (e) {
    }
    return !1
}
function WebEventTrigger(e, t) {
    try {
        if (WE && WE.trigger) {
            typeof t != "string" && (t = JSON.stringify(t));
            return WE.trigger(e, t)
        }
    } catch (n) {
    }
    return !1
}
var qg, handle;
qg = {req: !0,config: {startDate: +(new Date("01/21/2014 11:59:59")),pmDate: +(new Date("01/21/2014 15:00:00")),localDate: +(new Date),shortDate: 0,shortDiff: 10,loginDate: 7200,ajax: {hdinfo: {timeout: 3e4,url: "http://tc.hd.xiaomi.com/hdinfo"},hdget: {timeout: 3e4,url: "http://tc.hd.xiaomi.com/hdget"}},url: {login: "http://m.xiaomi.com/mshopapi/index.php/v1/authorize/sso?client_id=180100031013&callback=" + encodeURIComponent(window.location.href),bbsurl: "http://bbs.xiaomi.cn/thread-9084600-1-1.html"},goods: {miphone: {name: "手机",pay: "http://tc.hd.xiaomi.com/check?_a=payment_check&_m=1",noyuyue: "http://p.www.xiaomi.com/m/opentip/phone/tip_NoRegister.html?_el=0&v=20140121",saledone: "http://p.www.xiaomi.com/m/opentip/phone/tip_SaledOverAll.html?_el=0&v=20140121",queryurl: "http://a.hd.xiaomi.com/register/check/a/28/m/1"},mitv: {name: "电视",pay: "http://tc.hd.xiaomi.com/check?_a=payment_check_tv&_m=1",noyuyue: "http://p.www.xiaomi.com/m/opentip/tv/tip_NoRegister.html?_pf=0&v=20140121",saledone: "http://p.www.xiaomi.com/m/opentip/tv/tip_SaledOverAll.html?_pf=0&v=20140121",queryurl: "http://a.hd.xiaomi.com/register/check/a/27/m/1"},mibox: {name: "盒子",pay: "http://tc.hd.xiaomi.com/check?_a=payment_check_box&_m=1",noyuyue: "http://p.www.xiaomi.com/m/opentip/box/tip_NoRegister.html?_el=0&v=20140121",saledone: "http://p.www.xiaomi.com/m/opentip/box/tip_SaledOverAll.html?_el=0&v=20140121",queryurl: "http://a.hd.xiaomi.com/register/check/a/18/m/1"},mipower: {name: "电源",pay: "http://tc.hd.xiaomi.com/check?_a=payment_check_power&_m=1",noyuyue: "http://p.www.xiaomi.com/m/opentip/power/tip_NoRegister.html?_zm=0&v=20140121",saledone: "http://p.www.xiaomi.com/m/opentip/power/tip_SaledOverAll.html?_zm=0&v=20140121",queryurl: "http://a.hd.xiaomi.com/register/check/a/30/m/1"}}},init: function() {
        this.getInfo()
    },statu: {user: {isLogin: !1,reg: {},buy: {},clearBuy: function() {
                for (var e in qg.statu.user.buy)
                    qg.statu.user.buy[e] = !1
            }},hd: {start: !1,pmStart: !1,loginTime: !1,end: {},allEnd: !1,fk: !1}},getInfo: function() {
        var e = this;
        $.ajax({url: e.config.ajax.hdinfo.url,dataType: "jsonp",jsonpCallback: "hdinfo",timeout: e.config.ajax.hdinfo.timeout,beforeSend: function() {
                e.ajax.hdinfo.load();
                e.req = !1
            },error: function(t) {
                if (e.ajax.notFound(t, !0))
                    return;
                e.ajax.hdinfo.connect()
            },success: function(t) {
                e.req = !0;
                e.ajax.hdinfo.success(t)
            },complete: function() {
            }})
    },getDate: function() {
        var e = this, t = {};
        $.each(e.statu.user.buy, function(e, n) {
            n && (t.product = e.replace("mi", ""))
        });
        if (!e.statu.hd.fk)
            return;
        t.fk = handle.fk.num;
        $.ajax({url: e.config.ajax.hdget.url,dataType: "jsonp",data: t,jsonpCallback: "hdcontrol",timeout: e.config.ajax.hdget.timeout,beforeSend: function() {
                e.ajax.hdget.load();
                e.req = !1
            },error: function(t) {
                if (e.ajax.notFound(t, !1))
                    return;
                e.ajax.hdget.connect()
            },success: function(t) {
                e.req = !0;
                e.ajax.hdget.success(t)
            },complete: function() {
            }})
    },ajax: {notFound: function(e, t) {
            if (e.status === 404) {
                qg.req = !0;
                qg.statu.user.clearBuy();
                handle.ajax.error.notFound(t);
                return !0
            }
            return !1
        },hdget: {load: function() {
                qg.req && handle.ajax.hdget.load()
            },connect: function(e) {
                !e || e === "0" ? e = 2e3 : e = parseInt(e) * 1e3;
                setTimeout(function() {
                    qg.getDate()
                }, e)
            },success: function(e) {
                qg.getStatus.hd(e);
                qg.process.hdget();
                for (var t in qg.statu.user.buy)
                    if (qg.statu.user.buy[t] === !0) {
                        if (qg.statu.hd.end[t]) {
                            qg.statu.user.buy[t] = !1;
                            handle.ajax.hdget.saledover(t);
                            return
                        }
                        if (e.status[t].hdurl !== "") {
                            qg.statu.user.buy[t] = !1;
                            handle.ajax.hdget.success(e.status[t].hdurl)
                        } else {
                            handle.ajax.hdget.reload(e.d22a51);
                            qg.ajax.hdget.repull(e.d22a51)
                        }
                    }
            },repull: function(e) {
                qg.ajax.hdget.connect(e)
            }},hdinfo: {load: function() {
                qg.req && handle.ajax.hdinfo.load()
            },connect: function() {
                handle.ajax.error.timeout();
                setTimeout(function() {
                    qg.getInfo()
                }, 2e3)
            },success: function(e) {
                handle.ajax.hdinfo.success();
                qg.config.currentDate = e.stime;
                qg.config.shortDate = (qg.config.localDate - qg.config.currentDate * 1e3) / 1e3;
                qg.getStatus.hd(e);
                qg.getStatus.user(e);
                qg.process.hdinfo()
            }}},getStatus: {hd: function(e) {
            var t = qg.config.startDate, n = qg.config.currentDate * 1e3;
            n >= t && (qg.statu.hd.start = !0);
            if (n > qg.config.pmDate || e.pmstart === !0)
                qg.statu.hd.pmStart = !0;
            for (var r in e.status)
                e.status[r].hdstop === !1 && e.status[r].hdstart === !0 || e.status[r].hdstop === !1 && e.status[r].hdstart === !1 && qg.statu.hd.pmStart === !1 ? qg.statu.hd.end[r] = !1 : qg.statu.hd.end[r] = !0
        },user: function(e) {
            !$.cookie("userId") || (qg.statu.user.isLogin = !0);
            for (var t in e.status) {
                qg.statu.user.reg[t] = e.status[t].reg;
                qg.statu.user.buy[t] = !1
            }
        },checkEnd: function(e) {
            qg.statu.hd.allEnd = !0;
            for (var t in qg.statu.hd.end)
                qg.statu.hd.end[t] ? e(t) : qg.statu.hd.allEnd = !1
        },loginTime: function() {
            var e = qg.config.startDate, t = qg.config.currentDate * 1e3, n = e - qg.config.loginDate * 1e3;
            t >= n && (qg.statu.hd.loginTime = !0)
        }},countDown: function() {
        var e = this, t = e.config.startDate, n = e.config.currentDate, r = t - e.config.loginDate * 1e3, i = setInterval(function() {
            var e = countdown(n, t);
            if (e[1]) {
                clearInterval(i);
                qg.statu.hd.start = !0;
                qg.process.hdinfo()
            } else {
                if (n * 1e3 === r) {
                    qg.statu.hd.loginTime = !0;
                    qg.process.hdinfo()
                }
                n += 1;
                if ((+(new Date) - n * 1e3) / 1e3 - qg.config.shortDate > qg.config.shortDiff) {
                    clearInterval(i);
                    location.reload()
                }
            }
            handle.hdinfo.showTime(e[0])
        }, 1e3)
    },process: {hdget: function() {
            qg.getStatus.checkEnd(function(e) {
                handle.end.one(e)
            });
            if (qg.statu.hd.allEnd) {
                handle.end.all();
                return
            }
        },hdinfo: function() {
            if (qg.statu.hd.start) {
                handle.hdinfo.start();
                qg.getStatus.checkEnd(function(e) {
                    handle.end.one(e)
                });
                if (qg.statu.hd.allEnd) {
                    handle.end.all();
                    return
                }
                if (!qg.statu.user.isLogin) {
                    handle.login.no();
                    handle.hdinfo.login();
                    return
                }
                for (var e in qg.statu.user.reg)
                    qg.statu.user.reg[e] && !qg.statu.hd.end[e] ? handle.hdinfo.reg.bind(e) : !qg.statu.user.reg[e] && !qg.statu.hd.end[e] && handle.hdinfo.reg.none(e)
            } else
                !qg.statu.hd.start && !qg.statu.hd.loginTime && handle.hdinfo.countdown();
            qg.statu.hd.loginTime && !qg.statu.hd.start && (isApp() || handle.hdinfo.login());
            qg.statu.hd.pmStart === !0 && $("#pmTip").hide()
        }}};
handle = {dom: {pop: $("#pop"),mask: $("#mask"),loading: $("#loading"),time: $("#time"),btn1: $("#btn1"),btn2: $("#btn2"),btn3: $("#btn3"),btn4: $("#btn4"),btn5: $("#btn5"),btn6: $("#btn6"),btn7: $("#btn7")},hdinfo: {countdown: function() {
            handle.hdinfo.showBtn.countdown();
            qg.getStatus.loginTime();
            qg.countDown()
        },start: function() {
            handle.dom.time.remove();
            var e = [], t = '<a href="' + qg.config.url.bbsurl + '">查看活动详情 &raquo;</a>';
            for (var n in qg.config.goods)
                e.push('<a class="qgbtn" id="' + n + '" name="' + n + '" href="javascript:;">购买' + qg.config.goods[n].name + "</a>");
            handle.dom.btn1.html(e[0]);
            handle.dom.btn2.html(e[1]);
            handle.dom.btn3.html(e[2]);
            handle.dom.btn4.html(e[3]);
            handle.dom.btn5.html(t)
        },showTime: function(e) {
            handle.dom.time.find("strong").html(e);
            handle.dom.time.show().off("click").on("click", function() {
                window.location.reload()
            })
        },showBtn: {countdown: function() {
                var e = '<a href="' + qg.config.goods.miphone.queryurl + '">查询手机资格</a>', t = '<a href="' + qg.config.goods.mitv.queryurl + '">查询电视资格</a>', n = '<a href="' + qg.config.goods.mibox.queryurl + '">查询盒子资格</a>', r = '<a href="' + qg.config.goods.mipower.queryurl + '">查询电源资格</a>', i = '<a href="' + qg.config.url.bbsurl + '">查看活动详情 &raquo;</a>';
                handle.dom.btn1.html(e);
                handle.dom.btn2.html(t);
                handle.dom.btn3.html(n);
                handle.dom.btn4.html(r);
                handle.dom.btn5.html(i)
            }},reg: {bind: function(e) {
                var t = e;
                $("#" + t).off("click").on("click", function() {
                    qg.statu.user.clearBuy();
                    if (!!qg.req) {
                        var e = $(this).attr("name");
                        qg.statu.user.buy[e] = !0;
                        if (qg.statu.hd.fk)
                            qg.getDate();
                        else {
                            handle.fk.key(parseInt($.cookie("userId")) % 7356);
                            handle.fk.show();
                            handle.fk.bind()
                        }
                    }
                    return !1
                })
            },none: function(e) {
                var t = e, n = qg.config.goods[e].noyuyue;
                $("#" + t).off("click").on("click", function() {
                    window.location.href = n;
                    return !1
                })
            }},login: function() {
            var e = qg.config.url.login, t = '<a class="error" href="' + e + '">为确保顺利购机,请提前登录 &raquo;</a>', n = '<a href="http://m.xiaomi.com/index.html#ac=account&op=index">您已登录 &raquo;</a>';
            qg.statu.user.isLogin ? handle.dom.btn7.html(n).show() : handle.dom.btn6.html(t).slideDown()
        }},ajax: {error: {timeout: function() {
                $("#loading:visible") && handle.dom.loading.html("努力加载中...")
            },notFound: function(e) {
                $("#loading:visible") && handle.dom.loading.hide();
                handle.ajax.error.showNotFound();
                e ? $("#notFound").find("#nbtn").off("click").on("click", function() {
                    window.location.reload()
                }) : $("#notFound").find("#nbtn").off("click").on("click", function() {
                    handle.dom.mask.hide();
                    handle.dom.pop.hide()
                })
            },showNotFound: function() {
                handle.dom.mask.show();
                handle.dom.pop.show().find(".pb").hide();
                handle.dom.pop.find("#notFound").show()
            }},hdinfo: {load: function() {
                handle.ajax.hdinfo.showLoad()
            },success: function() {
                handle.ajax.hdinfo.hideLoad()
            },showLoad: function() {
                handle.dom.mask.show();
                handle.dom.loading.show()
            },hideLoad: function() {
                if ($("#loading:visible")) {
                    handle.dom.mask.hide();
                    handle.dom.loading.hide().html("正在加载...")
                }
            }},hdget: {load: function() {
                handle.dom.mask.show();
                handle.dom.pop.show().find(".pb").hide();
                handle.dom.pop.find("#hdgetLoad").show()
            },reload: function(e) {
                handle.dom.pop.find(".pb").hide();
                handle.dom.pop.find("#hdgetReload").show().find("#t").html(e)
            },success: function(e) {
                handle.dom.mask.hide();
                handle.dom.pop.hide();
                var t = "http://t.hd.xiaomi.com/s/" + e + "&_m=1";
                window.location.href = t
            },saledover: function(e) {
                var t = qg.config.goods[e].saledone;
                handle.dom.mask.hide();
                handle.dom.pop.hide();
                window.location.href = t
            }}},end: {all: function() {
        },one: function(e) {
            var t = qg.config.goods[e].name, n = qg.config.goods[e].pay;
            $("#" + e).html("支付" + t).off("click").on("click", function() {
                window.location.href = n
            })
        }},login: {no: function() {
            $(".qgbtn").off("click").on("click", function() {
                isApp() ? WebEventTrigger("login", null) : window.location.href = qg.config.url.login
            })
        }},fk: {num: "",pop: $("#fk"),cbtn: $("#fk #close"),vbtn: $("#vBtn"),vcode: $("#vCode"),vInput: $("#vInput"),vTips: $("#vTips"),key: function(e) {
            var t = e.toString(), n = t.split(""), r = n.length;
            if (n.length < 4)
                for (var i = r, s = 4; i < s; i += 1)
                    n.unshift("0");
            else
                n = n.slice(r - 4);
            this.num = n.join("")
        },show: function() {
            handle.dom.mask.show();
            handle.dom.pop.show().find(".pb").hide();
            this.vcode.html(this.num);
            this.pop.show();
            this.vInput.focus()
        },bind: function() {
            this.vbtn.off("click").on("click", function() {
                var e = handle.fk.vInput.val();
                handle.fk.vKey(e)
            });
            this.vInput.on("keypress", function() {
                handle.fk.vTips.html("").hide()
            });
            this.cbtn.on("click", function() {
                handle.dom.mask.hide();
                handle.dom.pop.hide().find(".pb").hide();
                handle.fk.vTips.hide()
            })
        },vKey: function(e) {
            if (e === this.num) {
                qg.statu.hd.fk = !0;
                qg.getDate()
            } else {
                var t = '<p class="error">验证码有误,请重新填写</p>';
                this.vTips.html(t).show();
                this.vInput.val("").focus()
            }
        }}};
http://p.www.xiaomi.com/m/op/js/8d72jd7h/app-ck.js

 

 

 

 《一》    小米抢购技术交流   已满人

《二》     小米抢购技术交流群 未满

 

 

posted @ 2013-10-22 13:11  曾祥展  阅读(18543)  评论(67编辑  收藏  举报