// window.onerror=function(){return true} var Lmn = { // 基本设置 'web': { 'path': '/', 'name': '全球最奢华的游戏平台', 'template': '/Template/default/' }, // 临时变量数组 'temp': [], 'search': function(o){ var v = $.trim(o.val()); if(v == ''){ return; }else{ Lmn.go(Lmn.web.path + 'search/' + v); } }, 'isWeiXin': function(){ var ua = window.navigator.userAgent.toLowerCase(); if(ua.match(/MicroMessenger/i) == 'micromessenger'){ return true; }else{ return false; } }, // 弹出微信二维码 'subscribe': function(){ Lmn.submit( Lmn.web.path + 'ajax.php', [ {'name': 'action', 'value': 'wxewm'}, {'name': 'recid', 'value': window.recid ? window.recid : 0} ], false, function(res){ layer.open({ type: 1 ,content: '

'+res.word+'

' ,anim: 'scale' ,style: 'position:fixed; top:50%; left:50%; width: 200px; height: 300px; margin-left: -100px; margin-top: -150px; background-color: transparent;' }); } ) }, 'use': function(n, type){ if(typeof(n) == 'object'){ for(i in n){ this.use(n[i], type); } }else{ switch(n){ // zepto case 'zepto': this.js('js/zepto.min.js', type); break; // mui case 'mui': this.js('js/mui.min.js', type); this.css('css/mui.min.css', type); break; case 'layer': this.js('js/layer/mobile/layer.js', type); break; // 二维码 case 'qrcode': this.js('js/qrcode.js', type); break; // md5 case 'md5': this.js('js/md5.js', type); break; // 地图 case 'map': this.js('https://api.map.baidu.com/api?v=2.0&ak=tsd4DCaHbPB2faEe7oK8IsETGijMCGAs', type); break; // css case 'iconfont': this.css('https://at.alicdn.com/t/font_521509_avi1i41x83l680k9.css', type); break; case 'style': this.css('images/m.css?v=1', type); break; // 加载完成后进行初始化并加载默认的 case 'default': this.use(['zepto', 'mui', 'layer', 'iconfont', 'style']); break; default: if(n.indexOf('.js') > 0){ this.js(n, type); }else{ this.css(n, type); } } } }, 'js': function(n, type, fun){ if(typeof(n) == 'object'){ for(i in n){ this.js(n[i], type, fun); } }else{ this.temp['js'] = (this.temp['js'] == undefined) ? '' : this.temp['js']; if(this.temp['js'].indexOf('|' + n + '|') == -1){ this.temp['js'] += '|' + n + '|'; if(type == undefined || type == ''){ if(document.readyState == 'complete'){ $('body').append(''); if(fun){$('body').append('')} }else{ document.writeln(''); if(fun){document.writeln('')} } }else{ $.getScript(((n.indexOf('http') == 0) ? n : (this.web.template + n)), function(res, status){ if(fun){fun()}; }); } } } }, 'css': function(n, type){ if(typeof(n) == 'object'){ for(i in n){ this.css(n[i], type); } }else{ this.temp['css'] = (this.temp['css'] == undefined) ? '' : this.temp['css']; if(this.temp['css'].indexOf('|' + n + '|') == -1){ this.temp['css'] += '|' + n + '|'; if(type != undefined){ var head = document.getElementsByTagName('head').item(0); var link = document.createElement('link'); link.rel = 'stylesheet'; link.href = this.web.template + n; head.appendChild(link); }else{ document.writeln(''); } } } }, 'ajax': function(url, data, isloading, success, error, complete){ if(isloading){var loading} data = (data == undefined || data == '') ? [] : data; if(data.length == undefined){ data.isajax = 1; }else{ data.push({'name': 'isajax', 'value': 1}); } // $(':focus').blur(); $.ajax({ url: url, type: 'post', data: data, dataType: 'html', cache: false, beforeSend: function(){ if(isloading){loading = Lmn.loading()} }, success: function(res) { success && success(res) }, error: function() { error && error() }, complete: function() { if(isloading){Lmn.close(loading)} complete && complete(); } }); }, // 数据提交 'submit': function(action, data, isloading, success_fun, error_fun, complete_fun){ if(success_fun == undefined){ var success = function(res){ try{ res = eval("("+res+")"); switch(res.result){ case 'success': setTimeout(function(){ if(res.msg != undefined && res.msg != ''){ Lmn.msg(res.msg, {'time': 1000, 'icon': 1}, function(){ if(res.eval != undefined && res.eval != ''){ eval(res.eval); } }); }else if(res.eval != undefined && res.eval != ''){ eval(res.eval); } }); break; case 'failed': setTimeout(function(){ if(res.msg != undefined && res.msg != ''){ Lmn.msg(res.msg, {'time': 2500, 'icon': 5}, function(){ if(res.eval != undefined && res.eval != ''){ eval(res.eval); } }); }else if(res.eval != undefined && res.eval != ''){ eval(res.eval); } }); break; } }catch(e){ Lmn.msg('数据加载失败', {'icon': 7, 'time': 2500}); } } }else{ var success = function(res){ try{ res = eval("("+res+")"); success_fun(res); }catch(e){ Lmn.msg('操作失败了', {'icon': 7, 'time': 2500}); } } } if(error_fun == undefined){ var error = function(){ Lmn.msg('操作失败了', {'icon': 7, 'time': 2500}); } }else{ var error = error_fun; } Lmn.ajax(action, data, isloading, success, error, complete_fun); }, 'msg': function(str, opt, fun){ return mui.alert(str, Lmn.web.name, function() { if(fun){fun()} }); }, 'showerr': function(str){ return mui.alert(str ? str : '操作失败了', Lmn.web.name); }, 'loading': function(str){ $("body").append('
'); }, 'reload': function(){ layer.open({type: 2}); document.location.reload(); }, 'close': function(o){ o ? layer.close(o) : layer.closeAll(); $('.lmn-loading').remove(); }, 'go': function(url, time){ if(time){ setTimeout(function(){ location.href = url }, time); }else{ location.href = url } }, 'getCookie': function(n){ var results = document.cookie.match('(^|;) ?' + n + '=([^;]*)(;|$)'); if (results) return (unescape(results[2])); else return null; }, 'check': function(o, $d){ $d.prop('checked', o.checked); }, // 页面滚动 'scrollto': function(top, time){ $('body').scrollTo({scrollTop : top}); }, 'formatNumber': function(num, precision, separator){ var parts; if (!isNaN(parseFloat(num)) && isFinite(num)) { num = Number(num); num = (typeof precision !== 'undefined' ? num.toFixed(precision) : num).toString(); parts = num.split('.'); parts[0] = parts[0].toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + (separator || ',')); return parts.join('.'); } return NaN; }, 'q': function(sProp){ var re = new RegExp("[&,?]"+sProp + "=([^\\&]*)", "i"); var a = re.exec(document.location.search); if (a == null){ return ""; } else{ return a[1]; } }, 'waitSecond': function(second, selector, html, callback, flag){ if(second > 0){ if(flag == 'val'){ $(selector).val(html.replace("second", second)); }else{ $(selector).html(html.replace("second", second)); } setTimeout(function(){Lmn.waitSecond(second - 1, selector, html, function(){callback()}, flag)}, 1000); } else{ callback(); } }, 'getdata': function(item){ if(typeof(localStorage) == "undefined"){ var strCookie = document.cookie; var arrCookie = strCookie.split("; "); for(var i=0; i