home2.js 13 KB

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