View.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace Main\Src;
  3. use Dever;
  4. use Main\Lib\Core;
  5. class View extends Core
  6. {
  7. # 获取单页链接
  8. public function getLink($key, $name, $type = 5)
  9. {
  10. $link = Dever::url('agreement?key=' . $key . '&type=' . $type . '&name=' . $name, 'main');
  11. return $link;
  12. }
  13. # 获取单页详情
  14. public function getPage()
  15. {
  16. $this->data['info'] = $this->page();
  17. return $this->data;
  18. }
  19. # 获取单页详情
  20. public function page()
  21. {
  22. $type = Dever::input('type', 1);
  23. if (!$type) {
  24. Dever::alert('您访问的页面有误');
  25. }
  26. $key = Dever::input('key');
  27. if (!$key) {
  28. Dever::alert('您访问的页面有误');
  29. }
  30. $name = Dever::input('name');
  31. $where['type'] = $type;
  32. $where['key'] = $key;
  33. $info = Dever::db('main/page')->find($where);
  34. if (!$info) {
  35. $insert = $where;
  36. $insert['name'] = $name;
  37. $insert['content'] = $name;
  38. $id = Dever::db('main/page')->insert($insert);
  39. $info = Dever::db('main/page')->find($id);
  40. }
  41. return $info;
  42. }
  43. }