{"version":3,"file":"/m/all/js/libs/Util.js.map","sources":["/m/all/js/libs/Util.js"],"sourcesContent":["\r\n var system ={}; \r\n var p = navigator.platform; \r\n system.win = p.indexOf(\"Win\") == 0; \r\n system.mac = p.indexOf(\"Mac\") == 0; \r\n system.x11 = (p == \"X11\") || (p.indexOf(\"Linux\") == 0); \r\n var ua = window.navigator.userAgent.toLowerCase(); \r\n var osChannel = $.osChannel(); \r\n var locatPath = window.location.pathname.toLowerCase();\r\n \r\n\r\n if(system.win||system.mac||system.xll){\r\n //pc\r\n }else{ \r\n\r\n if(osChannel==\"android_browser\" || osChannel==\"ios_browser\" || ua.match(/MicroMessenger/i) == 'micromessenger'){\r\n var cookdown = $.getCookie(\"downApp\");\r\n if(cookdown ==\"closed\"){\r\n if(locatPath == \"/h5/goods/list/index.html\"){\r\n $(\".page-prdlist\").css(\"top\",\"0\")\r\n }\r\n $(\".downArea\").hide();\r\n }else{\r\n\r\n if(locatPath == \"/h5/goods/list/index.html\"){\r\n $(\".page-prdlist\").css(\"top\",\"3rem\")\r\n }\r\n $(\".downArea\").show();\r\n }\r\n \r\n }else{\r\n if(locatPath == \"/h5/goods/list/index.html\"){\r\n $(\".page-prdlist\").css(\"top\",\"0\")\r\n }\r\n $(\".downArea\").hide();\r\n }\r\n }\r\n if(ua.match(/MicroMessenger/i) == 'micromessenger'){\r\n //微信环境下,根据cookie判断下载引导图是否打开\r\n var cookwx = $.getCookie(\"wxApp\");\r\n if(cookwx ==\"wxclose\"){\r\n $(\".pop-share\").hide();\r\n }else{\r\n $(\".pop-share\").show();\r\n }\r\n }\r\n\r\n$('.pop-share .mask').click(function(event) {\r\n $.setCookie(\"wxApp\",\"wxclose\");\r\n $(\".pop-share\").hide();\r\n});\r\n\r\n$('.downArea .openDown').click(function(event) {\r\n //判断如果是微信环境,微信中无法打开立即下载,弹出引导提示图\r\n if(ua.match(/MicroMessenger/i) == 'micromessenger'){\r\n $(\".pop-share\").show();\r\n return;\r\n }\r\n var startTime = new Date()\r\n if(osChannel==\"android_browser\"){\r\n location.href = \"gmm://\"\r\n setTimeout(function(){\r\n var stopTime = new Date()\r\n if(stopTime - startTime< 1100){ \r\n location.href = \"https://a.gmm01.com/ud_android_def\"\r\n } \r\n },1000)\r\n \r\n \r\n }else if(osChannel==\"ios_browser\"){\r\n location.href = \"gmmchatios://\"\r\n setTimeout(function(){\r\n var stopTime = new Date()\r\n if(stopTime - startTime< 200){ \r\n location.href = \"https://a.gmm01.com/ud_ios_def\"\r\n } \r\n },100)\r\n }\r\n\r\n \r\n});\r\n\r\n\r\n\r\n\r\n$('.downArea .detClose').click(function(event) {\r\n $(this).parent(\".downArea\").hide();\r\n if(locatPath == \"/h5/goods/list/index.html\" || locatPath == \"/h5/goods/detail/index.html\"){\r\n $(\".page-prdlist\").css(\"top\",\"0\")\r\n }\r\n $.setCookie(\"downApp\",\"closed\");\r\n});\r\n\r\n\r\n\r\n\r\n\r\nDate.prototype.format = function (fmt) { //author: meizz\r\n var o = {\r\n \"M+\": this.getMonth() + 1, //月份\r\n \"d+\": this.getDate(), //日\r\n \"h+\": this.getHours(), //小时\r\n \"m+\": this.getMinutes(), //分\r\n \"s+\": this.getSeconds(), //秒\r\n \"q+\": Math.floor((this.getMonth() + 3) / 3), //季度\r\n \"S\": this.getMilliseconds() //毫秒\r\n };\r\n if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + \"\").substr(4 - RegExp.$1.length));\r\n for (var k in o)\r\n if (new RegExp(\"(\" + k + \")\").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : ((\"00\" + o[k]).substr((\"\" + o[k]).length)));\r\n return fmt;\r\n}\r\n\r\n\r\nString.prototype.trim=function(){ \r\nreturn this.replace(/(^\\s*)|(\\s*$)/g, \"\"); \r\n} \r\n\r\n$.iGetInnerText =function(testStr){\r\n var resultStr = testStr.replace(/\\ +/g, \"\"); //去掉空格\r\n resultStr = testStr.replace(/[ ]/g, \"\"); //去掉空格\r\n resultStr = testStr.replace(/[\\r\\n]/g, \"\"); //去掉回车换行\r\n return resultStr;\r\n}\r\n\r\n$.urlParam = function(name) {\r\n var results = new RegExp('[\\\\?&]' + name + '=([^]*)').exec(window.location.href);\r\n if(!results) return 0;\r\n return results[1] || 0;\r\n};\r\n$.urlParamName = function(paramName) {\r\n var result = location.search.match(new RegExp(\"[\\?\\&]\" + paramName + \"=([^\\&]+)\", \"i\"));\r\n if (result == null || result.length < 1) {\r\n return \"\";\r\n }\r\n return result[1];\r\n};\r\n\r\nvar record={num:\"\"};\r\n//校验价格格式\r\n$.checkPrice=function( nowPrice){\r\n var pricelReg=/^\\d{1,7}\\.{0,1}\\d{0,2}$/;\r\n var caseprice=nowPrice.val();\r\n if(caseprice> 9999999){\r\n nowPrice.val(9999999);\r\n $.toast(\"价格输入过大!\");\r\n }\r\n if (nowPrice.val()!=\"\" && pricelReg.test(nowPrice.val())){\r\n record.num=\"\"\r\n record.num=nowPrice.val();\r\n return true;\r\n }else {\r\n if(nowPrice.val()!=\"\"){\r\n nowPrice.val(record.num);\r\n /// $.toast(\"价格格式输入错误!\");\r\n return false;\r\n }else{\r\n record.num=\"\"\r\n return false;\r\n }\r\n }\r\n\r\n}\r\n\r\nvar amount={num:\"\"};\r\n//校验数量格式\r\n$.checkAmount=function( nowAmount){\r\n var pricelReg=/^\\d{1,7}\\.{0,1}\\d{0,2}$/;\r\n // var pricelReg=/[^\\d.]/g;\r\n var caseprice=nowAmount.val();\r\n if(caseprice> 9999999){\r\n nowAmount.val(9999999);\r\n $.toast(\"数量输入过大!\");\r\n }\r\n \r\n if (nowAmount.val()!=\"\" && pricelReg.test(nowAmount.val())){\r\n amount.num=\"\"\r\n amount.num=nowAmount.val();\r\n return true;\r\n }else {\r\n if(nowAmount.val()!=\"\"){\r\n nowAmount.val(amount.num);\r\n /// $.toast(\"价格格式输入错误!\");\r\n return false;\r\n }else{\r\n amount.num=\"\"\r\n return false;\r\n }\r\n }\r\n}\r\n$.checkPrice=function(nowAmount,hasLengthLimit){\r\n var caseprice=nowAmount.val();\r\n if(caseprice> 9999999){\r\n nowAmount.val(9999999);\r\n $.toast(\"数量或金额输入过大!\");\r\n }\r\n nowAmount.val(caseprice.replace(/[^\\d.]/g,'').replace(/^\\./g,'').replace(\".\",\"$#$\").replace(/\\./g,\"\").replace(\"$#$\",\".\").replace(/^(\\-)*(\\d+)\\.(\\d\\d).*$/,'$1$2.$3'))\r\n //只允许正数和小数\r\n //第一个字符只能是数字\r\n //只能输入一个小数点\r\n //小数点后最多输入两位小数\r\n}\r\n$.checkNum=function(nowAmount,hasLengthLimit){\r\n var caseprice=nowAmount.val();\r\n nowAmount.val(caseprice.replace(/[^\\d.]/g,'').replace(/^\\./g,'').replace(\".\",\"$#$\").replace(/\\./g,\"\").replace(\"$#$\",\".\").replace(/^(\\-)*(\\d+)\\.(\\d\\d).*$/,'$1$2.$3'))\r\n //只允许正数和小数\r\n //第一个字符只能是数字\r\n //只能输入一个小数点\r\n //小数点后最多输入两位小数\r\n}\r\nvar Util = \r\n{\r\n\t\t//G买卖web版本src_code\r\n\t\tSRC_CODE:11,\r\n\t\t//检测当前浏览器是否是ie\r\n\t\tisIE:function ()\r\n\t\t{\r\n\t\t\tvar agent = navigator.userAgent.toLowerCase();\r\n\t\t return /msie/.test(agent); \r\n\t\t},\r\n\t\t//自定义弹框,显示信息or错误\r\n\t\talert:function(content,title){\r\n\t\t\tif($(\"#div_tempmessage\").html()){\r\n\t\t\t\t//弹框存在时,不能多次弹\r\n\t\t\t}\r\n\t\t\telse{\r\n\t\t\t\tvar html = \"\";\r\n\t\t\t\tif(!title){\r\n\t\t\t\t\ttitle = \"错误!\"\r\n\t\t\t\t\thtml = \"
\";\t\t\r\n\t\t\t\t}\r\n\t\t\t\telse{\r\n\t\t\t\t\thtml = \"\";\r\n\t\t\t\t} \r\n\t\t\t\t$(\"body\").append(html);\r\n\t\t\t}\r\n\t\t},\r\n\t\t//关闭弹框\r\n\t\tdestroy:function(e){\r\n\t\t\t$('#div_tempmessage').remove();\r\n $(\".wrapBg\").hide();\r\n\t\t},\r\n//计算时间\r\n formatDuring:function(mss){\r\n var days = Math.floor(mss / (1000 * 60 * 60 * 24));\r\n var hours = Math.floor((mss % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));\r\n var minutes = Math.floor((mss % (1000 * 60 * 60)) / (1000 * 60));\r\n var seconds = Math.floor((mss % (1000 * 60)) / 1000);\r\n if(days>0){\r\n return days + \"天前\" ;\r\n }else if(hours>0){\r\n return hours + \"小时前\" ;\r\n }else if(minutes>0){\r\n return minutes + \"分钟前\";\r\n }\r\n },\r\n\r\n //获取url中query的值\r\n\t\turlParam:function(name){\r\n\t\t\tvar results = new RegExp('[\\\\?&]' + name + '=([^]*)').exec(window.location.href);\r\n\t\t\tif(!results)\r\n\t\t\t{\r\n\t\t\t\tresults=0;\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tresults=results[1] || 0;\r\n\t\t\t}\r\n\r\n\t\t\treturn results;\r\n\t\t},\r\n\t\t//向cookie中写入值\r\n\t\tsetValue:function(name,value){\r\n\t\t\tdocument.cookie=name+\"=\"+escape(value);\r\n\t\t},\r\n\t\t//从cookie中取值,无的话返回null\r\n\t\tgetValue:function(name){\t\t\t\r\n\t\t\tvar value = null;\r\n\t\t\t//读取cookie\r\n\t\t\tvar arrCookie=document.cookie.split(\";\"); \r\n\t\t\tfor(var i=0;i