My.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. ->order('id desc')
  21. ->page($page, 10)
  22. ->select();
  23. foreach ($commentList as $index => $item) {
  24. $item->create_date = human_date($item->createtime);
  25. $item->hidden(['ip', 'useragent', 'deletetime', 'aid', 'subscribe', 'status', 'type', 'updatetime']);
  26. }
  27. $this->success('', ['commentList' => $commentList]);
  28. }
  29. /**
  30. * 关于我们
  31. */
  32. public function aboutus()
  33. {
  34. $pageInfo = Page::getByDiyname('aboutus');
  35. if (!$pageInfo || $pageInfo['status'] != 'normal') {
  36. $this->error(__('单页未找到'));
  37. }
  38. $pageInfo->image = cdnurl($pageInfo->image, true);
  39. $pageInfo->visible(['id', 'title', 'image', 'content', 'createtime']);
  40. $pageInfo = $pageInfo->toArray();
  41. $this->success('', ['pageInfo' => $pageInfo]);
  42. }
  43. }