123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- var self, param;
- var goalArr = [],
- patientArr = [],
- description = "",
- subNum = 0,
- judgeClear = false,
- $resultList = $("#device_goal");
- // 初始化画面-积分数据
- var goalList = function() {
- plus.nativeUI.showWaiting();
- var obj = {type: "NORMAL", status: 1},
- params = {
- taskRule: JSON.stringify(obj),
- page: 1,
- size: 100
- }
- sendPost("/doctor/healthBank/selectTaskRule", params, queryFails, function(res) {
- if(res.status == 200) {
- plus.nativeUI.closeWaiting();
- var list = res.data.detailModelList;
- var html = template("result_tmpl", {list: list});
- // 渲染数据
- if(!list || list.length == 0) {
- $("#no_result_wrap").show()
- } else {
- $resultList.empty().append(html);
- }
- } else {
- plus.nativeUI.closeWaiting();
- queryFails(res);
- }
- }, 'post')
- },
- //查询失败回调
- queryFails = function(res) {
- if(res) {
- mui.toast(res.msg)
- } else {
- mui.toast("加载失败!")
- }
- },
- load = function() {
- if(self.patient) {
- $("#sure").show();
- patientArr.push(self.patient)
- } else {
- $("#next").show();
- }
- },
- // 移除勾选
- spliceArr = function(goalId) {
- for(var i = 0, len = goalArr.length; i < len; i++) {
- if(goalArr[i] == goalId) {
- goalArr.splice(i, 1)
- return
- }
- }
- },
- // 提交数据
- submitData = function() {
- plus.nativeUI.showWaiting();
- var obj = {
- patientIds: patientArr,
- ruleId: goalArr[0],
- description: description
- },
- params = {
- object: JSON.stringify(obj)
- }
- sendPost("/doctor/healthBank/doctorAddInteger", params, queryFails, function(res) {
- if(res.status == 200) {
- plus.nativeUI.closeWaiting();
- if(res.data.status == -1) {
- mui.toast(res.data.message || "网络错误,请求失败!")
- return false;
- }
- mui.toast("操作成功!")
- setTimeout(function() {
- var vm = plus.webview.getWebviewById("pati_detail")
- mui.fire(vm,"reLoad")
- var mv = plus.webview.getWebviewById("health-bank")
- mui.fire(mv,"reLoad")
- mui.back()
- }, 200)
- } else {
- plus.nativeUI.closeWaiting();
- queryFails(res);
- }
- }, 'POST')
- },
- setDialog = function() {
- var judgeText = judgeClear ? "清零" : "-10分"
- dialog({
- content: '<p style="font-size:16px;">你将给予居民' + judgeText + ',请简要说明原因。</p><textarea id="reason" placeholder="请简要说明原因(必填)"></textarea>',
- okValue: '确认',
- cancelValue: '取消打分',
- cancel: function () {
- return;
- },
- ok: function() {
- description = $("#reason").val();
- if(!description || description.length <= 0) {
- mui.toast("扣分描述为必填项!");
- return false;
- }
- submitData()
- }
- }).showModal();
- },
- // 绑定页面事件
- bindEvents = function () {
-
- $("#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));
-
- })
- $("#device_goal").on("tap", ".sel-label", function() {
- goalArr = [];
- subNum = 0;
- var goalId = $(this).parent().attr("data-id"),
- jsonTradeDirection = $(this).parent().attr("data-tradeDirection"),
- jsonIntegrate = $(this).parent().attr("data-integrate");
- if(jsonIntegrate == 0) {
- judgeClear = true;
- } else {
- judgeClear = false;
- }
- if(jsonTradeDirection < 0) {
- subNum++;
- }
- if($(this).hasClass("active")) {
- $(this).removeClass("active");
- } else {
- $("#device_goal .sel-label").removeClass("active");
- $(this).addClass("active");
- goalArr.push(goalId);
- }
- })
- //滚动切换
- document.querySelector('.mui-slider').addEventListener('slide', function(event) {
- $("#con_tit div").removeClass("active")
- if (event.detail.slideNumber === 0) {
- $("#con_tit div").eq(0).addClass("active");
- } else if (event.detail.slideNumber === 1) {
- $("#con_tit div").eq(1).addClass("active");
- } else if (event.detail.slideNumber === 2) {
- $("#con_tit div").eq(2).addClass("active");
- } else if (event.detail.slideNumber === 3) {
- $("#con_tit div").eq(3).addClass("active");
- }
- });
- // 下一步
- $("#next").on("tap", function() {
- if(goalArr.length == 0) {
- mui.toast("请选择任务栏!");
- return false;
- }
- openWebview("health-award.html",{
- subNum: subNum,
- goalArr: goalArr,
- judgeClear: judgeClear
- });
- });
- $("#sure").on("tap", function() {
- if(goalArr.length == 0) {
- mui.toast("请先选择积分任务!")
- return false;
- }
- if(subNum > 0) {
- setDialog();
- } else {
- // 提交数据
- submitData();
- }
- })
- };
- // 页面业务处理流程开始
- mui.plusReady(function() {
- //获取当前页面
- self = plus.webview.currentWebview();
- load();
- //绑定事件
- bindEvents();
- //数据渲染
- goalList()
- })
|