12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- var page = 1,
- pagesize = 15,
- hasMore = true;
- mui.init();
- mui.plusReady(function(){
- getList(true);
- initScroll();
- bindEvents();
- });
- function initScroll(){
- //阻尼系数
- var deceleration = mui.os.ios?0.003:0.0009;
- mui('.mui-scroll-wrapper').scroll({
- bounce: false,
- indicators: true, //是否显示滚动条
- deceleration:deceleration
- });
-
- mui('.mui-scroll-wrapper').pullRefresh({
- down: {
- callback: function() {
- setTimeout(function() {
- getList(true);
- mui('.mui-scroll-wrapper').pullRefresh().endPulldownToRefresh();
- }, 1000);
- }
- },
- up:{
- contentrefresh: '正在加载...',
- callback: function(){
- var self = this;
- setTimeout(function() {
- getList(false);
- mui('.mui-scroll-wrapper').pullRefresh().endPullupToRefresh(!hasMore);
- }, 1000);
- }
- }
- });
- }
- function getList(isInit){
- page = isInit ? 1 : page;
- plus.nativeUI.showWaiting();
- var url = "doctor/questionnaire/getQuestionnaireList",
- params = {pageNo: page, pageSize: pagesize};
- sendGet(url, params, null, function(res){
- if(res.status == 200){
- if(isInit && res.data.length == 0){
- $("#no_result_wrap").show();
- $(".mui-scroll-wrapper").hide();
- }else{
- page ++;
- $("#no_result_wrap").hide();
- $(".mui-scroll-wrapper").show();
- if(res.data.length < pagesize){
- hasMore = false;
- isInit && mui(".mui-scroll-wrapper").pullRefresh().endPullupToRefresh(!hasMore);
- }else{
- hasMore = true;
- }
- var html = template("list_tmp", {list: res.data});
- if(isInit){
- $("#survey_list").empty().append(html);
- }else{
- $("#survey_list").append(html);
- }
- }
- }else{
- mui.toast(res.msg);
- }
- plus.nativeUI.closeWaiting();
- }, true);
- }
- function bindEvents(){
- $(".header-link").on('tap', function(){
- var templateList = plus.webview.getWebviewById("template_list");
- if(templateList){
- mui.fire(templateList, "refresh");
- openWebview("template_list.html");
- }else{
- openWebview("template_list.html");
- }
- });
-
- $("body").on("tap", "li", function(){
- var surveyId = $(this).attr("data-code");
- openWebview("survey_info.html", {code : surveyId});
- });
-
- window.addEventListener('refresh', function(){
- getList(true);
- });
- }
- template.helper("setPhoto", function(p) {
- return getImgUrl(p);
- });
|