123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- var domanUrl = "//" + window.location.host,
- path="//w.iamberry.com",
- base_path= path +"/wechat_rg/wechat";
- function errorfn(xhr) {
- if(xhr.readyState == 4 && xhr.status == 200) {} else {
- var ref = location.href.split("#")[0],
- src = '';
- if(ref.indexOf('?') != -1) {
- src = ref + "&date=" + new Date().getTime()
- } else {
- src = ref + "?date=" + new Date().getTime()
- }
- location.href = src;
- return
- }
- }
- function gotoTop(acceleration, stime) {
- acceleration = acceleration || 0.1;
- stime = stime || 10;
- var x1 = 0,
- y1 = 0,
- x2 = 0,
- y2 = 0,
- x3 = 0,
- y3 = 0;
- if(document.documentElement) {
- x1 = document.documentElement.scrollLeft || 0;
- y1 = document.documentElement.scrollTop || 0
- }
- if(document.body) {
- x2 = document.body.scrollLeft || 0;
- y2 = document.body.scrollTop || 0
- }
- var x3 = window.scrollX || 0;
- var y3 = window.scrollY || 0;
- var x = Math.max(x1, Math.max(x2, x3));
- var y = Math.max(y1, Math.max(y2, y3));
- var speeding = 1 + acceleration;
- window.scrollTo(Math.floor(x / speeding), Math.floor(y / speeding));
- if(x > 0 || y > 0) {
- var run = "gotoTop(" + acceleration + ", " + stime + ")";
- window.setTimeout(run, stime)
- }
- };
- function accDiv(arg1, arg2) {
- var t1 = 0,
- t2 = 0,
- r1, r2;
- try {
- t1 = arg1.toString().split(".")[1].length
- } catch(e) {}
- try {
- t2 = arg2.toString().split(".")[1].length
- } catch(e) {}
- with(Math) {
- r1 = Number(arg1.toString().replace(".", ""));
- r2 = Number(arg2.toString().replace(".", ""));
- return(r1 / r2) * pow(10, t2 - t1)
- }
- };
- Number.prototype.div = function(arg) {
- return accDiv(this, arg)
- };
- function accAdd(arg1, arg2) {
- var r1, r2, m, c;
- try {
- r1 = arg1.toString().split(".")[1].length
- } catch(e) {
- r1 = 0
- }
- try {
- r2 = arg2.toString().split(".")[1].length
- } catch(e) {
- r2 = 0
- }
- c = Math.abs(r1 - r2);
- m = Math.pow(10, Math.max(r1, r2));
- if(c > 0) {
- var cm = Math.pow(10, c);
- if(r1 > r2) {
- arg1 = Number(arg1.toString().replace(".", ""));
- arg2 = Number(arg2.toString().replace(".", "")) * cm
- } else {
- arg1 = Number(arg1.toString().replace(".", "")) * cm;
- arg2 = Number(arg2.toString().replace(".", ""))
- }
- } else {
- arg1 = Number(arg1.toString().replace(".", ""));
- arg2 = Number(arg2.toString().replace(".", ""))
- }
- return(arg1 + arg2) / m
- };
- Number.prototype.add = function(arg) {
- return accAdd(arg, this)
- };
- function accSub(arg1, arg2) {
- var r1, r2, m, n;
- try {
- r1 = arg1.toString().split(".")[1].length
- } catch(e) {
- r1 = 0
- }
- try {
- r2 = arg2.toString().split(".")[1].length
- } catch(e) {
- r2 = 0
- }
- m = Math.pow(10, Math.max(r1, r2));
- n = (r1 >= r2) ? r1 : r2;
- return((arg1 * m - arg2 * m) / m).toFixed(n)
- };
- Number.prototype.sub = function(arg) {
- return accMul(arg, this)
- };
- function accMul(arg1, arg2) {
- var m = 0,
- s1 = arg1.toString(),
- s2 = arg2.toString();
- try {
- m += s1.split(".")[1].length
- } catch(e) {}
- try {
- m += s2.split(".")[1].length
- } catch(e) {}
- return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m)
- };
- Number.prototype.mul = function(arg) {
- return accMul(arg, this)
- };
- function getParam(paramName) {
- paramValue = "", isFound = !1;
- if(this.location.search.indexOf("?") == 0 && this.location.search.indexOf("=") > 1) {
- arrSource = unescape(this.location.search).substring(1, this.location.search.length).split("&"), i = 0;
- while(i < arrSource.length && !isFound) {
- arrSource[i].indexOf("=") > 0 && arrSource[i].split("=")[0].toLowerCase() == paramName.toLowerCase() && (paramValue = arrSource[i].split("=")[1], isFound = !0), i++
- }
- }
- return paramValue == "" && (paramValue = null), paramValue
- };
- function dc(objectid) {
- if(document.getElementById && document.getElementById(objectid)) {
- return document.getElementById(objectid)
- } else if(document.all && document.all(objectid)) {
- return document.all(objectid)
- } else if(document.layers && document.layers[objectid]) {
- return document.layers[objectid]
- } else {
- return false
- }
- };
- function formatDate(now) {
- now = new Date(now);
- var year = now.getFullYear();
- var month = now.getMonth() + 1;
- var date = now.getDate();
- var hour = now.getHours();
- var minute = now.getMinutes();
- var second = now.getSeconds();
- return year + "-" + month + "-" + date + " " + hour + ":" + minute + ":" + second
- };
- function springFestivalPop() {
- if(getCookie("WATERO_WEB_") == null) {
- maskspringFestival.show();
- $(".mui-backdrop").append('<div style="position:relative;"><img src="//s.iamberry.com/watero/images/shop/springFestival_2017.png" style="width:80%;margin:10% 10% auto 10%;"/><button type="button" id="close-springFestival" class="mui-btn my-btn-red" style="position: absolute;bottom: 5%;left: 50%;-webkit-transform: translateX(-50%)">我知道了</button></div>');
- mui('body').on('tap', '#close-springFestival', function(e) {
- setCookie();
- $(".mui-backdrop").hide();
- });
- }
- };
- function getCookie(name) {
- var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
- if(arr = document.cookie.match(reg))
- return unescape(arr[2]);
- else
- return null;
- };
- var maskspringFestival = mui.createMask(function() {
- return false;
- }); //callback为用户点击蒙版时自动执行的回调;
- function setCookie() {
- var Days = 30;
- var exp = new Date();
- exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
- document.cookie = "WATERO_WEB_=OK;Path=/;expires=" + exp.toGMTString();
- };
- /**
- * 该方法用于将Undefined转换为空值
- * @param val
- */
- function convertUndefinedToEmpty(val) {
- if (undefined == val || null == val||typeof val == undefined || typeof val == 'undefined'|| 'undefined' == val) {
- val = "";
- }
- return val;
- }
- /**
- * 该方法用于将Undefined转换为空值
- * @param val
- */
- function cufte(val) {
- return convertUndefinedToEmpty(val);
- }
- /**
- * 空值返回0,其他值返回原值
- * @param val
- */
- function cufteInt(val) {
- if(convertUndefinedToEmpty(val) == "")
- return 0;
- return val;
- }
- /**
- * 空值返回false
- * @param val
- */
- function isEmpty(val) {
- if(convertUndefinedToEmpty(val) == "")
- return false;
- return true;
- }
|