123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>问卷调查详情</title>
- <meta name="format-detection" content="telephone=no"/>
- <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
- <meta name="apple-mobile-web-app-capable" content="yes"/>
- <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
- <link rel="stylesheet" href="../../../css/cross.css" type="text/css"/>
- <link rel="stylesheet" href="../../../css/cross.ui.css" type="text/css"/>
- <link rel="stylesheet" type="text/css" href="../../../iconfont/iconfont.css" />
- <link rel="stylesheet" type="text/css" href="../../../widget/artDialog/6.0.5/css/ui-dialog.min.css">
- <style type="text/css">
- .bgc-74bf00{background-color: #74bf00;}
- .footer{position: fixed; width: calc(100% - 20px); bottom: 10px; left:0;}
- </style>
- </head>
- <body>
- <h1 class="c-f16 c-333 c-t-center mt15 s_title"></h1>
- <p class="plr10 ptb10 c-f14 s_comment"></p>
- <div class="plr10 footer"><a class="c-btn c-100 c-btn-radius c-f16 bgc-74bf00">开始填写</a></div>
- </body>
- <script src="../../../js/jquery/2.1.3/jquery.js"></script>
- <script type="text/javascript" src="../../../js/weixin_common.js" ></script>
- <script type="text/javascript" src="../../../js/common_http.js" ></script>
- <script type="text/javascript" src="../../../js/app.js" ></script>
- <script type="text/javascript" src="../../../widget/artDialog/6.0.5/js/dialog-plus.min.js"></script>
- <script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
- <script type="text/javascript">
- var d = dialog({contentType:'load', skin:'bk-popup'});
- var Request = new Object();
- Request = GetRequest();
- var dataId = Request["survey_id"];
- var userAgent = window.localStorage.getItem(agentName);
- var toUser = Request["toUser"];
- var toName = decodeURIComponent(Request["toName"]);
- var openid = Request["openid"];
- var represented = Request["represented"];
- $(function(){
- localStorage.setItem("survey_id",dataId);
- if(!userAgent) {
- localStorage.setItem("toUser",toUser);
- window.location.href = server + "wx/html/home/html/zhmm-login.html?openid=" + openid+"&type=30";
- return false;
- }else{
- queryInit();
- }
- });
- function queryInit(){
- var newUaObj = JSON.parse(userAgent);
- //判断关系
- function hasFamilyRelation(a,b){
- return new Promise(function(resolve, reject) {
- var data={
- patient:a,
- familyMember:b
- }
- sendPost("patient/family/is_authorize", data, "json", "get", function(res){
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请求家庭成员关系失败'}).show();
- }, function(res){
- if(res.status == 200) {
- window.localStorage.setItem('nowPatientName',res.data.name);
- resolve(res)
- }else if(res.status == 100) {
- dialog({
- content:'对不起,'+res.data.name+'未授权给您,如需查看,请切换'+res.data.name+'账号登录',
- okValue:'切换账号',
- ok: function() {
- window.localStorage.setItem(pageName, JSON.stringify({pageurl: location.href}))
- window.location.href = "../../grzx/html/change-login.html?type=0&openid="+ Request["openid"];
- },
- cancelValue: '我不看了',
- cancel: function () {
- wx.closeWindow();
- }
- }).showModal();
- }else{
- relogin();
- }
-
- })
- })
- }
- //重新登录操作
- function relogin(){
- dialog({
- content:'对不起,该消息是发给'+toName+',如需查看,请切换'+toName+'账号登录',
- okValue:'切换账号',
- ok: function() {
- window.localStorage.setItem(pageName, JSON.stringify({pageurl: location.href}))
- window.location.href = "../../grzx/html/change-login.html?type=0&openid="+ Request["openid"];
- },
- cancelValue: '我不看了',
- cancel: function () {
- wx.closeWindow();
- }
- }).showModal();
- }
- //保存信息
- function saveUserInfo(a,b){
- Promise.all([hasFamilyRelation(a,b)]).then(function () {
- newUaObj.represented = represented;
- window.localStorage.setItem(agentName,JSON.stringify(newUaObj));
- userAgent = window.localStorage.getItem(agentName);
- getSummary();
- bindEvents();
- })
- }
-
- function initFamilyData () {
- //从微信模板消息进入
- if(represented && userAgent && toUser){
- if(toUser == represented){
- saveUserInfo(represented,newUaObj.uid)
- }else if(toUser != represented && represented == newUaObj.uid){
- //本人代理
- saveUserInfo(represented,newUaObj.uid)
- }else if(toUser != represented && toUser == newUaObj.uid){
- //需要判定关系 200有授权 100家人 1无关系
- saveUserInfo(represented,newUaObj.uid)
- }else{
- //重新登录
- relogin();
- }
- }else{
- getSummary();
- bindEvents();
- }
- }
- initFamilyData();
- }
- function getSummary(){
- d.show();
- // var dataId = localStorage.getItem("survey_id");
- var url = "/patient/questionnaire/getSurveySummary",
- params = {id: dataId};
- sendPost(url,params,"JSON","GET",function(res){
- //failed
- d.close();
- if(res.msg){
- dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg,bottom:true}).show();
- }else{
- dialog({contentType:'tipsbox', skin:'bk-popup' , content:'数据加载失败!',bottom:true}).show();
- }
- },function(res){
- //success
- d.close();
- if(res.status==200){
- var data = res.data;
- $("h1").text(data.title);
- $("p").text(data.comment);
- if(res.data.status == 2){ //问卷状态 1正常 2暂停
- dialog({
- content:'对不起,该问卷已暂停作答',//'对不起,您已更换账号,需重新登录<span style="color:#333">'+handerAccount+'</span>账号后,方可处理该邀请。',
- okValue:'我知道了',
- ok: function() {
- $(".footer").hide();
- }
- }).showModal();
- }
- //如果用户已经填写了问卷,也不显示开始按钮
- if(res.data.complete == 1){//complete 0未答 1已答
- $(".footer").hide();
- }
- }else{
- if(res.status==-2){
- dialog({
- content:'对不起,该消息不是您的消息,您无法查看哦~',//'对不起,您已更换账号,需重新登录<span style="color:#333">'+handerAccount+'</span>账号后,方可处理该邀请。',
- okValue:'我知道了',
- ok: function() {
- wx.closeWindow();
- }
- }).showModal();
- }else{
- if(res.msg){
- dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg,bottom:true}).show();
- }else{
- dialog({contentType:'tipsbox', skin:'bk-popup' , content:'数据加载失败!',bottom:true}).show();
- }
- }
- }
- });
- }
-
- function bindEvents(){
- $(".c-btn").on('click', function(){
- // var dataId = localStorage.getItem("survey_id");
- window.location.href = "question.html?survey_id="+dataId;
- });
- }
- </script>
- </html>
|