|
@@ -13,7 +13,7 @@ use think\exception\ValidateException;
|
|
|
use think\response\Json;
|
|
|
|
|
|
/**
|
|
|
- *
|
|
|
+ *
|
|
|
*
|
|
|
* @icon fa fa-circle-o
|
|
|
*/
|
|
@@ -112,6 +112,67 @@ class Message extends Backend
|
|
|
}
|
|
|
$this->success();
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 编辑
|
|
|
+ *
|
|
|
+ * @param $ids
|
|
|
+ * @return string
|
|
|
+ * @throws DbException
|
|
|
+ * @throws \think\Exception
|
|
|
+ */
|
|
|
+ public function edit($ids = null)
|
|
|
+ {
|
|
|
+ $row = $this->model->get($ids);
|
|
|
+ if (!$row) {
|
|
|
+ $this->error(__('No Results were found'));
|
|
|
+ }
|
|
|
+ $adminIds = $this->getDataLimitAdminIds();
|
|
|
+ if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) {
|
|
|
+ $this->error(__('You have no permission'));
|
|
|
+ }
|
|
|
+ if (false === $this->request->isPost()) {
|
|
|
+ $this->view->assign('row', $row);
|
|
|
+ return $this->view->fetch();
|
|
|
+ }
|
|
|
+ $params = $this->request->post('row/a');
|
|
|
+ if (empty($params)) {
|
|
|
+ $this->error(__('Parameter %s can not be empty', ''));
|
|
|
+ }
|
|
|
+ if($row->status==2){
|
|
|
+ $this->error(__('该消息已经发送,不能修改!'));
|
|
|
+ }
|
|
|
+ $params = $this->preExcludeFields($params);
|
|
|
+ $template_id = $params['template_id'];
|
|
|
+ $template= Template::getById($template_id);
|
|
|
+ $params['template_name']=$template->name;
|
|
|
+ $params['template_dsc']=$template->description;
|
|
|
+ $group_id =$params['group_id'];
|
|
|
+ $group= UserGroup::getById($group_id);
|
|
|
+ $params['template_image']=$template->image;
|
|
|
+ $params['group_name']=$group->name;
|
|
|
+ $result = false;
|
|
|
+ Db::startTrans();
|
|
|
+ try {
|
|
|
+ //是否采用模型验证
|
|
|
+ if ($this->modelValidate) {
|
|
|
+ $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
|
|
|
+ $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
|
|
|
+ $row->validateFailException()->validate($validate);
|
|
|
+ }
|
|
|
+ $result = $row->allowField(true)->save($params);
|
|
|
+ Db::commit();
|
|
|
+ } catch (ValidateException|PDOException|Exception $e) {
|
|
|
+ Db::rollback();
|
|
|
+ $this->error($e->getMessage());
|
|
|
+ }
|
|
|
+ if (false === $result) {
|
|
|
+ $this->error(__('No rows were updated'));
|
|
|
+ }
|
|
|
+ $this->success();
|
|
|
+ }
|
|
|
+
|
|
|
public function getType()
|
|
|
{
|
|
|
$list[0]['id']=0;
|
|
@@ -126,11 +187,26 @@ class Message extends Backend
|
|
|
$list[4]['name']='购物车';
|
|
|
$list[5]['id']=5;
|
|
|
$list[5]['name']='消息列表';
|
|
|
+ $list[6]['id']=6;
|
|
|
+ $list[6]['name']='explore首页';
|
|
|
+ $list[7]['id']=7;
|
|
|
+ $list[7]['name']='explore详情';
|
|
|
+ $list[8]['id']=8;
|
|
|
+ $list[8]['name']='我的积分';
|
|
|
+ $list[9]['id']=9;
|
|
|
+ $list[9]['name']='koc';
|
|
|
+ $list[10]['id']=10;
|
|
|
+ $list[10]['name']='vip Center';
|
|
|
+ $list[11]['id']=11;
|
|
|
+ $list[11]['name']='我的优惠券';
|
|
|
+ $list[12]['id']=12;
|
|
|
+ $list[12]['name']='登录注册';
|
|
|
+ $list[13]['id']=13;
|
|
|
+ $list[13]['name']='签到';
|
|
|
$i=$this->request->request('keyValue');
|
|
|
if ($i) {
|
|
|
return json(['list' => $list[$i], 'total' => count($list[$i])]);
|
|
|
}
|
|
|
-
|
|
|
return json(['list' => $list, 'total' => count($list)]);
|
|
|
}
|
|
|
/**
|