Prechádzať zdrojové kódy

使用that, 大量fix小块的冗余注释, fix on get_data(a,b,c) 现在c 可以直接给到[{...}] , 会自动进行 JSON.stringify();

jason.lu 6 rokov pred
rodič
commit
3b9344b599

+ 2 - 1
sourcecode/h5app/vue/src/components/schoolCard.vue

@@ -44,8 +44,9 @@
                     photo: this.photo
                 };
                 console.log(present);
+                //FIXME : wrong address given !
                 BasicFunction.get_data("ajaxpostpresent", function (response) {
-                    console.log("------ Data Rcvd in PresentReg --------");
+                    console.log("------ Data Rcvd in School Card --------");
                     console.log(response);
                     if(response.ret === "10000"){
                         // 不需要 设置 SessionID, 已经自动保存在jSessionID中

+ 17 - 13
sourcecode/h5app/vue/src/components/schoolidCard.vue

@@ -40,7 +40,7 @@
             />
         </van-cell-group>
         <p>宿舍区</p>
-        <van-radio-group v-model="dormDistrict">
+            <van-radio-group v-model="dormDistrict">
             <van-radio name="0" checked-color="#fd6740" style="float: left; margin-right: 20px" :disabled="isReadonly">南区</van-radio>
             <van-radio name="1" checked-color="#fd6740" style="float: left; margin-right: 20px" :disabled="isReadonly">西南</van-radio>
             <van-radio name="2" checked-color="#fd6740" style="float: left; margin-right: 20px" :disabled="isReadonly">斋区</van-radio>
@@ -81,11 +81,13 @@
         },
         methods: {
             uploadNameChange: function () {
+                let that = this;
                 BasicFunction.get_data("smartUsers/updateBatch", function (response) {
-                    console.log("------ Data Rcvd in PresentReg --------");
+                    console.log("------ Data Rcvd in uploadNameChange --------");
                     console.log(response);
                     if (response.ret === "10000") {
-                        history.go(0);
+                        that.isReadonly = true;
+                        Toast.success("上传成功")
                     } else {
                         // 注册失败的处理
                         Toast.fail("上传失败,请检查网络");
@@ -93,11 +95,14 @@
                 }, [this.userDo]);
             },
             uploadReviewChange: function () {
+                let that = this;
                 BasicFunction.get_data("smartIdentity/updateBatch", function (response) {
-                    console.log("------ Data Rcvd in PresentReg --------");
+                    console.log("------ Data Rcvd in uploadReviewChange --------");
                     console.log(response);
                     if (response.ret === "10000") {
-                        history.go(0);
+                        //history.go(0);
+                        that.isReadonly = true;
+                        Toast.success("上传成功")
                     } else {
                         // 注册失败的处理
                         Toast.fail("上传失败,请检查网络");
@@ -122,20 +127,19 @@
                     return;
                 }
                 // post_present()
-                this.userDo.name = this.weixinName;
+                this.userDo.name = this.personName;  // changed to personName instead.
                 this.uploadNameChange();
                 this.reviewDo.gender = this.gender;
                 this.reviewDo.dormDistrict = this.dormDistrict;
                 this.uploadReviewChange();
 
             },
-
             getIdentityInfo: function (obj) {
                 //this;
                 var userId = localStorage.getItem("frontend-userid");
                 window.schoolIdCard = this;
                 BasicFunction.get_data("smartUsers/list?uid=" + userId, function (response) {
-                    console.log("------ Data Rcvd in PresentReg --------");
+                    console.log("------ Data Rcvd in getIdentityInfo --------");
                     console.log(response);
                     if (response.ret === "10000") {
                         var t = response.model.list;
@@ -149,15 +153,15 @@
             },
             getReviewInfo:function (obj) {
                 var userId = localStorage.getItem("frontend-userid");
-                window.schoolIdCard = this;
+                let that = this;
                 BasicFunction.get_data("smartIdentity/list?userId=" + userId, function (response) {
-                    console.log("------ Data Rcvd in PresentReg --------");
+                    console.log("------ Data Rcvd in getReviewInfo --------");
                     console.log(response);
                     if (response.ret === "10000") {
                         var t = response.model.list;
-                        window.schoolIdCard.gender = t[0].userSex; // 左侧是vue页面内的变量名字, 右侧是后台数据里的变量名称
-                        window.schoolIdCard.dormDistrict = t[0].dormDistrict;
-                        window.schoolIdCard.reviewDo = t[0];
+                        that.gender = t[0].userSex; // 左侧是vue页面内的变量名字, 右侧是后台数据里的变量名称
+                        that.dormDistrict = t[0].dormDistrict;
+                        that.reviewDo = t[0];
                     } else {
 
                         Toast.fail("获取失败,请检查网络");

+ 22 - 24
sourcecode/h5app/vue/src/connector/basic-service.js

@@ -121,11 +121,15 @@ var BasicFunction = new (function () {
 
     this.get_data = function (url, callback, data, onescope) {
         console.log('calling get_data()');
-        BasicFunction.Queue.list.push({url: url, callback: callback, gid: -1, data: data, scope: onescope});
+        let jsonData = data;
+        if(typeof data != "string"){
+            jsonData = JSON.stringify(jsonData);
+        }
+        BasicFunction.Queue.list.push({url: url, callback: callback, gid: -1, data: jsonData, scope: onescope});
     };
 
     this.new_data_group = function (groupName, callback) {
-        var gid = -1;
+        let gid = -1;
         BasicFunction.Queue.groups.forEach(function (val) {
             if (val.groupName === groupName) {
                 gid = val.gid;
@@ -142,7 +146,7 @@ var BasicFunction = new (function () {
     };
 
     this.group_get_data = function (groupName, url, callback) {
-        var gid = -1;
+        let gid = -1;
         BasicFunction.Queue.groups.forEach(function (val) {
             if (val.groupName === groupName) {
                 gid = val.gid;
@@ -222,13 +226,13 @@ var BasicFunction = new (function () {
     }
 
     this.on_gp_success = function(response) {
-        var obj = response.json();
+        let obj = response.json();
         return obj;
     };
 
     this.onReqeustDataReceived = function(responseJson) {
         console.warn(responseJson);
-        var a = responseJson;
+        let a = responseJson;
         if (!BasicFunction.check_if_authfail(a)) {
             const error = new Error(responseJson.statusText);
             error.response = responseJson;
@@ -247,7 +251,7 @@ var BasicFunction = new (function () {
 
     this.check_if_authfail = function (errormsg) {
         BasicFunction.logerror(errormsg);
-        var a = errormsg;
+        let a = errormsg;
         if (a == null || typeof a !== "string") {
             return false;
         } else {
@@ -261,8 +265,8 @@ var BasicFunction = new (function () {
     this.check_if_success = function (response) {
         // this == BasicFunction
         BasicFunction.loglog("---------------Check-If-Success----------------");
-        var a = response.json();
-        var b = response.status;
+        let a = response.json();
+        let b = response.status;
         if (typeof a === "string") {
             try {
                 a = JSON.parse(a);
@@ -329,19 +333,13 @@ var BasicFunction = new (function () {
     };
 
     this.send_alert = function (a, b) {
-
-
         if (BasicFunction.Queue.shouldStop) return;
-
         if (BasicFunction.AlertClosingTimeout > 0) {
             clearTimeout(BasicFunction.AlertClosingTimeout);
         }
-
         BasicFunction.logwarn(a);
         BasicFunction.logwarn(b);
-
         // alert(a +"\n"+ b);
-
         BasicFunction.AlertClosingTimeout = setTimeout(function () {
             //$("#mpAlert").hide();
         }, 10000);
@@ -349,7 +347,7 @@ var BasicFunction = new (function () {
     };
 
     this.getUserName = function (uid) {
-        var uname = null;
+        let uname = null;
         BasicFunction.Users.list.forEach(function (val, aid) {
             BasicFunction.loglog(aid);
             if (val.worker.staffId === uid) {
@@ -367,9 +365,9 @@ var BasicFunction = new (function () {
     };
 
     this.on_username_retn = function (obj) {
-        var uid = this.url.substring(this.url.indexOf("staffId=") + 8);
+        let uid = this.url.substring(this.url.indexOf("staffId=") + 8);
         let ruid = parseInt(uid);
-        var out = BasicFunction.first_parse(this, obj);
+        let out = BasicFunction.first_parse(this, obj);
         if (out.list.length > 0) {
             BasicFunction.Users.list.push({
                 uid: ruid, worker: out.list[0]
@@ -384,15 +382,15 @@ var BasicFunction = new (function () {
         if (typeof (liveMinutes) !== 'number') {
             liveMinutes = 60 * 2;//默认120分钟
         }
-        var minutes = liveMinutes * 60 * 1000;
-        var exp = new Date();
+        let minutes = liveMinutes * 60 * 1000;
+        let exp = new Date();
         exp.setTime(exp.getTime() + minutes + 8 * 3600 * 1000);
         //path=/表示全站有效,而不是当前页
         document.cookie = name + "=" + value + ";path=/;expires=" + exp.toUTCString();
     };
 
     this.setCookie = function (c_name, value, expiredays) {
-        var exdate = new Date();
+        let exdate = new Date();
         exdate.setDate(exdate.getDate() + expiredays);
         document.cookie = c_name + "=" + escape(value) +
             ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString())
@@ -400,10 +398,10 @@ var BasicFunction = new (function () {
 
     this.getCookie = function (c_name) {
         if (document.cookie.length > 0) {
-            var c_start = document.cookie.indexOf(c_name + "=");
+            let c_start = document.cookie.indexOf(c_name + "=");
             if (c_start !== -1) {
                 c_start = c_start + c_name.length + 1;
-                var c_end = document.cookie.indexOf(";", c_start);
+                let c_end = document.cookie.indexOf(";", c_start);
                 if (c_end === -1) c_end = document.cookie.length;
                 return unescape(document.cookie.substring(c_start, c_end))
             }
@@ -415,14 +413,14 @@ var BasicFunction = new (function () {
 
     this.getUserId = function() {
          BasicFunction.loglog("Original  USERID : " + userId);
-        var use = getCookie("doibyUser");
+        let use = getCookie("doibyUser");
         if (use == null || use === undefined || use.length <= 0) {
             location.href = "sign-in1.html?from=entrance-1&msg=nologin-mustauth";
             return;
         }
          BasicFunction.loglog("Got UID From COOKIE : " + use);
         try {
-            var mm = parseInt(use);
+            let mm = parseInt(use);
             if (mm > 0) {
                 BasicFunction.userId = mm;
             }

+ 1 - 4
sourcecode/h5app/vue/src/views/PresentRegister.vue

@@ -156,14 +156,11 @@
                     console.log("------ Data Rcvd in PresentReg --------");
                     console.log(response);
                     if(response.ret === "10000"){
-                        // 不需要 设置 SessionID, 已经自动保存在jSessionID中
                         that.$router.push('index');
                     } else {
-                        // 注册失败的处理
                         Toast.fail("上传失败,请检查网络");
                     }
-                }, JSON.stringify(present));
-                // this.$router.push('index');
+                }, present);
             },
             onReadPhoto(file) {
                 this.photo = file;

+ 1 - 1
sourcecode/h5app/vue/src/views/index.vue

@@ -78,7 +78,7 @@
             // 判断userId 是不是空的
 
             let presentList = [];
-            BasicFunction.get_data("smartGoods/list?ownerId" + userId, function (response) {
+            BasicFunction.get_data("smartGoods/list?isDel=0&ownerId=" + userId, function (response) {
                 console.log("------ Data Rcvd in Index --------");
                 console.log(response);
                 if (response.ret === "10000") {

+ 1 - 31
sourcecode/h5app/vue/src/views/me.vue

@@ -4,9 +4,7 @@
             <schoolid-card
             />
             <school-card
-                />
-
-
+            />
         </div>
         <add-present-button :can_add="button_active"/>
     </div>
@@ -23,38 +21,10 @@
             return {
                 button_active: true
             }
-
         },
         created: function () {
             this.button_active = false;
-
             var userId = localStorage.getItem("frontend-userid");
-            BasicFunction.get_data("smartIdentity/list?userId="+userId, function (response) {
-                console.log("------ Data Rcvd in PresentReg --------");
-                console.log(response);
-                if(response.ret === "10000"){
-                    // 不需要 设置 SessionID, 已经自动保存在jSessionID中
-                    this.$router.push('index');
-                } else {
-                    // 注册失败的处理
-                    Toast.fail("读取失败,请检查网络");
-                }
-            }, {});
-
-            BasicFunction.get_data("smartIdentity/updateBatch", function (response) {
-                console.log("------ Data Rcvd in PresentReg --------");
-                console.log(response);
-                if(response.ret === "10000"){
-                    this.$router.push('index');
-                } else {
-                    // 注册失败的处理
-                    Toast.fail("上传失败,请检查网络");
-                }
-            }, [{"reviewId":1,"userId":1,"dormDistrict":10,
-                "userSex":1,"userSchoolCard":20123333222,
-                "userReviewStatus":1000,
-                "reviewerId":1,"reviewerNote":"nmo",
-                "reviewerNoteToUser":"noo"}]);
         }
     }
 </script>