Msg.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace Factory\Admin;
  3. use Dever;
  4. class Msg extends Core
  5. {
  6. # 列表
  7. public function getList()
  8. {
  9. $data = Dever::load('message/lib/data')->read($this->id, $this->user['msg_type'], true, false, 4);
  10. $html = '';
  11. if ($data) {
  12. foreach ($data as $k => $v) {
  13. $data[$k]['cdate_string'] = Dever::ddate($v['cdate']);
  14. if ($v['param']) {
  15. $data[$k]['param'] = Dever::json_decode($v['param']);
  16. }
  17. $read = Dever::url('admin/msg.read', 'factory');
  18. $button = '';
  19. if ($v['link']) {
  20. $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>';
  21. } elseif ($v['param'] && strstr($v['param'], '{')) {
  22. $data[$k]['param'] = Dever::json_decode($v['param']);
  23. if ($data[$k]['param']) {
  24. $view = '';
  25. if ($data[$k]['param']['type'] == 1) {
  26. $view = Dever::url('order_view?type=2&order_id=' . $data[$k]['param']['id'], 'factory');
  27. } elseif ($data[$k]['param']['type'] == 2) {
  28. $view = Dever::url('stat_view?id=' . $data[$k]['param']['id'] . '&type=factory&show=2', 'factory');
  29. }
  30. if ($view) {
  31. $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>';
  32. }
  33. }
  34. }
  35. if (!$button) {
  36. $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>';
  37. }
  38. $html .= '<tr><td>'.$v['name'].'</td><td>'.$v['content'].'</td><td>'.$data[$k]['cdate_string'].'</td><td>'.$button.'</td></tr>';
  39. }
  40. }
  41. return $html;
  42. }
  43. # 消息已读
  44. public function read_api()
  45. {
  46. $id = Dever::input('id');
  47. Dever::load('message/lib/data')->view($this->id, $id);
  48. return 'ok';
  49. }
  50. }