homepage.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. var docSex = null,
  2. hospital = '';
  3. mui.init();
  4. mui.plusReady(function() {
  5. plus.nativeUI.showWaiting();
  6. initData();
  7. });
  8. mui.previewImage();
  9. function initData(){
  10. var params = {};
  11. sendPost("doctor/baseinfo", params, queryFailed, success);
  12. }
  13. function getCount(){
  14. var url = "doctor/baseinfoCount",
  15. params = {};
  16. sendPost(url, params, null, function(res){
  17. if(res.status == 200){
  18. var count = res.data.concernCount;
  19. $("#concernCount").text(count);
  20. }else{
  21. mui.toast(res.msg)
  22. }
  23. })
  24. }
  25. var exBreif, exSkill, exMobile,oldMobile;
  26. function success(req) {
  27. if(req.status == 200) {
  28. exBreif = req.data.introduce;
  29. exSkill = req.data.expertise;
  30. exMobile = req.data.mobile;
  31. hospital = req.data.hospital;
  32. docSex = req.data.sex;
  33. //编辑手机号和身份证号,隐藏信息 2016-11-23 raolu start
  34. oldMobile = req.data.mobile;
  35. var sMobile = req.data.mobile.length> 0 ? (req.data.mobile.substr(0,3)+"****"+req.data.mobile.substr(-4)) : "";
  36. req.data.sMobile = sMobile;
  37. var slen = req.data.idcard ? req.data.idcard.length : 0,
  38. idcard = req.data.idcard,
  39. sID = slen > 13 ? (idcard.substr(0,4) + new Array(slen-8).join("*") +idcard.substr(-4)) : "";
  40. req.data.sIdcard = sID;
  41. //2016-11-23 end
  42. var cont = template("detail_info_tmpl", req.data);
  43. $(".content").html(cont);
  44. initDocPhoto("docPic", req.data.photo, req.data.sex);//图片加载失败时使用默认图片
  45. clickEvent();
  46. //获取关注人数
  47. getCount();
  48. //获取我的文章
  49. getMyArticle();
  50. plus.nativeUI.closeWaiting();
  51. } else {
  52. mui.toast(req.msg);
  53. plus.nativeUI.closeWaiting();
  54. }
  55. };
  56. function queryFailed(res) {
  57. if(res && res.msg) {
  58. plus.nativeUI.toast(res.msg);
  59. } else {
  60. plus.nativeUI.toast("数据加载失败");
  61. }
  62. plus.nativeUI.closeWaiting();
  63. };
  64. function clickEvent() {
  65. document.getElementById('edit_photo').addEventListener('tap', function() {
  66. var imgDom = document.getElementById("docPic");
  67. var url1 = showActionSheet(imgDom, this);
  68. });
  69. /*
  70. * 修改擅长
  71. */
  72. $("#edit_expertise").click(function() {
  73. var oldCont = $(this).html();
  74. if(!oldCont){
  75. oldCont="";
  76. }
  77. gotoModify("skill", oldCont.trim());
  78. });
  79. /*
  80. * 修改简介
  81. */
  82. $("#edit_introduce").click(function() {
  83. var oldCont = $(this).html().trim();
  84. if(!oldCont){
  85. oldCont="";
  86. }
  87. gotoModify("brief", oldCont.trim());
  88. });
  89. /**
  90. * 身份证修改
  91. */
  92. $("#idcard").click(function() {
  93. var cardValue = $(this).html();
  94. if(!cardValue){
  95. cardValue="";
  96. }
  97. gotoModify("idcard", cardValue.trim());
  98. });
  99. /**
  100. * 修改性别
  101. */
  102. $("#sexli").click(function() {
  103. gotoModify("sex", docSex);
  104. });
  105. $("#mobile").click(function() {
  106. openWebviewExtras("edit_mobilephone.html",{"mobile":oldMobile});
  107. });
  108. //跳转去文章列表页面
  109. $("#moreArticle").click(function(){
  110. openWebviewExtras("../../jkjy/html/myArticle.html",{});
  111. });
  112. $("#articlePanel").on('click', '.article-item', function(){
  113. var code = $(this).attr("data-id");
  114. openWebview("../../jkjy/html/articleDetail.html", {
  115. articleId: code,
  116. referrer: ''
  117. });
  118. })
  119. }
  120. /*
  121. * 保存
  122. */
  123. function submit() {
  124. var mobileReg = /^[1][3578][0-9]{9}$/;
  125. var intro = $("#doc_brief").val();
  126. var exper = $("#doc_skill").val();
  127. var mobile = $("#mobile").val();
  128. if(!mobileReg.test(mobile)){
  129. mui.toast("请填写正确的手机号码!");
  130. return;
  131. }
  132. mobileModify = exMobile != mobile;
  133. if(intro == exBreif && exper == exSkill && !mobileModify && !isModify) {
  134. mui.toast("暂无修改");
  135. return;
  136. }
  137. uploadSingleImg(exper, intro, mobile);
  138. }
  139. var firstLevelCategoryId;
  140. function getMyArticle(){
  141. sendPost("/third/jkEdu/Article/getCategoryByName",{name:'健康文章'}, null, function(res){
  142. if(res.status == 200){
  143. firstLevelCategoryId = res.data.cid;
  144. queryListData();
  145. }
  146. },'get')
  147. }
  148. function queryListData(){
  149. var params ={
  150. firstLevelCategoryId: firstLevelCategoryId,
  151. secondLevelCategoryId: '',
  152. isAuthentication: "1",//文章是否认证
  153. insertTimeStart: '',
  154. insertTimeEnd: '',
  155. currentUserRole: hospital,
  156. iDisplayStart: 0,
  157. iDisplayLength: 1,
  158. currentUserRoleLevel: 4,
  159. roleType:1,
  160. isMyArticle: true
  161. }
  162. sendPost("/doctor/jkEdu/article/queryArticleAPPList",params, null, function(res){
  163. plus.nativeUI.closeWaiting();
  164. if(res.status == 200){
  165. var html = template('articleimgLi', {list : res.data.aaData});
  166. $("#articlePanel").append(html);
  167. }else{
  168. mui.toast(res.msg);
  169. }
  170. },'get')
  171. }
  172. template.helper("setContent", function(str){
  173. var reg=/<[^<>]+>/g;
  174. str = str.replace(reg, '');
  175. return str;
  176. });
  177. template.helper("getArticleImage", function(str){
  178. if(str){
  179. if(str.indexOf("../") > -1){
  180. return ""; //原福州代码中返回的相对路径
  181. }
  182. var url = getImgUrl(str);
  183. return "<img src='"+url+"'>";
  184. }
  185. return "";
  186. });
  187. template.helper("formatDate", function(str){
  188. if(str){
  189. return str.substr(0,19)
  190. }else{
  191. return "";
  192. }
  193. });
  194. window.addEventListener('getDocInfo', function(e) {
  195. initData();
  196. });