Browse Source

Merge branch 'dev' of ssh://10.10.100.21/source/smartschool-platform

koul 7 years ago
parent
commit
784e7d1c2c

+ 11 - 7
frontend/wechat-web/src/modules/home/HomePage.jsx

@@ -269,7 +269,7 @@ class HomePage extends Component {
                         setTimeout(() => {
                             Toast.success('切换成功!', 1)
                             switchCurrentUser(1)()
-                        }, 500)
+                        }, 400)
                     }
                 }
             },
@@ -280,7 +280,7 @@ class HomePage extends Component {
                         setTimeout(() => {
                             Toast.success('切换成功!', 1)
                             switchCurrentUser(2)()
-                        }, 500)
+                        }, 400)
                     }
                 }
             },
@@ -400,7 +400,6 @@ class HomePage extends Component {
     }
 
     onStuSwitch = (stuIndex) => {
-
         if (this.state.studentIndex !== stuIndex) {
             Toast.loading('学生切换中...', 0)
             setTimeout(() => {
@@ -409,11 +408,16 @@ class HomePage extends Component {
                     studentIndex: stuIndex
                 })
                 switchUser({
-                    stuName: this.props.userInfo.students[stuIndex].stuName,
-                    stuId: this.props.userInfo.students[stuIndex].stuId,
-                    student: this.props.userInfo.students[stuIndex]
+                    parent: {
+                        ...this.props.userInfo.parent,
+                        student: this.props.userInfo.parent.students[stuIndex]
+                    },
+                    user: {
+                        ...this.props.userInfo.user,
+                        student: this.props.userInfo.parent.students[stuIndex]
+                    }
                 })()
-            }, 500)
+            }, 400)
         }
 
     }

+ 1 - 0
frontend/wechat-web/src/modules/user/UserInfo.js

@@ -248,6 +248,7 @@ class UserInfo extends Component {
 
             switchUser({
                 parent: {
+                    ...this.props.userInfo.parent,
                     student: {
                         ...this.props.userInfo.parent.student,
                         stuPhoto: userPhoto

+ 38 - 20
frontend/wechat-web/src/utils/common.js

@@ -192,6 +192,26 @@ export function getParenthesesStr(text) {
     return result
 }
 
+/**
+ * 是否以某一字符串开头
+ * @param s
+ * @returns {boolean}
+ */
+String.prototype.startWith = function (s) {
+    if (s == null || s == "" || this.length == 0 || s.length > this.length)
+        return false;
+    if (this.substr(0, s.length) == s)
+        return true;
+    else
+        return false;
+    return true;
+}
+
+/**
+ * 是否以某一字符串结尾
+ * @param s
+ * @returns {boolean}
+ */
 String.prototype.endWith = function (s) {
     if (s == null || s == "" || this.length == 0 || s.length > this.length)
         return false;
@@ -202,7 +222,10 @@ String.prototype.endWith = function (s) {
     return true;
 }
 
-
+/**
+ * 是否存在于参数字符串列表中
+ * @returns {boolean}
+ */
 String.prototype.isStrEquals = function () {
     let args = arguments
     if (isObjNull(args) || args.length == 0) {
@@ -221,6 +244,20 @@ String.prototype.isStrEquals = function () {
     }
 }
 
+/**
+ * 字符串全局替换
+ * @param reg
+ * @param s
+ * @returns {string}
+ */
+String.prototype.replaceAll = function (reg, s) {
+    if (isObjEmpty(this)) {
+        return ''
+    }
+    return this.replace(new RegExp(reg, 'gm'), s)
+}
+
+
 //yyyy-MM-dd hh:mm:ss
 Date.prototype.format = function (fmt) {
     let o = {
@@ -241,25 +278,6 @@ Date.prototype.format = function (fmt) {
 }
 
 
-String.prototype.startWith = function (s) {
-    if (s == null || s == "" || this.length == 0 || s.length > this.length)
-        return false;
-    if (this.substr(0, s.length) == s)
-        return true;
-    else
-        return false;
-    return true;
-}
-
-
-String.prototype.replaceAll = function (reg, s) {
-    if (isObjEmpty(this)) {
-        return ''
-    }
-    return this.replace(new RegExp(reg, 'gm'), s)
-}
-
-
 /**
  * Map转json
  * @param m

+ 13 - 0
frontend/wechat-web/src/utils/fetchRequest.js

@@ -1,6 +1,10 @@
 import {getStrValue, isObjNull} from "./common";
 
 export function fetchPost(url, params, header) {
+    if (window.navigator.onLine == false) {
+        return Promise.reject('网络连接失败,请检查网络连接')
+    }
+
     if (isObjNull(header)) {
         header = {}
     }
@@ -33,6 +37,10 @@ export function fetchPost(url, params, header) {
 }
 
 export function fetchGet(url, params, header) {
+    if (window.navigator.onLine == false) {
+        return Promise.reject('网络连接失败,请检查网络连接')
+    }
+
     if (isObjNull(header)) {
         header = {}
     }
@@ -67,6 +75,11 @@ export function fetchGet(url, params, header) {
     return fetchResult(request)
 }
 
+/**
+ * 处理网络请求结果
+ * @param request
+ * @returns {*}
+ */
 function fetchResult(request) {
     try {
         return request.then(response => {