diff --git a/components/Oss.php b/components/Oss.php index 3f41fd5..268c50a 100644 --- a/components/Oss.php +++ b/components/Oss.php @@ -21,8 +21,8 @@ class Oss { $this->accessKeyId = 'LTAI5tMaDbEbWyQWpwmxp24y'; $this->accessKeySecret = '3bjqbBFC08YIub3c8ry9Elz05UF1J7'; - $this->bucket = 'cxgjyz'; - $this->endpoint = 'https://oss-cn-beijing.aliyuncs.com'; + $this->bucket = 'cxgjsz1'; + $this->endpoint = 'https://oss-cn-shenzhen.aliyuncs.com'; try { if (!isset($this->client)) { diff --git a/models/Banner.php b/models/Banner.php index 2dd37d6..d1bd3e8 100644 --- a/models/Banner.php +++ b/models/Banner.php @@ -28,6 +28,8 @@ use app\models\Model; * @property int $deleted_at 更新时间 * @property int $media 媒体类型:0=图片,1=视频 * @property string $video_url 视频 + * @property string $text 视频 + * @property string $other_img_url 视频 */ class Banner extends \yii\db\ActiveRecord { @@ -61,8 +63,9 @@ class Banner extends \yii\db\ActiveRecord [['cx_mch_id', 'user_id', 'zone_id', 'url_type', 'sort', 'is_delete', 'status', 'created_at', 'updated_at', 'deleted_at', 'media'], 'integer'], [['app_id'], 'string', 'max' => 64], [['app_ext'], 'string', 'max' => 1024], - [['img_url', 'page_url', 'video_url'], 'string', 'max' => 2048], + [['img_url', 'page_url', 'video_url','other_img_url'], 'string', 'max' => 2048], [['title'], 'string', 'max' => 512], + [['text'], 'string'], ]; } @@ -124,6 +127,10 @@ class Banner extends \yii\db\ActiveRecord '0' => '小程序页面', '1' => '外部链接', '2' => '小程序', + '3' => '公众号图片', + '4' => '视频号图片', + '5' => '抖音号图片', + '6' => '文章', ]; } @@ -151,14 +158,14 @@ class Banner extends \yii\db\ActiveRecord { return [ '0' => '图片', - '1' => '视频', +// '1' => '视频', ]; } public static function type() { return [ - '1' => 'banner', +// '1' => 'banner', '2' => '轮播', ]; } @@ -178,7 +185,7 @@ class Banner extends \yii\db\ActiveRecord 'cx_mch_id' => $cx_mch_id, 'status' => 1, ]) - ->select('id,url_type,app_id,app_ext,img_url,title,page_url,media,video_url,type') + ->select('id,url_type,app_id,app_ext,img_url,title,page_url,media,video_url,type,other_img_url,text') ->orderBy(['sort' => SORT_ASC, 'created_at' => SORT_DESC])->asArray()->all(); foreach ($list as $index => $item) { if ($item['media'] == self::MEDIA_IMG) { diff --git a/modules/admin/controllers/WechatController.php b/modules/admin/controllers/WechatController.php index 8327738..a70eb88 100644 --- a/modules/admin/controllers/WechatController.php +++ b/modules/admin/controllers/WechatController.php @@ -30,6 +30,9 @@ use app\models\PickLinkForm; class WechatController extends Controller { + public $ids = [ + 12,13,14,15,16,17,18,19,20,21,22,23,24,25 + ]; public function behaviors() { return array_merge(parent::behaviors(), [ @@ -77,9 +80,18 @@ class WechatController extends Controller $form->attributes = \Yii::$app->request->get(); $form->zone_id = Banner::ZONE_ID_WXAPP_INDEX; $form->cx_mch_id = $this->cx_mch_id; - $data = $form->search(); + $data = $form->search($this->ids,'not in'); return $this->render('mp-slide', $data); } + public function actionMpSlideT() + { + $form = new SlideListForm(); + $form->attributes = \Yii::$app->request->get(); + $form->zone_id = Banner::ZONE_ID_WXAPP_INDEX; + $form->cx_mch_id = $this->cx_mch_id; + $data = $form->search($this->ids,'in'); + return $this->render('mp-slide-t', $data); + } public function actionMpSlideEdit($id = 0) { @@ -111,10 +123,16 @@ class WechatController extends Controller return $this->responseHandler($data); } $return_url = \Yii::$app->request->referrer; + $is = false; + if(in_array($id,$this->ids)){ + $is = true; + } return $this->render('mp-slide-edit', [ 'model' => $model, 'return_url' => $return_url, - 'links' => (new PickLinkForm())->getPickLink() + 'links' => (new PickLinkForm())->getPickLink(), + 'is' => $is, + 'id' => $id, ]); } diff --git a/modules/admin/models/Menu.php b/modules/admin/models/Menu.php index 55eb43c..cf463e9 100644 --- a/modules/admin/models/Menu.php +++ b/modules/admin/models/Menu.php @@ -561,6 +561,13 @@ class Menu 'is_show' => true, 'route' => 'admin/wechat/mp-slide', ], + [ + 'name' => '首页配置', + 'is_menu' => true, + 'is_show' => true, + 'route' => 'admin/wechat/mp-slide-t', + ], + [ 'name' => '订阅消息', 'is_menu' => true, diff --git a/modules/admin/models/SlideEditForm.php b/modules/admin/models/SlideEditForm.php index 431639f..2982f90 100644 --- a/modules/admin/models/SlideEditForm.php +++ b/modules/admin/models/SlideEditForm.php @@ -34,16 +34,18 @@ class SlideEditForm extends AdminModel public $media; public $status; public $video_url; + public $other_img_url; + public $text; public function rules() { return [ [['app_id', 'app_ext', 'title', 'page_url', 'video_url'], 'trim'], - [['app_id', 'app_ext', 'title', 'page_url', 'video_url'], 'string'], + [['app_id', 'app_ext', 'title', 'page_url', 'video_url','text','other_img_url'], 'string'], [['cx_mch_id', 'user_id', 'zone_id', 'url_type', 'sort', 'status','type'],'integer'], [['status'], 'in', 'range' => [0, 1]], - [['cx_mch_id', 'user_id', 'zone_id', 'url_type', 'model', 'status', 'media'], 'required'], +// [['cx_mch_id', 'user_id', 'zone_id', 'url_type', 'model', 'media'], 'required'], [['img_url'], 'required', 'on' => 'img'], [['video_url'], 'required', 'on' => 'video'], ]; @@ -81,6 +83,8 @@ class SlideEditForm extends AdminModel $this->model->title = $this->title; $this->model->sort = $this->sort; $this->model->type = $this->type; + $this->model->other_img_url = $this->other_img_url; + $this->model->text = $this->text; if($this->url_type == Banner::URL_TYPE_MP_PAGE){ $this->model->page_url = $this->page_url; } else if($this->url_type == Banner::URL_TYPE_MP){ diff --git a/modules/admin/models/SlideListForm.php b/modules/admin/models/SlideListForm.php index 8928969..f19e9ac 100644 --- a/modules/admin/models/SlideListForm.php +++ b/modules/admin/models/SlideListForm.php @@ -36,7 +36,7 @@ class SlideListForm extends AdminModel ]; } - public function search() + public function search($id,$type='in') { if(!$this->validate()){ $pagination = new Pagination([ @@ -53,6 +53,8 @@ class SlideListForm extends AdminModel 'zone_id' => $this->zone_id, "is_delete" => 0, 'cx_mch_id' => $this->cx_mch_id + ])->andWhere([ + $type,'id',$id ]) ->select('id,url_type,app_id,app_ext,img_url,title,page_url,sort,created_at,status,media,video_url'); $count = $query->count(); @@ -69,6 +71,9 @@ class SlideListForm extends AdminModel $item['created_at_cn'] = date('Y-m-d H:i:s',$item['created_at']); $item['status_cn'] = Banner::getStatus($item['status']); $item['media_cn'] = Banner::getMedia($item['media']); + if(in_array($item['id'],$id)){ + $item['status'] = -1; + } $list[$index] = $item; } return [ diff --git a/modules/admin/views/wechat/mp-slide-edit.php b/modules/admin/views/wechat/mp-slide-edit.php index a55b3fa..121dc65 100644 --- a/modules/admin/views/wechat/mp-slide-edit.php +++ b/modules/admin/views/wechat/mp-slide-edit.php @@ -13,12 +13,30 @@ use app\widgets\PickLinker; use app\models\Banner; use app\widgets\PickFile; +use app\assets\UeditorAsset; - -$this->title = '编辑轮播图'; -$this->params['breadcrumbs'][] = ['label' => '轮播图' , 'url' => [\Yii::$app->urlManager->createUrl(["admin/wechat/mp-slide"])]]; +UeditorAsset::register($this); +$skip_k = []; +if(!$is){ + $skip_k = [3,4,5,6,7,8,9]; + $this->title = '编辑轮播图'; + $this->params['breadcrumbs'][] = ['label' => '轮播图' , 'url' => [\Yii::$app->urlManager->createUrl(["admin/wechat/mp-slide"])]]; +}else{ + $this->title = '编辑配置'; + $this->params['breadcrumbs'][] = ['label' => '配置' , 'url' => [\Yii::$app->urlManager->createUrl(["admin/wechat/mp-slide"])]]; + if($id == 12){ + $skip_k = [0,1,2,3,4,5,7,8,9]; + }else{ + $skip_k = [6]; + } +} $this->params['breadcrumbs'][] = $this->title; $url_type_labels = Banner::urlTypeLabels(); +foreach ($url_type_labels as $k=>$v){ + if(in_array($k,$skip_k)){ + unset($url_type_labels[$k]); + } +} $status_labels = Banner::statusLabels(); $media_labels = Banner::mediaLabels(); $type = Banner::type(); @@ -33,23 +51,35 @@ $type = Banner::type();
- + value="title ?>">
-
+ 'images', + 'id' => 'img_url_upload', + 'name' => 'img_url', + 'label' => '主图', + 'value' => $model->img_url, + 'tip' => '图片大小750×330', + 'imageCompressEnable' => 1, + 'imageCompressBorder' => 750 + ])?> + +
+
- +
$val):?> url_type == $key ? 'checked=""' : ''?>> @@ -57,16 +87,19 @@ $type = Banner::type();
-
- -
- + +
+ +
+ +
+ + + +
- - - -
-
+ +
@@ -81,34 +114,60 @@ $type = Banner::type();
-
- -
- -
-
升序,值越小排序越靠前
-
+
-
+ +
+ + + + +
+ +
+ +
+
升序,值越小排序越靠前
+
+ + + +
- 'images', - 'id' => 'img_url_upload', - 'name' => 'img_url', - 'label' => '图片', - 'value' => $model->img_url, - 'tip' => '图片大小750×330', - 'imageCompressEnable' => 1, - 'imageCompressBorder' => 750 - ])?> + + + 'video', 'id' => 'video_url_upload', @@ -117,15 +176,40 @@ $type = Banner::type(); 'value' => $model->video_url, 'tip' => '' ])?> - -
- -
- status == 0 ? 'checked=""' : ''?>> - status == 1 ? 'checked=""' : ''?>> + +
+ +
+ status == 0 ? 'checked=""' : ''?>> + status == 1 ? 'checked=""' : ''?>> +
+
-
-
+ + + 'images', + 'id' => 'img_url_uploads11231', + 'name' => 'other_img_url', + 'label' => '附图', + 'value' => $model->other_img_url, +// 'tip' => '图片大小750×330', + 'imageCompressEnable' => 1, + 'imageCompressBorder' => 750 + ])?> + + + + +
+ +
+ +
+
+ + +
@@ -174,7 +258,17 @@ $type = Banner::type(); //console.log(obj) var url = 'urlManager->createUrl(["/admin/wechat/mp-slide-edit", 'id' => $model->id ? $model->id : 0]) ?>'; var returnUrl = ""; + console.log(returnUrl) var data = obj.field; + try{ + data.text = UE.getEditor('editor').getContent(); + }catch (e){ + + } + if('' == 12){ + data.url_type = 6 + + } data._csrf = _csrf; $.ajax(url, { type: "POST", @@ -249,6 +343,62 @@ $type = Banner::type(); init_page(); }); + var ue = UE.getEditor('editor', { + serverUrl: "urlManager->createUrl(['file/upload']) ?>", + toolbars: [ + [ + 'anchor', //锚点 + 'undo', //撤销 + 'redo', //重做 + 'bold', //加粗 + 'indent', //首行缩进 + 'italic', //斜体 + 'underline', //下划线 + 'strikethrough', //删除线 + 'subscript', //下标 + 'fontborder', //字符边框 + 'superscript', //上标 + 'formatmatch', //格式刷 + 'source', //源代码 + 'blockquote', //引用 + 'pasteplain', //纯文本粘贴模式 + 'selectall', //全选 + 'preview', //预览 + 'horizontal', //分隔线 + 'removeformat', //清除格式 + 'time', //时间 + 'date', //日期 + 'unlink', //取消链接 + 'cleardoc', //清空文档 + 'insertcode', //代码语言 + 'fontfamily', //字体 + 'fontsize', //字号 + 'paragraph', //段落格式 + 'simpleupload', //单图上传 + 'insertimage', //多图上传 + 'link', //超链接 + 'emotion', //表情 + 'spechars', //特殊字符 + 'help', //帮助 + 'justifyleft', //居左对齐 + 'justifyright', //居右对齐 + 'justifycenter', //居中对齐 + 'justifyjustify', //两端对齐 + 'forecolor', //字体颜色 + 'insertorderedlist', //有序列表 + 'insertunorderedlist', //无序列表 + 'fullscreen', //全屏 + 'rowspacingtop', //段前距 + 'rowspacingbottom', //段后距 + 'wordimage', //图片转存 + 'lineheight', //行间距 + 'customstyle', //自定义标题 + 'autotypeset', //自动排版 + 'drafts', // 从草稿箱加载 + ] + ] + }); + endBlock(); ?> registerJs($this->blocks['js_script_wrap'], \yii\web\View::POS_END); ?> \ No newline at end of file diff --git a/modules/admin/views/wechat/mp-slide-t.php b/modules/admin/views/wechat/mp-slide-t.php new file mode 100644 index 0000000..cb03350 --- /dev/null +++ b/modules/admin/views/wechat/mp-slide-t.php @@ -0,0 +1,407 @@ +title = '首页配置'; +$this->params['breadcrumbs'][] = $this->title; +$status_labels = Banner::statusLabels(); +$status = \Yii::$app->request->get('status'); +?> +
+
+
+ title ?> +
+ +
+ + + + + + + + + + + + + + + + $item):?> + + + + + + + + + + + + + +
+
+ +
+
ID标题内容添加时间操作
+
+ +
+
+ + " style="width:168px;max-width: 168px;"> + + + + + + + " class="layui-btn layui-btn-normal layui-btn-xs show-btn">显示 + " class="layui-btn layui-btn-danger layui-btn-xs del-btn">删除 + + " class="layui-btn layui-btn-warm layui-btn-xs hide-btn">隐藏 + + 编辑 +
+
+ $pagination, + 'prevPageLabel' => '上一页', + 'nextPageLabel' => '下一页', + 'firstPageLabel' => '首页', + 'lastPageLabel' => '尾页', + 'maxButtonCount' => 5, + 'options' => [ + 'class' => 'layui-pagination layui-laypage', + ], + 'prevPageCssClass' => 'layui-laypage-prev', + 'pageCssClass' => "layui-laypage-item", + 'nextPageCssClass' => 'layui-laypage-first', + 'firstPageCssClass' => 'layui-laypage-last', + 'lastPageCssClass' => 'layui-laypage-last', + 'linkOptions' => [ + 'class' => 'page-link', + ], + 'disabledListItemSubTagOptions' => ['tag' => 'a', 'class' => 'layui-disabled'], + ]) + ?> +
+
+
+
+ +registerJs($this->blocks['js_script_wrap'], \yii\web\View::POS_END); ?> \ No newline at end of file