/*! * M['weburl'] 网站网址 * M['lang'] 网站语言 * M['tem'] 模板目录路径 * M['user_name'] 页面登录用户名 * met_prevarrow, met_nextarrow slick插件翻页按钮自定义html * M['device_type'] 客户端判断(d:PC端,t:平板端,m:手机端) * M['n'] 当前模块名称 * M['c'] 当前类 * M['a'] 当前方法 * M['langtxt'] 当前语言文字 * M['langset'] 当前后台语言 * M['anyid'] 当前模块id * M['met_editor'] 当前系统编辑器名称 * M['met_keywords'] 页面关键词 * M['url']['admin'] 后台文件夹路径 * M['url']['static'] * M['url']['static_vendor'] * M['url']['static2'] * M['url']['static2_vendor'] * M['url']['static2_plugin'] * M['url']['uiv2'] 模板框架v2路径 * M['url']['uiv2_css'] * M['url']['uiv2_js'] * M['url']['app'] 应用文件夹路径 * M['url']['pub'] 后台模块公用文件夹路径 * M['url']['epl'] 后台模块公用示例文件夹路径 * M['url']['ui'] 应用前后台公用UI文件app/system/include/piblic/ui/里面 * M['url']['own_form'] 当前页面程序地址 * M['url']['own_name'] 当前模块地址 * M['url']['own'] 当前模块后台路径 * M['url']['own_tem'] 当前页面模板路径 * M['url']['api'] app站点地址 * M['url']['editor'] 当前编辑器应用文件夹路径 */ $(function () { var myDate=new Date().getTime(); var appfun = function () { var $self = this; if($self.isEmpty(M['n'])) M['n'] = $('div[data-m_name]').data('m_name'); $self.own_name = M['weburl'] + 'app/index.php?n=' + M['n']; $self.config(); //select2 if($('[data-plugin="select2"]').length) $self.select2(true); }; appfun.prototype = { config:function(){ var $self = this; $.ajax({ type: "GET", url: $self.own_name + '&c=index&a=doajaxcl&lang=' + M['lang'], dataType: "jsonp", async: false }).done(function (data) { CL = data; }); }, select2:function(drawdt){ // drawdt true 执行默认操作 false 不执行 var $self = this,select = []; //选择器 M['plugin']['select2'] = [ M['url']['static2_vendor'] + 'select2/select2.min.css', M['url']['static2_vendor'] + 'select2/select2.full.min.js', M['url']['static2_vendor'] + 'select2/i18n/zh-CN.js', ]; $.include(M['plugin']['select2'],function(){ $('[data-plugin="select2"]').each(function(indexs,item){ var _self = $(this), defaults = _self.data('default'), select2url = _self.data('select2-url') + '&'+ myDate; select[indexs] = _self.select2({ placeholder: '输入搜索内容', //提示语 ajax: { url: select2url, dataType: 'jsonp', delay: 500, data: function (params) { return { querys: params.term, //search term tname: _self.data('tname'), //指定简短表 fiend: _self.data('fiend'), //指定字段值 allnone: _self.data('allnone'), //是否只显示应用的值 source: _self.data('source'), //查看来源标记 condition: _self.data('condition') //查询限制条件 }; }, results: function (data, page) { return {results: data.results}; } } }); //默认值处理 if(!$self.isEmpty(defaults) && drawdt == true){ $.getJSON( select2url, { tname: _self.data('tname'), //指定简短表 fiend: _self.data('fiend'), //指定字段值 allnone: _self.data('allnone'), //是否只显示应用的值 source: _self.data('source'), //查看来源标记 condition: _self.data('condition'), //查询限制条件 default: defaults, //默认值 division: _self.data('division') //默认值分隔符 }, function(obj){ $.each(obj.results, function(index, ele) { $.each(ele.children, function(indexop, eleop) { var option = new Option(eleop.text, eleop.id, true, true); select[indexs].append(option).trigger('change'); }) }); } ) } }); }); }, isEmpty: function (val) { switch (typeof val) { case 'undefined': return true; case 'string': if (val.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, '').length == 0) return true; break; case 'boolean': if (!val) return true; break; case 'number': if (0 === val || isNaN(val)) return true; break; case 'object': if (null === val || val.length === 0) return true; for (var i in val) { return false; } return true; } return false; } }; APPFUN = new appfun(); //缓存 $.ajaxSetup({cache: false}); });