123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- // 基本信息(包括userAgent)
- var baseInfo = null,
- // 基础环境信息(包括当前webview)
- baseEnv = null;
-
- // 搜索框
- var $searchbar = $('.searchbar'),
- // 搜索输入框
- $searchbarInput = $('.searchbar input'),
- $searchCancel = $('#cancel_btn'),
- // 搜索结果展示容器
- $searchtResult = $('#search_result'),
- // 患者分组列表
- $resultList = $('#result_list');
- var self;
- var docInfo;
- var selectJudge = 0,
- activityIdArr = [0],
- activityTitleArr = ["积分排行榜"];
- var scrollered,
- keyword = "",
- page = 1,
- pagesize = 10;
-
- // 获取登录相关信息
- var getBaseInfo = function() {
- // 登录的相关信息
- var userAgent = JSON.parse(plus.storage.getItem("userAgent"))
- return {
- userAgent: userAgent,
- teamInfo: JSON.parse(plus.storage.getItem("teamInfo"))
- }
- },
- // 获取基础环境信息
- getBaseEnvPromise = function () {
- self = plus.webview.currentWebview();
- docInfo = JSON.parse(plus.storage.getItem("docInfo"));
- var env = {
- webview: plus&&plus.webview.currentWebview()
- };
- return Promise.resolve().then(function(res) {
- return env;
- });
- },
- //下拉刷新上拉加载
- updatePullUpText = function(scroller, list) {
- var $wrap = $(scroller.wrapper),
- $pullupLabel = $wrap.find('.pullUpLabel');
- $(".pullUp").removeClass("loading");
- if(!list) {
- $pullupLabel.text('没有更多');
- } else if(list.length < 10) {
- $(".pullUp").hide();
- } else {
- $pullupLabel.text('上拉加载更多');
- }
- scroller.on('refresh', function() {
- if(!list) {
- $pullupLabel.text('没有更多');
- } else if(list.length < 10) {
- $(".pullUp").hide();
- } else {
- $pullupLabel.text('上拉加载更多');
- }
- });
- },
- // 初始化画面患者-积分列表
- searchList = function(boolean) {
- plus.nativeUI.showWaiting();
- var params = {
- doctorId:docInfo.code,
- name: keyword,
- activityId: selectJudge,
- page: page,
- size: pagesize
- }
- sendPost("/doctor/healthBank/findCreditRanking", params, queryFails, function(res) {
- if(res.status == 200) {
- page += 1;
- var list = res.data.detailModelList;
- updatePullUpText(scrollered, list);
- plus.nativeUI.closeWaiting();
- var html = template("result_tmpl", {list: list});
- if(boolean) {
- $resultList.empty().append(html);
- if(list.length == 0) {
- $("#no_result_wrap").show();
- } else {
- $("#no_result_wrap").hide();
- }
- } else {
- $resultList.append(html);
- }
- $('#wrapper').show();
- scrollered.refresh();
- } else {
- plus.nativeUI.closeWaiting();
- queryFails(res);
- }
- }, 'post')
- },
- // 活动下的积分排行
- activityPatList = function(boolean) {
- plus.nativeUI.showWaiting();
- var params = {
- doctorId:docInfo.code,
- name: keyword,
- activityId: selectJudge,
- page: page,
- size: pagesize
- }
- sendPost("/doctor/healthBank/findActivityRanking", params, queryFails, function(res) {
- if(res.status == 200) {
- page += 1;
- var list = res.data.detailModelList;
- updatePullUpText(scrollered, list);
- plus.nativeUI.closeWaiting();
- var html = template("result_tmpl", {list: list});
- if(boolean) {
- $resultList.empty().append(html);
- if(list.length == 0) {
- $("#no_result_wrap").show();
- } else {
- $("#no_result_wrap").hide();
- }
- } else {
- $resultList.append(html);
- }
- $('#wrapper').show();
- scrollered.refresh();
- } else {
- plus.nativeUI.closeWaiting();
- queryFails(res);
- }
- }, 'post')
- },
- //查询失败回调
- queryFails = function(res) {
- if(res) {
- mui.toast(res.msg)
- } else {
- mui.toast("加载失败!")
- }
- },
- /**
- * 获取积分活动列表
- */
- getActivityList = function() {
- sendPost("/doctor/healthBank/selectTask",{task: "{}", page: 1, size: 100}, null, function(res){
- if(res.status == 200){
- var dataList = res.data.detailModelList;
- for(var i = 0; i < dataList.length; i++){
- activityIdArr.push(dataList[i].id);
- activityTitleArr.push(dataList[i].title);
- }
- setActiveSortTit(activityIdArr, activityTitleArr);
- }
- },'post')
- },
- /**
- * 设置选择活动标题
- */
- setActiveSortTit = function(activityIdArr, activityTitleArr) {
- $('#sort_tit').mobiscroll({
- theme: 'ios',
- lang: 'zh',
- customWheels: true,
- wheels: [
- [{
- keys: activityIdArr,
- values: activityTitleArr
- }]
- ],
- onSelect: function(valueText, inst) {
- var dd = eval("[" + valueText + "]");
- $(this).html(dd[0].values).attr("data-code", dd[0].keys);
- selectJudge = dd[0].keys
- page = 1
- if(selectJudge == 0) {
- searchList(true)
- } else {
- activityPatList(true)
- }
- }
- }
- )},
- // 绑定页面事件
- bindEvents = function () {
- //初始化下拉刷新 上拉加载
- scrollered = $("#wrapper").initScroll({
- pullDownAction: function() {
- page = 1
- if(selectJudge == 0) {
- searchList(true)
- } else {
- activityPatList(true)
- }
- },
- pullUpAction: function() {
- if(selectJudge == 0) {
- searchList(false)
- } else {
- activityPatList(false)
- }
- }
- });
- $searchbarInput.bind('input propertychange', function() {
- keyword = $(this).val();
- if(keyword == "") {
- $searchCancel.hide()
- } else {
- $searchCancel.show()
- }
- page = 1;
- if(selectJudge == 0) {
- searchList(true)
- } else {
- activityPatList(true)
- }
- });
- $searchCancel.on("tap", function() {
- $(this).hide()
- $searchbarInput.val("")
- keyword = "";
- page = 1;
- if(selectJudge == 0) {
- searchList(true)
- } else {
- activityPatList(true)
- }
- });
- $resultList.on("tap", "li", function() {
- patient = $(this).attr("data-code")
- openWebview("pati_detail.html", {
- patient: patient
- });
- });
- };
- // 页面业务处理流程开始
- mui.plusReady(function() {
- //获取当前页面
- var self = plus.webview.currentWebview();
- getBaseEnvPromise();
- //绑定事件
- bindEvents();
- //数据渲染
- searchList(true);
- getActivityList();
- })
|