LoveBaseController.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +---------------------------------------------------------------------
  9. // | Author: Dean <zxxjjforever@163.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\love\controller;
  12. use app\common\Wechat;
  13. use app\love\model\LotteryLogModel;
  14. use app\love\model\UserModel;
  15. use cmf\controller\HomeBaseController;
  16. use think\facade\Request;
  17. use think\facade\Session;
  18. class LoveBaseController extends HomeBaseController
  19. {
  20. protected $user = null;
  21. protected $mating = null;
  22. public function initialize()
  23. {
  24. parent::initialize();
  25. $userId = cmf_get_current_user_id();
  26. //记录回调
  27. $domain = $this->request->url(true);
  28. Session::set('domain', $domain);
  29. if (empty($userId)) {
  30. if ($this->request->isAjax()) {
  31. $this->error("您尚未登录", cmf_url("love/Login/index"));
  32. } else {
  33. $this->redirect(cmf_url("love/Login/index"));
  34. }
  35. }
  36. $this->user = UserModel::get($userId);
  37. if (empty($this->user)) {
  38. Session::destroy();
  39. $this->redirect(cmf_url("love/Login/index"));
  40. }
  41. //拉黑
  42. if ($this->user['user_status'] == 0) {
  43. $this->redirect(cmf_url('love/register/ban'));
  44. }
  45. //完善资料
  46. if ($this->user['is_complete'] == 2) {
  47. if (empty($this->user['sex'])) {
  48. $this->redirect(cmf_url('love/register/sex'));
  49. } else {
  50. $this->redirect(cmf_url('love/register/intro'));
  51. }
  52. }
  53. //分享页面
  54. $wx_api_sign = Wechat::instance()->getJsSign(Request::url(true));
  55. $this->assign('domain', $this->request->domain());
  56. $this->assign('wx_api_sign', json_encode($wx_api_sign));
  57. }
  58. /**
  59. * 会员状态
  60. */
  61. protected function checkStatus()
  62. {
  63. if ($this->user['check_status'] != 2) {
  64. $this->error('请等待审核!');
  65. }
  66. }
  67. }