/*! www.xiaomi.com - v1.1.0 - 2014 */ if ("undefined" == typeof XIAOMI || !XIAOMI) var XIAOMI = {}; XIAOMI.namespace = function () { var i, j, d, a = arguments, o = null; for (i = 0; i < a.length; i += 1) for (d = ("" + a[i]).split("."), o = XIAOMI, j = "XIAOMI" == d[0] ? 1 : 0; j < d.length; j += 1) o[d[j]] = o[d[j]] || {}, o = o[d[j]]; return o }, XIAOMI.lang = XIAOMI.lang || {}, function () { var L = XIAOMI.lang, OP = Object.prototype, ARRAY_TOSTRING = "[object Array]", FUNCTION_TOSTRING = "[object Function]", OBJECT_TOSTRING = "[object Object]", NOTHING = [], HTML_CHARS = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'", "/": "/", "`": "`" }, ADD = ["toString", "valueOf"], OB = { isArray: function (o) { return OP.toString.apply(o) === ARRAY_TOSTRING }, isBoolean: function (o) { return "boolean" == typeof o }, isFunction: function (o) { return "function" == typeof o || OP.toString.apply(o) === FUNCTION_TOSTRING }, isNull: function (o) { return null === o }, isNumber: function (o) { return "number" == typeof o && isFinite(o) }, isObject: function (o) { return o && ("object" == typeof o || L.isFunction(o)) || !1 }, isString: function (o) { return "string" == typeof o }, isUndefined: function (o) { return "undefined" == typeof o }, _IEEnumFix: -[1] ? function () { } : function (r, s) { var i, fname, f; for (i = 0; i < ADD.length; i += 1) fname = ADD[i], f = s[fname], L.isFunction(f) && f != OP[fname] && (r[fname] = f) }, escapeHTML: function (html) { return html.replace(/[&<>"'\/`]/g, function (match) { return HTML_CHARS[match] }) }, preventDefault: function (e) { e.preventDefault ? e.preventDefault() : e.returnValue = !1 }, extend: function (subc, superc, overrides) { if (!superc || !subc) throw new Error("extend failed, please check that all dependencies are included."); var i, F = function () { }; if (F.prototype = superc.prototype, subc.prototype = new F, subc.prototype.constructor = subc, subc.superclass = superc.prototype, superc.prototype.constructor == OP.constructor && (superc.prototype.constructor = superc), overrides) { for (i in overrides) L.hasOwnProperty(overrides, i) && (subc.prototype[i] = overrides[i]); L._IEEnumFix(subc.prototype, overrides) } }, augmentObject: function (r, s) { if (!s || !r) throw new Error("Absorb failed, verify dependencies."); var i, p, a = arguments, overrideList = a[2]; if (overrideList && overrideList !== !0) for (i = 2; i < a.length; i += 1) r[a[i]] = s[a[i]]; else { for (p in s) !overrideList && p in r || (r[p] = s[p]); L._IEEnumFix(r, s) } return r }, augmentProto: function (r, s) { if (!s || !r) throw new Error("Augment failed, verify dependencies."); var i, a = [r.prototype, s.prototype]; for (i = 2; i < arguments.length; i += 1) a.push(arguments[i]); return L.augmentObject.apply(this, a), r }, dump: function (o, d) { var i, len, s = [], OBJ = "{...}", FUN = "f(){...}", COMMA = ", ", ARROW = " => "; if (!L.isObject(o)) return o + ""; if (o instanceof Date || "nodeType" in o && "tagName" in o) return o; if (L.isFunction(o)) return FUN; if (d = L.isNumber(d) ? d : 3, L.isArray(o)) { for (s.push("["), i = 0, len = o.length; len > i; i += 1) s.push(L.isObject(o[i]) ? d > 0 ? L.dump(o[i], d - 1) : OBJ : o[i]), s.push(COMMA); s.length > 1 && s.pop(), s.push("]") } else { s.push("{"); for (i in o) L.hasOwnProperty(o, i) && (s.push(i + ARROW), s.push(L.isObject(o[i]) ? d > 0 ? L.dump(o[i], d - 1) : OBJ : o[i]), s.push(COMMA)); s.length > 1 && s.pop(), s.push("}") } return s.join("") }, substitute: function (s, o, f, recurse) { for (var i, j, k, key, v, meta, token, dump, objstr, saved = [], lidx = s.length, DUMP = "dump", SPACE = " ", LBRACE = "{", RBRACE = "}"; (i = s.lastIndexOf(LBRACE, lidx), !(0 > i)) && (j = s.indexOf(RBRACE, i), !(i + 1 > j)); ) token = s.substring(i + 1, j), key = token, meta = null, k = key.indexOf(SPACE), k > -1 && (meta = key.substring(k + 1), key = key.substring(0, k)), v = o[key], f && (v = f(key, v, meta)), L.isObject(v) ? L.isArray(v) ? v = L.dump(v, parseInt(meta, 10)) : (meta = meta || "", dump = meta.indexOf(DUMP), dump > -1 && (meta = meta.substring(4)), objstr = v.toString(), v = objstr === OBJECT_TOSTRING || dump > -1 ? L.dump(v, parseInt(meta, 10)) : objstr) : L.isString(v) || L.isNumber(v) || (v = "~-" + saved.length + "-~", saved[saved.length] = token), s = s.substring(0, i) + v + s.substring(j + 1), recurse === !1 && (lidx = i - 1); for (i = saved.length - 1; i >= 0; i -= 1) s = s.replace(new RegExp("~-" + i + "-~"), "{" + saved[i] + "}", "g"); return s }, trim: function (s) { try { return s.replace(/^\s+|\s+$/g, "") } catch (e) { return s } }, merge: function () { var i, o = {}, a = arguments, l = a.length; for (i = 0; l > i; i += 1) L.augmentObject(o, a[i], !0); return o }, later: function (when, o, fn, data, periodic) { when = when || 0, o = o || {}; var f, r, m = fn, d = data; if (L.isString(fn) && (m = o[fn]), !m) throw new TypeError("method undefined"); return L.isUndefined(data) || L.isArray(d) || (d = [data]), f = function () { m.apply(o, d || NOTHING) }, r = periodic ? setInterval(f, when) : setTimeout(f, when), { interval: periodic, cancel: function () { this.interval ? clearInterval(r) : clearTimeout(r) } } }, isValue: function (o) { return L.isObject(o) || L.isString(o) || L.isNumber(o) || L.isBoolean(o) } }; L.hasOwnProperty = OP.hasOwnProperty ? function (o, prop) { return o && o.hasOwnProperty && o.hasOwnProperty(prop) } : function (o, prop) { return !L.isUndefined(o[prop]) && o.constructor.prototype[prop] !== o[prop] }, OB.augmentObject(L, OB, !0), L.augment = L.augmentProto, XIAOMI.augment = L.augmentProto, XIAOMI.extend = L.extend } (); ; (function () { function parse(s, buf, offset) { var i = buf && offset || 0, ii = 0; for (buf = buf || [], s.toLowerCase().replace(/[0-9a-f]{2}/g, function (oct) { 16 > ii && (buf[i + ii++] = _hexToByte[oct]) }); 16 > ii; ) buf[i + ii++] = 0; return buf } function unparse(buf, offset) { var i = offset || 0, bth = _byteToHex; return bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]] + "-" + bth[buf[i++]] + bth[buf[i++]] + "-" + bth[buf[i++]] + bth[buf[i++]] + "-" + bth[buf[i++]] + bth[buf[i++]] + "-" + bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]] } function v1(options, buf, offset) { var i = buf && offset || 0, b = buf || []; options = options || {}; var clockseq = null != options.clockseq ? options.clockseq : _clockseq, msecs = null != options.msecs ? options.msecs : (new Date).getTime(), nsecs = null != options.nsecs ? options.nsecs : _lastNSecs + 1, dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 1e4; if (0 > dt && null == options.clockseq && (clockseq = clockseq + 1 & 16383), (0 > dt || msecs > _lastMSecs) && null == options.nsecs && (nsecs = 0), nsecs >= 1e4) throw new Error("uuid.v1(): Can't create more than 10M uuids/sec"); _lastMSecs = msecs, _lastNSecs = nsecs, _clockseq = clockseq, msecs += 122192928e5; var tl = (1e4 * (268435455 & msecs) + nsecs) % 4294967296; b[i++] = tl >>> 24 & 255, b[i++] = tl >>> 16 & 255, b[i++] = tl >>> 8 & 255, b[i++] = 255 & tl; var tmh = msecs / 4294967296 * 1e4 & 268435455; b[i++] = tmh >>> 8 & 255, b[i++] = 255 & tmh, b[i++] = tmh >>> 24 & 15 | 16, b[i++] = tmh >>> 16 & 255, b[i++] = clockseq >>> 8 | 128, b[i++] = 255 & clockseq; for (var node = options.node || _nodeId, n = 0; 6 > n; n++) b[i + n] = node[n]; return buf ? buf : unparse(b) } function v4(options, buf, offset) { var i = buf && offset || 0; "string" == typeof options && (buf = "binary" == options ? new BufferClass(16) : null, options = null), options = options || {}; var rnds = options.random || (options.rng || _rng)(); if (rnds[6] = 15 & rnds[6] | 64, rnds[8] = 63 & rnds[8] | 128, buf) for (var ii = 0; 16 > ii; ii++) buf[i + ii] = rnds[ii]; return buf || unparse(rnds) } var _rng, _global = this; if ("function" == typeof require) try { var _rb = require("crypto").randomBytes; _rng = _rb && function () { return _rb(16) } } catch (e) { } if (!_rng && _global.crypto && crypto.getRandomValues) { var _rnds8 = new Uint8Array(16); _rng = function () { return crypto.getRandomValues(_rnds8), _rnds8 } } if (!_rng) { var _rnds = new Array(16); _rng = function () { for (var r, i = 0; 16 > i; i++) 0 === (3 & i) && (r = 4294967296 * Math.random()), _rnds[i] = r >>> ((3 & i) << 3) & 255; return _rnds } } for (var BufferClass = "function" == typeof Buffer ? Buffer : Array, _byteToHex = [], _hexToByte = {}, i = 0; 256 > i; i++) _byteToHex[i] = (i + 256).toString(16).substr(1), _hexToByte[_byteToHex[i]] = i; var _seedBytes = _rng(), _nodeId = [1 | _seedBytes[0], _seedBytes[1], _seedBytes[2], _seedBytes[3], _seedBytes[4], _seedBytes[5]], _clockseq = 16383 & (_seedBytes[6] << 8 | _seedBytes[7]), _lastMSecs = 0, _lastNSecs = 0, uuid = v4; if (uuid.v1 = v1, uuid.v4 = v4, uuid.parse = parse, uuid.unparse = unparse, uuid.BufferClass = BufferClass, _global.define && define.amd) define(function () { return uuid }); else if ("undefined" != typeof module && module.exports) module.exports = uuid; else { var _previousRoot = _global.uuid; uuid.noConflict = function () { return _global.uuid = _previousRoot, uuid }, _global.uuid = uuid } }).call(this); ; XIAOMI.namespace("app.analytics"), XIAOMI.app.analytics = function (element, options) { this.options = { page: "首页", position: ["A1"], url: !0, BDurl: !0, mstSite: "CN-WW", mstPage: "PC", mstArea: "RM", mstPosition: ["A"], mstHostParams: "", isMst: !1, JQelement: !1 }; for (var p in options) this.options[p] = options[p]; for (var _this = this, isUrl = _this.options.url ? !0 : !1, isBDurl = _this.options.BDurl ? !0 : !1, bindFunction = function (links) { $.each(links, function (k, v) { var mstParamString = isUrl ? $(v).attr("href") : XIAOMI.lang.trim($(v).text()), BDparamString = isBDurl ? $(v).attr("href") : XIAOMI.lang.trim($(v).text()), paramIndex = k, BDparmas_1 = _this.options.page, BDparmas_2 = BDparmas_1 + "_" + _this.options.position[i] + "_" + paramIndex, BDparmas_3 = BDparmas_2 + "_" + BDparamString, BDparmas = "'PC','" + BDparmas_3 + "'", mstParmas = "'" + _this.options.mstSite + "-" + _this.options.mstPage + "-" + _this.options.mstArea + "-" + _this.options.mstPosition[i] + paramIndex + "', '" + mstParamString; mstParmas = mstParmas += "" === _this.options.mstHostParams ? "', '" + paramIndex + "'" : "', '" + _this.options.mstHostParams + "'", _this.options.isMst ? $(v).attr("onclick", "_msq.push(['trackEvent'," + mstParmas + "]);_hmt.push(['_trackEvent'," + BDparmas + "]);") : $(v).attr("onclick", "_hmt.push(['_trackEvent'," + BDparmas + "]);") }) }, i = 0; i < element.length; i++) { var links = _this.options.JQelement ? element[i] : $(element[i]).find("a"); bindFunction(links) } }, XIAOMI.namespace("app.updateMiniCart, app.addShopCart, app.addShopCartEvent"), XIAOMI.app.updateMiniCart = function () { var num = XIAOMI.app.cookie("xm_user_www_num"); return num && parseFloat(num) > 0 ? ($(".J_cartNum").html("(" + num + ")").show(), num) : ($(".J_cartNum").html("").hide(), 0) }, XIAOMI.app.addShopCart = function (gid, callback, obj) { if (gid && "function" == typeof callback) { var ajaxUrl = XIAOMI.GLOBAL_CONFIG.orderSite + "/cart/add/" + gid; $.ajax({ url: ajaxUrl, dataType: "jsonp", jsonp: "jsonpcallback", success: function (data) { callback(data, obj), XIAOMI.app.updateMiniCart() } }) } }, XIAOMI.app.addShopCartEvent = function (options) { var op = { obj: ".xmAddShopCart", callback: null }; $.extend(op, options || {}), $(document).on("click", op.obj, function () { var gid = $(this).attr("data-gid"), isDisabled = $(this).attr("data-disabled"), isPackage = $(this).attr("data-package"); if ("false" === isDisabled) { if ($(this).attr("data-disabled", "true"), !gid || "true" === isPackage || null === op.callback) return !0; var dmSkuArr = XIAOMI.GLOBAL_CONFIG.damiaoGoodsId ? XIAOMI.GLOBAL_CONFIG.damiaoGoodsId : !1, isToDm = !1; if (dmSkuArr !== !1 && "object" == typeof dmSkuArr) for (var i = 0; i < dmSkuArr.length; i += 1) if (gid === dmSkuArr[i]) { isToDm = !0; break } if (isToDm === !0) { var dmLogin = new XIAOMI.app.miniLogin; XIAOMI.app.cookie("serviceToken") ? XIAOMI.app.dmFun.init({ sku: gid, callback: op.callback, obj: $(this) }) : XIAOMI.app.cookie("userId") ? (dmLogin._proxyiframe(), XIAOMI.app.dmFun.init({ sku: gid, callback: op.callback, obj: $(this) })) : dmLogin._toLogin() } else XIAOMI.app.addShopCart(gid, op.callback, $(this)) } return !1 }) }, function () { for (var method, noop = function () { }, methods = ["assert", "clear", "count", "debug", "dir", "dirxml", "error", "exception", "group", "groupCollapsed", "groupEnd", "info", "log", "markTimeline", "profile", "profileEnd", "table", "time", "timeEnd", "timeStamp", "trace", "warn"], length = methods.length, console = window.console = window.console || {}; length--; ) method = methods[length], console[method] || (console[method] = noop) } (), XIAOMI.namespace("app.cookie"), XIAOMI.app.cookie = function (key, value, options) { if (arguments.length > 1 && "[object Object]" !== String(value)) { if (options = jQuery.extend({}, options), (null === value || void 0 === value) && (options.expires = -1), "number" == typeof options.expires) { var days = options.expires, t = options.expires = new Date; t.setDate(t.getDate() + days) } return value = String(value), document.cookie = [encodeURIComponent(key), "=", options.raw ? value : encodeURIComponent(value), options.expires ? "; expires=" + options.expires.toUTCString() : "", options.path ? "; path=" + options.path : "", options.domain ? "; domain=" + options.domain : "", options.secure ? "; secure" : ""].join("") } options = value || {}; var result, decode = options.raw ? function (s) { return s } : decodeURIComponent; return (result = new RegExp("(?:^|; )" + encodeURIComponent(key) + "=([^;]*)").exec(document.cookie)) ? decode(result[1]) : null }, XIAOMI.namespace("app.dmFun"), XIAOMI.app.dmFun = { init: function (options) { this.config = { sku: null, callback: null, obj: null, sourceVal: "bigtap" }, this.inTheQueue = !1, $.extend(this.config, options), this.startQueue(), this.getDmSys(); var _this = this; $("#xmDmReload").on("click", function () { _this.config.obj.trigger("click") }) }, getDmSys: function () { var _this = this, hdget = XIAOMI.GLOBAL_CONFIG.damiaoSite + "hdget/cn?source=" + _this.config.sourceVal + "&product=" + _this.config.sku + "&addcart=1&m=1&_=" + (new Date).getTime(); $.ajax({ type: "GET", url: hdget, dataType: "jsonp", jsonp: "jsonpcallback", jsonpCallback: "hdcontrol", timeout: 3e4, error: function () { return _this.inTheQueue ? (_this.stopQueue(), void $("#xmDmError").modal({ show: !0, backdrop: "static" })) : !1 }, success: function (data) { var jsonStr = data.status, token = jsonStr[_this.config.sku].hdurl, isOver = jsonStr[_this.config.sku].hdstart === !1 && jsonStr[_this.config.sku].hdstop === !0 ? !0 : !1, speed = data.d22a51 ? 1e3 * data.d22a51 : 5e3; return _this.inTheQueue ? isOver === !0 ? (_this.stopQueue(), alert("抱歉,商品已售罄!"), !1) : (_this.getDmTimer && clearInterval(_this.getDmTimer), void (token ? _this.getShopCart(token) : (_this.inTheQueue || _this.startQueue(), _this.getDmTimer = setInterval(function () { _this.getDmSys() }, speed)))) : !1 } }) }, getShopCart: function (token) { if (!token) return !1; var _this = this, addCart = XIAOMI.GLOBAL_CONFIG.orderSite + "/cart/add/" + this.config.sku + "?source=" + _this.config.sourceVal + "&token=" + token; $.ajax({ type: "GET", url: addCart, dataType: "jsonp", jsonp: "jsonpcallback", success: function (data) { _this.stopQueue(), _this.config.callback(data, _this.config.obj), XIAOMI.app.updateMiniCart() } }) }, startQueue: function () { var _this = this; $("#xmDmError").modal("hide"), $("#xmDmQueue").modal({ show: !0, backdrop: "static" }), _this.queueAnimate(), _this.inTheQueue = !0, $("#xmDmQueue").on("hidden.bs.modal", function () { _this.stopQueue(), _this.config.obj.attr("data-disabled", "false") }) }, stopQueue: function () { $("#xmDmQueue").modal("hide"), this.inTheQueue = !1, this.getDmTimer && clearInterval(this.getDmTimer), window.queueAnimateTimer && clearInterval(queueAnimateTimer) }, queueAnimate: function () { var flag = 0, speed = 200, loop = function () { flag -= 90, -900 >= flag && (flag = 0), $("#mituWalking").css({ "background-position": flag + "px 0" }) }; window.queueAnimateTimer = setInterval(loop, speed) }, showLoading: function () { var _this = this; $("#getDmLoading").modal("show"), $("#getDmLoading").on("hidden.bs.modal", function () { _this.config.obj.attr("data-disabled", "false") }) }, hideLoading: function () { $("#getDmLoading").modal("hide") } }, XIAOMI.namespace("app.footer"), XIAOMI.app.footer = { init: function () { var _this = this; _this.retinizer(), _this.weixin(), _this.siteList(), XIAOMI.app.analytics([".J_menuNavMain"], { page: "导航", position: ["A"], mstPage: "HP", mstArea: "NV", mstPosition: ["A"], isMst: !0 }) }, retinizer: function () { var img = new Image; if ("srcset" in img) return !1; if ("undefined" == typeof window.devicePixelRatio || window.devicePixelRatio <= 1.5) return !1; var $img = $("img"); $img.each(function () { var srcset = $(this).attr("srcset"); srcset && srcset.split(" 2x")[0] && $(this).attr("src", srcset.split(" 2x")[0]) }) }, siteList: function () { $(".J_globalList").on({ mouseenter: function () { $(this).find(".global-site-list").show() }, mouseleave: function () { $(this).find(".global-site-list").hide() } }) }, weixin: function () { $(".J_modalWeixin").on("click", function () { var $modalWeixin = $("#J_modalWeixin"); $modalWeixin.css({ width: $modalWeixin.attr("data-width"), height: $modalWeixin.attr("data-height") }).modal({ backdrop: !0, keyboard: !0, show: !0 }) }) } }, XIAOMI.namespace("app.getRegions"), XIAOMI.app.getRegions = { getUrl: "/region/index", getData: function (parent, target, sId) { var _this = this; $.ajax({ type: "GET", url: _this.getUrl, data: "parent=" + parent, dataType: "json", success: function (data) { data && _this.formatData(data, target, sId) } }) }, formatData: function (jsonData, target, sId) { for (var dataArray = jsonData.regions, lens = dataArray.length, obj = $("#" + target), options = "", i = 0; lens > i; i += 1) { var isSelected = dataArray[i].region_id === sId ? "selected" : ""; options += "" } $("#" + target).html(options).attr("disabled", !1) } }, XIAOMI.namespace("app.History"), XIAOMI.app.History = function () { var historyVal = XIAOMI.app.cookie("XM_scan_history"), itemArray = null, goodsUrl = null; if (!historyVal) return !1; historyVal = historyVal.split("#m#"); for (var lens = historyVal.length - 1, objArr = [], i = 0; lens > i; i++) { itemArray = historyVal[i].split(","), goodsUrl = XIAOMI.GLOBAL_CONFIG.wwwSite + "/item/" + itemArray[3]; var pro = {}; pro.imgUrl = itemArray[0], pro.goodsUrl = goodsUrl, pro.name = itemArray[1], pro.price = itemArray[2], pro.starClass = itemArray[4], pro.gid = itemArray[3], objArr.push(pro) } return objArr }, XIAOMI.namespace("app.lazyLoad"), XIAOMI.app.lazyLoad = function (option) { var settings = { defObj: "#lazyLoad-box", defHeight: 50 }; settings = $.extend(settings, option || {}); var defObj = (settings.defHeight, "object" == typeof settings.defObj ? settings.defObj.find("img") : $(settings.defObj).find("img")), isIpad = "ipad" === navigator.userAgent.toLowerCase().match(/iPad/i) ? !0 : !1, pageTop = function () { var d = document, y = isIpad ? window.pageYOffset : Math.max(d.documentElement.scrollTop, d.body.scrollTop); return isIpad && (settings.defHeight = 0), d.documentElement.clientHeight + y + settings.defHeight }, rechangeSrc = function (obj) { var src2 = obj.attr("src2"); src2 && obj.css({ opacity: "0.3" }).attr("src", src2).removeAttr("src2").animate({ opacity: "1" }) }, imgLoad = function () { defObj.each(function () { isIpad ? rechangeSrc($(this)) : $(this).offset().top <= pageTop() && rechangeSrc($(this)) }) }; imgLoad(), $(window).bind("scroll", function () { imgLoad() }), $(window).bind("resize", function () { imgLoad() }) }, XIAOMI.namespace("app.miniCart"), XIAOMI.app.miniCart = { elmCartBtn: $("#J_miniCart"), elmCartList: $("#J_miniCartList"), loadingStr: '
数据加载中,请稍后...
', speed: 500, init: function () { var _this = this, timeOut = null; return "undefined" != typeof miniCartDisable && miniCartDisable ? !1 : "undefined" != typeof XIAOMI.GLOBAL_CONFIG.closeMiniCart && "1" === XIAOMI.GLOBAL_CONFIG.closeMiniCart ? !1 : (_this.elmCartBtn.on({ mouseenter: function () { clearTimeout(timeOut), $(this).hasClass("mini-cart-on") || ($(this).addClass("mini-cart-on"), _this.show(), _this.getData()) }, mouseleave: function () { timeOut = setTimeout(function () { _this.close() }, _this.speed) } }), _this.elmCartList.on({ mouseenter: function () { clearTimeout(timeOut) }, mouseleave: function () { timeOut = setTimeout(function () { _this.close() }, _this.speed) } }), void _this.elmCartList.on("click", ".delItem", function (e) { var gId = $(this).attr("gid"), isBigtap = $(this).attr("data-isbigtap"); return "true" !== isBigtap || confirm("您正在删除开放购买活动商品\n\n删除后您失去本次开放购买资格,无法下单购买此商品。\n确认删除此商品吗?") ? (e.preventDefault(), void _this.delGoods(gId)) : !1 })) }, show: function () { var _this = this; _this.elmCartList.show() }, close: function () { var _this = this; _this.elmCartBtn.removeClass("mini-cart-on"), _this.elmCartList.html(this.loadingStr).hide() }, delGoods: function (gId) { var _this = this; $.ajax({ type: "POST", url: XIAOMI.GLOBAL_CONFIG.orderSite + "/cart/delete/" + gId, dataType: "jsonp", jsonp: "jsonpcallback", cache: "false", success: function (data) { 1 === data.deleteBatch && (_this.getData(), XIAOMI.app.updateMiniCart()) } }) }, getData: function () { var _this = this; $.ajax({ type: "POST", url: XIAOMI.GLOBAL_CONFIG.orderSite + "/cart/miniNew", dataType: "jsonp", jsonp: "jsonpcallback", cache: !1, success: function (data) { _this.formatData(data), XIAOMI.app.updateMiniCart() } }) }, formatData: function (data) { var _this = this; if (0 === data.errorno && data.totalItem > 0) { var lens = data.items.length, goodsUrl = null, listHtml = "购物车中还没有商品,赶紧选购吧!
') } }, XIAOMI.namespace("app.miniLogin"), XIAOMI.app.miniLogin = function () { this.orderSite = XIAOMI.GLOBAL_CONFIG.orderSite, this.quickLoginUrl = XIAOMI.GLOBAL_CONFIG.quickLoginUrl }, XIAOMI.app.miniLogin.prototype = { constructor: XIAOMI.app.miniLogin, _proxyiframe: function () { var iframesrc = this.orderSite + "/user/proxy/stop/1", iframebody = ""; $(document.body).append(iframebody), $("iframe[name='proxy']").load(function () { $("iframe[name='proxy']").remove() }) }, _toLogin: function (rel) { function appendTobody(url) { var iframeURL = url ? url : _this.quickLoginUrl, content = "", boxWidth = $("#loginBox").attr("data-width"), boxHeight = $("#loginBox").attr("data-Height"); $("#loginBox-con").css({ height: boxHeight }).html(content), $("#loginBox").css({ width: boxWidth, "margin-left": -boxWidth / 2 }).modal({ backdrop: !0, keyboard: !0, show: !0 }) } function goLocation() { clearInterval(timer), rel ? window.location.href = rel : window.location.reload(!0) } function checkHash() { -1 !== window.location.href.indexOf("order") ? XIAOMI.app.cookie("serviceToken") && goLocation() : XIAOMI.app.cookie("userId") && goLocation() } var _this = this, shref = encodeURIComponent(window.location.href); $.ajax({ url: _this.orderSite + "/site/loginurl?followup=" + shref, dataType: "jsonp", jsonp: "jsonpcallback", success: function (data) { appendTobody(data.url) }, Complete: function () { }, error: function () { appendTobody() } }); var timer = window.setInterval(checkHash, 1e3) }, init: function () { var _this = this; -1 !== window.location.pathname.indexOf("cart") && XIAOMI.app.cookie("userId") && !XIAOMI.app.cookie("serviceToken") && _this._proxyiframe(), $("[data-needLogin='true']").on("click", function () { window.location.href = "https://account.xiaomi.com/pass/serviceLogin" }) }, _isLogined: function (rel, e) { XIAOMI.app.cookie("serviceToken") || (XIAOMI.app.cookie("userId") ? this._proxyiframe() : (e && XIAOMI.lang.preventDefault(e), this._toLogin(rel))) }, autoExec: function (rel) { this._isLogined(rel) } }, XIAOMI.namespace("app.navMenus, app.navigation"), XIAOMI.app.navMenus = function () { function toggleMenu(elm, curIndex, show, opt) { var options, $menu, $elm = $(elm); return options = $.extend({}, defaults, opt), $menu = $elm.children(options.menuSelector), "toggle" === options.effect ? show ? $menu.removeClass("current").children(options.submenuSelector).hide().end().eq(curIndex).addClass("current").children(options.submenuSelector).show() : $menu.removeClass("current").children(options.submenuSelector).hide() : "slide" === options.effect ? show ? ($menu.removeClass("current").children(options.submenuSelector).stop(!0, !0).delay(options.speed).slideUp(options.speed), $menu.eq(curIndex).addClass("current").children(options.submenuSelector).stop(!0, !0).slideDown(options.speed)) : $menu.removeClass("current").children(options.submenuSelector).stop(!0, !0).slideUp(options.speed) : "fade" === options.effect && (show ? ($menu.removeClass("current").children(options.submenuSelector).stop(!0, !0).fadeOut(options.speed), $menu.eq(curIndex).children(options.submenuSelector).stop(!0, !0).fadeIn(options.speed)) : $menu.removeClass("current").children(options.submenuSelector).stop(!0, !0).fadeOut(options.speed)), $menu.eq(curIndex).children(options.submenuSelector) } function init(elm, opt) { function bindToggleEvent(curIndex, show) { options.delay > 0 && "click" !== options.triggerEvent ? show ? (timeoutToggle && window.clearTimeout(timeoutToggle), timeoutToggle = window.setTimeout(function () { toggleMenu($elm, curIndex, !0, options) }, options.delay)) : (window.clearTimeout(timeoutToggle), timeoutToggle = window.setTimeout(function () { toggleMenu($elm, curIndex, !1, options) }, options.delay)) : show ? toggleMenu($elm, curIndex, !0, options) : toggleMenu($elm, curIndex, !1, options), "function" == typeof options.callback && options.callback($elm, curIndex, options) } var options, $menu, timeoutToggle, $elm = $(elm); return 0 === $elm.length ? $elm : $elm.length > 1 ? ($elm.each(function () { init($(this), opt) }), this) : (options = $.extend({}, defaults, opt), $menu = $elm.children(options.menuSelector), "hover" === options.triggerEvent ? $menu.on({ mouseenter: function () { bindToggleEvent($menu.index($(this)), !0) }, mouseleave: function () { bindToggleEvent($menu.index($(this)), !1) } }) : "click" === options.triggerEvent && $menu.on("click", function (e) { e.preventDefault(), $(this).hasClass("toggled") ? ($(this).removeClass("toggled"), bindToggleEvent($menu.index($(this)), !1)) : ($menu.removeClass("toggled"), $(this).addClass("toggled"), bindToggleEvent($menu.index($(this)), !0)) }), void (window.ActiveXObject && !window.XMLHttpRequest && $menu.find(options.submenuSelector).find("a").on("click", function () { window.location.href = $(this).attr("href") }))) } var defaults; return defaults = { menuSelector: ".menu", submenuSelector: ".children", triggerEvent: "hover", effect: "toggle", delay: 200, speed: 200, callback: function () { } }, { toggleMenu: toggleMenu, init: init } } (), XIAOMI.app.navCategory = function () { function toggleCategoryList(option) { "show" === option ? ($categoryContainer.addClass("nav-category-toggled"), $categoryTriggerBtn.find(".iconfont").html(""), $categoryList.show()) : "static" === option ? ($categoryContainer.addClass("nav-category-toggled"), $categoryList.show()) : ($categoryContainer.removeClass("nav-category-toggled"), $categoryTriggerBtn.find(".iconfont").html(""), $categoryList.hide().find(".nav-category-list").children("li").removeClass("current")) } function bindChildrenList() { var timeoutChildrenList; $categoryList.find(".nav-category-list").children("li").on({ mouseenter: function () { var $this = $(this); window.clearTimeout(timeoutChildrenList), $this.hasClass("current") || (timeoutChildrenList = window.setTimeout(function () { $this.addClass("current").siblings("li").removeClass("current"); var $children = $this.find(".nav-category-children"); if ($children.length && $children.offset().top - $categoryContainer.offset().top - $categoryContainer.height() + $children.height() > $categoryList.height()) { var bottomFix = $children.offset().top - $categoryContainer.offset().top - $categoryContainer.height() + 73 - $categoryList.height(); $children.css({ top: "auto", bottom: bottomFix }) } }, 100)) }, mouseleave: function () { var $this = $(this); window.clearTimeout(timeoutChildrenList), 0 === $categoryList.find(".nav-category-list").children("li").index($this) ? $categoryList.find(".nav-category-list").children("li").removeClass("current") : $this.hasClass("current") && (timeoutChildrenList = window.setTimeout(function () { $this.removeClass("current") }, 100)) } }), $categoryList.on({ mouseleave: function () { } }) } function init() { function addSrcset(elm) { var $imgs = elm.find("img"); $imgs.each(function () { if (/40x40/.test($(this).attr("src"))) { var url2x = $(this).attr("src").replace("40x40", "80x80"); $(this).attr("srcset", url2x + " 2x") } }) } var isCategoryStatic = "undefined" != typeof isCategoryToggled ? isCategoryToggled : !1, templateHtml = '{{? it.children}}{{~it.children :value:index}} {{? index < 6}}{{?}} {{~}}{{?}}', templateCategory = doT.template(templateHtml); if ("undefined" == typeof categoryTree) return !1; if ($("#J_categoryContainer").find(".nav-category-list").html(templateCategory(categoryTree)), XIAOMI.app.analytics([$(".nav-category-content > a"), $(".nav-category-content .links").find("a"), $(".nav-category-content .children-list").find("a"), $(".nav-category-content .children-special-section").find("a")], { page: "分类导航", position: ["A", "B", "C", "D"], mstPage: "HP", mstArea: "PC", mstPosition: ["A", "B", "C", "D"], JQelement: !0, isMst: !0, BDurl: !1 }), addSrcset($(".nav-category-list")), isCategoryStatic) toggleCategoryList("static"); else { $categoryTriggerBtn.append(''); var timeoutCategory; $categoryContainer.on({ mouseenter: function () { window.clearTimeout(timeoutCategory), $(this).hasClass("nav-category-toggled") || (timeoutCategory = window.setTimeout(function () { toggleCategoryList("show") }, 200)) }, mouseleave: function () { window.clearTimeout(timeoutCategory), $(this).hasClass("nav-category-toggled") && (timeoutCategory = window.setTimeout(function () { toggleCategoryList("hide") }, 200)) } }) } bindChildrenList() } var $categoryContainer = $("#J_categoryContainer"), $categoryTriggerBtn = $categoryContainer.children(".btn-category-list"), $categoryList = $categoryContainer.children(".nav-category-section"); return { init: init } } (), XIAOMI.namespace("app.placeholder"), XIAOMI.app.placeholder = function (el, opt) { var defaults, options, elmPlaceholder, elm = $(el), isPlaceholderSupported = "placeholder" in document.createElement("input"); return 0 === elm.length ? elm : elm.length > 1 ? (elm.each(function () { XIAOMI.app.placeholder($(this), opt) }), this) : (defaults = { blurClass: "xm-ph-blur" }, options = $.extend({}, defaults, opt), elmPlaceholder = elm.attr("placeholder"), void (!isPlaceholderSupported && elmPlaceholder && (elm.is("textarea") ? "" === elm.html() && elm.addClass(options.blurClass).html(elmPlaceholder) : "" === elm.val() && elm.addClass(options.blurClass).val(elmPlaceholder), elm.on({ focus: function () { $(this).is("textarea") ? $(this).html() === elmPlaceholder && $(this).removeClass(options.blurClass).html("") : $(this).val() === elmPlaceholder && $(this).removeClass(options.blurClass).val("") }, blur: function () { $(this).is("textarea") ? "" === $(this).html() && $(this).addClass(options.blurClass).html(elmPlaceholder) : "" === $(this).val() && $(this).addClass(options.blurClass).val(elmPlaceholder) } })))) }, XIAOMI.namespace("app.carousel"), XIAOMI.app.carousel = function () { function init(elm, opt) { function slideList(targetPage) { var offsetX = "-" + targetPage * itemWidth * itemPerSlide + "px"; $list.animate({ "margin-left": offsetX }, options.speed), targetPage > 0 && countPage - 1 > targetPage ? ($btnPrev.removeClass("page-btn-prev-disabled"), $btnNext.removeClass("page-btn-next-disabled")) : 0 === targetPage ? ($btnPrev.addClass("page-btn-prev-disabled"), $btnNext.removeClass("page-btn-next-disabled")) : targetPage === countPage - 1 && ($btnPrev.removeClass("page-btn-prev-disabled"), $btnNext.addClass("page-btn-next-disabled")) } function autoPlay() { return 0 >= countPage ? !1 : void (timeoutAuto = setInterval(function () { curIndex += 1, curIndex > countPage - 1 && (curIndex = 0), slideList(curIndex) }, options.delay)) } var options, $listWrap, $list, $btnPrev, $btnNext, itemLength, itemWidth, itemHeight, itemPerSlide, countPage, timeoutAuto, $elm = $(elm), curIndex = 0; return 0 === $elm.length ? $elm : $elm.length > 1 ? ($elm.each(function () { init($(this), opt) }), this) : (options = $.extend({}, defaults, opt), $listWrap = $elm.find(options.listWrapSelector), $list = $listWrap.find(options.listSelector), $btnPrev = $elm.find(options.prevBtnSelector), $btnNext = $elm.find(options.nextBtnSelector), itemWidth = options.itemWidth || $list.children(options.itemSelector).outerWidth(), itemHeight = options.itemHeight || $list.children(options.itemSelector).outerHeight() - 1, itemLength = $list.children(options.itemSelector).length, itemPerSlide = 4 !== itemLength ? Math.ceil($listWrap.width() / itemWidth) : 4, countPage = Math.ceil(itemLength / itemPerSlide), 1 === countPage && ($btnPrev.hide(), $btnNext.hide()), $listWrap.css({ height: itemHeight }), $list.css({ width: itemWidth * itemLength, "margin-left": 0 }), $btnPrev.addClass("page-btn-prev-disabled"), 1 >= countPage && $btnNext.addClass("page-btn-next-disabled"), options.autoPlay && (autoPlay(), $elm.on({ mouseenter: function () { timeoutAuto && clearInterval(timeoutAuto) }, mouseleave: function () { autoPlay() } })), $btnPrev.off().on("click", function (e) { e.preventDefault(), $(this).hasClass("page-btn-prev-disabled") || (curIndex -= 1, 0 >= curIndex && (curIndex = 0, $(this).addClass("page-btn-prev-disabled")), $btnNext.removeClass("page-btn-next-disabled"), slideList(curIndex)) }), void $btnNext.off().on("click", function (e) { e.preventDefault(), $(this).hasClass("page-btn-next-disabled") || (curIndex += 1, curIndex > countPage - 1 && (curIndex = countPage - 1, $(this).addClass("page-btn-next-disabled")), $btnPrev.removeClass("page-btn-prev-disabled"), slideList(curIndex)) })) } var defaults; return defaults = { listWrapSelector: ".J_carouselWrap", listSelector: ".J_carouselList", itemSelector: "li", prevBtnSelector: ".J_carouselPrev", nextBtnSelector: ".J_carouselNext", itemWidth: null, itemHeight: null, autoPlay: !0, speed: 500, delay: 5e3 }, { init: init } } (), XIAOMI.namespace("app.search"), XIAOMI.app.search = { speed: 200, inputObj: null, keyword: null, init: function () { var timeoutFocus, _this = this, timeOut = null, $searchForm = $("#J_searchForm"), searchConfig = {}; _this.inputObj = $searchForm.find(".search-text"), _this.inputObj.data("search-config") && (searchConfig = $.parseJSON(_this.inputObj.data("search-config").replace(/'/g, '"'))), $searchForm.append($('')), _this.inputObj.on({ focus: function () { window.clearTimeout(timeoutFocus), $("#J_keywordList").css("opacity", 1), $searchForm.addClass("search-form-focus"), !$(this).val() && searchConfig.defaultWords && _this.formatData(searchConfig.defaultWords) }, blur: function () { $("#J_keywordList").css("opacity", 0), timeoutFocus = window.setTimeout(function () { $searchForm.removeClass("search-form-focus") }, 200) }, keyup: function (e) { $.trim($(this).val()).length <= 0 && searchConfig.defaultWords && (_this.keyword = null, _this.formatData(searchConfig.defaultWords)), _this.focusMove(e.which), clearTimeout(timeOut), 40 !== e.which && 38 !== e.which && (timeOut = setTimeout(function () { _this.keyword = _this.inputObj.val(), _this.getResult(_this.keyword) }, _this.speed)) } }), $searchForm.on("mouseenter", "#J_keywordList li", function () { $(this).addClass("current").siblings().removeClass("current") }), _this.submit() }, getResult: function (k) { var _this = this; k && $.ajax({ type: "GET", url: XIAOMI.GLOBAL_CONFIG.wwwSite + "/search/tips?keyword=" + encodeURIComponent(k), dataType: "jsonp", jsonp: "jsonpcallback", jsonpCallback: "xmsearch", cache: !0, success: function (data) { data.length > 0 ? _this.inputObj.val() && _this.formatData(data) : _this.removeList() } }) }, formatData: function (data) { for (var listHtml = "", i = 0, lens = data.length; lens > i; i += 1) { var keywordStr = data[i].replace(this.keyword, '' + this.keyword + " "); listHtml += '