wucl 2 年之前
父節點
當前提交
c2de5b718b

+ 29 - 10
pages/index/index.vue

@@ -76,6 +76,7 @@
 				],
 				commitQuestions: [],
 				index: 1
+
 			}
 		},
 
@@ -83,11 +84,30 @@
 			this.initWS();
 			this.getDocument();
 		},
+		watch:{
+			questions:{
+				handler(newValue,oldValue){
+					let lastItemIndex = this.questions.length-1;
+					let preouisLastItemIndex = this.questions.length-2;
+					let lastScore =100;
+					for (let i in newValue){
+						if (newValue[i].score != null && newValue[i].score != "") {
+							lastScore = lastScore - (parseFloat(newValue[i].score));
+							if (i == preouisLastItemIndex && lastScore>=0){
+								this.questions[lastItemIndex].score = lastScore
+							}
+						}
+						
+					}
+				},
+				deep:true
+			}
+		},
 		methods: {
 			initWS() {
 				let socket = uni.connectSocket({
-					//url: 'wss://kps.scdayou.com/ws/apo/ws',
-					url: 'ws://127.0.0.1:8090/apo/ws',
+					url: 'wss://kps.scdayou.com/ws/apo/ws',
+					//url: 'ws://127.0.0.1:8090/apo/ws',
 					method: 'GET',
 					success: () => {
 						console.log("socket success")
@@ -102,13 +122,15 @@
 			getDocument() {
 				var that = this;
 				uni.request({
-					url: "http://127.0.0.1:8090/apo/document/current",
-					//url: "https://kps.scdayou.com/apo/document/current",
+					//url: "http://127.0.0.1:8090/apo/document/current",
+					url: "https://kps.scdayou.com/apo/document/current",
 					data: null,
 					method: "get",
 					success: function(res) {
 						that.formData = res.data.data;
-						that.questions = that.formData.questions[0];
+						if (that.formData.questions!=null){
+							that.questions = that.formData.questions[0];
+						}
 					},
 				})
 			},
@@ -138,10 +160,8 @@
 				for (let i in that.questions) {
 					that.commitQuestions.push(that.questions[i]);
 				}
-				console.log("当前的", xQuestions)
 				that.questions = [];
 				for (let i=this.index; i<that.formData.questions.length;i++){
-					console.log("i",i)
 					if (that.formData.questions[i].length>0){
 						this.questions = that.formData.questions[i];
 						this.index = i+1;
@@ -150,13 +170,12 @@
 				}
 
 
-				console.log("that.commotData", that.commitQuestions)
 
 				that.formData.result = that.commitQuestions;
 				that.formData.questions = [];
 				uni.request({
-					url: "http://127.0.0.1:8090/apo/document/commit",
-					//url: "https://kps.scdayou.com/apo/document/commit",
+					//url: "http://127.0.0.1:8090/apo/document/commit",
+					url: "https://kps.scdayou.com/apo/document/commit",
 					data: that.formData,
 					method: "post",
 					success: function(res) {

+ 27 - 10
unpackage/dist/dev/mp-weixin/pages/index/index.js

@@ -30,11 +30,29 @@ const _sfc_main = {
     this.initWS();
     this.getDocument();
   },
+  watch: {
+    questions: {
+      handler(newValue, oldValue) {
+        let lastItemIndex = this.questions.length - 1;
+        let preouisLastItemIndex = this.questions.length - 2;
+        let lastScore = 100;
+        for (let i in newValue) {
+          if (newValue[i].score != null && newValue[i].score != "") {
+            lastScore = lastScore - parseFloat(newValue[i].score);
+            if (i == preouisLastItemIndex && lastScore >= 0) {
+              this.questions[lastItemIndex].score = lastScore;
+            }
+          }
+        }
+      },
+      deep: true
+    }
+  },
   methods: {
     initWS() {
       let socket = common_vendor.index.connectSocket({
-        //url: 'wss://kps.scdayou.com/ws/apo/ws',
-        url: "ws://127.0.0.1:8090/apo/ws",
+        url: "wss://kps.scdayou.com/ws/apo/ws",
+        //url: 'ws://127.0.0.1:8090/apo/ws',
         method: "GET",
         success: () => {
           console.log("socket success");
@@ -49,13 +67,15 @@ const _sfc_main = {
     getDocument() {
       var that = this;
       common_vendor.index.request({
-        url: "http://127.0.0.1:8090/apo/document/current",
-        //url: "https://kps.scdayou.com/apo/document/current",
+        //url: "http://127.0.0.1:8090/apo/document/current",
+        url: "https://kps.scdayou.com/apo/document/current",
         data: null,
         method: "get",
         success: function(res) {
           that.formData = res.data.data;
-          that.questions = that.formData.questions[0];
+          if (that.formData.questions != null) {
+            that.questions = that.formData.questions[0];
+          }
         }
       });
     },
@@ -82,22 +102,19 @@ const _sfc_main = {
       for (let i in that.questions) {
         that.commitQuestions.push(that.questions[i]);
       }
-      console.log("当前的", xQuestions);
       that.questions = [];
       for (let i = this.index; i < that.formData.questions.length; i++) {
-        console.log("i", i);
         if (that.formData.questions[i].length > 0) {
           this.questions = that.formData.questions[i];
           this.index = i + 1;
           return;
         }
       }
-      console.log("that.commotData", that.commitQuestions);
       that.formData.result = that.commitQuestions;
       that.formData.questions = [];
       common_vendor.index.request({
-        url: "http://127.0.0.1:8090/apo/document/commit",
-        //url: "https://kps.scdayou.com/apo/document/commit",
+        //url: "http://127.0.0.1:8090/apo/document/commit",
+        url: "https://kps.scdayou.com/apo/document/commit",
         data: that.formData,
         method: "post",
         success: function(res) {

+ 1 - 1
unpackage/dist/dev/mp-weixin/project.config.json

@@ -8,7 +8,7 @@
     "urlCheck": false,
     "es6": true,
     "postcss": false,
-    "minified": false,
+    "minified": true,
     "newFeature": true,
     "bigPackageSizeSupport": true,
     "babelSetting": {