以下は、Xiaomiがそれを分析した後、Redmi Rushを実装するために購入するときに、JSコードです。
コードコピーは次のとおりです。
hdcontrol({"stime":1381645438、 "status":{"appro":false、 "miphone":{"hdstart":false、 "hdstop":false、 "hdurl": ""、 "duration":null} 、 "Mibox":{"hdstart":false、hdstop ":false、" hdurl ":" "、" duration ":null}}}))
コードコピーは次のとおりです。
fornum(a){
10> a? "0"+a:a:a
}
関数カウントダウン(a、b){
varc = newdate(b).gettime()/1e3、
d = ca、
e = parseint(d%60)、
f = parseint(d/60%60)、g = parseint(d/3600%24)、
h = parseint(d/3600/24)、
i = [e.toString()、
f.toString()、
g.toString()];
return0> = d?["00時間00分00秒"、!0]:h> 0?(windo._timestr = h+"day"+fornum(i [2])+"time"+fornum(i [1 ])+「minute」+fornum(i [0])+"second"、[h+"<span> day </span>"+fornum(i [2])+"<span> time </span>" +fornum(i [1])+"<span> min </span>"+fornum(i [0])+"<span> second </span>"、!1] :( window._timestr = fornum (i [2])+"time"+fornum(i [1])+"minute"+fornum(i [0])+"second"、[fornum(i [2])+"<span> /span > "+fornum(i [1])+" <span> min </span> "+fornum(i [0])+" <span> second </span> "、!1]}
functionwebeventtrigger(a、b){
試す{
if(we && we.trigger)
"string"!= typeofb &&(b = json.stringify(b))、we.trigger(a、b)
} catch(c){}
戻る!1
}
functionisApp(){
試す{
if(we)return!0
} catch(a){}
戻る!1
}
varquickbuy = {init:function(){
vara = this;
this.config = {}、
this.config.hdurl={miphone:"m3/840410D8656D74E5F334591BD8A408A726799AEC13477D90B5E48DAD36547351/4334F49A1EE391261005E8AC5A0C9 D2FDA23BB72A2D20AB3F58343496FD4983D/tip_SaledOverAll.html",mibox:"tv/B1CF7B57BFEAE1EBC37700694C123D894C668BF11F6F25D59311FD369 42B3D6A/130F1B18D11F53CA1D0147B24E926C5A9B7676E57BE3D47959D6557545E8A339/tip_SaledOverAll.html"
}、
this.config.mode = ""、
this.mode = {miphone:!1、mibox:!1}、
this.modemodals = {miphone: "#modal_miphone"、mibox: "#modal_mibox"}、
this.modecookies = {miphone: "xm_hd_so_phone"、mibox: "xm_hd_so_box"}、
this.config.startdate =+newDate( "10/15/201312:00:00")、
this.maskload = $( "#maskload")、
this.config.minsigntime = 120、
this.results = null、
this.timer = null、
this.timecount = math.floor(math.abs(10*math.random()-5))+5;
varb =!0;
for(varcinthis.mode)
$ .cookie(this.modecookies [c])||(b =!1)、$。cookie(this.modecookies [c])&& this.saleout();
B ||($。Cookie( "xm_diff_hd")?(this.config.servertime = this.localtime()+parseint($ .config.startDate/1E3,10)?$ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::づ 火::::: ::::::::::::: launch()):this.getData())}、getData:function(a、b){
varc = this、a = a || null;
b &&(b = b)、
$ .ajax({
URL: "http://tc.hd.xiaomi.com/hdget"、
データタイプ:「jsonp」、
jsonpcallback: "hdcontrol"、
タイムアウト:7e3、
beforesend:function(){
c.maskload.css( "display"、 "block")}
エラー:function(){
c.maskload.css( "display"、 "none")、
アラート(「サーバーは大きなプレッシャーにさらされています。ページを更新してください!」)
}、
成功:関数(d){
if(c.maskload.css( "display"、 "none")、 "undefined" == typeofd)
ReturnLert(「サーバーは大きなプレッシャーにさらされています。ページを更新してください!」)、
void0;
if(c.results = d、a ||(c.config.servertime = c.results.stime)、!$。cookie( "xm_diff_hd")){
vare = parseint(c.config.servertime-c.localtime()、10);
$ .cookie( "xm_diff_hd"、e、{
パス:"/"、
ドメイン: "。xiaomi.com"、
期限切れ:1
})
}
if(a){
c.InitialData();
for(varfinc.mode)
if(c.config [f] .hdstart ===!1 && c.config [f] .hdstop ===!0){
varg = c.modecookies [f];
$ .cookie(g、1、{path: "/"、domain: "。xiaomi.com"、expires:1})、
c.saleout()
} elseb && b.call()
}
|| c.launch()
}})}、
InitialData:function(){
this.config.allow = this.results.status.allow、
this.config.mibox = this.results.status.mibox、
this.config.miphone = this.results.status.miphone
}、
起動:function(){
this.timestart()、
this.countdown()
}、
Timestart:function(){
vara =これ、
b = 1e3*a.config.servertime、
c = a.config.startdate、
d = c-1e3*60*a.config.minsigntime;
b> = d && c> b &&!isapp()?
$ .cookie( "userid")?
($( "#view_button")。css( "visibility"、 "hidden")、
$( "#bulyse_btn_1").html( '<class = "btn_buy" href = "http://bbs.xiaomi.cn/thread-8205768-1.html">アクティビティ詳細</a>')、
$( "#bulyse_btn_2")。html( '<class = "btn_buybtn_02" href = "javascript:;"> login </a>')):a.tologin():b> = c && a.tobuy()
}、
Tologin:function(){
$( "#view_button")。css( "visibility"、 "hidden")、
$( "#bulyse_btn_1").html( '<class = "btn_buy" href = "http://bbs.xiaomi.cn/thread-8205768-1.html">アクティビティ詳細</a>')、
$( "#bulyse_btn_2")。html( '<aclass = "btn_buybtn_02" href = "javascript:;">事前にログイン</a>')、
$( "#bulyse_btn_2")。find( "。btn_02")。
webeventtrigger( "login"、null)||(window.location.href = "http://m.xiaomi.com/mshopapi/index.php/v1/authorize/sso?client_id=180100031013&c allback ="+encoduricentone(window 。
)}、
countdown:function(){
vara =これ、
b = null、
c = a.config.startdate;
b = a.config.servertime?a.config.servertime:parseint(+newdate/1e3,10);
vard = c-1e3*60*a.config.minsigntime、
e = setInterval(function(){
varf = countdown(b、c);
f [1]?(clearInterval(e)、$( "#countdown")。css( "display"、 "none")、a.tobuy()):( 1e3*b!= d || isApp()| |($。cookie( "userid")?($( "#view_button")。css( "visibility"、 "hidden")、
$( "#bulyse_btn_1").html( '<class = "btn_buy" href = "http://bbs.xiaomi.cn/thread-8205768-1.html">アクティビティ詳細</a>')、
$( "#bulyse_btn_2")。html( '<aclass = "btn_buy" href = "javascript:;"> login </a>')):a.tologin())、b ++)、
$( "#countdown")。html(f [0])}、1e3)}、
tobuy:function(){
vara = this;
a.gobuy();
varb = a.ModeModals [a.config.mode];
$(b).find( "。close")。on( "click"、function(){
$(b).css( "display"、 "none")、
window.cleartimeout(a.timer)、
A.timer = null})}、
saleout:function(){
vara = {miphone: "#bulyse_btn_2"、mibox: "#bulyse_btn_1"}、
b = {miphone: "http://t.hd.xiaomi.com/r/?_a = payment_check&_m = 1"、mibox: "http://m.xiaomi.com/index.html#ac = home&op=addcart_id = 2505 "}、
c = {miphone: "xiaomi mobile 3"、mibox: "pay xiaomi tv"};
for(vardintthis.mode)
$ .cookie(this.modecookies [d])&&($(a [d])。html( '<aclass = "btn_buy" href = "'+b [d]+'">'+c)+ "</a>")、
$(this.modemodals [d])。is( ":visible")&& $(this.modemodals [d])。
localtime:function(){
vara = parseint(+newdate/1e3,10);
リターナ
}、
toprocess:function(a){
varb =これ、
C = B.Timer、
d = b.timecount || 10、e = $(b.modemodals [a])。find( "。re_countdown")、
f = $(b.modemodals [a])。find( "。modal_btn")、
g = function(){0 == d?(f.html( '<aclass = "into_buy_btn" href = "javascript:;">アクティビティ</a>')
b.tobuygo(b.config.mode)、
c && window.cleartimeout(c)、
c = null):( e.html( "("+d+")")、
d-、、
b.timer = window.settimeout(function(){g()}、1e3))};
c && window.cleartimeout(c)、g()}、
gobuy:function(){
vara =これ、
b = {Miphone: "Xiaomi Mobile 3"、Miboxを購入: "Xiaomi TVを購入}、
c = {miphone: "#bulyse_btn_2"、mibox: "#bulyse_btn_1"};
for(vardina.mode)
$ .cookie(a.modecookies [d])||($(c [d])。html( '<aclass = "btn_buybtn_go" data-type = "'+d+'」href =" javascript:; ">' +b [d]+"</a>")、
$(c [d])。is( ":hidden")&& $(c [d])。css( "display"、 "block"));
$( "#open_button")。find( "。btn_buy_go")。
varb = a.config.mode = $(this).attr( "data-type");
if($
$(a.modemodals [b])。css( "display"、 "block")、
$(a.modemodals [b])。find( "。close")。on( "click"、function(){
$(a.modemodals [b])。css( "display"、 "none")、window.cleartimeout(a.timer)、a.timer = null})、a.toprocess(b)});
else {if(webeventtrigger( "login"、null))return;
window.location.href = "http://m.xiaomi.com/mshopapi/index.php/v1/authorize/sso?client_id=180100031013&callback="+encodeuricomponent(w indow.location.href)}})}
Tobuygo:function(a){
varb = this;
window.cleartimeout(b.timer)、
b.timer = null、
$(b.modemodals [a])。find( "。modal_btn")。find( "。into_buy_btn")。関数(){
if($(b.modemodals [a])。css( "display"、 "block")、b.config.allow)if(b.config [a] .hdurl){
varc = "http://t.hd.xiaomi.com/s/"+b.config [a] .hdurl+"&_m = 1";
window.settimeout(function(){window.location.href = c}、500)
}それ以外{
vard = "http://p.www.xiaomi.com/m/activities/open/"+b.config.hdurl [a];
window.settimeout(function(){window.location.href = d}、500)
} elseif(
b.config [a] .hdstart ===!1 && b.config [a] .hdstop ===!0){
vard = "http://p.www.xiaomi.com/m/activities/open/"+b.config.hdurl [a];
window.settimeout(function(){window.location.href = d}、500)
} else $(b.modemodals [a])
b.toprocess(a)
})})}};