123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- namespace Factory\Admin;
- use Dever;
- class Msg extends Core
- {
- # 列表
- public function getList()
- {
- $data = Dever::load('message/lib/data')->read($this->id, $this->user['msg_type'], true, false, 4);
- $html = '';
- if ($data) {
- foreach ($data as $k => $v) {
- $data[$k]['cdate_string'] = Dever::ddate($v['cdate']);
- if ($v['param']) {
- $data[$k]['param'] = Dever::json_decode($v['param']);
- }
- $read = Dever::url('admin/msg.read', 'factory');
- $button = '';
- if ($v['link']) {
- $button = '<a href="javascript:;" onclick="read(\''.$read.'\', '.$v['id'].');jump(\''.$v['link'].'\')" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 layui-btn layui-btn-xs">查看</button></a>';
- } elseif ($v['param'] && strstr($v['param'], '{')) {
- $data[$k]['param'] = Dever::json_decode($v['param']);
- if ($data[$k]['param']) {
- $view = '';
- if ($data[$k]['param']['type'] == 1) {
- $view = Dever::url('order_view?type=2&order_id=' . $data[$k]['param']['id'], 'factory');
- } elseif ($data[$k]['param']['type'] == 2) {
- $view = Dever::url('stat_view?id=' . $data[$k]['param']['id'] . '&type=factory&show=2', 'factory');
- }
- if ($view) {
- $button = '<a href="javascript:;" onclick="read(\''.$read.'\', '.$v['id'].');jump(\''.$view.'\')"><button type="button" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 layui-btn layui-btn-xs">查看</button></a>';
- }
- }
- }
- if (!$button) {
- $button = '<a href="javascript:;" onclick="read(\''.$read.'\', '.$v['id'].');showAlert(\''.$v['content'].'\')" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 layui-btn layui-btn-xs">查看</button></a>';
- }
-
- $html .= '<tr><td>'.$v['name'].'</td><td>'.$v['content'].'</td><td>'.$data[$k]['cdate_string'].'</td><td>'.$button.'</td></tr>';
- }
- }
- return $html;
- }
- # 消息已读
- public function read_api()
- {
- $id = Dever::input('id');
- Dever::load('message/lib/data')->view($this->id, $id);
- return 'ok';
- }
- }
|