home2.js 13 KB

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