Silent 6 gadi atpakaļ
vecāks
revīzija
5a006e772a

+ 30 - 0
database/migrations/2018_07_23_213740_add_pic_url_to_contents.php

xqd
@@ -0,0 +1,30 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddPicUrlToContents extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('contents', function (Blueprint $table) {
+            $table->string('pic_url', 200)->nullable()->after('title')->comment('视频封面');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        //
+    }
+}

+ 9 - 0
resources/views/admin/contents/create.blade.php

xqd
@@ -65,6 +65,15 @@
                                         <span class="help-block">{{ $errors->first('title') }}</span>
                                     @endif
                                 </div>
+                                <div class="form-group row">
+                                    <label class="col-sm-2 col-sm-offset-1 control-label">视频封面</label>
+                                    <div class="col-sm-8">
+                                        {!!  widget('Tools.ImgUpload')->single('video-cover', 'data[pic_url]') !!}
+                                    </div>
+                                    @if($errors->has('pic_url'))
+                                        <span class="help-block">{{ $errors->first('pic_url') }}</span>
+                                    @endif
+                                </div>
                             @endif
 
                             <div class="form-group row">

+ 9 - 0
resources/views/admin/contents/edit.blade.php

xqd
@@ -66,6 +66,15 @@
                                         <span class="help-block">{{ $errors->first('content') }}</span>
                                     @endif
                                 </div>
+                                <div class="form-group row">
+                                    <label class="col-sm-2 col-sm-offset-1 control-label">视频封面</label>
+                                    <div class="col-sm-8">
+                                        {!!  widget('Tools.ImgUpload')->single('video-cover', 'data[pic_url]', $item->pic_url) !!}
+                                    </div>
+                                    @if($errors->has('pic_url'))
+                                        <span class="help-block">{{ $errors->first('pic_url') }}</span>
+                                    @endif
+                                </div>
                             @endif
 
                             <div class="form-group row">

+ 49 - 11
wechat/pages/index/index.js

xqd xqd xqd
@@ -19,7 +19,8 @@ Page({
     shareImage: '',
     shareText: '',
     shareTextPosX: '',
-    shareTextPosY: ''
+    shareTextPosY: '',
+    shareTempFilePath: ''
   },
   onLoad: function () {
     wx.getSystemInfo({
@@ -49,6 +50,14 @@ Page({
             shareTextPosX: res.data.shareTextPosX,
             shareTextPosY: res.data.shareTextPosY,
           })
+          wx.downloadFile({
+            url: res.data.shareImage,
+            success: res => {
+              this.setData({
+                shareImage: res.tempFilePath
+              })
+            }
+          })
         }
       }
     })
@@ -198,26 +207,55 @@ Page({
     ctx.textAlign = 'center'
     // ctx.fillText('我已成功打卡14天', width / 2, height / 2 - 7)
     ctx.fillText(text, text_x, text_y)
-    ctx.draw()
+    ctx.draw(false, this.getTempFilePath)
   },
   togglePopup() {
     this.setData({
       showPopup: !this.data.showPopup
     });
   },
-  handleShare() {
+  getTempFilePath: function () {
     wx.canvasToTempFilePath({
       canvasId: 'shareCanvas',
       success: (res) => {
-        wx.saveImageToPhotosAlbum({
-          filePath: res.tempFilePath,
-          success: () => {
-            wx.showToast({
-              title: '已保存到相册'
-            })
-          }
+        this.setData({
+          shareTempFilePath: res.tempFilePath
         })
       }
-      }, this)
+    })
+  },
+  handleShare() {
+    // wx.canvasToTempFilePath({
+    //   canvasId: 'shareCanvas',
+    //   success: (res) => {
+    //     wx.saveImageToPhotosAlbum({
+    //       filePath: res.tempFilePath,
+    //       success: () => {
+    //         wx.showToast({
+    //           title: '已保存到相册'
+    //         })
+    //       }
+    //     })
+    //   }
+    //   }, this)
+    if (!this.data.shareTempFilePath) {
+      wx.showModal({
+        title: '提示',
+        content: '图片绘制中,请稍后重试',
+        showCancel: false
+      })
+    }
+    wx.saveImageToPhotosAlbum({
+      filePath: this.data.shareTempFilePath,
+      success: (res) => {
+        
+      },
+      complete: res => {
+        this.setData({
+          showPopup: false
+        })
+      }
+    })
   }
+  
 })

+ 1 - 1
wechat/pages/index/index.wxml

xqd
@@ -46,6 +46,6 @@
   <zan-popup show="{{ showPopup }}" bindclose="togglePopup">
     <canvas canvas-id="shareCanvas" style="width: {{shareCanvasWidth}}px; height:{{shareCanvasHeight}}px">
     </canvas>
-    <button class="share-btn" size="mini" bindtap="handleShare">生成图片发到朋友圈</button>
+    <button class="share-btn" bindtap="handleShare" type='primary'>生成图片发到朋友圈</button>
   </zan-popup>
 </view>

+ 1 - 5
wechat/pages/index/index.wxss

xqd
@@ -126,10 +126,6 @@ swiper {
   border: none;
 }
 .share-btn {
-  position: absolute;
-  left: 0;
-  right: 0;
-  margin: auto;
-  bottom: 24px;
+  margin-top: 20px;
   width: 80%;
 }

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

xqd
@@ -18,6 +18,9 @@ Page({
 
   bindGetUserInfo: function (e) {
     if(e.detail.errMsg == 'getUserInfo:ok') {
+      wx.showLoading({
+        title: '登录中',
+      })
       app.login(e.detail)
     }
   },