Ben há 8 anos atrás
pai
commit
9a52ac4cdd

BIN
.vs/miaomiao/v14/.suo


+ 1 - 1
miaomiao/www/js/config/config.js

xqd
@@ -1,6 +1,6 @@
 (function (app) {
     //全局配置 
     app.constant("config", {
-         server: 'http://localhost/' 
+        server: 'http://q8.9026.com/'
     });
 })(angular.module('app'));

+ 22 - 7
miaomiao/www/js/controllers/account.js

xqd xqd
@@ -1,26 +1,41 @@
 (function (app) {
-    app.controller('loginCtrl', function ($scope, userService, storage,$ionicHistory, $state, msg, $http) {
+    app.controller('loginCtrl', ["$scope", "userService", "storage", "$state", "msg", "$http", "util","$timeout",
+        function ($scope, userService, storage, $state, msg, $http, util, $timeout) {
         $scope.vm = {
             mobile: '',
             verify_code: '',
             waitSeconds: "获取验证码"
         };
         $scope.login = function () {
-            $state.go('app.home');
-            return;
             msg.loading('登录中...');
-            userService.login($scope.vm.mobile, $scope.vm.password).then(function (result) {
+            userService.login($scope.vm.mobile, $scope.vm.verify_code).then(function (result) {
                 msg.hide();
+                debugger;
                 storage.setObject('user', result.data.data.user);
                 storage.set('token', result.data.data.token);
                 $http.defaults.headers.common["Authorization"] = 'Bearer ' + result.data.data.token;
-                $state.go('app.borrow');
+                $state.go('app.home');
             }, function (erro) {
-                console.log("login erro:"+JSON.stringify(erro));
                 msg.hide();
                 msg.error(erro.data.message);
             });
         }
+        //获取验证码
+        $scope.getVerifyCode = function () {
+            if (!util.isMobile($scope.vm.mobile)) {
+                msg.text('请输入正确的手机号');
+                return;
+            }
+            $scope.vm.waitSeconds = "正在发送";
+            userService.getVerifyCode($scope.vm.mobile).then(function (result) {
+                wait(50);
+                $scope.returncode = result.data;
+            }, function (error) {
+                $scope.vm.waitSeconds = "获取验证码";
+                wait(0);
+                msg.error(error.data.Message);
+            });
+        };
         var wait = function (seconds) {
             if (seconds > 0) {
                 $scope.vm.waitSeconds = "" + seconds + "秒";
@@ -32,6 +47,6 @@
                     wait(seconds - 1);
             }, 1000);
         };
-    });
+    }]);
   
 })(angular.module('app.controllers'));

+ 4 - 30
miaomiao/www/js/services/userservice.js

xqd
@@ -1,48 +1,22 @@
 (function (app) {
     app.factory('userService', ['$http', 'config', "util", 'storage', function ($http, config, util, storage) {
         return {
-            login:function (username,password) {
+            login: function (phone, verify_code) {
                 return $http({
                     url: config.server + 'api/auth/login',
                     method: "post",
-                    data: { phone: username, password: password, type:2 }
+                    data: { phone: phone, verify_code: verify_code}
                 })
             },
-            register: function (data) {
-                return $http({
-                    url: config.server + 'api/auth/register',
-                    method: "post",
-                    data: data
-                })
-            },
-           
             getVerifyCode:function (mobile) {
                 return $http({
                     url: config.server + 'api/auth/code',
                     method: "post",
-                    data: { phone: mobile, type:2}
-                })
-            },
-            getRegisterCode:function (mobile) {
-                return $http({
-                    url: config.server + 'api/auth/code',
-                    method: "post",
-                    data: { phone: mobile, type:3}
-                })
-            },
-            resetPassword: function (data) {
-                return $http({
-                    url: config.server + 'api/auth/reset',
-                    method: "post",
-                    data: data
+                    data: { phone: mobile}
                 })
             },
             isLogin: function () {
-                return $http({
-                    url: config.server + 'api/auth/is_login',
-                    method: "get",
-                })
-                // return !util.empty(storage.get("token")) && storage.getObject("user");
+             return !util.empty(storage.get("token")) && storage.getObject("user");
             } 
         };
     }]);

+ 1 - 1
miaomiao/www/templates/account/login.html

xqd
@@ -9,7 +9,7 @@
             </div>
             <div class="item item-input">
                 <input type="text" ng-model="vm.verify_code" placeholder="短信验证码">
-                <button ng-click="getRegisterCode()" class="button button-calm" style="margin-right:5px">{{vm.waitSeconds}}</button>
+                <button ng-click="getVerifyCode()" class="button button-calm" style="margin-right:5px">{{vm.waitSeconds}}</button>
             </div>
         </div>
         <div class="padding">