jason.lu 6 years ago
parent
commit
cecd02adfe

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

@@ -90,7 +90,7 @@ var BasicFunction = new (function () {
         // .then(BasicFunction.onCheckFail);
     };
 
-    this.onReachServer = function (checkResponse) {
+    this.onReachServer = function () {
         BasicFunction.Queue.IS_LOADED = true;
         BasicFunction.logwarn("Using SERVER : ");
         BasicFunction.logwarn(BasicFunction.Queue.SVR_URL);
@@ -102,7 +102,7 @@ var BasicFunction = new (function () {
             BasicFunction.logwarn("Backup Failed : " + BasicFunction.Queue.backup[BasicFunction.Queue.nowuse]);
             BasicFunction.logwarn(this);
             var out = "";
-            BasicFunction.Queue.backup.forEach(function (val, index, arr) {
+            BasicFunction.Queue.backup.forEach(function (val, index) {
                 out += index + ":[" +val +"] \n";
             });
             BasicFunction.logerror("抱歉, 服务器连接失败! \n 请确认 "+ out +" 其中之一可用");
@@ -116,13 +116,12 @@ var BasicFunction = new (function () {
                 .then(function (response) {return response.json();} )
                 .then(BasicFunction.onReachServer)
                 .catch(BasicFunction.onCheckFail);
-            //.fail(BasicFunction.onCheckFail).done(BasicFunction.onReachServer);
         }
     };
 
-    this.get_data = function (url, callback, data, scope) {
+    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: scope});
+        BasicFunction.Queue.list.push({url: url, callback: callback, gid: -1, data:data, scope: onescope});
     };
 
     this.new_data_group = function (groupName, callback) {
@@ -198,6 +197,7 @@ var BasicFunction = new (function () {
             url: BasicFunction.Queue.SVR_URL + url,
             apiName: url,
             data: data,
+            scope: scope,
             sendTime: new Date()
         }).then(BasicFunction.checkStatus)
             .then(BasicFunction.parseJson)

+ 21 - 0
sourcecode/h5app/vue/src/views/index.vue

@@ -55,6 +55,25 @@
         computed: {
             presents: function() {
                 // return get_present_data()
+
+                var userId = localStorage.getItem("frontend-userid");
+                // 判断userId 是不是空的
+
+                BasicFunction.get_data("smartGoods/list?ownerId" + userId , function(response){
+                    console.log("------ Data Rcvd in Login --------");
+                    console.log(response);
+                    if(response.ret === "10000"){
+                        // response 就是
+                        console.warn(response);
+                        var list = response.model.list;
+                        if(list == undefined || list.length == 0) // ....
+                        console.warn(list);
+                    } else {
+                        // 注册失败的处理
+                        console.warn("注册失败");
+                    }
+                }, {});
+
                 return [
                     {
                         id: 0,
@@ -82,6 +101,8 @@
             }
         }
     }
+
+
 </script>
 
 <style scoped>

+ 21 - 29
sourcecode/h5app/vue/src/views/login.vue

@@ -80,45 +80,25 @@
                     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(data) { console.log(data.model.list); } );
-                BasicFunction.get_data("ajaxlogin", function(response){
+                window.routerme = this.$router;
+                BasicFunction.get_data("ajaxlogin?u="+this.phone+"&p="+this.password , function(response){
                     console.log("------ Data Rcvd in Login --------");
                     console.log(response);
                     if(response.ret === "10000"){
                         // 不需要 设置 SessionID, 已经自动保存在jSessionID中
-                        this.$router.push('index');
+                        // userId
+                        localStorage.setItem("frontend-userid", response.model.userId);
+                        window.routerme.push('index');
                     } else {
                         // 密码错误的处理
                         console.warn("登录失败");
                     }
-                }, { u: this.phone, p : this.passWord });
+                }, {});
                 // this.$router.push('index');
             },
             Register() {
-                BasicFunction.get_data("ajaxlogin", function(response){
-                    console.log("------ Data Rcvd in Login --------");
+                BasicFunction.get_data("ajaxregister", function(response){
+                    console.log("------ Data Rcvd in Reg --------");
                     console.log(response);
                     if(response.ret === "10000"){
                         // 不需要 设置 SessionID, 已经自动保存在jSessionID中
@@ -127,7 +107,19 @@
                         // 注册失败的处理
                         console.warn("注册失败");
                     }
-                }, { u: this.phone, p : this.passWord });
+                }, { u: this.phone, p : this.passWord, });
+            },
+            SendOTP() {
+                BasicFunction.get_data("ajaxsendotp", function(response){
+                    console.log("------ Data Rcvd in OTP --------");
+                    console.log(response);
+                    if(response.ret === "10000"){
+                        // 提示用户已经发送
+                    } else {
+                        // 发送失败
+                        console.warn("发送失败");
+                    }
+                }, { u: this.phone });
             }
         }
     }