Silent 6 år sedan
förälder
incheckning
18b99386fd

+ 15 - 0
app/Http/Controllers/Api/LoginController.php

xqd
@@ -0,0 +1,15 @@
+<?php
+
+namespace App\Http\Controllers\Api;
+
+use Illuminate\Http\Request;
+use App\Http\Controllers\Controller;
+use Illuminate\Support\Facades\Log;
+
+class LoginController extends Controller
+{
+    public function index(Request $request)
+    {
+        Log::info($request->all());
+    }
+}

+ 2 - 1
app/Http/Middleware/VerifyCsrfToken.php

xqd
@@ -15,7 +15,8 @@ class VerifyCsrfToken extends BaseVerifier
         //
         "notify",
         "admin/Base/Attachment/*",
-        'admin/upload/*'
+        'admin/upload/*',
+        'api/*'
     ];
 
 }

+ 3 - 1
app/Providers/RouteServiceProvider.php

xqd xqd
@@ -16,6 +16,8 @@ class RouteServiceProvider extends ServiceProvider
      */
     protected $namespace = 'App\Http\Controllers';
 
+    protected $api_namespace = 'App\Http\Controllers\Api';
+
     /**
      * Define your route model bindings, pattern filters, etc.
      *
@@ -86,7 +88,7 @@ class RouteServiceProvider extends ServiceProvider
     {
         Route::prefix('api')
              ->middleware('api')
-             ->namespace($this->namespace)
+             ->namespace($this->api_namespace)
              ->group(base_path('routes/api.php'));
     }
 }

+ 2 - 1
routes/api.php

xqd xqd
@@ -1,6 +1,7 @@
 <?php
 
 use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Route;
 
 /*
 |--------------------------------------------------------------------------
@@ -17,7 +18,7 @@ use Illuminate\Http\Request;
 //    return $request->user();
 //});
 
-
+Route::get('login', 'LoginController@login');
 
 //
 //$api = app('Dingo\Api\Routing\Router');

+ 8 - 2
wechat/app.js

xqd
@@ -27,14 +27,20 @@ App({
   globalData: {
     userInfo: null
   },
-  login: function () {
+  login: function (info) {
     wx.login({
       success: res => {
         wx.request({
-          url: api.headUrl + res.code,
+          url: api.loginUrl,
+          method: 'POST',
           header: {
             'content-type': 'json'
           },
+          data: {
+            code: res.code,
+            iv: info.iv,
+            encryptData: info.encryptData
+          },
           success: info => {
             if (info.data.status == 'success') {
               wx.setStorageSync('pt_student_id', info.data.id);

+ 8 - 7
wechat/app.json

xqd xqd xqd
@@ -1,5 +1,5 @@
 {
-  "pages":[
+  "pages": [
     "pages/index/index",
     "pages/announce/announce",
     "pages/article/article",
@@ -8,15 +8,16 @@
     "pages/rate/rate",
     "pages/rate-review/rate-review",
     "pages/my-log/my-log",
-    "pages/apply-leave/apply-leave"
+    "pages/apply-leave/apply-leave",
+    "pages/login/index"
   ],
-  "window":{
-    "backgroundTextStyle":"light",
+  "window": {
+    "backgroundTextStyle": "light",
     "navigationBarBackgroundColor": "#fff",
     "navigationBarTitleText": "WeChat",
-    "navigationBarTextStyle":"black"
+    "navigationBarTextStyle": "black"
   },
-  "tabBar":{
+  "tabBar": {
     "backgroundColor": "#111111",
     "list": [
       {
@@ -51,4 +52,4 @@
       "provider": "wx92c68dae5a8bb046"
     }
   }
-}
+}

+ 7 - 1
wechat/pages/index/index.js

xqd xqd
@@ -3,7 +3,6 @@ var app = getApp()
 Page({
   
   onLoad: function () {
-    console.log('onLoad')
     wx.getSystemInfo({
       success: (res) => {
         this.setData({
@@ -14,5 +13,12 @@ Page({
         })
       }
     })
+
+    var pt_student_id = wx.getStorageSync('pt_student_id')
+    if (!pt_student_id) {
+      wx.redirectTo({
+        url: '/pages/login/index',
+      })
+    }
   }
 })

+ 73 - 0
wechat/pages/login/index.js

xqd
@@ -0,0 +1,73 @@
+// pages/login/index.js
+var app = getApp();
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+    
+  },
+
+  bindGetUserInfo: function (e) {
+    if(e.detail.errMsg == 'getUserInfo:ok') {
+      app.login(e.detail)
+    }
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+  
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+  
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+  
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+  
+  }
+})

+ 8 - 0
wechat/pages/login/index.json

xqd
@@ -0,0 +1,8 @@
+{
+  "usingComponents": {
+    "zan-button": "/bower_components/zanui-weapp/dist/btn/index",
+    "zan-button-group": "/bower_components/zanui-weapp/dist/btn-group/index",
+    "zan-row": "/bower_components/zanui-weapp/dist/row/index",
+    "zan-col": "/bower_components/zanui-weapp/dist/col/index"
+  }
+}

+ 17 - 0
wechat/pages/login/index.wxml

xqd
@@ -0,0 +1,17 @@
+<!--pages/login/index.wxml-->
+<view id='login-container' class='{{ loginDialogClass }}'>
+  <view class='login-wrapper'>
+    <view class='login-dialog'>
+      <zan-row>
+        <zan-col col="24" col-class="custom-zan-col">
+          <view class='login-header'>登录确认</view>
+        </zan-col>
+      </zan-row>
+      <zan-row>
+        <zan-col col="24" col-class="custom-zan-col">
+          <zan-button type="primary" openType='getUserInfo' bindgetuserinfo="bindGetUserInfo">确认</zan-button>
+        </zan-col>
+      </zan-row>
+    </view>
+  </view>
+</view>

+ 19 - 0
wechat/pages/login/index.wxss

xqd
@@ -0,0 +1,19 @@
+/* pages/login/index.wxss */
+
+#login-container {
+  position: absolute;
+  top: 0;
+  left: 0;
+  width: 100%;
+  height: 100%;
+  background-color: rgba(0, 0, 0, 0.8)
+}
+.login-wrapper {
+  margin-top: 40%;
+  padding: 20px;
+}
+.login-header {
+  background-color: #ffffff;
+  text-align: center;
+  padding: 20px;
+}

+ 2 - 1
wechat/utils/api.js

xqd
@@ -1,5 +1,6 @@
 const headUrl = 'http://t20.9026.com/api/';
 
 module.exports = {
-  headUrl: headUrl
+  headUrl: headUrl,
+  loginUrl: headUrl + 'login'
 }