123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- var self;
- var scrollered,
- scrollered1,
- page = 1,
- size = 10;
- var activityLoaded = false; // 标志参与活动未加载
- var accountId = null;
- // 标签
- var $searchtResult = $('#search_result'),
- $searchtResult1 = $('#search_result1'),
- $goalList = $('#goal_list'),
- $activityList = $('#activity_list');
- var $patImg = $("#patImg");
- window.addEventListener("reLoad", function refresh(e) {
- patiDetail();
- });
- //下拉刷新上拉加载
- var 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('上拉加载更多');
- }
- });
- },
- // 初始化画面-积分数据
- patiDetail = function() {
- plus.nativeUI.showWaiting();
- var obj = {
- patientId: self.patient
- },
- params = {
- account: JSON.stringify(obj),
- page: 1,
- size: 1
- }
- sendPost("/doctor/healthBank/findAccount", params, queryFails, function(res) {
- if(res.data.status == 200) {
- plus.nativeUI.closeWaiting();
- var data = res.data.detailModelList[0]
- accountId = data.id;
- var setImgHtml = template("set_pat_img", {data: data});
- // 渲染数据
- $patImg.empty().append(setImgHtml);
- $("#cityRanking").html(data.cityRanking);
- $("#teamRanking").html(data.teamRanking);
- $("#pati_name").html(data.accountName);
- $("#nowGoal").html(data.total);
- $("#finishTime").html(data.taskTotal);
- $("#joinTime").html(data.activityTotal);
- // $("#getAward").html();
- getAllGoal(true)
- } else {
- plus.nativeUI.closeWaiting();
- queryFails(res);
- }
- }, 'POST')
- },
- // 全部积分数据
- getAllGoal = function(boolean) {
- plus.nativeUI.showWaiting();
- var obj = {
- accountId: accountId
- },
- params = {
- creditsLogDo: JSON.stringify(obj),
- page: page,
- size: size
- }
- sendPost("/doctor/healthBank/selectDetails", params, queryFails, function(res) {
- if(res.status == 200) {
- var list = res.data.detailModelList;
- updatePullUpText(scrollered, list);
- plus.nativeUI.closeWaiting();
- var html = template("result_tmpl", {list: list});
- if(boolean) {
- $goalList.empty().append(html);
- if(list.length == 0) {
- $("#no_result_wrap").show();
- } else {
- $("#no_result_wrap").hide();
- }
- } else {
- $goalList.append(html);
- }
- $('#wrapper').show();
- scrollered.refresh();
- } else {
- plus.nativeUI.closeWaiting();
- queryFails(res);
- }
- }, 'POST')
- },
- // 全部活动数据
- getActivity = function(boolean) {
- plus.nativeUI.showWaiting();
- var params = {
- patientId: self.patient,
- page: page,
- size: size
- }
- sendPost("/doctor/healthBank/selectByPatient", params, queryFails, function(res) {
- if(res.status == 200) {
- activityLoaded = true
- plus.nativeUI.closeWaiting();
- var list = res.data.detailModelList;
- updatePullUpText(scrollered1, list);
- var html = template("activity_tmpl", {list: list});
- if(boolean) {
- $activityList.empty().append(html);
- if(list.length == 0) {
- $(".set-border-bg").hide()
- $("#no_result_wrap1").show();
- } else {
- $(".set-border-bg").show()
- $("#no_result_wrap1").hide();
- }
- } else {
- $activityList.append(html);
- }
- $('#wrapper1').show();
- scrollered1.refresh();
- } else {
- plus.nativeUI.closeWaiting();
- queryFails(res);
- }
- }, 'post')
- },
- //查询失败回调
- queryFails = function(res) {
- if(res) {
- mui.toast(res.msg)
- } else {
- mui.toast("加载失败!")
- }
- },
- // 绑定页面事件
- bindEvents = function () {
- $(".integral").on("tap", function() {
- openWebview("select_goal.html", {
- patient: self.patient
- })
- });
- //初始化下拉刷新 上拉加载
- scrollered = $("#wrapper").initScroll({
- pullDownAction: function() {
- page = 1
- getAllGoal(true);
- },
- pullUpAction: function() {
- page++
- getAllGoal(false);
- }
- });
- scrollered1 = $("#wrapper1").initScroll({
- pullDownAction: function() {
- page = 1;
- getActivity(true);
- },
- pullUpAction: function() {
- page++;
- getActivity(false);
- }
- });
-
- $("#con_tit div").on("tap", function() {
- var $this = $(this),
- index = $this.index();
- if($this.hasClass("active")){
- return false;
- }
-
- $this.siblings().removeClass("active");
- $this.addClass("active");
-
- mui('.mui-slider').slider().gotoItem(parseInt(index));
-
- if(!activityLoaded){
- getActivity(true)
- }
- })
-
- //滚动切换
- document.querySelector('.mui-slider').addEventListener('slide', function(event) {
- if (event.detail.slideNumber === 0) {
- $("#con_tit div").eq(0).addClass("active");
- $("#con_tit div").eq(1).removeClass("active");
- } else if (event.detail.slideNumber === 1) {
- if(!activityLoaded){
- getActivity(true)
- }
- $("#con_tit div").eq(0).removeClass("active");
- $("#con_tit div").eq(1).addClass("active");
- }
- });
- };
- // 页面业务处理流程开始
- mui.plusReady(function() {
- //获取当前页面
- self = plus.webview.currentWebview();
- //绑定事件
- bindEvents();
- //数据渲染
- patiDetail();
- })
|