Silent 6 lat temu
rodzic
commit
73f48fe705

+ 9 - 0
app/Http/Controllers/WeChat/ApiController.php

xqd
@@ -743,4 +743,13 @@ class ApiController extends Controller
 
         return $response;
     }
+
+    public function checkCardIsEnd(Request $request)
+    {
+        if(empty($request->input('check_card_id')) || empty($check_card = CheckCard::find($request->input('check_card_id')))) {
+            return response()->json(['status' => 'success', 'result' => 'yes']);
+        }
+        $result = empty($check_card->end_date_time) ? 'no' : 'yes';
+        return response()->json(['status' => 'success', 'result' => $result]);
+    }
 }

+ 2 - 1
routes/wechat.php

xqd
@@ -21,4 +21,5 @@ Route::post('getPhone', 'ApiController@getPhone');
 Route::get('getFormSet', 'ApiController@getFormSet');
 Route::post('submitForm', 'ApiController@submitForm');
 Route::any('payNotify', 'ApiController@payNotify');
-Route::get('getShareText', 'ApiController@getShareText');
+Route::get('getShareText', 'ApiController@getShareText');
+Route::get('checkCardIsEnd', 'ApiController@checkCardIsEnd');

+ 17 - 5
wechat/pages/index/index.js

xqd
@@ -71,12 +71,24 @@ Page({
             })
             if (validLocation) {
               var start_time = wx.getStorageSync('check_card_start_time')
-              if (start_time) {
-                this.setData({
-                  startTime: start_time,
-                  isLearning: true
+              var check_card_id = wx.getStorageSync('check_card_id')
+              if (start_time && check_card_id) {
+                wx.request({
+                  url: api.checkCardIsEndUrl,
+                  method: 'GET',
+                  data: {
+                    check_card_id: check_card_id
+                  },
+                  success: res => {
+                    if (res.data.status == 'success' && res.data.result == 'no') {
+                      this.setData({
+                        startTime: start_time,
+                        isLearning: true
+                      })
+                      this.startClock()
+                    }
+                  }
                 })
-                this.startClock()
               }
             }
           },

+ 1 - 0
wechat/utils/api.js

xqd
@@ -22,4 +22,5 @@ module.exports = {
   submitFormUrl: headUrl + 'submitForm',
   applyLeaveUrl: headUrl + 'applyLeave',
   getShareTextUrl: headUrl + 'getShareText',
+  checkCardIsEndUrl: headUrl + 'checkCardIsEnd',
 }