YanaDH 7 vuotta sitten
vanhempi
commit
a5bbcbc46c

+ 46 - 35
miaomiao/www/.idea/workspace.xml

xqd xqd xqd xqd xqd xqd xqd xqd
@@ -24,8 +24,8 @@
       <file leaf-file-name="login.html" pinned="false" current-in-tab="false">
         <entry file="file://$PROJECT_DIR$/templates/account/login.html">
           <provider selected="true" editor-type-id="text-editor">
-            <state vertical-scroll-proportion="-4.75">
-              <caret line="7" column="40" selection-start-line="7" selection-start-column="31" selection-end-line="7" selection-end-column="40" />
+            <state vertical-scroll-proportion="-1.3571428">
+              <caret line="2" column="13" selection-start-line="2" selection-start-column="13" selection-end-line="2" selection-end-column="13" />
               <folding>
                 <element signature="n#style#0;n#img#0;n#div#0;n#ion-content#0;n#ion-view#0;n#!!top" expanded="true" />
                 <element signature="n#style#0;n#span#0;n#div#0;n#ion-content#0;n#ion-view#0;n#!!top" expanded="true" />
@@ -34,21 +34,31 @@
           </provider>
         </entry>
       </file>
-      <file leaf-file-name="userservice.js" pinned="false" current-in-tab="false">
-        <entry file="file://$PROJECT_DIR$/js/services/userservice.js">
+      <file leaf-file-name="account.js" pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/js/controllers/account.js">
           <provider selected="true" editor-type-id="text-editor">
             <state vertical-scroll-proportion="0.0">
-              <caret line="3" column="21" selection-start-line="3" selection-start-column="21" selection-end-line="3" selection-end-column="21" />
+              <caret line="44" column="34" selection-start-line="44" selection-start-column="34" selection-end-line="44" selection-end-column="34" />
               <folding />
             </state>
           </provider>
         </entry>
       </file>
-      <file leaf-file-name="account.js" pinned="false" current-in-tab="true">
-        <entry file="file://$PROJECT_DIR$/js/controllers/account.js">
+      <file leaf-file-name="userservice.js" pinned="false" current-in-tab="true">
+        <entry file="file://$PROJECT_DIR$/js/services/userservice.js">
           <provider selected="true" editor-type-id="text-editor">
-            <state vertical-scroll-proportion="0.68715084">
-              <caret line="50" column="20" selection-start-line="50" selection-start-column="20" selection-end-line="50" selection-end-column="45" />
+            <state vertical-scroll-proportion="0.33509701">
+              <caret line="10" column="57" selection-start-line="10" selection-start-column="57" selection-end-line="10" selection-end-column="57" />
+              <folding />
+            </state>
+          </provider>
+        </entry>
+      </file>
+      <file leaf-file-name="router.js" pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/js/config/router.js">
+          <provider selected="true" editor-type-id="text-editor">
+            <state vertical-scroll-proportion="-5.0666666">
+              <caret line="11" column="30" selection-start-line="11" selection-start-column="30" selection-end-line="11" selection-end-column="30" />
               <folding />
             </state>
           </provider>
@@ -96,8 +106,6 @@
         <option value="$PROJECT_DIR$/js/controllers/add.js" />
         <option value="E:/Graduation design/huiwei/index.html" />
         <option value="$PROJECT_DIR$/templates/account/loginAccount.html" />
-        <option value="$PROJECT_DIR$/templates/account/login.html" />
-        <option value="$PROJECT_DIR$/js/config/router.js" />
         <option value="E:/Graduation design/huiwei/package.json" />
         <option value="E:/Graduation design/huiwei/gulpfile.js" />
         <option value="E:/Graduation design/lala/package.json" />
@@ -107,6 +115,8 @@
         <option value="$PROJECT_DIR$/js/controllers/home.js" />
         <option value="$PROJECT_DIR$/templates/home/dream-detail.html" />
         <option value="$PROJECT_DIR$/css/style.css" />
+        <option value="$PROJECT_DIR$/templates/account/login.html" />
+        <option value="$PROJECT_DIR$/js/config/router.js" />
         <option value="$PROJECT_DIR$/js/services/userservice.js" />
         <option value="$PROJECT_DIR$/js/controllers/account.js" />
       </list>
@@ -524,13 +534,6 @@
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/js/config/router.js">
-      <provider selected="true" editor-type-id="text-editor">
-        <state vertical-scroll-proportion="0.17690875">
-          <caret line="5" column="28" selection-start-line="5" selection-start-column="28" selection-end-line="5" selection-end-column="28" />
-        </state>
-      </provider>
-    </entry>
     <entry file="file://E:/Graduation design/huiwei/package.json">
       <provider selected="true" editor-type-id="text-editor">
         <state vertical-scroll-proportion="0.7050093">
@@ -582,7 +585,7 @@
         <state vertical-scroll-proportion="0.17625232">
           <caret line="14" column="37" selection-start-line="14" selection-start-column="37" selection-end-line="14" selection-end-column="37" />
           <folding>
-            <element signature="n#style#0;n#div#0;n#div#0;n#ion-content#0;n#ion-view#0;n#!!top" expanded="true" />
+            <element signature="n#style#0;n#div#0;n#div#0;n#ion-content#0;n#ion-view#0;n#!!top" expanded="false" />
           </folding>
         </state>
       </provider>
@@ -616,23 +619,23 @@
         <state vertical-scroll-proportion="0.29469547">
           <caret line="428" column="14" selection-start-line="428" selection-start-column="14" selection-end-line="428" selection-end-column="14" />
           <folding>
-            <element signature="n#style#0;n#button#0;n#ion-nav-buttons#0;n#ion-view#0;n#!!top" expanded="true" />
-            <element signature="n#style#0;n#div#0;n#div#0;n#div#0;n#div#1;n#ion-content#0;n#ion-view#0;n#!!top" expanded="true" />
-            <element signature="n#style#0;n#img#0;n#div#0;n#div#1;n#div#0;n#div#2;n#ion-content#0;n#ion-view#0;n#!!top" expanded="true" />
-            <element signature="n#style#0;n#div#2;n#div#1;n#div#0;n#div#2;n#ion-content#0;n#ion-view#0;n#!!top" expanded="true" />
-            <element signature="n#style#0;n#img#1;n#div#2;n#div#1;n#div#0;n#div#2;n#ion-content#0;n#ion-view#0;n#!!top" expanded="true" />
-            <element signature="n#style#0;n#div#1;n#div#1;n#div#1;n#div#2;n#ion-view#0;n#!!top" expanded="true" />
-            <element signature="n#style#0;n#div#0;n#div#2;n#div#1;n#div#1;n#div#2;n#ion-view#0;n#!!top" expanded="true" />
-            <element signature="n#style#0;n#span#0;n#div#1;n#div#1;n#div#2;n#ion-view#0;n#!!top" expanded="true" />
-            <element signature="n#style#0;n#a#0;n#span#0;n#div#1;n#div#1;n#div#2;n#ion-view#0;n#!!top" expanded="true" />
+            <element signature="n#style#0;n#button#0;n#ion-nav-buttons#0;n#ion-view#0;n#!!top" expanded="false" />
+            <element signature="n#style#0;n#div#0;n#div#0;n#div#0;n#div#1;n#ion-content#0;n#ion-view#0;n#!!top" expanded="false" />
+            <element signature="n#style#0;n#img#0;n#div#0;n#div#1;n#div#0;n#div#2;n#ion-content#0;n#ion-view#0;n#!!top" expanded="false" />
+            <element signature="n#style#0;n#div#2;n#div#1;n#div#0;n#div#2;n#ion-content#0;n#ion-view#0;n#!!top" expanded="false" />
+            <element signature="n#style#0;n#img#1;n#div#2;n#div#1;n#div#0;n#div#2;n#ion-content#0;n#ion-view#0;n#!!top" expanded="false" />
+            <element signature="n#style#0;n#div#1;n#div#1;n#div#1;n#div#2;n#ion-view#0;n#!!top" expanded="false" />
+            <element signature="n#style#0;n#div#0;n#div#2;n#div#1;n#div#1;n#div#2;n#ion-view#0;n#!!top" expanded="false" />
+            <element signature="n#style#0;n#span#0;n#div#1;n#div#1;n#div#2;n#ion-view#0;n#!!top" expanded="false" />
+            <element signature="n#style#0;n#a#0;n#span#0;n#div#1;n#div#1;n#div#2;n#ion-view#0;n#!!top" expanded="false" />
           </folding>
         </state>
       </provider>
     </entry>
     <entry file="file://$PROJECT_DIR$/templates/account/login.html">
       <provider selected="true" editor-type-id="text-editor">
-        <state vertical-scroll-proportion="-4.75">
-          <caret line="7" column="40" selection-start-line="7" selection-start-column="31" selection-end-line="7" selection-end-column="40" />
+        <state vertical-scroll-proportion="-1.3571428">
+          <caret line="2" column="13" selection-start-line="2" selection-start-column="13" selection-end-line="2" selection-end-column="13" />
           <folding>
             <element signature="n#style#0;n#img#0;n#div#0;n#ion-content#0;n#ion-view#0;n#!!top" expanded="true" />
             <element signature="n#style#0;n#span#0;n#div#0;n#ion-content#0;n#ion-view#0;n#!!top" expanded="true" />
@@ -640,18 +643,26 @@
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/js/services/userservice.js">
+    <entry file="file://$PROJECT_DIR$/js/config/router.js">
       <provider selected="true" editor-type-id="text-editor">
-        <state vertical-scroll-proportion="0.0">
-          <caret line="3" column="21" selection-start-line="3" selection-start-column="21" selection-end-line="3" selection-end-column="21" />
+        <state vertical-scroll-proportion="-5.0666666">
+          <caret line="11" column="30" selection-start-line="11" selection-start-column="30" selection-end-line="11" selection-end-column="30" />
           <folding />
         </state>
       </provider>
     </entry>
     <entry file="file://$PROJECT_DIR$/js/controllers/account.js">
       <provider selected="true" editor-type-id="text-editor">
-        <state vertical-scroll-proportion="0.68715084">
-          <caret line="50" column="20" selection-start-line="50" selection-start-column="20" selection-end-line="50" selection-end-column="45" />
+        <state vertical-scroll-proportion="0.0">
+          <caret line="44" column="34" selection-start-line="44" selection-start-column="34" selection-end-line="44" selection-end-column="34" />
+          <folding />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/js/services/userservice.js">
+      <provider selected="true" editor-type-id="text-editor">
+        <state vertical-scroll-proportion="0.33509701">
+          <caret line="10" column="57" selection-start-line="10" selection-start-column="57" selection-end-line="10" selection-end-column="57" />
           <folding />
         </state>
       </provider>

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

xqd
@@ -5,10 +5,11 @@
               url: '/account/login',
               cache:"false",
               templateUrl: 'templates/account/login.html',
-              controller: 'loginCtrl'
+              controller: 'wechatLoginCtrl'
           })
             .state('loginAccount', {
                 url: '/account/loginAccount',
+                params:{wechat:null},
                 templateUrl: 'templates/account/loginAccount.html',
                 controller: 'loginCtrl'
             })

+ 69 - 64
miaomiao/www/js/controllers/account.js

xqd xqd
@@ -1,36 +1,7 @@
 (function (app) {
-    app.controller('loginCtrl', ["$scope", "userService","$ionicNavBarDelegate", "storage", "$state", "msg", "$http", "util","$timeout",
+    app.controller('wechatLoginCtrl', ["$scope", "userService","$ionicNavBarDelegate", "storage", "$state", "msg", "$http", "util","$timeout",
         function ($scope, userService,$ionicNavBarDelegate, storage, $state, msg, $http, util, $timeout) {
              $ionicNavBarDelegate.showBackButton(false);
-
-            $scope.vm = {
-            mobile: '',
-            verify_code: '',
-            waitSeconds: "获取验证码"
-        };
-        $scope.login = function () {
-            msg.loading('登录中...');
-            userService.login($scope.vm.mobile, $scope.vm.verify_code).then(function (result) {
-                msg.hide();
-                storage.setObject('user', result.data.data.user);
-                storage.set('token', result.data.data.token);
-                $http.defaults.headers.common["Authorization"] = 'Bearer ' + result.data.data.token;
-                $scope.user=storage.getObject('user');
-                $state.go('app.home');
-            }, function (error) {
-               // msg.hide();
-                // msg.error(error.data.message);
-            });
-        };
-   /*     $scope.loginbywx = function () {
-            var scope = "snsapi_userinfo", state = "_" + (+new Date());
-            Wechat.auth(scope, state, function (response) {
-
-                alert(JSON.stringify(response));
-            }, function (reason) {
-                alert("Failed: " + reason);
-            });
-        };*/
             $scope.loginbywx = function(){
                 var scope = "snsapi_userinfo", state = "_" + (+new Date());
                 Wechat.auth(scope, state, function (response) {
@@ -48,44 +19,78 @@
                     $scope.user=storage.getObject('user');
                     $state.go('app.home');
                 },function(error){
-                    $state.go("loginAccount")
+                    $state.go("loginAccount",{wechat:$scope.wecaht})
                 });
             };
-        //获取验证码
-        $scope.getVerifyCode = function () {
-            // if (!util.isMobile($scope.vm.mobile)) {
-            //     msg.text('请输入正确的手机号');
-            //     return;
-            // }
-            if ($scope.vm.waitSeconds!="获取验证码") {
-               msg.text('请稍后再试', true);
-               return;
-            }
-            $scope.vm.waitSeconds = "正在发送";
-            userService.getVerifyCode($scope.vm.mobile).then(function (result) {
-                wait(50);
-                // $scope.returncode = result.data;
-                if(result.data.data.verify_code)msg.success(result.data.data.verify_code);
-            }, function (error) {
-                $scope.vm.waitSeconds = "获取验证码";
-                wait(0);
-                // msg.error(error.data.message);
-            });
-        };
-        var wait = function (seconds) {
-            if (seconds > 0) {
-                $scope.vm.waitSeconds = "" + seconds + "秒";
-            } else {
-                $scope.vm.waitSeconds = "获取验证码";
-            }
-            $timeout(function () {
-                if (seconds >= 1)
-                    wait(seconds - 1);
-            }, 1000);
-        };
+    }]);
+    app.controller('loginCtrl', ["$scope", "userService","$ionicNavBarDelegate", "storage", "$state", "msg", "$http", "util","$timeout",
+        function ($scope, userService,$ionicNavBarDelegate, storage, $state, msg, $http, util, $timeout) {
+            $ionicNavBarDelegate.showBackButton(false);
+            $scope.wecaht = $stateParams.wechat;
+            $scope.vm = {
+                mobile: '',
+                verify_code: '',
+                waitSeconds: "获取验证码"
+            };
+            $scope.login = function () {
+                msg.loading('登录中...');
+                userService.login($scope.vm.mobile, $scope.vm.verify_code,$scope.wechat).then(function (result) {
+                    msg.hide();
+                    storage.setObject('user', result.data.data.user);
+                    storage.set('token', result.data.data.token);
+                    $http.defaults.headers.common["Authorization"] = 'Bearer ' + result.data.data.token;
+                    $scope.user=storage.getObject('user');
+                    $state.go('app.home');
+                }, function (error) {
+                    // msg.hide();
+                    // msg.error(error.data.message);
+                });
+            };
+            /*     $scope.loginbywx = function () {
+             var scope = "snsapi_userinfo", state = "_" + (+new Date());
+             Wechat.auth(scope, state, function (response) {
+
+             alert(JSON.stringify(response));
+             }, function (reason) {
+             alert("Failed: " + reason);
+             });
+             };*/
+
+            //获取验证码
+            $scope.getVerifyCode = function () {
+                // if (!util.isMobile($scope.vm.mobile)) {
+                //     msg.text('请输入正确的手机号');
+                //     return;
+                // }
+                if ($scope.vm.waitSeconds!="获取验证码") {
+                    msg.text('请稍后再试', true);
+                    return;
+                }
+                $scope.vm.waitSeconds = "正在发送";
+                userService.getVerifyCode($scope.vm.mobile).then(function (result) {
+                    wait(50);
+                    // $scope.returncode = result.data;
+                    if(result.data.data.verify_code)msg.success(result.data.data.verify_code);
+                }, function (error) {
+                    $scope.vm.waitSeconds = "获取验证码";
+                    wait(0);
+                    // msg.error(error.data.message);
+                });
+            };
+            var wait = function (seconds) {
+                if (seconds > 0) {
+                    $scope.vm.waitSeconds = "" + seconds + "秒";
+                } else {
+                    $scope.vm.waitSeconds = "获取验证码";
+                }
+                $timeout(function () {
+                    if (seconds >= 1)
+                        wait(seconds - 1);
+                }, 1000);
+            };
             $scope.clear = function(){
                 document.getElementById("tel").value = "";
             }
-    }]);
+        }]);
   
 })(angular.module('app.controllers'));

+ 2 - 2
miaomiao/www/js/services/userservice.js

xqd
@@ -8,11 +8,11 @@
                     data: { wechat: wechat}
                 })
             },
-            login: function (phone, verify_code) {
+            login: function (phone, verify_code,wechat) {
                 return $http({
                     url: config.server + 'api/auth/login',
                     method: "post",
-                    data: { phone: phone, verify_code: verify_code}
+                    data: { phone: phone, verify_code: verify_code, wechat:wechat}
                 })
             },
             getVerifyCode:function (mobile) {

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

xqd
@@ -1,6 +1,6 @@
 <ion-view view-title="瞄喵">
     <ion-content>
-        <div  class="lglogin">
+        <div class="lglogin">
             <img ng-src="img/icon_login.svg"  style="margin:0 auto;display:block;width:100px;border-radius:50px"/>
             <span style="font-size: 15px; color: #E1E1E1; margin-top: 30px">- 微信登录 -</span>
             <div class="lgsocial">