home2.js 13 KB

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