jason.lu há 6 anos atrás
pai
commit
8319fbb500

+ 7 - 6
sourcecode/h5app/vue/src/connector/basic-service.js

@@ -113,15 +113,15 @@ var BasicFunction = new (function () {
             // AJAX
             BasicFunction.goajax({url: BasicFunction.Queue.SVR_URL + "fcFlow/list", timeout: 1000})
                 .then(BasicFunction.checkStatus)
-                .then(BasicFunction.parseJson)
+                .then(function (response) {return response.json();} )
                 .then(BasicFunction.onReachServer)
                 .catch(BasicFunction.onCheckFail);
             //.fail(BasicFunction.onCheckFail).done(BasicFunction.onReachServer);
         }
     };
 
-    this.get_data = function (url, callback, scope) {
-        BasicFunction.Queue.list.push({url: url, callback: callback, gid: -1, scope: scope});
+    this.get_data = function (url, callback, data, scope) {
+        BasicFunction.Queue.list.push({url: url, callback: callback, gid: -1, data:data, scope: scope});
     };
 
     this.new_data_group = function (groupName, callback) {
@@ -168,9 +168,9 @@ var BasicFunction = new (function () {
         if (BasicFunction.Queue.list.length > 0) {
             let one = BasicFunction.Queue.list.pop();
             if (one.gid === -1) {
-                request_data(one.url, one.callback, one.scope);
+                request_data(one.url, one.callback, one.data, one.scope);
             } else {
-                g_request_data(one.url, one.callback, one.gid, one.scope);
+                g_request_data(one.url, one.callback, one.gid, one.data, one.scope);
             }
         }
         if (BasicFunction.Queue.shouldStop === false) {
@@ -192,10 +192,11 @@ var BasicFunction = new (function () {
         throw error;
     };
 
-    function request_data(url, callback, scope) {
+    function request_data(url, callback, data, scope) {
         BasicFunction.goajax({
             url: BasicFunction.Queue.SVR_URL + url,
             apiName: url,
+            data: data,
             sendTime: new Date()
         }).then(BasicFunction.checkStatus)
           .then(BasicFunction.parseJson)

+ 1 - 1
sourcecode/h5app/vue/src/connector/simple-demo.js

@@ -25,7 +25,7 @@ var test_vue_app = new Vue({
 
 function js_load_something(){
     var uid = 5; //for test.
-    get_data("smartUsers/list"+"?userId="+uid,
+    BasicFunction.get_data("smartUsers/list"+"?userId="+uid,
         /**
          * 下面的function是访问网络成功后的结果回调,obj 类似
          *

+ 20 - 26
sourcecode/h5app/vue/src/views/login.vue

@@ -75,37 +75,31 @@
                     return;
                 }
                 // 检查手机号有无注册
-
-                // let API = "http://south.niimei.com:8866/server";
-                // let GETUSERINFO = "/smartUsers/list";
-                // this.$http.get(API+GETUSERINFO).then((data) => {
-                //     // 响应成功回调
-                //     console.log(data);
-                // }, (err) => {
-                //     // 响应错误回调
-                //     console.log(err);
-                //     console.log(this);
-                // });
-                // let login_info = {
-                //     phone: this.phone,
-                //     pass: this.password
-                // };
-                // if(get_data(login_info)) {
-                //     this.$router.push('index');
-                // } else {
-                //     this.phoneError = true;
-                //     this.passError = true;
-                // }
-                // 检查手机号有无验证
-                BasicFunction.get_data("smartUsers/list", function(response){
+                BasicFunction.get_data("ajaxlogin", function(response){
                     console.log("------ Data Rcvd in Login --------");
                     console.log(response);
-                });
+                    if(response.ret === "10000"){
+                        // 不需要 设置 SessionID, 已经自动保存在jSessionID中
+                        this.$router.push('index');
+                    } else {
+                        // 密码错误的处理
+                        console.warn("登录失败");
+                    }
+                }, { u: this.phone, p : this.passWord });
                 // this.$router.push('index');
-                this.$router.push('index');
             },
             Register() {
-                this.$router.push('verify');
+                BasicFunction.get_data("ajaxlogin", function(response){
+                    console.log("------ Data Rcvd in Login --------");
+                    console.log(response);
+                    if(response.ret === "10000"){
+                        // 不需要 设置 SessionID, 已经自动保存在jSessionID中
+                        this.$router.push('verify');
+                    } else {
+                        // 注册失败的处理
+                        console.warn("注册失败");
+                    }
+                }, { u: this.phone, p : this.passWord });
             }
         }
     }