/* * @Author: ly * @Date: 2018-10-22 16:20:42 * @Last Modified by: ly * @Last Modified time: 2019-08-05 18:33:59 */ //Number銆丼tring銆丅oolean锛 鐢╪ew //Object銆丄rray銆丗unction 涓嶇敤 // console.log('%c闈炲父寮€蹇冧翰鐖辩殑鎮ㄥ枩鎻愬僵铔嬶紒\n杩欓噷鏄秴閰风殑 <铚€缇嶠 plus <閰疯> 鍥㈤槦 {SHUWON + cooyo} \n闂垜浠彲浠ュ仛浠€涔堬紵\n1. 绮剧編閰风綉绔橽n2. 璐墿涓績寰俊浼氬憳杩愯惀寮€鍙慭n3. 骞村害H5浜掑姩灏忔父鎴廫n4. 鏁板瓧鍖栬繍钀ユ湇鍔n馃槉\n鎴戜滑鍥㈤槦寰堝崟绾笌鐑儏锛屽氨鍍廻onolulu锛佸彧鎯宠鐨勪笌浼椾笉鍚岋紒 \n鑱旂郴鍣滃櫆锛?8602845267', 'line-height:1.8;') console.log('%c http://www.shuwon.com 鉂わ笍鉂わ笍鉂わ笍 铚€缇庣綉缁?, 'padding:20px 0;color:red') ;(function (global, factory) { // typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : //鏄惁寮曠敤鍦╪ode // typeof define === 'function' && define.amd ? define(factory) : //鏄惁鏀寔amd (global.util = factory()); }(this, (function () { // 'use strict'; ie9涓嶆敮鎸 if (!util) { var util = { /************************************************************************ * ui ************************************************************************/ /** *瀵硅瘽鎻愮ず妗 * * @param {*} [string=''] 鏄剧ず鐨勬枃妗 * @param {*} [type='normal'] '榛樿鍗婇€忔槑,success 缁胯壊,error 绾㈣壊, warning 榛勮壊' */ toast: function (config) { if (Object.assign != undefined) { config = Object.assign({ string: '', type: 'normal', }, config); } var $toast = document.getElementsByClassName('_toast')[0] util.addClass($toast, 'active') util.removeClass($toast, 'success') $toast.childNodes[0].childNodes[0].innerHTML = config.string switch (config.type) { case 'normal': break; case 'success': util.addClass($toast, 'success') break; case 'error': util.addClass($toast, 'error') break; case 'warning': util.addClass($toast, 'warning') break; default: break; } setTimeout(function () { $toast.className = '_toast' }, 1500) }, /** *鐐瑰嚮鐪嬪ぇ鍥 * * @param {*} $objUl //鍒楄〃鐖剁骇 * @param {String} objClass //閫変腑鐨勫浘鐨凜lass */ Album: function ($objUl, objClass) { var div = document.createElement('div'); div.innerHTML = '
'; div.className = "_AlbumPictures"; var bo = document.body; bo.insertBefore(div, bo.lastChild); var $Album = document.getElementsByClassName('_AlbumPictures')[0], $photoImg = document.getElementById('_photoImg'), $SBL = document.getElementsByClassName('_SBL')[0], $SBR = document.getElementsByClassName('_SBR')[0]; var liIndex = 0, lilenght = $objUl.children.length - 1, parentLi; //鐪嬪ぇ鍥 for (var i = 0; i <= lilenght; i++) { $objUl.children[i].onclick = function (e) { $SBL.style = "display: block;" $SBR.style = "display: block;" parentLi = this if (parentLi.children[0].className.indexOf(objClass) !== -1) { $Album.className = '_AlbumPictures active'; $photoImg.src = parentLi.getElementsByTagName('img')[0].src liIndex = Array.prototype.indexOf.call(parentLi.parentNode.children, parentLi); if (liIndex == lilenght) { $SBR.style = "display: none;" } else if (liIndex == 0) { $SBL.style = "display: none;" } } else {} e.stopPropagation(); } } var $swiperBtnOff = document.getElementsByClassName('_swiperBtnOff')[0]; //鍏抽棴 $swiperBtnOff.addEventListener('click', function (e) { $Album.className = '_AlbumPictures'; }); //宸﹀垏鎹 $SBL.addEventListener('click', function (e) { liIndex <= 0 ? liIndex = 0 : liIndex--; if (liIndex == 0) { $SBL.style = "display: none;"; } else { $SBR.style = "display: block;"; } $photoImg.style = 'transform: translate(-100%,-50%);opacity: 0;transition: ease .5s;' $photoImg.addEventListener('transitionend', fnOut, false) e.stopPropagation(); }) //鍙冲垏鎹 $SBR.addEventListener('click', function (e) { liIndex == lilenght ? liIndex = lilenght : liIndex++; if (liIndex == lilenght) { $SBR.style = "display: none;"; } else { $SBL.style = "display: block;"; } $photoImg.style = 'transform: translate(0%,-50%);opacity: 0;transition: ease .5s;' $photoImg.addEventListener('transitionend', fnOut, false) e.stopPropagation(); }) function fnOut(e) { $photoImg.style = 'transform: translate(-50%,-50%);opacity:1;transition: ease .5s;' $photoImg.src = parentLi.parentNode.children[liIndex].children[0].src e.stopPropagation(); } }, /** *鍔犺浇浜嬬墿鐨勭櫨鍒嗘瘮(鏃犳硶鍒ゆ柇鑳屾櫙) * * @param {*} $obj 鎺ユ敹鍔犺浇杩涘害 * @param {*} $Loader 鍔犺浇浜嬬墿 * @return {*} callback */ LoadPercentage: function (config, callback) { if (Object.assign != undefined) { config = Object.assign({ obj: null, Loader: null, timer: 1000 }, config); } var $Loader, len = 0; var $Loader = util.ifIDorClass(config.Loader) var $obj = util.ifIDorClass(config.obj) //console.log( util.ifIDorClass(config.out)) if (($Loader == null) || ($obj == null)) return for (var i = 0; i < $Loader.length; i++) { (function (i) { if ($Loader[i].tagName == 'VIDEO') { $Loader[i].oncanplaythrough len++ doIt(len) //oncanplaythrough } else if ($Loader[i].tagName == 'IMG') { if ($Loader[i].complete) { len++; doIt(len) } else { $Loader[i].onload = function () { len++; doIt(len) } } } })(i); } function doIt(len) { var num = Math.round(len * 100 / $Loader.length) $obj[0].innerHTML = Math.round(len * 100 / $Loader.length) + '%'; if (len == $Loader.length) { var deadLine = false; onLoad() setTimeout(function () { deadLine = true; }, config.timer); //鏈€灏忓睍绀烘椂闂达紝绀轰緥涓?绉 function onLoad() { if (deadLine) { isCallback() && (callback(num)) } else { setTimeout(onLoad, 1000); // 杩樻病鏈夊埌鏈€灏忓睍绀烘椂闂达紝1绉掑悗閲嶈瘯 } } } } //isCallback 鏄惁鏈夎繑鍥炲€ function isCallback() { return callback == undefined ? false : true } }, /** * 鏂板缓toast鎻愮ず妗 * */ toastInit: function () { var $body = document.getElementsByTagName('body')[0]; var toastHTML = document.createElement('div'); toastHTML.innerHTML = '

'; toastHTML.className = "_toast"; $body.appendChild(toastHTML); }, /** *鍩虹鐗坆anner * * @param {*} $banner banner 鍒濆 * @param {*} $btnR 鎸夐挳R * @param {*} $btnL 鎸夐挳L * @param {*} $pagination 鍒嗛〉鍣ㄥ皬鐐 * @param {Number} [timer=5000] 鑷姩鍒囨崲鏃堕棿 榛樿5000 * @return {*} callback */ banner: function (config, callback) { console.log(config) if (Object.assign != undefined) { config = Object.assign({ $banner: null, $btnR: null, $btnL: null, $pagination: null, timer: 5000, effect: '' }, config); } var callbackData = { bannerIndex: 0 } var $li = config.$banner.children[0].children, $length = $li.length - 1, index = 0, able = '' for (var i = 0; i <= $length; i++) { able += '' } //pagination 涓簄ull 鍒欎笉鎵ц function isPagination() { return config.$pagination != null } //isBtn 涓簄ull 鍒欎笉鎵ц function isBtn() { return config.$btnR != null && config.$btnL != null } //isCallback 鏄惁鏈夎繑鍥炲€ function isCallback() { return callback == undefined ? false : true } isPagination() && (config.$pagination.innerHTML = able, util.addClass(config.$pagination.children[0], 'active')) util.addClass($li[index], 'active') var bannerInterval foo(config.timer, index) // 姝e父寰幆鍒囨崲banner function foo(timer, index) { bannerInterval = setTimeout(function () { Object.keys($li).forEach(function (index, item) { util.removeClass($li[index], 'active') isPagination() && (util.removeClass(config.$pagination.children[index], 'active')) }) index >= $length ? index = 0 : index++ callbackData.bannerIndex = index effect(config.effect) isCallback() && (callback(callbackData)) util.addClass($li[index], 'active') isPagination() && (util.addClass(config.$pagination.children[index], 'active')) foo(timer, index) }, timer); } //浜嬩欢鎵ц鍚庡垏鎹anner锛屽悗鎵цfoo 姝e父鍒囨崲 function fooC(timer, index) { isCallback() && (callback(callbackData)) Object.keys($li).forEach(function (index, item) { util.removeClass($li[index], 'active') isPagination() && (util.removeClass(config.$pagination.children[index], 'active')) }) effect(config.effect) util.addClass($li[index], 'active') isPagination() && (util.addClass(config.$pagination.children[index], 'active')) foo(timer, index) } // 鍒囨崲banner isBtn() && ( config.$btnR.addEventListener('click', function (e) { clearInterval(bannerInterval) index >= $length ? index = 0 : index++ callbackData.bannerIndex = index fooC(config.timer, index) }), config.$btnL.addEventListener('click', function (e) { clearInterval(bannerInterval) index <= 0 ? index = $length : index-- fooC(config.timer, index) }) ) isPagination() && ( config.$pagination.addEventListener('click', function (e) { var event = e || window.event; var target = event.target || event.srcElement; var lists = Array.from(config.$pagination.querySelectorAll('span')); index = lists.indexOf(target) if (index != -1) { callbackData.index = index clearInterval(bannerInterval) fooC(config.timer, index) } }) ) function effect(param) { if(param==''){ config.$banner.children[0].style.transform = "translate3d(" + (-index * config.$banner.clientWidth) + "px, 0px, 0px)" } } }, /** *鍒涢€犲悎鎴愬浘鐗 * * @param {*} $cntElem 鍒涢€犲悗鏄剧ず璺緞 * @param {*} $CreationSrc 鍒涢€犲悗鏄剧ず璺緞 */ createImg: function (config, callback) { if (Object.assign != undefined) { config = Object.assign({ $cntElem: null, }, config); } // 杩涜canvas鐢熸垚 var shareContent = config.$cntElem; //闇€瑕佹埅鍥剧殑鍖呰9鐨勶紙鍘熺敓鐨勶級DOM 瀵硅薄 var width = shareContent.offsetWidth; //鑾峰彇dom 瀹藉害 var height = shareContent.offsetHeight; //鑾峰彇dom 楂樺害 var canvas = document.createElement("canvas"); //鍒涘缓涓€涓猚anvas鑺傜偣 var scale = 2; //瀹氫箟浠绘剰鏀惧ぇ鍊嶆暟 鏀寔灏忔暟 canvas.width = width * scale; //瀹氫箟canvas 瀹藉害 * 缂╂斁 canvas.height = height * scale; //瀹氫箟canvas楂樺害 *缂╂斁 canvas.getContext("2d").scale(scale, scale); //鑾峰彇context,璁剧疆scale var opts = { scale: scale, // 娣诲姞鐨剆cale 鍙傛暟 canvas: canvas, //鑷畾涔 canvas // logging: true, //鏃ュ織寮€鍏筹紝渚夸簬鏌ョ湅html2canvas鐨勫唴閮ㄦ墽琛屾祦绋 width: width, //dom 鍘熷瀹藉害 height: height, useCORS: true // 銆愰噸瑕併€戝紑鍚法鍩熼厤缃 }; html2canvas(shareContent, opts).then(function (canvas) { var context = canvas.getContext('2d'); // 銆愰噸瑕併€戝叧闂姉閿娇 context.mozImageSmoothingEnabled = true; context.webkitImageSmoothingEnabled = true; context.msImageSmoothingEnabled = true; context.imageSmoothingEnabled = true; // 銆愰噸瑕併€戦粯璁よ浆鍖栫殑鏍煎紡涓簆ng,涔熷彲璁剧疆涓哄叾浠栨牸寮 var img = Canvas2Image.convertToJPEG(canvas, canvas.width, canvas.height); var IMG = img.src isCallback() && (callback(IMG)) }); //isCallback 鏄惁鏈夎繑鍥炲€ function isCallback() { return callback == undefined ? false : true } }, /** *椤甸潰璺宠浆 * @param {*} $PageTurningNumber 缈婚〉鐖剁骇div * @param {Number} page 褰撳墠椤垫暟 * @param {Number} PageSize 涓€椤垫潯鏁 * @param {Number} count 鎬绘潯鏁 * @param {*} php php鍐欐硶閾炬帴 green_140.html?page= */ PageTurningNumber: function (config) { if (Object.assign != undefined) { config = Object.assign({ $PageTurningNumber: null, page: 1, pageSize: 4, count: 100, php: util.truncate(0, window.location.pathname, window.location.pathname.length - 5) }, config); } config.page = Number(config.page) config.$PageTurningNumber.innerHTML = '棣栭〉灏鹃〉璺宠浆鍒?椤袋a class="_btnJump" href="javascript:void(0)">纭畾鍏? + Total(config.count) + '椤袋/span>' var $pageNumber = document.getElementsByClassName('pageNumber')[0], $btnJump = document.getElementsByClassName('_btnJump')[0], $Incoming = document.getElementsByClassName('_Incoming')[0] var liet = '', initial = 1, last = Total(config.count) config.page - 2 <= 1 ? initial = 1 : initial = config.page - 2 config.page + 2 >= last ? last = Total(config.count) : last = config.page + 2 for (i = initial; i <= last; i++) { liet += '' + i + '' } $pageNumber.innerHTML = liet function Total(n) { return Math.ceil(n / config.pageSize) } function active(i) { return config.page == i ? 'active' : '' } $btnJump.addEventListener('click', function (e) { if ($Incoming.value > Total(config.count) || (!util.regNumber($Incoming.value))) { return } window.location.href = config.php + '/' + $Incoming.value + '.html' }) }, /** * 杩斿洖椤堕儴 璋冪敤 scrollToTop */ backTop: function () { var offset = 300, offset_opacity = 200, scroll_top_duration = 500 var $body = document.getElementsByTagName('body')[0], $backTop = document.createElement('div'); $backTop.className = "backTop animate _iconfont"; $backTop.innerHTML = '' $body.appendChild($backTop); $backTop.addEventListener("click", function (e) { util.scrollToTop() }) window.onscroll = function () { //鍙橀噺t鏄粴鍔ㄦ潯婊氬姩鏃讹紝璺濈椤堕儴鐨勮窛绂 var t = document.documentElement.scrollTop || document.body.scrollTop; var scrollup = document.getElementById('scrollup'); //褰撴粴鍔ㄥ埌璺濈椤堕儴200px鏃讹紝杩斿洖椤堕儴鐨勯敋鐐规樉绀 if (t >= offset_opacity) { util.addClass($backTop, 'active') } else { //鎭㈠姝e父 util.removeClass($backTop, 'active') } } }, scrollToTop: function () { var c = document.documentElement.scrollTop || document.body.scrollTop; if (c > 0) { if (!window.requestAnimationFrame) { window.scrollTo(0, c - c / 8); util.scrollToTop() } else { window.requestAnimationFrame(util.scrollToTop); window.scrollTo(0, c - c / 8); } } }, /** *鍒嗕韩 * * @param {*} bdText 鏍囬 * @param {*} bdDesc 绠€浠 * @param {*} bdUrl 鍒嗕韩鐨勯摼鎺 */ share: function (config) { if (Object.assign != undefined) { config = Object.assign({ bdText: '', bdDesc: '', bdUrl: window.location.href, bdPic: null, }, config); } window._bd_share_config = { common: { bdText: config.bdText, bdDesc: config.bdDesc, bdUrl: config.bdUrl, bdPic: config.bdPic }, share: [{ "bdSize": 16 }], image: [{ viewType: 'list', viewPos: 'top', viewColor: 'black', viewSize: '16', viewList: ['qzone', 'tsina', 'huaban', 'tqq', 'renren'] }], selectShare: [{ "bdselectMiniList": ['qzone', 'tqq', 'kaixin001', 'bdxc', 'tqf'] }] } with(document) 0[(getElementsByTagName('head')[0] || body).appendChild(createElement('script')).src = 'http://bdimg.share.baidu.com/static/api/js/share.js?cdnversion=' + ~(-new Date() / 36e5)]; }, /** *鐎戝竷娴 * @param {*} $ul 鍒楄〃鐖剁骇 * @param {Number} row 鍑犲垪 * @param {Number} border 杈硅窛 */ waterfall: function (config) { if (Object.assign != undefined) { config = Object.assign({ $ul: '', row: 4, border: 20, }, config); } var li_bottom = 30 var $li = config.$ul.children; var max_H = 0 function ul_begin(row) { var h = []; var li_W = (config.$ul.offsetWidth - (config.border * (row - 1))) / row; var li_WB = (config.$ul.offsetWidth - (config.border * (row - 1))) / row + config.border; for (var i = 0; i < $li.length; i++) { config.$ul.children[i].style.width = li_W + 'px' li_H = $li[i].offsetHeight + li_bottom; if (i < row) { h[i] = li_H; $li[i].style.top = 0; $li[i].style.left = i * li_W + 'px'; if ($li[i].offsetLeft != 0) { $li[i].style.left = i * li_WB + 'px'; } } else { min_H = Math.min.apply(null, h); minKey = getarraykey(h, min_H); h[minKey] += li_H; $li[i].style.top = min_H + 'px'; $li[i].style.left = minKey * li_W + 'px'; if ($li[i].offsetLeft != 0) { //$li[i].style.left = i * li_WB + 'px'; $li[i].style.left = minKey * li_WB + 'px'; } } max_H = Math.max.apply(null, h); } config.$ul.style.height = max_H + 'px' } function getarraykey(s, v) { for (k in s) { if (s[k] == v) { return k; } } } window.onload = function () { ul_begin(config.row); }; window.onresize = function () { if (document.body.clientWidth <= 1024 && document.body.clientWidth >= 768) { row = 2 } else if (document.body.clientWidth < 768) { row = 1 } else { row = config.row } ul_begin(row); }; }, /************************************************************************ * 琛ㄥ崟鍒ゅ畾 ************************************************************************/ /** * 楠岃瘉鎵嬫満鍙风爜 * * @param {Number} 浼犲叆鐨勬墜鏈哄彿鐮 * @return true||false */ regPhone: function (phone) { reg = /^(13|15|17|18|19|14)[0-9]{9}$/; return reg.test(phone); }, /** *楠岃瘉鏁板瓧 * * @param {Number} number 鏁板瓧 * @return true||false */ regNumber: function (number) { reg = /^[0-9]*$/; return reg.test(number); }, /** * 濮撳悕 || 鍙兘杈撳叆涓嫳鏂 * @param {String} 鍚嶅瓧 * @return true||false */ regName: function (name) { reg = /^[\u4E00-\u9FA5A-Za-z]+$/;; return reg.test(name); }, /** * *鍒ゆ柇韬唤璇佸彿鐮佹槸鍚︾鍚堣姹 * @param {Number} IDcard 韬唤璇 * @return true||false */ regID: function (IDcard) { reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/; return reg.test(IDcard); }, /** * *鍒ゆ柇閭绗﹀悎瑕佹眰 * @param {Number} IDcard 韬唤璇 * @return true||false */ regEmail: function (Email) { reg = /^\w+\@+[0-9a-zA-Z]+\.(com|com.cn|edu|hk|cn|net)$/; return reg.test(Email); }, /** *鍒ゅ畾鏄惁绌烘垨鑰呯┖鏍 * * @param {*} Null */ regNull: function (Null) { if (Null == "") return true; var regu = "^[ ]+$"; var re = new RegExp(regu); return re.test(Null); }, /************************************************************************ * DOMs 鑺傜偣 ************************************************************************/ /** *鍒ゆ柇鏄痗lass 杩樻槸id * @param {*} ele 鍒ゅ畾鐨刣om * @returns 杩斿洖瀵瑰簲鐨勯澶囧畾涔 */ ifIDorClass: function (ele) { if (ele == null) { return false } else if (ele.indexOf('.') == 0) { return document.getElementsByClassName(ele.substr(1)) } else if (ele.indexOf('#') == 0) { return document.getElementById(ele.substr(1)) } }, /** *鍒ゅ畾鏄惁鏈塩lass * * @param {*} ele 鍒ゅ畾鐨刣om * @param {String} cls 鍒ゅ畾鐨刢lass * @return true||false */ hasClass: function (ele, cls) { return ele.className.match(new RegExp("(\\s|^)" + cls + "(\\s|$)")); }, /** *涓烘寚瀹氱殑dom鍏冪礌娣诲姞鏍峰紡 * * @param {*} ele 鎸囧畾鐨刣om * @param {String} cls 娣诲姞鐨刢lass */ addClass: function (ele, cls) { if (!util.hasClass(ele, cls)) ele.className += " " + cls; }, /** *鍒犻櫎鎸囧畾dom鍏冪礌鐨勬牱寮 * * @param {*} ele 鎸囧畾鐨刣om * @param {String} cls 鍒犻櫎鐨刢lass */ removeClass: function (ele, cls) { if (util.hasClass(ele, cls)) { var reg = new RegExp("(\\s|^)" + cls + "(\\s|$)"); ele.className = ele.className.replace(reg, ""); } }, /** *鎸囧畾dom娣诲姞鍜屽垹闄ょ浉鍚宑lass * * @param {*} ele * @param {*} cls */ toggleClass: function (ele, cls) { if (util.hasClass(ele, cls)) { util.removeClass(ele, cls); } else { util.addClass(ele, cls); } }, /************************************************************************ * browser娴忚鍣 ************************************************************************/ /** * // 鑾峰彇 url 涓殑鍙傛暟鍊 * * @param {*} name 闇€瑕佽幏鍙栫殑鍙傛暟鍚 * @returns 鍊 || null */ getSearch: function (name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); return r ? decodeURIComponent(r[2]) : null; }, /** * 鍒ゅ畾璁块棶绫诲瀷鏄數鑴戣繕鏄Щ鍔ㄧ * @returns 杩斿洖璁块棶绫诲瀷 */ userAgent: function (e) { if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) { /*window.location.href="浣犵殑鎵嬫満鐗堝湴鍧€";*/ return 'Mobile' } else { /*window.location.href="浣犵殑鐢佃剳鐗堝湴鍧€"; */ return 'pc' } }, /************************************************************************ * 鏃ユ湡绫 ************************************************************************/ /** *鏃堕棿鎴 * * @param {Number} timestamp 鏃堕棿鎴 * @returns 杞崲鎴愮殑鏃堕棿 * * Conversion[] 杞彉鍚庣殑鏃堕棿 * Remaining[] 杞彉鍚庡埌瀹為檯 */ CountdownNumber: function (timestamp) { var timeBox = { Conversion: [], Remaining: [] } var difference = 0 var currentTimer = Math.floor(new Date().getTime() / 1000); var dd_ = 0, hh_ = 0, mm_ = 0, ss_ = 0; difference = timestamp - currentTimer; dd_ = Math.floor(difference / (60 * 60 * 24)); //璁$畻鍓╀綑鐨勫ぉ鏁 hh_ = Math.floor(difference / (60 * 60)) - (dd_ * 24) //璁$畻鍓╀綑鐨勫皬鏃舵暟 mm_ = Math.floor(difference / 60) - (dd_ * 24 * 60) - (hh_ * 60) //璁$畻鍓╀綑鐨勫垎閽熸暟 ss_ = Math.floor(difference) - (dd_ * 24 * 60 * 60) - (hh_ * 60 * 60) - (mm_ * 60) //璁$畻鍓╀綑鐨勭鏁 if (hh_ <= 9) hh_ = '0' + hh_; if (mm_ <= 9) mm_ = '0' + mm_; if (ss_ <= 9) ss_ = '0' + ss_; var time = new Date(timestamp * 1000) timeBox.Conversion.Year = time.getFullYear() timeBox.Conversion.Month = time.getMonth() timeBox.Conversion.Date = time.getDate() timeBox.Conversion.Hours = time.getHours() timeBox.Conversion.Minutes = time.getMinutes() timeBox.Remaining.day = dd_ timeBox.Remaining.Hours = hh_ timeBox.Remaining.Minutes = mm_ timeBox.Remaining.second = ss_ return timeBox }, /************************************************************************ * 瀛楃涓茬被 ************************************************************************/ // 鎴彇缁欏畾闀垮害鐨勫瓧绗︿覆 truncate: function (str, string, len) { if (string.length > len) { string = string.substring(str, len); } return string; }, /************************************************************************ * 绉诲姩绔棶棰 ************************************************************************/ /** * 琛ㄥ崟鎶栧姩 * * @param {*} e * @retyrbs 鐢ㄤ簬鍏ㄥ睆琛ㄥ崟锛岄敭鐩樺脊鍑哄悗锛岄€€鍑哄鑷磇nput閿欎綅 */ inputShakeIos: function (e) { document.body.addEventListener('focusin', function () { //杞敭鐩樺脊鍑虹殑浜嬩欢澶勭悊 isReset = false; }); document.body.addEventListener('focusout', function () { //杞敭鐩樻敹璧风殑浜嬩欢澶勭悊 isReset = true; setTimeout(function () { //褰撶劍鐐瑰湪寮瑰嚭灞傜殑杈撳叆妗嗕箣闂村垏鎹㈡椂鍏堜笉褰掍綅 if (isReset) { window.scroll(0, 0); //澶辩劍鍚庡己鍒惰椤甸潰褰掍綅 } }, 300); }); }, /** * 琛ㄥ崟鎶栧姩 * * @param {*} e * @retyrbs 鐢ㄤ簬鍏ㄥ睆琛ㄥ崟锛岄敭鐩樺脊鍑哄悗锛岄€€鍑哄鑷磇nput閿欎綅 */ inputShakeAndroid: function (e) { window.onresize = function () { //閿洏寮硅捣涓庨殣钘忛兘浼氬紩璧风獥鍙g殑楂樺害鍙戠敓鍙樺寲 var resizeHeight = document.documentElement.clientHeight || document.body.clientHeight; if (resizeHeight < h) { //褰撹蒋閿洏寮硅捣锛屽湪姝ゅ鎿嶄綔 isReset = false; } else { //褰撹蒋閿洏鏀惰捣锛屽湪姝ゅ鎿嶄綔 isReset = true; setTimeout(function () { if (isReset) { window.scroll(0, 0); //澶辩劍鍚庡己鍒惰椤甸潰褰掍綅 } }, 300); } }; }, /************************************************************************ * 鍏朵粬 ************************************************************************/ /** *闃叉iframe宓屽 * */ isTop: function () { var isInTest = false if (sessionStorage || window.sessionStorage) { if (window.location.search) { if (window.location.search.indexOf('isInTest') !== -1) { sessionStorage.setItem('isInTest', true) } } isInTest = Boolean(sessionStorage.getItem('isInTest')) } if (window.self !== window.top && !isInTest) { window.location.href = 'http://www.shuwon.com' } }, /** * 铚€缇庨」鐩洃鎺 */ shuwonProject: function () { if (/shuwon/.test(location.search) || sessionStorage.getItem('debugger') == '12345677') { sessionStorage.setItem("debugger", "12345677"); } else { $.post("http://project.shuwon.cn/api/project/stop", { url: location.origin }, function (data) { if (data.result) window.location.href = "http://www.shuwon.com/over/"; }) } }, } } return util; //} })));