My.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace addons\cms\controller\wxapp;
  3. use addons\cms\model\Comment;
  4. use addons\cms\model\Page;
  5. /**
  6. * 我的
  7. */
  8. class My extends Base
  9. {
  10. protected $noNeedLogin = ['aboutus'];
  11. /**
  12. * 我发表的评论
  13. */
  14. public function comment()
  15. {
  16. $page = (int)$this->request->request('page');
  17. $commentList = Comment::
  18. with('archives')
  19. ->where(['user_id' => $this->auth->id])
  20. ->where(['type' => 'archives'])
  21. ->where('status', 'normal')
  22. ->order('id desc')
  23. ->page($page, 10)
  24. ->select();
  25. foreach ($commentList as $index => &$item) {
  26. $item->create_date = human_date($item->createtime);
  27. $item->hidden(['ip', 'useragent', 'deletetime', 'aid', 'subscribe', 'status', 'type', 'updatetime']);
  28. $item->aid = $item->archives->eid;
  29. if ($item->archives) {
  30. $item->archives->id = $item['archives']['eid'];
  31. }
  32. }
  33. $this->success('', ['commentList' => $commentList]);
  34. }
  35. /**
  36. * 关于我们
  37. */
  38. public function aboutus()
  39. {
  40. $pageInfo = Page::getByDiyname('aboutus');
  41. if (!$pageInfo || $pageInfo['status'] != 'normal') {
  42. $this->error(__('单页未找到'));
  43. }
  44. $pageInfo->image = cdnurl($pageInfo->image, true);
  45. $pageInfo->visible(['id', 'title', 'image', 'content', 'createtime']);
  46. $pageInfo = $pageInfo->toArray();
  47. $this->success('', ['pageInfo' => $pageInfo]);
  48. }
  49. }