MyCommentController.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /**
  3. * 我的评价控制器
  4. * @author 2015-12-11
  5. */
  6. class MyCommentController extends CController {
  7. public $layout = 'qyindex';
  8. /**
  9. * 我的评价首页
  10. */
  11. public function actionIndex() {
  12. // 环境判断
  13. // if (ENVIRONMENT == 'product') {
  14. if (false) {
  15. if (isset($_COOKIE['weixin_userid']) && isset($_COOKIE['weixin_userid_signature'])) {
  16. $signature = md5($_COOKIE['weixin_userid'].'wozhua=9527');
  17. if ($signature == $_COOKIE['weixin_userid_signature']) {
  18. $userid = $_COOKIE['weixin_userid'];
  19. } else {
  20. $this->render('error', ['msg' => '未查询到用户']);die;
  21. }
  22. } else {
  23. $this->redirect('https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxedb2ce71dfee8aa5&redirect_uri= api.yiguanjia.me%2Findex.php%3Fr%3Do2o%2FmyComment%2FcheckUserid&response_type=code&scope=snsapi_base&state=5e2b4706179f774e94903e1213d2222e#wechat_redirect');
  24. }
  25. } else {
  26. $userid = Yii::app()->request->getParam('weixin_userid', '');
  27. }
  28. $tech = TechInfo::getByUserid($userid);
  29. if (!$tech) {
  30. $this->render('error', ['msg' => '未查询到用户']);die;
  31. }
  32. $username = $tech->name;
  33. $user = $tech->_id;
  34. $timelist = O2oApp::getTimeList();
  35. $info = array(
  36. 'userid' => $userid,
  37. 'username' => $username,
  38. 'user' => $user,
  39. 'timelist' => $timelist,
  40. );
  41. $data = array_merge($info);
  42. $this->render('index', $data);
  43. }
  44. /**
  45. * 获取userid保存至cookie
  46. */
  47. public function actionCheckUserid() {
  48. $check = O2oApp::checkURI(24);
  49. if (!$check['success']) {
  50. $this->render('error', $check);die;
  51. } else {
  52. $userid = $check['userid'];
  53. }
  54. setcookie('weixin_userid', $userid);
  55. setcookie('weixin_userid_signature', md5($userid.'wozhua=9527'));
  56. $this->redirect(['index']);
  57. }
  58. /**
  59. * 获取评价列表接口
  60. */
  61. public function actionList() {
  62. $start = Yii::app()->request->getParam('start', 0);
  63. $end = Yii::app()->request->getParam('end', 0);
  64. $userid = Yii::app()->request->getParam('userid', '');
  65. $start = strtotime($start);
  66. $end = $end == 0 ? strtotime('+1 month', $start) : $end;
  67. $o2oApp = new O2oApp($userid);
  68. $commentData = $o2oApp->getComment($start, $end, true);
  69. echo json_encode($commentData);
  70. }
  71. public function actionInfo() {
  72. $order = Yii::app()->request->getParam('order', '');
  73. $user = Yii::app()->request->getParam('user', '');
  74. $this->layout = 'qyinfo';
  75. $data = array();
  76. $data['order'] = $order;
  77. $data['user'] = $user;
  78. $this->render('info', $data);
  79. }
  80. }