diff --git a/app/UploadFiles.php b/app/UploadFiles.php
index d3f7327..fb2ef51 100644
--- a/app/UploadFiles.php
+++ b/app/UploadFiles.php
@@ -2,9 +2,16 @@
namespace app;
use app\model\UploadFiles as AppUploadFiles;
+use think\facade\Filesystem;
class UploadFiles
{
+
+ public static function add()
+ {
+ return new AppUploadFiles();
+ }
+
public static function create($data,$allowFiled = [],$replace = false)
{
return AppUploadFiles::create($data,$allowFiled,$replace);
@@ -26,8 +33,15 @@ class UploadFiles
]);
}
- public static function clear()
+ public static function clear($id)
{
-
+ $model_file = AppUploadFiles::find($id);
+
+ $model_file->clear_time = time();
+ $model_file->status = 3;
+
+ $model_file->save();
+
+ return Filesystem::delete($model_file->getData('save_name'));
}
}
diff --git a/app/admin/controller/Admin.php b/app/admin/controller/Admin.php
index a8534e0..29c0c2d 100644
--- a/app/admin/controller/Admin.php
+++ b/app/admin/controller/Admin.php
@@ -3,9 +3,8 @@
namespace app\admin\controller;
use app\model\Admin as AppAdmin;
-use app\model\UploadFiles;
+use app\UploadFiles as AppUploadFiles;
use think\facade\View;
-use think\Request;
class Admin extends Common
{
@@ -58,8 +57,8 @@ class Admin extends Common
$model_admin = AppAdmin::find($this->adminInfo['id']);
if($model_admin->getData('avatar') != $post_data['avatar']){
- UploadFiles::destroy(['save_name'=>$model_admin->getData('avatar')]);
- UploadFiles::update(['used_time'=>time()],['save_name'=>$post_data['avatar']]);
+ AppUploadFiles::delete($model_admin->getData('avatar'));
+ AppUploadFiles::use($post_data['avatar']);
}
diff --git a/app/admin/controller/App.php b/app/admin/controller/App.php
deleted file mode 100644
index df07808..0000000
--- a/app/admin/controller/App.php
+++ /dev/null
@@ -1,226 +0,0 @@
-post();
-
- $model_app = ModelApp::where('mark_id',$post_data['mark_id'])->find();
-
- if(!empty($model_app)){
- return json_message('应用已存在,不能重复创建');
- }
-
- $model_app = new ModelApp();
-
- if(!empty($post_data['poster'])){
- UploadFiles::update(['userd_time'=>time()],['save_name'=>$post_data['poster']]);
- }
-
- if(!empty($post_data['detail'])){
-
- foreach ($post_data['detail'] as $key => $value) {
- if(isset($value['insert'])){
- if(isset($value['insert']['image'])){
- $full_save_name = $value['insert']['image'];
- $save_name = de_source_link($full_save_name);
- if($save_name){
- UploadFiles::update(['used_time'=>time()],['save_name'=>$save_name]);
- }
- }
- }
- }
- }
-
-
- $model_app->data($post_data,true);
-
- $model_app->save();
-
- return json_message();
- }
-
- /**
- * 显示指定的资源
- *
- * @param int $id
- * @return \think\Response
- */
- public function read($id)
- {
- //
- }
-
- /**
- * 显示编辑资源表单页.
- *
- * @param int $id
- * @return \think\Response
- */
- public function edit($id)
- {
- //
- $model_app = ModelApp::find($id);
- $app_list = get_app_info();
-
- View::assign('app_list',$app_list);
- View::assign('app',$model_app);
-
- return View::fetch();
- }
-
- /**
- * 保存更新的资源
- *
- * @param \think\Request $request
- * @param int $id
- * @return \think\Response
- */
- public function update(Request $request, $id)
- {
- //
- //
- $post_data = $request->post();
-
- $model_app = ModelApp::where('id',$id)->find();
-
- if(empty($model_app)){
- return json_message('应用不存在');
- }
-
- if(!empty($post_data['poster'])){
- if($post_data['poster'] != $model_app->getData('poster')){
- UploadFiles::destroy(['save_name'=>$model_app->getData('poster')]);
- UploadFiles::update(['userd_time'=>time()],['save_name'=>$post_data['poster']]);
- }
- }
-
- if(!empty($post_data['detail'])){
- $image_list = [];
- $new_image_list = [];
- foreach ($model_app->detail as $key => $value) {
- if(isset($value['insert'])){
- if(isset($value['insert']['image'])){
- $full_save_name = $value['insert']['image'];
- $save_name = de_source_link($full_save_name);
- if($save_name){
- $image_list[] = $save_name;
- }
- }
- }
- }
- foreach ($post_data['detail'] as $key => $value) {
- if(isset($value['insert'])){
- if(isset($value['insert']['image'])){
- $full_save_name = $value['insert']['image'];
- $save_name = de_source_link($full_save_name);
- if($save_name){
- $new_image_list[] = $save_name;
- }
- }
- }
- }
-
- $del_image_list = array_diff($image_list,$new_image_list);
-
- foreach ($del_image_list as $key => $value) {
- UploadFiles::destroy(['save_name'=>$value]);
- }
-
- $add_image_list = array_diff($new_image_list,$image_list);
-
- foreach ($add_image_list as $key => $value) {
- UploadFiles::update(['used_time'=>time()],['save_name'=>$value]);
- }
- }
-
-
- $model_app->data($post_data,true);
-
- $model_app->save();
-
- return json_message();
- }
-
- /**
- * 删除指定资源
- *
- * @param int $id
- * @return \think\Response
- */
- public function delete($id)
- {
- //
- $model_app = ModelApp::find($id);
-
- if(!empty($model_app->getData('poster'))){
- UploadFiles::udpate(['delete_time'=>time()],['save_name'=>$model_app->getData('poster')]);
- }
-
- if(!empty($model_app->getData('detail'))){
- foreach ($model_app->detail as $key => $value) {
- if(isset($value['insert'])){
- if(isset($value['insert']['image'])){
- $full_save_name = $value['insert']['image'];
- $save_name = de_source_link($full_save_name);
- if($save_name){
- UploadFiles::update(['delete_time'=>time()],['save_name'=>$save_name]);
- }
- }
- }
- }
- }
- $model_app->delete();
-
- return json_message();
- }
-}
diff --git a/app/admin/controller/File.php b/app/admin/controller/File.php
index da19f4c..6698ecc 100644
--- a/app/admin/controller/File.php
+++ b/app/admin/controller/File.php
@@ -3,6 +3,7 @@
namespace app\admin\controller;
use app\model\UploadFiles;
+use app\UploadFiles as AppUploadFiles;
use think\facade\View;
use think\Request;
@@ -18,9 +19,15 @@ class File extends Common
//
$type = $this->request->param('type',1);
+ $status = $this->request->param('status','');
- $list = UploadFiles::where('type',$type)->order('id desc')->paginate();
+ $model_list = UploadFiles::where('type',$type)->order('id desc');
+ if($status != ''){
+ $model_list->where('status',$status);
+ }
+
+ $list = $model_list->paginate();
View::assign('list',$list);
return View::fetch();
@@ -91,4 +98,11 @@ class File extends Common
{
//
}
+
+ public function clear($id)
+ {
+ AppUploadFiles::clear($id);
+
+ return json_message();
+ }
}
diff --git a/app/admin/controller/System.php b/app/admin/controller/System.php
index 7416351..8000805 100644
--- a/app/admin/controller/System.php
+++ b/app/admin/controller/System.php
@@ -6,10 +6,10 @@ use think\Request;
use think\facade\View;
use app\model\SystemConfig;
use think\facade\Cache;
-use app\model\UploadFiles;
use EasyWeChat\Factory;
use think\facade\Config;
use app\model\WxPublicAccount;
+use app\UploadFiles as AppUploadFiles;
class System extends Common
{
@@ -43,9 +43,9 @@ class System extends Common
foreach ($post_data as $key => $value) {
if(\in_array($key,$upload_files_config)){
$old_save_name = get_system_config($key);
- UploadFiles::update(['used_time'=>time()],['save_name'=>$value]);
+ AppUploadFiles::use($value);
if($old_save_name != $value){
- UploadFiles::destroy(['save_name'=>$old_save_name]);
+ AppUploadFiles::delete($old_save_name);
}
}
if(isset($list[$key])){
diff --git a/app/api/controller/Files.php b/app/api/controller/Files.php
index a91903b..1747bd6 100644
--- a/app/api/controller/Files.php
+++ b/app/api/controller/Files.php
@@ -5,8 +5,8 @@ namespace app\api\controller;
use think\Request;
use think\facade\Filesystem;
use think\facade\Config;
-use app\model\UploadFiles;
use app\BaseController;
+use app\UploadFiles as AppUploadFiles;
class Files extends BaseController
{
@@ -40,7 +40,7 @@ class Files extends BaseController
}
$dir_name = $request->param('dir','data');
- $model_file = new UploadFiles();
+ $model_file = AppUploadFiles::add();
$model_file->file_name = $file->getOriginalName();
$model_file->mime_type = $file->getOriginalMime();
$model_file->ext_name = $file->extension();
diff --git a/app/api/controller/WxOpen.php b/app/api/controller/WxOpen.php
index f9e76cf..42cc2f3 100644
--- a/app/api/controller/WxOpen.php
+++ b/app/api/controller/WxOpen.php
@@ -6,8 +6,8 @@ use app\BaseController;
use think\facade\Config;
use EasyWeChat\Factory;
use app\model\WxPublicAccount;
-use app\model\UploadFiles;
use app\model\SystemConfig;
+use app\UploadFiles as AppUploadFiles;
use think\facade\Cache;
class WxOpen extends BaseController
@@ -58,21 +58,24 @@ class WxOpen extends BaseController
if(!empty($model_auth_account->getData('head_img'))){
- UploadFiles::destroy(['save_name'=>$model_auth_account->getData('head_img')]);
+
+ AppUploadFiles::delete($model_auth_account->getData('head_img'));
}
$model_auth_account->head_img = \save_url_file($wx_public_account_info['authorizer_info']['head_img'],3);
- UploadFiles::update(['used_time'=>time()],['save_name'=>$model_auth_account->getData('head_img')]);
+
+ AppUploadFiles::use($model_auth_account->getData('head_img'));
$model_auth_account->service_type_info = $wx_public_account_info['authorizer_info']['service_type_info']['id'];
$model_auth_account->verify_type_info = $wx_public_account_info['authorizer_info']['verify_type_info']['id'];
$model_auth_account->user_name = $wx_public_account_info['authorizer_info']['user_name'];
$model_auth_account->alias = $wx_public_account_info['authorizer_info']['alias'];
if(!empty($model_auth_account->getData('qrcode_url'))){
- UploadFiles::destroy(['save_name'=>$model_auth_account->getData('qrcode_url')]);
+ AppUploadFiles::delete($model_auth_account->getData('qrcode_url'));
}
$model_auth_account->qrcode_url = save_url_file($wx_public_account_info['authorizer_info']['qrcode_url'],2);
- UploadFiles::update(['used_time'=>time()],['save_name'=>$model_auth_account->getData('qrcode_url')]);
+
+ AppUploadFiles::use($model_auth_account->getData('qrcode_url'));
$model_auth_account->business_info = json_encode($wx_public_account_info['authorizer_info']['business_info']);
$model_auth_account->principal_name = $wx_public_account_info['authorizer_info']['principal_name'];
$model_auth_account->signature = $wx_public_account_info['authorizer_info']['signature'];
diff --git a/public/static/lib/layui/lib/cropper/cropper.css b/public/static/lib/layui/lib/cropper/cropper.css
new file mode 100644
index 0000000..0c344e8
--- /dev/null
+++ b/public/static/lib/layui/lib/cropper/cropper.css
@@ -0,0 +1,11 @@
+body {
+}
+/*!
+ * Cropper v0.7.6-beta
+ * https://github.com/fengyuanchen/cropper
+ *
+ * Copyright 2014 Fengyuan Chen
+ * Released under the MIT license
+ */
+
+.cropper-container{position:relative;overflow:hidden;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent;-webkit-touch-callout:none}.cropper-container img{width:100%;height:100%;min-width:0!important;min-height:0!important;max-width:none!important;max-height:none!important}.cropper-modal,.cropper-canvas{position:absolute;top:0;right:0;bottom:0;left:0}.cropper-canvas{background-color:#fff;opacity:0;filter:alpha(opacity=0)}.cropper-modal{background-color:#000;opacity:.5;filter:alpha(opacity=50)}.cropper-dragger{position:absolute;top:10%;left:10%;width:80%;height:80%}.cropper-viewer{display:block;width:100%;height:100%;overflow:hidden;outline-width:1px;outline-style:solid;outline-color:#69f;outline-color:rgba(51,102,255,.75)}.cropper-dashed{position:absolute;display:block;border:0 dashed #fff;opacity:.5;filter:alpha(opacity=50)}.cropper-dashed.dashed-h{top:33.3%;left:0;width:100%;height:33.3%;border-top-width:1px;border-bottom-width:1px}.cropper-dashed.dashed-v{top:0;left:33.3%;width:33.3%;height:100%;border-right-width:1px;border-left-width:1px}.cropper-face,.cropper-line,.cropper-point{position:absolute;display:block;width:100%;height:100%;opacity:.1;filter:alpha(opacity=10)}.cropper-face{top:0;left:0;cursor:move;background-color:#fff}.cropper-line{background-color:#69f}.cropper-line.line-e{top:0;right:-3px;width:5px;cursor:e-resize}.cropper-line.line-n{top:-3px;left:0;height:5px;cursor:n-resize}.cropper-line.line-w{top:0;left:-3px;width:5px;cursor:w-resize}.cropper-line.line-s{bottom:-3px;left:0;height:5px;cursor:s-resize}.cropper-point{width:5px;height:5px;background-color:#69f;opacity:.75;filter:alpha(opacity=75)}.cropper-point.point-e{top:50%;right:-3px;margin-top:-3px;cursor:e-resize}.cropper-point.point-n{top:-3px;left:50%;margin-left:-3px;cursor:n-resize}.cropper-point.point-w{top:50%;left:-3px;margin-top:-3px;cursor:w-resize}.cropper-point.point-s{bottom:-3px;left:50%;margin-left:-3px;cursor:s-resize}.cropper-point.point-ne{top:-3px;right:-3px;cursor:ne-resize}.cropper-point.point-nw{top:-3px;left:-3px;cursor:nw-resize}.cropper-point.point-sw{bottom:-3px;left:-3px;cursor:sw-resize}.cropper-point.point-se{right:-3px;bottom:-3px;width:20px;height:20px;cursor:se-resize;opacity:1;filter:alpha(opacity=100)}.cropper-point.point-se:before{position:absolute;right:-50%;bottom:-50%;display:block;width:200%;height:200%;content:" ";background-color:#69f;opacity:0;filter:alpha(opacity=0)}@media (min-width:768px){.cropper-point.point-se{width:15px;height:15px}}@media (min-width:992px){.cropper-point.point-se{width:10px;height:10px}}@media (min-width:1200px){.cropper-point.point-se{width:5px;height:5px;opacity:.75;filter:alpha(opacity=75)}}.cropper-hidden{display:none!important}.cropper-invisible{position:fixed;top:0;left:0;z-index:-1;width:auto!important;max-width:none!important;height:auto!important;max-height:none!important;opacity:0;filter:alpha(opacity=0)}.cropper-move{cursor:move}.cropper-crop{cursor:crosshair}.cropper-disabled .cropper-canvas,.cropper-disabled .cropper-face,.cropper-disabled .cropper-line,.cropper-disabled .cropper-point{cursor:not-allowed}
\ No newline at end of file
diff --git a/public/static/lib/layui/lib/cropper/cropper.js b/public/static/lib/layui/lib/cropper/cropper.js
new file mode 100644
index 0000000..a522f18
--- /dev/null
+++ b/public/static/lib/layui/lib/cropper/cropper.js
@@ -0,0 +1,3087 @@
+/*!
+ * Cropper v3.0.0
+ */
+
+layui.define(['jquery'], function (exports) {
+ var $ = layui.jquery;
+ $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
+
+ var DEFAULTS = {
+ // Define the view mode of the cropper
+ viewMode: 0, // 0, 1, 2, 3
+
+ // Define the dragging mode of the cropper
+ dragMode: 'crop', // 'crop', 'move' or 'none'
+
+ // Define the aspect ratio of the crop box
+ aspectRatio: NaN,
+
+ // An object with the previous cropping result data
+ data: null,
+
+ // A selector for adding extra containers to preview
+ preview: '',
+
+ // Re-render the cropper when resize the window
+ responsive: true,
+
+ // Restore the cropped area after resize the window
+ restore: true,
+
+ // Check if the current image is a cross-origin image
+ checkCrossOrigin: true,
+
+ // Check the current image's Exif Orientation information
+ checkOrientation: true,
+
+ // Show the black modal
+ modal: true,
+
+ // Show the dashed lines for guiding
+ guides: true,
+
+ // Show the center indicator for guiding
+ center: true,
+
+ // Show the white modal to highlight the crop box
+ highlight: true,
+
+ // Show the grid background
+ background: true,
+
+ // Enable to crop the image automatically when initialize
+ autoCrop: true,
+
+ // Define the percentage of automatic cropping area when initializes
+ autoCropArea: 0.8,
+
+ // Enable to move the image
+ movable: true,
+
+ // Enable to rotate the image
+ rotatable: true,
+
+ // Enable to scale the image
+ scalable: true,
+
+ // Enable to zoom the image
+ zoomable: true,
+
+ // Enable to zoom the image by dragging touch
+ zoomOnTouch: true,
+
+ // Enable to zoom the image by wheeling mouse
+ zoomOnWheel: true,
+
+ // Define zoom ratio when zoom the image by wheeling mouse
+ wheelZoomRatio: 0.1,
+
+ // Enable to move the crop box
+ cropBoxMovable: true,
+
+ // Enable to resize the crop box
+ cropBoxResizable: true,
+
+ // Toggle drag mode between "crop" and "move" when click twice on the cropper
+ toggleDragModeOnDblclick: true,
+
+ // Size limitation
+ minCanvasWidth: 0,
+ minCanvasHeight: 0,
+ minCropBoxWidth: 0,
+ minCropBoxHeight: 0,
+ minContainerWidth: 200,
+ minContainerHeight: 100,
+
+ // Shortcuts of events
+ ready: null,
+ cropstart: null,
+ cropmove: null,
+ cropend: null,
+ crop: null,
+ zoom: null
+ };
+
+ var TEMPLATE = '
' + '
' + '
' + '
' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
' + '
';
+
+ var REGEXP_DATA_URL_HEAD = /^data:.*,/;
+ var REGEXP_USERAGENT = /(Macintosh|iPhone|iPod|iPad).*AppleWebKit/i;
+ var navigator = typeof window !== 'undefined' ? window.navigator : null;
+ var IS_SAFARI_OR_UIWEBVIEW = navigator && REGEXP_USERAGENT.test(navigator.userAgent);
+ var fromCharCode = String.fromCharCode;
+
+ function isNumber(n) {
+ return typeof n === 'number' && !isNaN(n);
+ }
+
+ function isUndefined(n) {
+ return typeof n === 'undefined';
+ }
+
+ function toArray(obj, offset) {
+ var args = [];
+
+ // This is necessary for IE8
+ if (isNumber(offset)) {
+ args.push(offset);
+ }
+
+ return args.slice.apply(obj, args);
+ }
+
+ // Custom proxy to avoid jQuery's guid
+ function proxy(fn, context) {
+ for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
+ args[_key - 2] = arguments[_key];
+ }
+
+ return function () {
+ for (var _len2 = arguments.length, args2 = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
+ args2[_key2] = arguments[_key2];
+ }
+
+ return fn.apply(context, args.concat(toArray(args2)));
+ };
+ }
+
+ function objectKeys(obj) {
+ var keys = [];
+
+ $.each(obj, function (key) {
+ keys.push(key);
+ });
+
+ return keys;
+ }
+
+ function isCrossOriginURL(url) {
+ var parts = url.match(/^(https?:)\/\/([^:/?#]+):?(\d*)/i);
+
+ return parts && (parts[1] !== location.protocol || parts[2] !== location.hostname || parts[3] !== location.port);
+ }
+
+ function addTimestamp(url) {
+ var timestamp = 'timestamp=' + new Date().getTime();
+
+ return url + (url.indexOf('?') === -1 ? '?' : '&') + timestamp;
+ }
+
+ function getImageSize(image, callback) {
+ // Modern browsers (ignore Safari, #120 & #509)
+ if (image.naturalWidth && !IS_SAFARI_OR_UIWEBVIEW) {
+ callback(image.naturalWidth, image.naturalHeight);
+ return;
+ }
+
+ // IE8: Don't use `new Image()` here (#319)
+ var newImage = document.createElement('img');
+
+ newImage.onload = function load() {
+ callback(this.width, this.height);
+ };
+
+ newImage.src = image.src;
+ }
+
+ function getTransform(options) {
+ var transforms = [];
+ var translateX = options.translateX;
+ var translateY = options.translateY;
+ var rotate = options.rotate;
+ var scaleX = options.scaleX;
+ var scaleY = options.scaleY;
+
+ if (isNumber(translateX) && translateX !== 0) {
+ transforms.push('translateX(' + translateX + 'px)');
+ }
+
+ if (isNumber(translateY) && translateY !== 0) {
+ transforms.push('translateY(' + translateY + 'px)');
+ }
+
+ // Rotate should come first before scale to match orientation transform
+ if (isNumber(rotate) && rotate !== 0) {
+ transforms.push('rotate(' + rotate + 'deg)');
+ }
+
+ if (isNumber(scaleX) && scaleX !== 1) {
+ transforms.push('scaleX(' + scaleX + ')');
+ }
+
+ if (isNumber(scaleY) && scaleY !== 1) {
+ transforms.push('scaleY(' + scaleY + ')');
+ }
+
+ return transforms.length ? transforms.join(' ') : 'none';
+ }
+
+ function getRotatedSizes(data, isReversed) {
+ var deg = Math.abs(data.degree) % 180;
+ var arc = (deg > 90 ? 180 - deg : deg) * Math.PI / 180;
+ var sinArc = Math.sin(arc);
+ var cosArc = Math.cos(arc);
+ var width = data.width;
+ var height = data.height;
+ var aspectRatio = data.aspectRatio;
+ var newWidth = void 0;
+ var newHeight = void 0;
+
+ if (!isReversed) {
+ newWidth = width * cosArc + height * sinArc;
+ newHeight = width * sinArc + height * cosArc;
+ } else {
+ newWidth = width / (cosArc + sinArc / aspectRatio);
+ newHeight = newWidth / aspectRatio;
+ }
+
+ return {
+ width: newWidth,
+ height: newHeight
+ };
+ }
+
+ function getSourceCanvas(image, data, options) {
+ var canvas = $('