Browse Source

定时任务

Silent 6 năm trước cách đây
mục cha
commit
ba8355066e

+ 2 - 2
app/Http/Controllers/WeChat/ApiController.php

xqd xqd
@@ -103,7 +103,7 @@ class ApiController extends Controller
         if(empty($res)) {
             return response()->json(['status' => 'fail', 'info' => '创建失败']);
         }
-        return response()->json(['status' => 'success', 'info' => '操作成功']);
+        return response()->json(['status' => 'success', 'check_card_id' => $res->id, 'info' => '操作成功']);
     }
 
     public function endCheckCard(Request $request)
@@ -117,6 +117,6 @@ class ApiController extends Controller
             return response()->json(['status' => 'fail', 'info' => '打卡失败']);
         }
 
-        return response()->json(['status' => 'success', 'info' => '操作成功']);
+        return response()->json(['status' => 'success', 'info' => '打卡成功']);
     }
 }

+ 22 - 3
wechat/pages/index/index.js

xqd xqd
@@ -81,10 +81,28 @@ Page({
       return;
     }
     if (isLearning) {
-      this.setData({
-        isLearning: !isLearning
+      let check_card_id = wx.getStorageSync('check_card_id');
+      wx.request({
+        url: api.endCheckCardUrl,
+        method: 'GET',
+        data: {
+          'check_card_id': check_card_id
+        },
+        success: res => {
+          if (res.data.status == 'success') {
+            that.setData({
+              isLearning: !isLearning
+            })
+            that.endClock()
+          } else {
+            wx.showToast({
+              title: res.data.info,
+              icon: 'none',
+              duration: 800
+            })
+          }
+        }
       })
-      this.endClock()
     } else {
       wx.request({
         url: api.startCheckCardUrl,
@@ -94,6 +112,7 @@ Page({
         },
         success: res => {
           if (res.data.status == 'success') {
+            wx.setStorageSync('check_card_id', res.data.check_card_id)
             that.setData({
               isLearning: !isLearning,
               startTime: new Date().getTime()

+ 2 - 1
wechat/utils/api.js

xqd
@@ -1,9 +1,10 @@
 const headUrl = 'http://t20.9026.com/wechat/';
 
 module.exports = {
+  isTest: true,
   headUrl: headUrl,
   loginUrl: headUrl + 'login',
   checkPositionUrl: headUrl + 'checkPosition',
   startCheckCardUrl: headUrl + 'startCheckCard',
-  isTest: true
+  endCheckCardUrl: headUrl + 'endCheckCard'
 }