survey_info.html 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>问卷调查详情</title>
  6. <meta name="format-detection" content="telephone=no"/>
  7. <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
  8. <meta name="apple-mobile-web-app-capable" content="yes"/>
  9. <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
  10. <link rel="stylesheet" href="../../../css/cross.css" type="text/css"/>
  11. <link rel="stylesheet" href="../../../css/cross.ui.css" type="text/css"/>
  12. <link rel="stylesheet" type="text/css" href="../../../iconfont/iconfont.css" />
  13. <link rel="stylesheet" type="text/css" href="../../../widget/artDialog/6.0.5/css/ui-dialog.min.css">
  14. <style type="text/css">
  15. .bgc-74bf00{background-color: #74bf00;}
  16. .footer{position: fixed; width: calc(100% - 20px); bottom: 10px; left:0;}
  17. </style>
  18. </head>
  19. <body>
  20. <h1 class="c-f16 c-333 c-t-center mt15 s_title"></h1>
  21. <p class="plr10 ptb10 c-f14 s_comment"></p>
  22. <div class="plr10 footer"><a class="c-btn c-100 c-btn-radius c-f16 bgc-74bf00">开始填写</a></div>
  23. </body>
  24. <script src="../../../js/jquery/2.1.3/jquery.js"></script>
  25. <script type="text/javascript" src="../../../js/weixin_common.js" ></script>
  26. <script type="text/javascript" src="../../../js/common_http.js" ></script>
  27. <script type="text/javascript" src="../../../js/app.js" ></script>
  28. <script type="text/javascript" src="../../../widget/artDialog/6.0.5/js/dialog-plus.min.js"></script>
  29. <script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
  30. <script type="text/javascript">
  31. var d = dialog({contentType:'load', skin:'bk-popup'});
  32. var Request = new Object();
  33. Request = GetRequest();
  34. var dataId = Request["survey_id"];
  35. var userAgent = window.localStorage.getItem(agentName);
  36. var toUser = Request["toUser"];
  37. var toName = decodeURIComponent(Request["toName"]);
  38. var openid = Request["openid"];
  39. var represented = Request["represented"];
  40. $(function(){
  41. localStorage.setItem("survey_id",dataId);
  42. if(!userAgent) {
  43. localStorage.setItem("toUser",toUser);
  44. window.location.href = server + "wx/html/home/html/zhmm-login.html?openid=" + openid+"&type=30";
  45. return false;
  46. }else{
  47. queryInit();
  48. }
  49. });
  50. function queryInit(){
  51. var newUaObj = JSON.parse(userAgent);
  52. //判断关系
  53. function hasFamilyRelation(a,b){
  54. return new Promise(function(resolve, reject) {
  55. var data={
  56. patient:a,
  57. familyMember:b
  58. }
  59. sendPost("patient/family/is_authorize", data, "json", "get", function(res){
  60. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请求家庭成员关系失败'}).show();
  61. }, function(res){
  62. if(res.status == 200) {
  63. window.localStorage.setItem('nowPatientName',res.data.name);
  64. resolve(res)
  65. }else if(res.status == 100) {
  66. dialog({
  67. content:'对不起,'+res.data.name+'未授权给您,如需查看,请切换'+res.data.name+'账号登录',
  68. okValue:'切换账号',
  69. ok: function() {
  70. window.localStorage.setItem(pageName, JSON.stringify({pageurl: location.href}))
  71. window.location.href = "../../grzx/html/change-login.html?type=0&openid="+ Request["openid"];
  72. },
  73. cancelValue: '我不看了',
  74. cancel: function () {
  75. wx.closeWindow();
  76. }
  77. }).showModal();
  78. }else{
  79. relogin();
  80. }
  81. })
  82. })
  83. }
  84. //重新登录操作
  85. function relogin(){
  86. dialog({
  87. content:'对不起,该消息是发给'+toName+',如需查看,请切换'+toName+'账号登录',
  88. okValue:'切换账号',
  89. ok: function() {
  90. window.localStorage.setItem(pageName, JSON.stringify({pageurl: location.href}))
  91. window.location.href = "../../grzx/html/change-login.html?type=0&openid="+ Request["openid"];
  92. },
  93. cancelValue: '我不看了',
  94. cancel: function () {
  95. wx.closeWindow();
  96. }
  97. }).showModal();
  98. }
  99. //保存信息
  100. function saveUserInfo(a,b){
  101. Promise.all([hasFamilyRelation(a,b)]).then(function () {
  102. newUaObj.represented = represented;
  103. window.localStorage.setItem(agentName,JSON.stringify(newUaObj));
  104. userAgent = window.localStorage.getItem(agentName);
  105. getSummary();
  106. bindEvents();
  107. })
  108. }
  109. function initFamilyData () {
  110. //从微信模板消息进入
  111. if(represented && userAgent && toUser){
  112. if(toUser == represented){
  113. saveUserInfo(represented,newUaObj.uid)
  114. }else if(toUser != represented && represented == newUaObj.uid){
  115. //本人代理
  116. saveUserInfo(represented,newUaObj.uid)
  117. }else if(toUser != represented && toUser == newUaObj.uid){
  118. //需要判定关系 200有授权 100家人 1无关系
  119. saveUserInfo(represented,newUaObj.uid)
  120. }else{
  121. //重新登录
  122. relogin();
  123. }
  124. }else{
  125. getSummary();
  126. bindEvents();
  127. }
  128. }
  129. initFamilyData();
  130. }
  131. function getSummary(){
  132. d.show();
  133. // var dataId = localStorage.getItem("survey_id");
  134. var url = "/patient/questionnaire/getSurveySummary",
  135. params = {id: dataId};
  136. sendPost(url,params,"JSON","GET",function(res){
  137. //failed
  138. d.close();
  139. if(res.msg){
  140. dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg,bottom:true}).show();
  141. }else{
  142. dialog({contentType:'tipsbox', skin:'bk-popup' , content:'数据加载失败!',bottom:true}).show();
  143. }
  144. },function(res){
  145. //success
  146. d.close();
  147. if(res.status==200){
  148. var data = res.data;
  149. $("h1").text(data.title);
  150. $("p").text(data.comment);
  151. if(res.data.status == 2){ //问卷状态 1正常 2暂停
  152. dialog({
  153. content:'对不起,该问卷已暂停作答',//'对不起,您已更换账号,需重新登录<span style="color:#333">'+handerAccount+'</span>账号后,方可处理该邀请。',
  154. okValue:'我知道了',
  155. ok: function() {
  156. $(".footer").hide();
  157. }
  158. }).showModal();
  159. }
  160. //如果用户已经填写了问卷,也不显示开始按钮
  161. if(res.data.complete == 1){//complete 0未答 1已答
  162. $(".footer").hide();
  163. }
  164. }else{
  165. if(res.status==-2){
  166. dialog({
  167. content:'对不起,该消息不是您的消息,您无法查看哦~',//'对不起,您已更换账号,需重新登录<span style="color:#333">'+handerAccount+'</span>账号后,方可处理该邀请。',
  168. okValue:'我知道了',
  169. ok: function() {
  170. wx.closeWindow();
  171. }
  172. }).showModal();
  173. }else{
  174. if(res.msg){
  175. dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg,bottom:true}).show();
  176. }else{
  177. dialog({contentType:'tipsbox', skin:'bk-popup' , content:'数据加载失败!',bottom:true}).show();
  178. }
  179. }
  180. }
  181. });
  182. }
  183. function bindEvents(){
  184. $(".c-btn").on('click', function(){
  185. // var dataId = localStorage.getItem("survey_id");
  186. window.location.href = "question.html?survey_id="+dataId;
  187. });
  188. }
  189. </script>
  190. </html>