home2.js 14 KB

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