Msg.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace store\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, 3);
  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', 'store');
  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'], 'store');
  27. } elseif ($data[$k]['param']['type'] == 2) {
  28. $view = Dever::url('stat_view?id=' . $data[$k]['param']['id'] . '&type=store&show=2', 'store');
  29. } elseif ($data[$k]['param']['type'] == 3) {
  30. $view = Dever::url('order_view?type=3&order_id=' . $data[$k]['param']['id'], 'store');
  31. }
  32. if ($view) {
  33. $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>';
  34. }
  35. }
  36. }
  37. if (!$button) {
  38. $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>';
  39. }
  40. $html .= '<tr><td>'.$v['name'].'</td><td>'.$v['content'].'</td><td>'.$data[$k]['cdate_string'].'</td><td>'.$button.'</td></tr>';
  41. }
  42. }
  43. return $html;
  44. }
  45. # 消息已读
  46. public function read_api()
  47. {
  48. $id = Dever::input('id');
  49. Dever::load('message/lib/data')->view($this->id, $id);
  50. return 'ok';
  51. }
  52. }