Browse Source

分享图片

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

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

@@ -3,6 +3,7 @@
 namespace App\Http\Controllers\WeChat;
 namespace App\Http\Controllers\WeChat;
 
 
 use App\Models\CheckCard;
 use App\Models\CheckCard;
+use App\Models\Content;
 use App\Models\Setting;
 use App\Models\Setting;
 use App\Models\Student;
 use App\Models\Student;
 use App\Models\StudentCourse;
 use App\Models\StudentCourse;
@@ -147,4 +148,14 @@ class ApiController extends Controller
 
 
         return response()->json(['status' => 'success', 'width' => $image->width(), 'height' => $image->height(), 'shareImage' => $image_url, 'shareText' => $text, 'shareTextPosX' => $pos[0], 'shareTextPosY' => $pos[1]]);
         return response()->json(['status' => 'success', 'width' => $image->width(), 'height' => $image->height(), 'shareImage' => $image_url, 'shareText' => $text, 'shareTextPosX' => $pos[0], 'shareTextPosY' => $pos[1]]);
     }
     }
+
+    public function getMoreVideos(Request $request)
+    {
+        $offset = $request->input('offset', 0);
+        $list = Content::where('type', 3)->orderBy('sort')->offset($offset)->limit(15)->get();
+        foreach($list as $item) {
+            $item->pic_url = 'https://u5.9026.com/addons/swdz_mall/core/web/uploads/image/0e/0e739254177172e4b815d75f88da77b4.png';
+        }
+        return response()->json(['status' => 'success', 'list' => $list]);
+    }
 }
 }

+ 2 - 0
app/Models/Student.php

@@ -2,6 +2,8 @@
 
 
 namespace App\Models;
 namespace App\Models;
 
 
+use Carbon\Carbon;
+use function foo\func;
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Database\Eloquent\Model;
 
 
 class Student extends Model
 class Student extends Model

+ 2 - 1
routes/wechat.php

@@ -5,4 +5,5 @@ Route::post('login', 'ApiController@login');
 Route::get('checkPosition', 'ApiController@checkPosition');
 Route::get('checkPosition', 'ApiController@checkPosition');
 Route::get('startCheckCard', 'ApiController@startCheckCard');
 Route::get('startCheckCard', 'ApiController@startCheckCard');
 Route::get('endCheckCard', 'ApiController@endCheckCard');
 Route::get('endCheckCard', 'ApiController@endCheckCard');
-Route::get('getShareInfo', 'ApiController@getShareInfo');
+Route::get('getShareInfo', 'ApiController@getShareInfo');
+Route::get('getMoreVideos', 'ApiController@getMoreVideos');

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

@@ -18,7 +18,8 @@ Page({
     shareCanvasHeight: 280,
     shareCanvasHeight: 280,
     shareImage: '',
     shareImage: '',
     shareText: '',
     shareText: '',
-    shareTextPos: ''
+    shareTextPosX: '',
+    shareTextPosY: ''
   },
   },
   onLoad: function () {
   onLoad: function () {
     wx.getSystemInfo({
     wx.getSystemInfo({
@@ -46,7 +47,8 @@ Page({
             shareCanvasHeight: res.data.height,
             shareCanvasHeight: res.data.height,
             shareImage: res.data.shareImage,
             shareImage: res.data.shareImage,
             shareText: res.data.shareText,
             shareText: res.data.shareText,
-            shareTextPos: res.data.shareTextPos
+            shareTextPosX: res.data.shareTextPosX,
+            shareTextPosY: res.data.shareTextPosY,
           })
           })
         }
         }
       }
       }
@@ -185,14 +187,19 @@ Page({
     const ctx = wx.createCanvasContext('shareCanvas')
     const ctx = wx.createCanvasContext('shareCanvas')
     let width = this.data.shareCanvasWidth
     let width = this.data.shareCanvasWidth
     let height = this.data.shareCanvasHeight
     let height = this.data.shareCanvasHeight
+    let image = this.data.shareImage
+    let text = this.data.shareText
+    let text_x = this.data.shareTextPosX
+    let text_y = this.data.shareTextPosY
+    // ctx.fillStyle = "#fff"
+    // ctx.fillRect(0, 0, width, height)
+    ctx.drawImage(image)
     ctx.fillStyle = "#fff"
     ctx.fillStyle = "#fff"
-    ctx.fillRect(0, 0, width, height)
-    ctx.fillStyle = "#000"
-    ctx.setFontSize(16)
+    ctx.setFontSize(24)
     ctx.textAlign = 'center'
     ctx.textAlign = 'center'
-    ctx.fillText('我已成功打卡14天', width / 2, height / 2 - 7)
+    // ctx.fillText('我已成功打卡14天', width / 2, height / 2 - 7)
+    ctx.fillText(text, text_x, text_y)
     ctx.draw()
     ctx.draw()
-    
   },
   },
   togglePopup() {
   togglePopup() {
     this.setData({
     this.setData({