common_math.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  1. /**
  2. * Created by lizhenya on 2018/5/19.
  3. */
  4. function openCart() {
  5. var t = $(window).width();
  6. 0 == $(".shopping_all").length ? t > 768 ? $("#shop_cart").animate({
  7. right: 35
  8. }, 300) : $("#shop_cart").animate({
  9. right: 0
  10. }, 300) : t > 980 ? $("#shop_cart").animate({
  11. right: 35
  12. }, 300) : $("#shop_cart").animate({
  13. right: 0
  14. }, 300),
  15. $(".compare_btn").hasClass("open") && closeCompare(),
  16. $(".shop_cart").addClass("bg")
  17. }
  18. function openBar() {
  19. toolbar.hasClass("open") || (toolbar.addClass("open"),
  20. $("#shop_cart .lazyload").removeClass("hidden").find("img").trigger("appear"),
  21. $(".global_toolbar").removeClass("default"),
  22. $(".toolbar_btn").css({
  23. top: "50%",
  24. marginTop: -$(".toolbar_btn").height() / 2
  25. })),
  26. $(".global_toolbar").removeClass("opacity"),
  27. $(".toolbar_btn").removeClass("default")
  28. }
  29. function closeBar() {
  30. $(".toolbar_btn a").removeClass("current"),
  31. toolbar.removeClass("open"),
  32. $(".toolbar_btn").removeClass("default")
  33. }
  34. function openCartMeiu() {
  35. var t = $(window).width();
  36. $(".bar_cart").hasClass("current") || $(".bar_cart").addClass("current").siblings("a").removeClass("current"),
  37. $(".global_toolbar").hasClass("open") ? closeBar() : openBar(),
  38. t > 768 ? $(".bar_cart").hasClass("current") || $(".bar_cart").trigger("click") : openBar()
  39. }
  40. function isChecked() {
  41. $("#shop_cart .go_btn").removeClass("disable"),
  42. $("#shop_cart .go_btn").attr("href", $("#shop_cart .go_btn").attr("data-url"));
  43. for (var t = "", e = document.getElementsByName("checkbox_c_Name"), i = 0; i < e.length; i++) {
  44. var r = $(e[i]).attr("data-url");
  45. if (1 == e[i].checked) {
  46. if ("undefined" != r) {
  47. var n = r.split("|")
  48. , o = $(e[i]).siblings(".amount_btn").find("input").val();
  49. t += "" != t ? "|" + n[1] + "," + o + "," + n[0] + ",1" : n[1] + "," + o + "," + n[0] + ",1"
  50. }
  51. } else if ("undefined" != r) {
  52. var n = r.split("|")
  53. , o = $(e[i]).siblings(".amount_btn").find("input").val();
  54. t += "" != t ? "|" + n[1] + "," + o + "," + n[0] + ",0" : n[1] + "," + o + "," + n[0] + ",0"
  55. }
  56. }
  57. var s = $("#vHidelink").val() + encodeURIComponent($("#vHideToken").val());
  58. s = (s = (s = s.replace("en-GB", "uk")).replace("ru-RU", "ru")).replace("test120.huawei.com/zh", "test120.huawei.com/zh/EBG/Home").replace("test120.huawei.com/cn", "test120.huawei.com/zh/EBG/Home");
  59. var a = {
  60. type: 23,
  61. vgUserId: $("#hidevUserName").val(),
  62. UpdateString: t
  63. };
  64. $.ajax({
  65. url: s,
  66. type: "POST",
  67. data: a,
  68. success: function(t) {},
  69. error: function(t) {}
  70. }),
  71. CheckedAll()
  72. }
  73. function BindFCPwdHref() {
  74. var t = $("#aForgotPassword").attr("href")
  75. , e = $("#aChangePassword").attr("href");
  76. try {
  77. var i = GetQueryString("redirect");
  78. if (IsEmpty(i)) {
  79. var r = getLanguages()
  80. , n = "http://" + window.location.host + "/" + r;
  81. $("#aForgotPassword").attr("href", t + n),
  82. $("#aChangePassword").attr("href", e + n)
  83. } else {
  84. var o = decodeURI(i);
  85. o = o.replace("+", " ").replace("+", " ").replace("+", " ").replace("+", " ").replace("+", " ").replace("+", " ").replace("+", " ").replace("+", " "),
  86. $("#aForgotPassword").attr("href", t + o),
  87. $("#aChangePassword").attr("href", e + o)
  88. }
  89. } catch (s) {}
  90. }
  91. var toolbar = $(".global_toolbar");
  92. $(function() {
  93. $("#wap_cartbtn_display").addClass("none");
  94. var t = $(window).height();
  95. $(window).width();
  96. setTimeout(function() {
  97. //BindDataTableAll()
  98. }, 5e3),
  99. $("body").click(function(t) {
  100. toolbar.hasClass("open") && closeBar()
  101. }),
  102. toolbar.click(function(t) {
  103. t.stopPropagation()
  104. }),
  105. $(".go_compare").click(function(t) {
  106. t.stopPropagation(),
  107. gpXlItemId = $("#hideItemId").val(),
  108. $(".m-pic_details.show").length > 3 ? $("#popup_full").fadeIn(300) : (LoadCompareAll(),
  109. joinCompareOne(this),
  110. $(".m-pic_details.show").length < 2 ? $(".m-compared .m-con .m-list .m-btn .m-db").removeClass("off") : $(".m-compared .m-con .m-list .m-btn .m-db").addClass("off"),
  111. $(".m-compared .m-con .m-list .m-btn .m-del").removeClass("delete"))
  112. }),
  113. $("#popup_full .solid_btn").click(function() {
  114. $("#popup_full").fadeOut(300)
  115. }),
  116. $("#compare_column").find(".m-db").click(function() {
  117. if ($(this).hasClass("off")) {
  118. var t = $("#hideCompareList").val()
  119. , e = $("#hideItemId").val()
  120. , i = $(this).attr("data-url")
  121. , r = "";
  122. r = (r = (r = (r = "?" == /\?/.exec(i) ? i + "&hideCompareList=" + t + e + "|" : i + "?hideCompareList=" + t + e + "|").replace("en-GB", "uk")).replace("ru-RU", "ru")).replace("test120.huawei.com/zh", "test120.huawei.com/zh/EBG/Home").replace("test120.huawei.com/cn", "test120.huawei.com/zh/EBG/Home"),
  123. window.open(r)
  124. }
  125. }),
  126. $(".select_all").click(function() {
  127. $("input.checkbox_c").prop("checked", $(this).prop("checked")),
  128. countAll()
  129. }),
  130. $(".select_all").bind("click", isChecked);
  131. $(window).width();
  132. $("#shop_cart h4 a").click(function() {
  133. closeCart(),
  134. closeCompare()
  135. }),
  136. $("#shop_cart").find(".go_btn").click(function() {
  137. if ($(this).hasClass("disable"))
  138. return !1;
  139. AllUpdateOrderShoppingCar()
  140. }),
  141. $(window).resize(function() {
  142. autoShopcartH()
  143. }),
  144. $(".compare_table tr:odd").addClass("gray_bg"),
  145. $(".compare_table tr td:last-child").addClass("last");
  146. var e;
  147. e = /MSIE /i.test(navigator.userAgent) ? 565 : 625,
  148. $("#choose_products li").click(function() {
  149. $(this).addClass("current").siblings("li").removeClass("current"),
  150. $(this).find("dl").each(function() {
  151. $(this).find("dd span:even").each(function() {
  152. var t = 0
  153. , e = $(this).outerHeight(!0)
  154. , i = $(this).next("span").outerHeight(!0);
  155. t = e >= i ? e : i,
  156. $(this).height(t),
  157. $(this).next("span").height(t)
  158. })
  159. });
  160. var t = 0
  161. , i = 60
  162. , r = $("#productBox").height();
  163. $(this).find("dl").each(function() {
  164. i += $(this).outerHeight(!0)
  165. }),
  166. i > e && i > r ? $(".choose_products").height(i) : $(".choose_products").height("auto");
  167. var n = $(document).scrollTop()
  168. , o = $("#choose_products").offset().top - $("#nav-cont.fix .nav-list").height()
  169. , s = $("#choose_products ul").offset().top;
  170. if (n >= o) {
  171. var a = (n = $(document).scrollTop()) - s + $("#nav-cont.fix .nav-list").height();
  172. $(this).find(".item_layer").css({
  173. top: a
  174. });
  175. var c = (t = a > 0 ? a : 0) + $("#pc_sidebar h3").height();
  176. if (i + c < e) {
  177. var h = $("#pc_sidebar").height() - c;
  178. $(this).find(".item_layer").css({
  179. "min-height": h
  180. })
  181. } else
  182. $(this).find(".item_layer").css({
  183. height: i
  184. }),
  185. $(".choose_products").height(i + t + 50)
  186. } else
  187. $(this).find(".item_layer").css({
  188. top: -50
  189. }),
  190. $(this).find(".item_layer").css({
  191. "min-height": e
  192. })
  193. }),
  194. $(".item_layer dd span a").click(function(t) {
  195. t.stopPropagation(),
  196. $("#choosen_tips").show(),
  197. $(".product_series .picbox font").hide(),
  198. $(this).parents(".item_layer").parent("li").removeClass("current"),
  199. $(".choose_products").height("auto")
  200. }),
  201. $(".r_item dd a").click(function() {
  202. $("#choosen_tips").show(),
  203. $(".product_series .picbox font").hide(),
  204. $(this).parents(".fixed_sidebar").hide()
  205. });
  206. var i = t - $(".fixed_sidebar h1").outerHeight(!0);
  207. $(".l_sidebar,.r_item").height(i),
  208. $(".l_sidebar li").click(function() {
  209. $(this).addClass("current").siblings("li").removeClass("current");
  210. var t = $(this).index();
  211. $(".item_wrap").eq(t).removeClass("none").siblings(".item_wrap").addClass("none")
  212. }),
  213. $(".wap_pro_sidebar").click(function() {
  214. $(".fixed_sidebar").fadeIn()
  215. }),
  216. $(".fixed_sidebar h1 a").click(function() {
  217. $(this).parents(".fixed_sidebar").fadeOut()
  218. }),
  219. $("body").click(function() {
  220. $("#pc_sidebar li").removeClass("current")
  221. }),
  222. $("#pc_sidebar,.item_layer").click(function(t) {
  223. t.stopPropagation()
  224. }),
  225. $(".toolbar_btn a:not('.bar_forum')").bind("click", function(t) {
  226. t.stopPropagation();
  227. var e = $(this).attr("data-id")
  228. , i = $("." + e);
  229. $(this).hasClass("current") ? $(this).removeClass("current") : $(this).addClass("current").siblings("a").removeClass("current"),
  230. i.hasClass("open") ? closeBar() : openBar()
  231. }),
  232. $(".wap_cartbtn").bind("click", function(t) {
  233. t.stopPropagation(),
  234. autoShopcartH(),
  235. $(this).hasClass("disable") || ($(".global_toolbar").hasClass("open") ? closeBar() : openBar())
  236. }),
  237. $(".js_column h4 a").click(function() {
  238. closeBar()
  239. })
  240. });
  241. var gpXlItemId = ""
  242. , winH = $(window).height()
  243. , compared_h = 0;
  244. $(window).load(function() {
  245. $(".js-m-compared .js-m-list").each(function() {
  246. var t = $(this).outerHeight();
  247. compared_h > t || (compared_h = t)
  248. }),
  249. $(".js-m-compared .js-m-list").outerHeight(compared_h),
  250. $(".js-m-compared").css("bottom", -compared_h - 200),
  251. $(".arrow-off").on("click", function() {
  252. var t = $(this);
  253. t.hasClass("active") ? (t.css("background", "url(/Assets/EBG/img/arrow-top.jpg) no-repeat center center"),
  254. t.removeClass("active"),
  255. $(".js-m-compared").removeClass("active").animate({
  256. bottom: -compared_h
  257. })) : (t.css("background", "url(/Assets/EBG/img/arrow-bottom.jpg) no-repeat center center"),
  258. t.addClass("active"),
  259. $(".js-m-compared").addClass("active").animate({
  260. bottom: 0
  261. }))
  262. }),
  263. $(".m-btn a.m-del").on("click", function() {
  264. gpXlItemId = "",
  265. $("#hideCompareNow").val("");
  266. for (var t = $("#hideCompareList").val().split("|"), e = 0; e < t.length - 1; e++) {
  267. var i = $(".m-bomb_box-block a[data-id='" + t[e] + "']")
  268. , r = i.attr("data-name");
  269. i.html(r),
  270. i.removeClass("disable")
  271. }
  272. $("#hideCompareList").val(""),
  273. $(".js-m-pic_details").css("display", "none").removeClass("show"),
  274. $(".js-m-list-ul").css("display", "block"),
  275. $(".m-pic_details.show").length < 2 ? $(".m-compared .m-con .m-list .m-btn .m-db").removeClass("off") : $(".m-compared .m-con .m-list .m-btn .m-db").addClass("off"),
  276. $(".m-compared .m-con .m-list .m-btn .m-del").addClass("delete")
  277. }),
  278. $("#shoppingCart").on("click", function() {
  279. var t = (new Date).getTime();
  280. hwaTrackEventClick($("#gLanguageCurrent").val() + "购物车按钮", "购物车按钮", "购物车按钮", "购物车按钮", t)
  281. })
  282. }),
  283. $(function() {
  284. BindFCPwdHref(),
  285. $(".close_popup").off().click(function() {
  286. $(this).parents(".popup_login").off().fadeOut(300),
  287. partnerRefresh = !1,
  288. $(window).width() < 750 && $("html,body").removeClass("position-fix").scrollTop($(".popup_login").attr("top"))
  289. }),
  290. "placeholder"in document.createElement("input") || $(".login_form input[placeholder]").each(function() {
  291. var t = $(this)
  292. , e = t.attr("placeholder");
  293. if ("password" != t.attr("type"))
  294. "" === t.val() && (t.val(e).addClass("placeholder"),
  295. t.css("color", "#aaa")),
  296. t.focus(function() {
  297. t.val() === e && (t.val("").removeClass("placeholder"),
  298. t.css("color", "#333"))
  299. }).blur(function() {
  300. "" === t.val() ? (t.val(e).addClass("placeholder"),
  301. t.css("color", "#aaa")) : t.val() == e ? t.css("color", "#aaa") : t.css("color", "#333")
  302. }).closest("form").submit(function() {
  303. t.val() === e && t.val("")
  304. });
  305. else {
  306. if (e) {
  307. var i = t.attr("id");
  308. if (!i) {
  309. var r = new Date;
  310. i = "lbl_placeholder" + r.getSeconds() + r.getMilliseconds(),
  311. t.attr("id", i)
  312. }
  313. }
  314. var n = $("<label>", {
  315. html: t.val() ? "" : e,
  316. "for": i,
  317. css: {
  318. position: "absolute",
  319. cursor: "text",
  320. color: "#aaaaaa",
  321. fontSize: t.css("fontSize"),
  322. fontFamily: t.css("fontFamily")
  323. }
  324. }).insertAfter(t)
  325. , o = function() {
  326. n.css({
  327. left: "60px",
  328. top: "10px"
  329. })
  330. };
  331. o(),
  332. t.on("focus blur input keyup propertychange resetplaceholder", function() {
  333. t.val() ? n.html(null) : (o(),
  334. n.html(e))
  335. })
  336. }
  337. }),
  338. $("#btnLoginpopup").unbind("click").click(function() {
  339. if (IsEmpty($("#userNamepopup").val()))
  340. $(".tips_error").html($("#userNamepopupErrMsg").val());
  341. else if (IsEmpty($("#pwdpopup").val()))
  342. $(".tips_error").html($("#passwordpopupErrMsg").val());
  343. else {
  344. $(".tips_error").empty();
  345. var t = $("#userNamepopup").val()
  346. , e = $("#pwdpopup").val()
  347. , i = new JSEncrypt;
  348. i.setPublicKey("MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCyCe6E+MNQHc0XM9M5kpe7a5DzjVbZ/hLXTMLyrqphdRhnQ5EUqyMC80c5LS2MN4SXzC4IIrMxvEbYNKgql7HxSvjYuqAAI/cw0kMm9Gy2ekYsn4UfwXlqgHC+155pnn5damCbm8iXxS/TpeIoKw4W+TVpboYXPey82Be3hWSBHQIDAQAB"),
  349. e = i.encrypt(e);
  350. var r = $("#HidPostLoginUrl").val()
  351. , n = {
  352. userName: t,
  353. pwd: e,
  354. languages: $("#gLanguageCurrent").val(),
  355. fromsite: location.host,
  356. authMethod: "password"
  357. };
  358. try {
  359. $.ajax({
  360. url: r,
  361. data: n,
  362. type: "POST",
  363. dataType: "jsonp",
  364. data: n,
  365. cache: !1,
  366. async: !1,
  367. jsonp: "jsonpCallback"
  368. })
  369. } catch (o) {
  370. return !1
  371. }
  372. }
  373. }),
  374. $(document).on("keydown", ".login_form", function(t) {
  375. if (13 == t.keyCode)
  376. return $("#btnLoginpopup").trigger("click"),
  377. !1
  378. })
  379. });
  380. var partnerRefresh = !1;
  381. $("#pwdpopup").keydown(function(t) {
  382. t.keyCode,
  383. $(".tips_error").html("")
  384. });
  385. var popupcountdown = 300
  386. , timerNew = null;
  387. $("#btn_popup_login").unbind("click").click(function() {
  388. $(".popup_login").css("display", "block"),
  389. $("#userNamepopup").attr("placeholder") != $("#userNamepopup").val() && $("#userNamepopup").val(""),
  390. $("#pwdpopup").val("")
  391. });
  392. var JSEncryptExports = {};
  393. //数量加减
  394. (function($) {
  395. $.fn.spinner = function(opts) {
  396. return this.each(function() {
  397. var defaults = {
  398. value: 1,
  399. min: 1
  400. }
  401. var options = $.extend(defaults, opts)
  402. var keyCodes = {
  403. up: 38,
  404. down: 40
  405. }
  406. var container = $('<div></div>')
  407. container.addClass('spinner')
  408. var textField = $(this).addClass('value').attr('maxlength', '2').val(options.value).bind('keyup paste change', function(e) {
  409. var field = $(this)
  410. if (e.keyCode == keyCodes.up)
  411. changeValue(1)
  412. else if (e.keyCode == keyCodes.down)
  413. changeValue(-1)
  414. else if (getValue(field) != container.data('lastValidValue'))
  415. validateAndTrigger(field)
  416. })
  417. textField.wrap(container)
  418. var increaseButton = $('<button class="increase">+</button>').click(function() {
  419. changeValue(1)
  420. })
  421. var decreaseButton = $('<button class="decrease">-</button>').click(function() {
  422. changeValue(-1)
  423. })
  424. validate(textField)
  425. container.data('lastValidValue', options.value)
  426. textField.before(decreaseButton)
  427. textField.after(increaseButton)
  428. function changeValue(delta) {
  429. textField.val(getValue() + delta)
  430. validateAndTrigger(textField)
  431. }
  432. function validateAndTrigger(field) {
  433. clearTimeout(container.data('timeout'))
  434. var value = validate(field)
  435. if (!isInvalid(value)) {
  436. textField.trigger('update', [field, value])
  437. }
  438. }
  439. function validate(field) {
  440. var value = getValue()
  441. if (value <= options.min)
  442. decreaseButton.attr('disabled', 'disabled')
  443. else
  444. decreaseButton.removeAttr('disabled')
  445. field.toggleClass('invalid', isInvalid(value)).toggleClass('passive', value === 0)
  446. if (isInvalid(value)) {
  447. var timeout = setTimeout(function() {
  448. textField.val(container.data('lastValidValue'))
  449. validate(field)
  450. }, 500)
  451. container.data('timeout', timeout)
  452. } else {
  453. container.data('lastValidValue', value)
  454. }
  455. return value
  456. }
  457. function isInvalid(value) {
  458. return isNaN(+value) || value < options.min;
  459. }
  460. function getValue(field) {
  461. field = field || textField;
  462. return parseInt(field.val() || 0, 10)
  463. }
  464. })
  465. }
  466. ;
  467. $('.spinnerExample').spinner({});
  468. }
  469. )(jQuery)
  470. function openContact() {
  471. "ar-sa" == $("#gLanguageCurrent").val() ? ($(".contact_btn").addClass("open"),
  472. $(".contact_btn b").show(),
  473. $(".contact_layer").animate({
  474. left: 35
  475. }, 330)) : ($(".contact_layer").css({
  476. "margin-top": $(".contact_btn").css("margin-top")
  477. }),
  478. $(".contact_layer").animate({
  479. right: 35
  480. }, 300),
  481. $(".contact_btn").addClass("open"),
  482. $(".contact_btn b").show(),
  483. closeCompare(),
  484. closeCart())
  485. }
  486. function closeContact() {
  487. "ar-sa" == $("#gLanguageCurrent").val() ? ($(".contact_btn").removeClass("open"),
  488. $(".contact_btn b").hide(),
  489. $(".contact_layer").animate({
  490. left: -250
  491. })) : ($(".contact_layer").animate({
  492. right: -250
  493. }, 300),
  494. $(".contact_btn").removeClass("open"),
  495. $(".contact_btn b").hide())
  496. }
  497. function closeCompare() {
  498. var e = $("#compare_column");
  499. winW > 768 ? e.animate({
  500. right: -335
  501. }, 300) : e.animate({
  502. right: "-100%"
  503. }, 300),
  504. $(".compare_btn b").hide(),
  505. $(".compare_btn").removeClass("open")
  506. }
  507. function closeCart() {
  508. 0 == $(".shopping_all").length ? winW > 768 ? $("#shopping_cart").animate({
  509. right: -335
  510. }, 300) : $("#shopping_cart").animate({
  511. right: "-100%"
  512. }, 300) : winW > 980 ? $("#shopping_cart").animate({
  513. right: -335
  514. }, 300) : $("#shopping_cart").animate({
  515. right: "-100%"
  516. }, 300),
  517. $(".shopping_cart").removeClass("bg"),
  518. $(".shopping_btn b").hide(),
  519. $(".shopping_btn").removeClass("open")
  520. }
  521. var winW = $(window).width()
  522. , hwa_DisablHwa = "" != document.domain || "1" == $("#hidDisableHwa").val() || navigator.userAgent.match(/AppleWebKit.*Mobile.*/) || navigator.userAgent.indexOf("iPad") > -1;
  523. !hwa_DisablHwa && checkDomain(),
  524. $(function() {
  525. // get_FeedBack_Url()
  526. })