Browse Source

新增了匿名访问的方式

Mask96 5 years ago
parent
commit
f30a7cd95f
1 changed files with 54 additions and 22 deletions
  1. 54 22
      src/components/WebQn.vue

+ 54 - 22
src/components/WebQn.vue

@@ -127,17 +127,34 @@ export default {
     }
     this.webQnUrl = this.$baseUrl + "/web-qn/" + id;
     console.log("webQnUrl", this.webQnUrl);
-    axios.get(this.webQnUrl).then(webQnResponse => {
-      console.log(webQnResponse.data);
-      let qnId = webQnResponse.data.qnId;
-      let qnDataUrl = this.webQnUrl + "/complete-info";
-      console.log("qnDataUrl", qnDataUrl);
-      axios.get(qnDataUrl).then(r => {
-        this.questionaire = r.data;
-        this.webQuestionaire = webQnResponse.data;
-        // this.questionaire.info = r.data.info;
-        console.log(this.questionaire);
-      });
+    axios.get(this.webQnUrl + "/judge").then(response => {
+      console.log("open way:", response.data);
+      this.openWay = response.data;
+      if (response.data == "Project") {
+        console.log("匿名方式问卷打开");
+        let qnDataUrl = this.webQnUrl + "/complete-info-incognito";
+        console.log("qnDataUrl:", qnDataUrl);
+        axios.get(qnDataUrl).then(r => {
+          this.questionaire = r.data;
+          this.webQuestionaire = { status: 1 };
+          // this.webQuestionaire = webQnResponse.data;
+          // this.questionaire.info = r.data.info;
+          console.log("匿名方式问卷内容:", this.questionaire);
+        });
+      } else {
+        console.log("登录方式问卷打开");
+        axios.get(this.webQnUrl).then(webQnResponse => {
+          let qnId = webQnResponse.data.qnId;
+          let qnDataUrl = this.webQnUrl + "/complete-info";
+          console.log("qnDataUrl", qnDataUrl);
+          axios.get(qnDataUrl).then(r => {
+            this.questionaire = r.data;
+            this.webQuestionaire = webQnResponse.data;
+            // this.questionaire.info = r.data.info;
+            console.log("登录方式问卷内容", this.questionaire);
+          });
+        });
+      }
 
       // 获取最新的配额
       // let $this = this;
@@ -303,11 +320,10 @@ export default {
   watch: {
     questionHEAD() {
       //换题后返回页面顶部
-      console.log('before scroll', document.documentElement.scrollTop);
+      console.log("before scroll", document.documentElement.scrollTop);
       document.documentElement.scrollTop = 0;
-      console.log('after scroll', document.documentElement.scrollTop)
-    },
-    
+      console.log("after scroll", document.documentElement.scrollTop);
+    }
   },
   methods: {
     getParam: function(name) {
@@ -330,13 +346,25 @@ export default {
     //     }
     // },
     start() {
-      this.webQuestionaire.status = 2;
-      axios
-        .put(this.webQnUrl, { status: 2 })
-        .then(() => console.log("update status success"));
+      if (this.openWay == "Project") {
+        // 匿名方式打开
+        this.webQuestionaire.status = 2;
+      } else {
+        // 登录状态打开方式
+        this.webQuestionaire.status = 2;
+        axios
+          .put(this.webQnUrl, { status: 2 })
+          .then(() => console.log("update status success"));
+      }
     },
     getUserName() {
-      return this.webQuestionaire.phoneNumber;
+      if (this.openWay == "Project") {
+        // 匿名方式打开
+        return "incognito";
+      } else {
+        // 登录状态打开方式
+        return this.webQuestionaire.phoneNumber;
+      }
     },
     getOrgCode() {
       let orgCode = "webqn";
@@ -624,7 +652,12 @@ export default {
           .then(() => {
             // this.updateAnswerSheetDataUploaded(true);
             // alert('问卷结果已提交');
-            this.webQuestionaire.status = 3;
+            if (this.openWay == "Project") {
+              this.webQuestionaire.status = 3;
+            } else {
+              // 登录状态打开方式
+              this.webQuestionaire.status = 3;
+            }
           });
       }
     },
@@ -705,5 +738,4 @@ export default {
   margin-top: 40px;
   margin-left: 2%;
 }
-
 </style>