|
|
@@ -8,6 +8,7 @@ use think\facade\Route as Url;
|
|
|
use app\admin\model\user\UserNotice as UserNoticeModel;
|
|
|
use app\admin\model\user\UserNoticeSee as UserNoticeSeeModel;
|
|
|
use app\admin\model\wechat\WechatUser as UserModel;
|
|
|
+use think\facade\Config;
|
|
|
|
|
|
/**
|
|
|
* 用户通知
|
|
|
@@ -41,11 +42,17 @@ class UserNotice extends AuthController
|
|
|
*/
|
|
|
public function create()
|
|
|
{
|
|
|
+ $sender = Config::get('app.notice_sender');
|
|
|
$f = array();
|
|
|
- $f[] = Form::input('user', '发送人', '系统管理员');
|
|
|
+ $f[] = Form::input('user', '发送人', $sender);
|
|
|
+ $f[] = Form::frameImageOne('icon', '图标', Url::buildUrl('admin/widget.images/index', array('fodder' => 'icon')))->icon('image')->width('100%')->height('500px');
|
|
|
$f[] = Form::input('title', '通知标题');
|
|
|
- $f[] = Form::input('content', '通知内容')->type('textarea');
|
|
|
- $f[] = Form::radio('type', '消息类型', 1)->options([['label' => '系统消息', 'value' => 1], ['label' => '用户通知', 'value' => 2]]);
|
|
|
+ $f[] = Form::input('content', '通知内容')->type('textarea')->rows(10);
|
|
|
+ $f[] = Form::radio('type', '消息类型', 1)->options([
|
|
|
+ ['label' => '系统通知', 'value' => 0],
|
|
|
+ // ['label' => '分组通知', 'value' => 1],
|
|
|
+ ['label' => '用户通知', 'value' => 2],
|
|
|
+ ]);
|
|
|
$form = Form::make_post_form('添加用户通知', $f, Url::buildUrl('save'));
|
|
|
$this->assign(compact('form'));
|
|
|
return $this->fetch('public/form-builder');
|
|
|
@@ -82,9 +89,14 @@ class UserNotice extends AuthController
|
|
|
if (!$notice) return Json::fail('数据不存在!');
|
|
|
$f = array();
|
|
|
$f[] = Form::input('user', '发送人', $notice["user"]);
|
|
|
+ $f[] = Form::frameImageOne('icon', '图标', Url::buildUrl('admin/widget.images/index', array('fodder' => 'icon')), $notice->getData('icon'))->icon('image')->width('100%')->height('500px');
|
|
|
$f[] = Form::input('title', '通知标题', $notice["title"]);
|
|
|
- $f[] = Form::input('content', '通知内容', $notice["content"])->type('textarea');
|
|
|
- $f[] = Form::radio('type', '消息类型', $notice["type"])->options([['label' => '系统消息', 'value' => 1], ['label' => '用户通知', 'value' => 2]]);
|
|
|
+ $f[] = Form::input('content', '通知内容', $notice["content"])->type('textarea')->rows(10);
|
|
|
+ $f[] = Form::radio('type', '消息类型', $notice["type"])->options([
|
|
|
+ ['label' => '系统通知', 'value' => 0],
|
|
|
+ // ['label' => '分组通知', 'value' => 1],
|
|
|
+ ['label' => '用户通知', 'value' => 2],
|
|
|
+ ]);
|
|
|
$form = Form::make_post_form('编辑通知', $f, Url::buildUrl('update', ["id" => $id]), 2);
|
|
|
$this->assign(compact('form'));
|
|
|
return $this->fetch('public/form-builder');
|
|
|
@@ -124,10 +136,12 @@ class UserNotice extends AuthController
|
|
|
*/
|
|
|
public function delete($id)
|
|
|
{
|
|
|
- if (!UserNoticeModel::del($id))
|
|
|
+ if (!UserNoticeModel::del($id)) {
|
|
|
return Json::fail(UserNoticeModel::getErrorInfo('删除失败,请稍候再试!'));
|
|
|
- else
|
|
|
+ } else {
|
|
|
+ UserNoticeSeeModel::where('nid', $id)->delete();
|
|
|
return Json::successful('删除成功!');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -142,7 +156,7 @@ class UserNotice extends AuthController
|
|
|
$model = new UserModel;
|
|
|
$model = $model::alias('A');
|
|
|
$model = $model->field('A.*');
|
|
|
- if ($notice["type"] == 2) {
|
|
|
+ if ($notice["type"] == 1) {
|
|
|
if ($notice["uid"] != "") {
|
|
|
$uids = explode(",", $notice["uid"]);
|
|
|
array_splice($uids, 0, 1);
|
|
|
@@ -152,7 +166,7 @@ class UserNotice extends AuthController
|
|
|
$model = $model->where("A.uid", $notice['uid']);
|
|
|
}
|
|
|
$model->order('A.uid desc');
|
|
|
- } else {
|
|
|
+ } else if($notice['type'] == 2) {
|
|
|
$model = $model->join('UserNoticeSee B', 'A.uid = B.uid', 'RIGHT');
|
|
|
$model = $model->where("B.nid", $notice['id']);
|
|
|
$model->order('B.add_time desc');
|