home2.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. var docType, docInfo;
  2. var myScroll;
  3. function initScroller(){
  4. //阻尼系数
  5. var deceleration = mui.os.ios?0.003:0.0009;
  6. mui('.mui-scroll-wrapper').scroll({
  7. scrollX: true,
  8. bounce: false,
  9. indicators: true, //是否显示滚动条
  10. deceleration:deceleration
  11. });
  12. myScroll = mui(".mui-scroll").pullToRefresh({
  13. down: {
  14. callback: function() {
  15. var self = this;
  16. setTimeout(function() {
  17. load();
  18. self.endPullDownToRefresh();
  19. }, 1000);
  20. }
  21. },
  22. scrollLeft: function(){
  23. xScroll = true;
  24. }
  25. });
  26. }
  27. mui.plusReady(function() {
  28. initScroller();
  29. //切换角色事件
  30. initQiehuanDom();
  31. //初始化扫码按钮
  32. initSaoMaDom();
  33. docType = parseInt(plus.storage.getItem("docType"));
  34. docInfo = JSON.parse(plus.storage.getItem("docInfo"));
  35. $("#doc_name").html(docInfo.name);
  36. $("#doc_type").html(docInfo.jobName);
  37. //控制团队报告
  38. if(docInfo.isLeader == 1){
  39. $('#work_resport').show()
  40. }else{
  41. $('#work_resport').hide()
  42. }
  43. //控制协同服务
  44. if(docInfo.hospital){
  45. if(docInfo.hospital.substr(0,6) == '350211' && docInfo.isLeader == 1){
  46. $('#xtfw_li').show()
  47. }else{
  48. $('#xtfw_li').hide()
  49. }
  50. }else{
  51. $('#xtfw_li').hide()
  52. }
  53. initDocPhoto("doc_photo", docInfo.photo, docInfo.sex);//图片加载失败时使用默认图片
  54. load();
  55. checkIdcard(docInfo.idcard);
  56. /*
  57. * 刷新页面数据
  58. */
  59. window.addEventListener("refresh", load);
  60. });
  61. /**
  62. * 初始化扫码按钮
  63. */
  64. function initSaoMaDom(){
  65. var flag = isMultiRole();
  66. var docInfo = JSON.parse(plus.storage.getItem("docInfo"));
  67. if(docInfo.level==3){//登录者是健康管理师
  68. // if(flag){
  69. // $('#div-saoma').addClass("abs-right60").show();
  70. // }else{
  71. // $('#div-saoma').addClass("abs-right10").show();
  72. // }
  73. }
  74. }
  75. function load(){
  76. getSignCount(); //签约、待签约数量
  77. // getPatiTypeAmount();//病种人群数量
  78. updateBadgeNumber(); //刷新应用角标数字
  79. // getGroupMsgCount(); // 获取讨论组总数
  80. // sendPost("doctor/baseinfo", null, function(res){
  81. // mui.toast(res.msg);
  82. // }, function(res){
  83. // if(res.status==200){
  84. // var data = res.data;
  85. // $('#fullNum').html(res.data.evaluateScore?res.data.evaluateScore:'<span style="font-size:0.58rem">暂无评分</span>')
  86. // }
  87. // },'POST','',true);
  88. }
  89. /*
  90. * 获取患者类型数量
  91. */
  92. function getPatiTypeAmount() {
  93. var postUrl = "/doctor/family_contract/patientGroupByServerType";
  94. var params = {};
  95. sendGet(postUrl, params, null, function(res) {
  96. if(res.status == 200) {
  97. var allAmount = 0;
  98. var useAmount = 0;
  99. var otherAmount = 0;
  100. $.each(res.data, function(i, v) {
  101. if(v.labelCode == 1){//普通人群
  102. document.getElementById("normal_amount").innerText = "( "+ v.amount +" 人)";
  103. useAmount = useAmount + v.amount;
  104. }
  105. if(v.labelCode == 3){//老年人
  106. document.getElementById("old_amount").innerText = "( "+ v.amount +" 人)";
  107. useAmount = useAmount + v.amount;
  108. }
  109. if(v.labelCode == 4){//高血压
  110. document.getElementById("hypertension_amount").innerText = "( "+ v.amount +" 人)";
  111. useAmount = useAmount + v.amount;
  112. }
  113. if(v.labelCode == 5){//糖尿病
  114. document.getElementById("diabetes_amount").innerText = "( "+ v.amount +" 人)";
  115. useAmount = useAmount + v.amount;
  116. }
  117. allAmount = allAmount + v.amount;//总人数
  118. });
  119. otherAmount = allAmount - useAmount;//其他的人数
  120. document.getElementById("other_amount").innerText = "( "+ otherAmount +" 人)";
  121. } else {
  122. console.error(res.msg);
  123. }
  124. },'POST','',true);
  125. }
  126. /*
  127. * 获取签约情况
  128. */
  129. function getSignCount() {
  130. sendPost("doctor/baseinfoCount", {doctorType: docType}, null, function(res) {
  131. if(res.status == 200) {
  132. $('#waitNum').html(res.data.concernCount||0);
  133. $('#last_amount').html(res.data.concernCount||0);
  134. $('#signNum').html(res.data.doctoConsult||0);
  135. $('#fullNum').html(res.data.doctorScore?res.data.doctorScore:'<span style="font-size:0.58rem">暂无评分</span>')
  136. } else {
  137. console.error(res.msg);
  138. }
  139. },'POST','',true);
  140. }
  141. /*
  142. * 刷新应用角标数字
  143. */
  144. function updateBadgeNumber() {
  145. var userId = plus.storage.getItem('im_userid');
  146. imClient.Application.getBadgeNo(userId, function(result) {
  147. console.log(JSON.stringify(result));
  148. try {
  149. if(result && result.badge != null) {
  150. plus.runtime.setBadgeNumber(result.badge);
  151. }
  152. } catch(e) {
  153. }
  154. })
  155. }
  156. function initHtml1(data, page){
  157. var json = data[0];
  158. var html = "";
  159. //load_doc_more
  160. if(!json){
  161. $("#load_doc_more").closest(".view-more").hide();
  162. return;
  163. }
  164. if(json.length<10){
  165. $("#load_doc_more").closest(".view-more").hide()
  166. }
  167. if(docType==3){
  168. $.each(json, function(i, v) {
  169. html += '<li data-name="'+ v.name+'" data-type="2" data-code='+v.code+' data-sex='+v.sex+'>' +
  170. '<div class="avatar">' +
  171. '<img class="default" src="../images/loading_03.gif" alt="医生头像" />' +
  172. '<img class="photo" data-sex="'+ v.sex +'" src="'+ getImgUrl(v.photo) +'" alt="医生头像" style="display: none" />' +
  173. '</div>' +
  174. '<div class="info">' +
  175. '<p><span class="name">'+ v.name+'</span></p>' +
  176. '<p class="c-909090">'+v.hospitalName+'</p>' +
  177. '</div>' +
  178. '</li>';
  179. });
  180. } else {
  181. $.each(json, function(i, v) {
  182. html += '<li data-name="'+ v.name+'" data-type="3" data-code='+v.code+' data-sex='+v.sex+'>' +
  183. '<div class="avatar">' +
  184. '<img class="default" src="../images/loading_03.gif" alt="医生头像" />' +
  185. '<img class="photo" data-sex="'+ v.sex +'" src="'+ getImgUrl(v.photo) +'" alt="医生头像" style="display: none" />' +
  186. '</div>' +
  187. '<div class="info">' +
  188. '<p><span class="name">'+v.name+'</span></p>' +
  189. '<p class="c-909090">签约总数:'+ v.count+'</p>' +
  190. '</div>' +
  191. '</li>';
  192. });
  193. }
  194. if(json.length==0){
  195. html += '<li class="zwsj">' +
  196. '<div class="info">' +
  197. '<p style="text-align: center;line-height: 56px;">暂无数据<br/></p>' +
  198. '</div>' +
  199. '</li>';
  200. }
  201. if(page==1){
  202. $('#doc_list').html(html);
  203. }else{
  204. $('#doc_list').append(html);
  205. }
  206. $('.my-team img.photo').error(function(){
  207. this.src = $(this).attr('data-sex')==1 ?
  208. "../../../images/d-male.png" : "../../../images/d-female.png";
  209. }).load(function(){
  210. $(this).prev().hide();
  211. $(this).show();
  212. });
  213. }
  214. function initHtml2(data, page){
  215. var json = data[1];
  216. html = "";
  217. if(!json){
  218. $("#load_pro_more").closest(".view-more").hide();
  219. return;
  220. }
  221. if(json.length<10){
  222. $("#load_pro_more").closest(".view-more").hide();
  223. }
  224. $.each(json, function(i, v) {
  225. html +='<li data-name="'+ v.name+'" data-type="1" data-code='+v.code+' data-sex='+v.sex+'>' +
  226. '<div class="avatar">' +
  227. '<img class="default" src="../images/loading_03.gif" alt="医生头像" />' +
  228. '<img class="photo" data-sex="'+ v.sex +'" src="'+ getImgUrl(v.photo) +'" alt="医生头像" style="display: none" />' +
  229. '</div>' +
  230. '<div class="info">' +
  231. '<p>' +
  232. '<span class="name">'+v.name+'</span>' +
  233. '<span class="c-909090 ml10" >'+(v.deptName || "")+'</span>' +
  234. '<span class="c-909090 ml10" style="overflow:hidden;width: 54%;height: 20px;display: inline-block;white-space: nowrap;text-overflow: ellipsis;">'+v.hospitalName+'</span>' +
  235. '</p>' +
  236. '<p class="c-909090 clearfix">' +
  237. '<span class="fl">总咨询次数:'+(v.allCount || 0 )+'</span>' +
  238. '<span class="fr">今日咨询次数:'+(v.currentCount || 0)+'</span>' +
  239. '</p>' +
  240. '</div>' +
  241. '</li>';
  242. });
  243. if(json.length==0){
  244. html += '<li class="zwsj">' +
  245. '<div class="info">' +
  246. '<p style="text-align: center;line-height: 56px;">暂无数据</p>' +
  247. '</div>' +
  248. '</li>';
  249. }
  250. if(page==1){
  251. $('#pro_doc_list').html(html);
  252. }else{
  253. $('#pro_doc_list').append(html);
  254. }
  255. $('.my-team img.photo').error(function(){
  256. this.src = $(this).attr('data-sex')==1 ?
  257. "../../../images/d-male.png" : "../../../images/d-female.png";
  258. }).load(function(){
  259. $(this).prev().hide();
  260. $(this).show();
  261. });
  262. }
  263. /*
  264. * 签约数跳转
  265. */
  266. $("#sign_amount").on("tap", "li", function() {
  267. var type = $(this).data("type");
  268. if(type == 5){
  269. mui.openWindow({
  270. url: "../../mine/html/manyidu.html",
  271. id: 'manyidu.html',
  272. waiting:{
  273. autoShow:false
  274. },
  275. extras:{
  276. type: type
  277. }
  278. });
  279. }else if(type==2){
  280. mui.openWindow({
  281. url: "../../xiaoxi/html/jiankangzixun.html"
  282. });
  283. }else if(type==1){
  284. mui.openWindow({
  285. url: "../../qygl/html/follow_manage.html"
  286. });
  287. }
  288. });
  289. /*
  290. * 跳转到居民
  291. */
  292. mui(".mod-bd").on("tap", ".patient-type", function() {
  293. var patiType = this.getAttribute("data-type");
  294. var huanzheWv = plus.webview.getWebviewById("huanzhe.html");
  295. var mainWv = plus.webview.getWebviewById("main");
  296. if(mainWv) {
  297. if(huanzheWv){
  298. huanzheWv.evalJS("showGroup("+ patiType +")");
  299. mui.fire(mainWv, "activeHuanzhe");
  300. }else{
  301. var subStyles = {
  302. top: "0px",
  303. bottom: "51px",
  304. scorllIndicator: "none",
  305. bounceBackground: "#17b3ec"
  306. };
  307. huanzheWv = mui.openWindow({
  308. url:"huanzhe.html",
  309. id:"huanzhe.html",
  310. styles:subStyles,
  311. waiting:{
  312. autoShow:true,//自动显示等待框,默认为true
  313. title:'正在加载...'//等待对话框上显示的提示内容
  314. }
  315. });
  316. mainWv.append(huanzheWv);
  317. huanzheWv.evalJS("showGroup("+ patiType +")");
  318. mui.fire(mainWv, "activeHuanzhe");
  319. }
  320. }
  321. });
  322. function toErweima(){
  323. mui.openWindow('../../mine/html/erweima.html','erweima',{
  324. extras:{code:docCode,name:docName,job:docJob,sex:sex,photo:photo,hospitalName:hospitalName}
  325. }
  326. )
  327. }
  328. /*
  329. * 我的服务跳转
  330. */
  331. mui(".list-fuwu2").on("tap", "li[data-href]", function() {
  332. //添加特殊处理,处理随访咨询
  333. var _this = this;
  334. if($(this).attr("id") == "suifang"){
  335. var patiType = _this.getAttribute("data-href"),
  336. type = _this.getAttribute("data-type");
  337. openWebview(patiType,{type: type, photo:docInfo.photo, name: docInfo.name,code: docInfo.code, job: docInfo.jobName, sex:docInfo.sex,hospitalName: docInfo.hospitalName });
  338. }else if($(this).attr("data-id") == "gongzuo"){//工作报告
  339. mui.openWindow({
  340. id: "gongzuobaogao",
  341. url: "../../tuandui/html/gongzuobaogao.html",
  342. extras: {
  343. teamCode:docInfo.adminTeamCode
  344. }
  345. })
  346. }else if($(this).attr("data-id") == "manbing"){//慢病
  347. mui.openWindow({
  348. id: "manbingguanli",
  349. url: "../../mbgl/html/manbingguanli.html",
  350. extras: {
  351. }
  352. })
  353. }else{
  354. var patiType = this.getAttribute("data-href"),
  355. type = this.getAttribute("data-type"),
  356. origin = this.getAttribute("data-origin");
  357. openWebview(patiType,{type: type, photo:docInfo.photo, name: docInfo.name,code: docInfo.code, job: docInfo.jobName, sex:docInfo.sex,hospitalName: docInfo.hospitalName,origin: origin});
  358. }
  359. return false;
  360. }).on('tap','#xfdd', function() {
  361. if(docType == "3") {
  362. openWebview("../../prescription/html/xufangdingdan-jg.html");
  363. } else if(docType == "2") {
  364. openWebview("../../prescription/html/xufangdingdan.html");
  365. }
  366. }).on('tap', 'li[data-href1]', function(){
  367. mui.toast("暂未开放");
  368. })
  369. /*
  370. * 医学交流跳转
  371. */
  372. mui(".list-doctor").on("tap", "li", function() {
  373. if(!$(this).hasClass("zwsj")){
  374. var code = this.getAttribute("data-code");
  375. var name = $(this).attr("data-name");
  376. var photo = $(this).find("img.photo").attr("src");
  377. var sex = $(this).attr("data-sex");
  378. mui.openWindow({
  379. id: "p2p",
  380. url: "../../message/html/p2p.html",
  381. extras: {
  382. otherCode: code,
  383. otherName: name,
  384. otherPhoto: photo,
  385. otherSex: sex
  386. }
  387. })
  388. }
  389. });//创建讨论组
  390. /*
  391. * 我的团队跳转
  392. */
  393. /*$("#groupCountDiv").on("tap", function(){
  394. mui.openWindow('../html/gongzuozu.html','gongzuozu',{});
  395. })
  396. function getGroupMsgCount(){
  397. sendPost("/doctor/talkgroup/count", {}, function(res){
  398. mui.toast("查询我的团队总数出错!");
  399. }, function(res){
  400. if(res.status=="200"){
  401. $('#groupCount').html(res.data);
  402. } else{
  403. mui.toast("查询我的团队总数出错!");
  404. }
  405. })
  406. }*/
  407. $("#zixun_link").on("tap", function() {
  408. openWebview("../../mygl/html/zixun-xuanzeyisheng.html");
  409. });
  410. $(function() {
  411. $(".mod-team .c-lab-mor >li").on("click", function() {
  412. var i = $(this).index();
  413. $(this).addClass('curr').siblings().removeClass('curr');
  414. $(".my-team> li").eq(i).show().siblings().hide();
  415. })
  416. });
  417. /*
  418. * 代理签约成功后刷新我的居民个数、签约数
  419. */
  420. window.addEventListener("refreshPatCount", function() {
  421. // getPatiTypeAmount();
  422. getSignCount();
  423. });
  424. //健管师扫码事件
  425. $("#div-saoma").on('tap', function() {
  426. openWebview("../../prescription/html/saoerweima.html");
  427. })