多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# 加载时初始化 ~~~ var para = []; para.push({'id':'box','down_back':'down','up_back':'up','down_auto':1}); ref(para); ~~~ # 单个列表内容函数 ~~~ function list_template(o){ var html = []; var list = o.list; for(var i in list){ for(var j in list[i]){ eval(j + ' = list[i].' + j + ';'); } html.push(''); } return html.join(''); } ~~~ # 非刷新加载数据,如点击载入数据则无需ref_down_end复位操作 ~~~ $('#click').on('click',function(){ var Ucache = decode_Uinfo(); var para = {}; para.url = 'url'; para.data = {'sbh_type':'down_click','uuid':uuid,'u_id':Ucache.u_id,'PIN':1}; para.pass = ['uuid','u_id']; net(para); }); //1.浮框显示回调信息 function exec_down_click(o){ $('#PIN').val(o.next); var list = $('#list'); switch(o.succeed){ case 2: list.html(''); sbh_note(o.msg); break; default: list.html(list_template(o)); break; } } //2.载入无数据文字 function exec_down_click(o){ $('#PIN').val(o.next); var list = $('#list'); switch(o.succeed){ case 2: list.html('<div style="text-align: center; color: #CCCCCC;">' + o.msg + '</div>'); break; default: list.html(list_template(o)); break; } } ~~~ # 刷新处理 ~~~ function down(){ var Ucache = decode_Uinfo(); var para = {}; para.url = 'url'; para.data = {'sbh_type':'down','uuid':uuid,'u_id':Ucache.u_id,'PIN':1}; para.pass = ['uuid','u_id']; net(para); } function exec_down(o){ $('#PIN').val(o.next); var list = $('#list'); switch(o.succeed){ case 2: list.html('<div style="text-align: center; color: #FFFFFF;">' + o.msg + '</div>'); break; default: list.html(list_template(o)); break; } ref_down_end('box'); } ~~~ # 加载 ~~~ function up(){ var Ucache = decode_Uinfo(); var PIN = $('#PIN').val(); var para = {}; para.url = 'url'; para.data = {'sbh_type':'up','uuid':uuid,'u_id':Ucache.u_id,'PIN':PIN}; para.pass = ['uuid','u_id']; net(para); ref_up_end(this); } function exec_up(o){ $('#PIN').val(o.next); switch(o.succeed){ case 2: sbh_note(o.msg); break; default: $('#list').append(list_template(o)); break; } } ~~~ # 列表按钮点击,弹出选择框 ~~~ mui("#box").on('tap', '.option', function (event) { this.click(); event.stopPropagation(); var id = this.id; var enable = $(this).attr('enable'); option(id,enable); }); function option(id){ var buttons = []; buttons.push({title:'操作一','option':'opt_1'}); buttons.push({title:'操作二','option':'opt_2'}); var a = plus.nativeUI.actionSheet({title:'请选择以下操作', cancel:'取消', buttons:buttons }, function(e){ if(e.index != 0){ var option = buttons[Number(e.index)-1].option; switch(option){ case 'opt_1': break; case 'opt_2': break; default: break; } } a=null; } // 10秒没操作则自动关闭 setTimeout(function(){ a&&a.close(); }, 10000); } ~~~