MyCommentController.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. $reditect = "api.yiguanjia.club/index.php?r=o2o/myComment/checkUserid";
  24. $reditect = urlencode($reditect);
  25. $this->redirect('https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx08ddb347281baf39&redirect_uri='.$reditect.'&response_type=code&scope=snsapi_base&state=5e2b4706179f774e94903e1213d2222e#wechat_redirect');
  26. }
  27. } else {
  28. $userid = Yii::app()->request->getParam('weixin_userid', '');
  29. }
  30. $tech = TechInfo::getByUserid($userid);
  31. if (!$tech) {
  32. $this->render('error', ['msg' => '未查询到用户']);die;
  33. }
  34. $username = $tech->name;
  35. $user = $tech->_id;
  36. $timelist = O2oApp::getTimeList();
  37. $info = array(
  38. 'userid' => $userid,
  39. 'username' => $username,
  40. 'user' => $user,
  41. 'timelist' => $timelist,
  42. );
  43. $data = array_merge($info);
  44. $this->render('index', $data);
  45. }
  46. /**
  47. * 获取userid保存至cookie
  48. */
  49. public function actionCheckUserid() {
  50. $check = O2oApp::checkURI(1);
  51. if (!$check['success']) {
  52. $this->render('error', $check);die;
  53. } else {
  54. $userid = $check['userid'];
  55. }
  56. setcookie('weixin_userid', $userid);
  57. setcookie('weixin_userid_signature', md5($userid.'wozhua=9527'));
  58. $this->redirect(['index']);
  59. }
  60. /**
  61. * 获取评价列表接口
  62. */
  63. public function actionList() {
  64. $start = Yii::app()->request->getParam('start', 0);
  65. $end = Yii::app()->request->getParam('end', 0);
  66. $userid = Yii::app()->request->getParam('userid', '');
  67. $start = strtotime($start);
  68. $end = $end == 0 ? strtotime('+1 month', $start) : $end;
  69. $o2oApp = new O2oApp($userid);
  70. $commentData = $o2oApp->getComment($start, $end, true);
  71. echo json_encode($commentData);
  72. }
  73. public function actionInfo() {
  74. $order = Yii::app()->request->getParam('order', '');
  75. $user = Yii::app()->request->getParam('user', '');
  76. $this->layout = 'qyinfo';
  77. $data = array();
  78. $data['order'] = $order;
  79. $data['user'] = $user;
  80. $this->render('info', $data);
  81. }
  82. }