homepage.js 5.6 KB

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