|
|
$(document).ready(function () {
|
|
|
var ctx = $("#ctx").val();
|
|
|
var sid = $.getUrlParam("sid");
|
|
|
var surveyId = $.getUrlParam("surveyId");
|
|
|
var template = $.getUrlParam("template");
|
|
|
$("#sid").val(sid);
|
|
|
$("#id").val(surveyId);
|
|
|
loadSurveyData(function () {
|
|
|
let prefix = window.location.href.split("/static/");
|
|
|
console.warn("preview.js", prefix[0]);
|
|
|
// console.warn("---->", getCookie("RE_TURN"));
|
|
|
// 说明:根据cookie,确认返回
|
|
|
if (Number(getCookie("RE_TURN")) == 0) {
|
|
|
$("#surveyList").attr("href", prefix[0] + "/#/dw/survey");
|
|
|
} else if (Number(getCookie("RE_TURN")) == 1) {
|
|
|
$("#surveyList").attr("href", prefix[0] + "/#/dw/survey2");
|
|
|
}
|
|
|
$("#designSurvey").attr(
|
|
|
"href",
|
|
|
prefix[0] + "/static/diaowen/design.html?surveyId=" + surveyId
|
|
|
);
|
|
|
$("#dwPhone").hide();
|
|
|
$("#dwPad").hide();
|
|
|
var tag = $("#tag").val();
|
|
|
$("#PcSurvey").attr(
|
|
|
"src",
|
|
|
prefix[0] +
|
|
|
"/static/diaowen/answer-p.html?surveyId=" +
|
|
|
surveyId +
|
|
|
"&sid=" +
|
|
|
sid +
|
|
|
"&tag=" +
|
|
|
tag
|
|
|
);
|
|
|
bindEvent();
|
|
|
if (template != null && template === "1") {
|
|
|
$("#editorPreview").hide();
|
|
|
$("#templatePreview").show();
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
|
|
|
function bindEvent() {
|
|
|
$(".centerTabbarBtn").click(function () {
|
|
|
let prefix = window.location.href.split("/static/");
|
|
|
console.warn("preview.js", prefix[0]);
|
|
|
var surveyId = $("#id").val();
|
|
|
var sid = $("#sid").val();
|
|
|
var tag = $("#tag").val();
|
|
|
$(".centerTabbarBtn").removeClass("active");
|
|
|
$(this).addClass("active");
|
|
|
var thHref = $(this).attr("href");
|
|
|
if (thHref === "#dwPc") {
|
|
|
} else if (thHref === "#dwPad") {
|
|
|
$("#PadSurvey").attr(
|
|
|
"src",
|
|
|
prefix[0] +
|
|
|
"/static/diaowen/answer-m.html?surveyId=" +
|
|
|
surveyId +
|
|
|
"&sid=" +
|
|
|
sid +
|
|
|
"&tag=" +
|
|
|
tag
|
|
|
);
|
|
|
} else if (thHref === "#dwPhone") {
|
|
|
$("#PhoneSurvey").attr(
|
|
|
"src",
|
|
|
prefix[0] +
|
|
|
"/static/diaowen/answer-m.html?surveyId=" +
|
|
|
surveyId +
|
|
|
"&sid=" +
|
|
|
sid +
|
|
|
"&tag=" +
|
|
|
tag
|
|
|
);
|
|
|
}
|
|
|
$(".dwPreviewBody").hide();
|
|
|
$(thHref).show();
|
|
|
return false;
|
|
|
});
|
|
|
|
|
|
$("#confirgDevSuvey").click(function () {
|
|
|
let prefix = window.location.href.split("/static/");
|
|
|
console.warn("确认发布", prefix[0]);
|
|
|
var ctx = $("#ctx").val();
|
|
|
var surveyId = $("#id").val();
|
|
|
var url = ctx + "/design/survey-design/devSurvey.do";
|
|
|
var data = "surveyId=" + surveyId;
|
|
|
$.ajax({
|
|
|
headers: {
|
|
|
token: localStorage.getItem("Ls-Token"),
|
|
|
},
|
|
|
url: url,
|
|
|
data: data,
|
|
|
type: "post",
|
|
|
success: function (httpResult) {
|
|
|
if (httpResult.resultCode === 200) {
|
|
|
// 返回页
|
|
|
window.location.href = prefix[0] + "/#/dw/survey/back";
|
|
|
// 原先地址页
|
|
|
// window.location.href = prefix[0] + "/#/dw/survey/c/url/" + surveyId;
|
|
|
} else {
|
|
|
alert(httpResult.resultMsg);
|
|
|
}
|
|
|
},
|
|
|
error: function (xmlHttpRequest, textStatus, errorThrown) {
|
|
|
// alert(xmlHttpRequest);
|
|
|
if (xmlHttpRequest.status === 401) {
|
|
|
window.location.href = "/#/login";
|
|
|
} else if (xmlHttpRequest.status === 403) {
|
|
|
alert("没有发布权限");
|
|
|
// window.location.href="/#/exception/403";
|
|
|
}
|
|
|
},
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
|
|
|
function loadSurveyData(callback) {
|
|
|
var ctx = $("#ctx").val();
|
|
|
var surveyId = $("#id").val();
|
|
|
var url = ctx + "/survey/info.do";
|
|
|
var data = "id=" + surveyId;
|
|
|
$.ajax({
|
|
|
headers: {
|
|
|
token: localStorage.getItem("Ls-Token"),
|
|
|
},
|
|
|
url: url,
|
|
|
data: data,
|
|
|
type: "get",
|
|
|
success: function (httpResult) {
|
|
|
if (httpResult.resultCode == 401) {
|
|
|
window.location.href = "/#/login";
|
|
|
}
|
|
|
//surveyName
|
|
|
if (httpResult.resultCode == 200) {
|
|
|
$("#surveyName").val(httpResult.data.surveyName);
|
|
|
}
|
|
|
if (callback != null) {
|
|
|
callback();
|
|
|
}
|
|
|
},
|
|
|
});
|
|
|
}
|