homepage.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. var val = $.trim($(this).text());
  107. openWebviewExtras("edit_mobilephone.html",{"mobile": val});
  108. });
  109. //跳转去文章列表页面
  110. $("#moreArticle").click(function(){
  111. openWebviewExtras("../../jkjy/html/myArticle.html",{});
  112. });
  113. $("#articlePanel").on('click', '.article-item', function(){
  114. var code = $(this).attr("data-id");
  115. openWebview("../../jkjy/html/articleDetail.html", {
  116. articleId: code,
  117. referrer: ''
  118. });
  119. })
  120. }
  121. /*
  122. * 保存
  123. */
  124. function submit() {
  125. var mobileReg = /^[1][3578][0-9]{9}$/;
  126. var intro = $("#doc_brief").val();
  127. var exper = $("#doc_skill").val();
  128. var mobile = $("#mobile").val();
  129. if(!mobileReg.test(mobile)){
  130. mui.toast("请填写正确的手机号码!");
  131. return;
  132. }
  133. mobileModify = exMobile != mobile;
  134. if(intro == exBreif && exper == exSkill && !mobileModify && !isModify) {
  135. mui.toast("暂无修改");
  136. return;
  137. }
  138. uploadSingleImg(exper, intro, mobile);
  139. }
  140. var firstLevelCategoryId;
  141. function getMyArticle(){
  142. sendPost("/third/jkEdu/Article/getCategoryByName",{name:'健康文章'}, null, function(res){
  143. if(res.status == 200){
  144. firstLevelCategoryId = res.data.cid;
  145. queryListData();
  146. }
  147. },'get')
  148. }
  149. function queryListData(){
  150. var params ={
  151. firstLevelCategoryId: firstLevelCategoryId,
  152. secondLevelCategoryId: '',
  153. isAuthentication: "1",//文章是否认证
  154. insertTimeStart: '',
  155. insertTimeEnd: '',
  156. currentUserRole: hospital,
  157. iDisplayStart: 0,
  158. iDisplayLength: 1,
  159. currentUserRoleLevel: 4,
  160. roleType:1,
  161. isMyArticle: true
  162. }
  163. sendPost("/doctor/jkEdu/article/queryArticleAPPList",params, null, function(res){
  164. plus.nativeUI.closeWaiting();
  165. if(res.status == 200){
  166. var html = template('articleimgLi', {list : res.data.aaData});
  167. $("#articlePanel").append(html);
  168. }else{
  169. mui.toast(res.msg);
  170. }
  171. },'get')
  172. }
  173. template.helper("setContent", function(str){
  174. var reg=/<[^<>]+>/g;
  175. str = str.replace(reg, '');
  176. return str;
  177. });
  178. template.helper("getArticleImage", function(str){
  179. if(str){
  180. if(str.indexOf("../") > -1){
  181. return ""; //原福州代码中返回的相对路径
  182. }
  183. var url = getImgUrl(str);
  184. return "<img src='"+url+"'>";
  185. }
  186. return "";
  187. });
  188. template.helper("formatDate", function(str){
  189. if(str){
  190. return str.substr(0,19)
  191. }else{
  192. return "";
  193. }
  194. });
  195. window.addEventListener('getDocInfo', function(e) {
  196. initData();
  197. });