public-consult-detail.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>公共咨询</title>
  6. <meta name="author" content="yihu.com"/>
  7. <meta name="format-detection" content="telephone=no"/>
  8. <meta name="viewport"
  9. content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
  10. <meta name="apple-mobile-web-app-capable" content="yes"/>
  11. <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
  12. <link rel="stylesheet" type="text/css" href="../../../css/cross.css" />
  13. <link rel="stylesheet" type="text/css" href="../../../css/cross.ui.css">
  14. <link rel="stylesheet" type="text/css" href="../../../iconfont/iconfont.css" />
  15. <link rel="stylesheet" type="text/css" href="../../../css/ss-style.css" />
  16. <style>
  17. .discus.c-list > li.c-list-label { margin-left: 15px }
  18. </style>
  19. <script type="text/javascript" src="../../../js/jquery/2.1.3/jquery.js"></script>
  20. <script src="../js/ui_search_one.js"></script>
  21. <link rel="stylesheet" type="text/css" href="../../../widget/mobiscroll/2.15.1/css/mobiscroll.css">
  22. <script src="../../../widget/mobiscroll/2.15.1/js/mobiscroll.js"></script>
  23. <link rel="stylesheet" type="text/css" href="../../../widget/artDialog/6.0.5/css/ui-dialog.min.css">
  24. <script src="../../../widget/artDialog/6.0.5/js/dialog-plus.min.js"></script>
  25. <script src="../../../js/mui.min.js"></script>
  26. <script src="../../../js/app.js"></script>
  27. <script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
  28. <script src="../../../js/common_http.js"></script>
  29. <script type="text/javascript" src="../../../js/weixin_common.js" ></script>
  30. </head>
  31. <body>
  32. <div class="mt10 pb10">
  33. <div class="">
  34. <ul class="c-list c-border-tb zx-timper">
  35. <li class="">
  36. <div class=" c-avatar-m"><img id="photo" src=""></div>
  37. <div class="c-list-info">
  38. <h4 class="c-nowrap" id="name"></h4>
  39. <p class="c-nowrap" id="czrq"></p>
  40. </div>
  41. </li>
  42. <li class="c-list-label">
  43. <h2 class="c-333 c-f17 c-bold mb5" id="title" style="word-break: break-word;"></h2>
  44. <!--<p class="c-333 c-f15">发病时间:<span id="when"></span></p>-->
  45. <p class="c-333 c-f15">疾病类型:<span id="diseaseName"></span></p>
  46. <p class="c-333 c-f15" style="word-break: break-word;">主要症状:<span id="content"></span></p>
  47. <p class="mt10 soper-pic" id="imageList"></p>
  48. </li>
  49. </ul>
  50. <div id="ulReply"></div>
  51. <a href="javascript:;" class="view-more c-37a6ed" id="view_more">点击查看更多</a>
  52. </div>
  53. </div>
  54. <div class="timper-addfix" onclick="add()"><i class="iconfont icon-jia"></i></div>
  55. <!-- 放置要缩放的图片的容器 -->
  56. <section class="imgzoom-pack">
  57. <div class="imgzoom-x">关闭</div>
  58. <div class="imgzoom-del"></div>
  59. <div class="imgzoom-img"><img src="" /></div>
  60. </section>
  61. <script>
  62. var d = dialog({contentType:'load', skin:'bk-popup'});
  63. var userAgent = window.localStorage.getItem(agentName);
  64. var Request = new Object();
  65. Request = GetRequest();
  66. var code = Request["code"];
  67. var toUser = Request["toUser"];
  68. var toName = decodeURIComponent(Request["toName"]);
  69. var openid = Request["openid"];
  70. var represented = Request["represented"];
  71. var id = 0;
  72. var pagesize = 10;
  73. var total = 0;
  74. var pagetype = 36;
  75. $(function(){
  76. if(!userAgent) {
  77. localStorage.setItem("toUser",toUser);
  78. window.location.href = server + "wx/html/home/html/zhmm-login.html?type=" + pagetype + "&openid=" + openid;
  79. return false;
  80. }
  81. var newUaObj = JSON.parse(window.localStorage.getItem(agentName))
  82. //判断关系
  83. function hasFamilyRelation(a,b){
  84. return new Promise(function(resolve, reject) {
  85. var data={
  86. patient:a,
  87. familyMember:b
  88. }
  89. sendPost("patient/family/is_authorize", data, "json", "get", function(res){
  90. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请求家庭成员关系失败'}).show();
  91. }, function(res){
  92. if(res.status == 200) {
  93. window.localStorage.setItem('nowPatientName',res.data.name);
  94. resolve(res)
  95. }else if(res.status == 100) {
  96. dialog({
  97. content:'对不起,'+res.data.name+'未授权给您,如需查看,请切换'+res.data.name+'账号登录',
  98. okValue:'切换账号',
  99. ok: function() {
  100. window.localStorage.setItem(pageName, JSON.stringify({pageurl: location.href}))
  101. window.location.href = "../../grzx/html/change-login.html?type=0&openid="+ Request["openid"];
  102. },
  103. cancelValue: '我不看了',
  104. cancel: function () {
  105. wx.closeWindow();
  106. }
  107. }).showModal();
  108. }else{
  109. relogin();
  110. }
  111. })
  112. })
  113. }
  114. //重新登录操作
  115. function relogin(){
  116. dialog({
  117. content:'对不起,该消息是发给'+toName+',如需查看,请切换'+toName+'账号登录',
  118. okValue:'切换账号',
  119. ok: function() {
  120. window.localStorage.setItem(pageName, JSON.stringify({pageurl: location.href}))
  121. window.location.href = "../../grzx/html/change-login.html?type=0&openid="+ Request["openid"];
  122. },
  123. cancelValue: '我不看了',
  124. cancel: function () {
  125. wx.closeWindow();
  126. }
  127. }).showModal();
  128. }
  129. //保存信息
  130. function saveUserInfo(a,b){
  131. Promise.all([hasFamilyRelation(a,b)]).then(function () {
  132. newUaObj.represented = represented;
  133. window.localStorage.setItem(agentName,JSON.stringify(newUaObj));
  134. userAgent = window.localStorage.getItem(agentName);
  135. detailInfo();
  136. })
  137. }
  138. function initFamilyData () {
  139. //从微信模板消息进入
  140. if(represented && userAgent && toUser){
  141. if(toUser == represented){
  142. saveUserInfo(represented,newUaObj.uid)
  143. }else if(toUser != represented && represented == newUaObj.uid){
  144. //本人代理
  145. saveUserInfo(represented,newUaObj.uid)
  146. }else if(toUser != represented && toUser == newUaObj.uid){
  147. //需要判定关系 200有授权 100家人 1无关系
  148. saveUserInfo(represented,newUaObj.uid)
  149. }else{
  150. //重新登录
  151. relogin();
  152. }
  153. }else{
  154. detailInfo();
  155. }
  156. }
  157. initFamilyData();
  158. document.getElementById('view_more').addEventListener("tap", function() {
  159. reply();
  160. });
  161. });
  162. //填充咨询详情
  163. function detailInfo() {
  164. d.show();
  165. var data = {};
  166. data.consult = code;
  167. $.ajax(server + "patient/consult/public/info", {
  168. data: data,
  169. type: 'POST',
  170. dataType: 'json',
  171. beforeSend: function(request) {
  172. request.setRequestHeader("userAgent", userAgent);
  173. },
  174. error: function(res) {
  175. d.close();
  176. if(res.status == 999 || res.status == 998 || res.status == 997){
  177. loginUrl(res.status);
  178. return;
  179. }
  180. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'加载失败'}).show();
  181. },
  182. success: function(res) {
  183. if(res.status == 999 || res.status == 998 || res.status == 997){
  184. loginUrl(res.status);
  185. }
  186. else if (res.status == 200) {
  187. var photo = getImgUrl(res.data.photo);
  188. var name = res.data.name;
  189. var title = res.data.question;
  190. var when = res.data.when;
  191. var diseaseName = res.data.diseaseName;
  192. var content = res.data.content;
  193. var images = res.data.images;
  194. var czrq = res.data.czrq;
  195. var url1 = "../../../images/p-default.png";
  196. if(photo) url1 = photo;
  197. if(!name) name = "";
  198. if(!title) title = "";
  199. if(!when) when = "";
  200. if(!content) content = "";
  201. if(!diseaseName) diseaseName = "";
  202. if(!images) images = "";
  203. var imageList = images.split(',');
  204. if(!czrq) czrq = "";
  205. document.getElementById("photo").src = url1;
  206. document.getElementById("name").innerHTML = name;
  207. document.getElementById("czrq").innerHTML = czrq;
  208. document.getElementById("title").innerHTML = title;
  209. //document.getElementById("when").innerHTML = when;
  210. document.getElementById("diseaseName").innerHTML = diseaseName;
  211. document.getElementById("content").innerHTML = content;
  212. if(imageList.length > 0){
  213. var html = "";
  214. for(var i=0; i<imageList.length; i++){
  215. if(imageList[i] != ""){
  216. html += "<img src='" + getImgUrl(imageList[i]) + "' onclick='viewImg(this)'>";
  217. }
  218. }
  219. document.getElementById("imageList").innerHTML = html;
  220. }
  221. d.close();
  222. reply();
  223. } else {
  224. d.close();
  225. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'加载失败'}).show();
  226. }
  227. }
  228. });
  229. }
  230. //获取回复信息
  231. function reply() {
  232. d.show();
  233. var data = {};
  234. data.consult = code;
  235. data.id = id;
  236. data.pagesize = pagesize;
  237. $.ajax(server + "patient/consult/public/reply_list", {
  238. data: data,
  239. type: 'POST',
  240. dataType: 'json',
  241. beforeSend: function(request) {
  242. request.setRequestHeader("userAgent", userAgent);
  243. },
  244. error: function(res) {
  245. d.close();
  246. if(res.status == 999 || res.status == 998 || res.status == 997){
  247. loginUrl(res.status);
  248. return;
  249. }
  250. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'加载失败'}).show();
  251. document.querySelector("#view_more").innerText = "数据加载失败";
  252. },
  253. success: function(res) {
  254. if(res.status == 999 || res.status == 998 || res.status == 997){
  255. loginUrl(res.status);
  256. }
  257. else if (res.status == 200) {
  258. if(res.isFirst){
  259. total = res.total;
  260. }
  261. if (res.list.length > 0) {
  262. var list = res.list;
  263. var $list = document.querySelector("#ulReply");
  264. for (var i = 0; i < list.length; i++) {
  265. id = list[i].id;
  266. var $ul = document.createElement("ul");
  267. $ul.className = "c-list discus";
  268. var photo = getImgUrl(list[i].photo);
  269. if(photo == null || photo == ""){
  270. photo = "../../../images/p-default.png";
  271. }
  272. var content = '<li class="">';
  273. content += '<div class=" c-avatar-m"><img src="' + photo + '"></div>';
  274. content += '<div class="c-list-info"><h4 class="c-nowrap">' + list[i].name + '</h4>';
  275. content += '<p class="c-nowrap">' + list[i].czrq + '</p></div>';
  276. content += '<div class="c-list-action"><span>' + total + 'F</span></div>';
  277. content += '</li><li class="c-list-label c-333"><div class="c-list-info">'
  278. content += '<p class="c-333 c-f15" style="word-break: break-word;">' + list[i].content + "</p>";
  279. content += '<p class="mt10">';
  280. var images = list[i].images;
  281. if(images == null) images = "";
  282. var imageList = images.split(',');
  283. if(imageList.length > 0){
  284. for(var j=0; j<imageList.length; j++){
  285. if(imageList[j] != ""){
  286. content += "<img style='height: 60px; width: 60px; margin: 0 5px;' src='" + getImgUrl(imageList[j]) + "' onclick='viewImg(this)'>";
  287. }
  288. }
  289. }
  290. content += "</p></div></li>";
  291. $ul.innerHTML = content;
  292. $list.appendChild($ul);
  293. total = total - 1;
  294. }
  295. } else {
  296. document.querySelector("#view_more").innerText = "已无更多回复";
  297. }
  298. d.close();
  299. } else {
  300. d.close();
  301. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'加载失败'}).show();
  302. document.querySelector("#view_more").innerText = "数据加载失败";
  303. }
  304. }
  305. });
  306. }
  307. function add(){
  308. window.location.href = "public-consult-reply.html?code=" + code;
  309. }
  310. //查看图片
  311. function viewImg(dom) {
  312. var $img = $(dom);
  313. var thissrc = getImgUrl($img.attr("src"));
  314. var mWid = $(window).width();
  315. var mHei = $(window).height();
  316. var nHtml = '<div class="delimgpop"><div class="del-img-box"><div class="del-img-con"><img class="del-pop-img" src="' + thissrc + '" style="max-width:' + mWid + 'px; max-height:' + mHei + 'px;"></div></div></div>';
  317. $("body").append(nHtml);
  318. $(".delimgpop").click(function() {
  319. $(this).remove()
  320. });
  321. };
  322. </script>
  323. </body>
  324. </html>