function likeAction() { if ($this->isget()) { $url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxbe73369f870a0158&redirect_uri=http%3a%2f%2fh5.jiang-mei.com%2fyiboh5%2fcms%2fcp%2flike%2f?id=" . $_GET['id'] . "&response_type=code&scope=snsapi_base&state=123#wechat_redirect"; $this->getToken($url); //获取记录详情 $map['id'] = $_GET['id']; $model = new sevenListModel(); $info = $model->get('*', $map); //获取当天任务详情 $set = $model->table('seven_set')->get('*', array('id' => 1)); $start = $set['start'] ? $set['start'] : strtotime(date('Ymd')); $rule = $model->table('seven_rule')->get('*', array('times' => ($info['addtime'] - $start) / 86400 + 1)); $this->assign('rule', $rule); //获取点赞人数 $like = $model->table('like')->count(array('sid' => $_GET['id'])); $info['like'] = $like; $this->assign('info', $info); //判断当前用户是否点赞 $where['sid'] = $_GET['id']; $where['openid'] = $_SESSION['openid']; $is_like = $model->has(array('AND' => $where)); $this->assign('is_like', $is_like); $this->display(); } else { $map['sid'] = $_POST['id']; $map['openid'] = $_SESSION['openid']; $model = new model('like'); if ($model->has(array('AND' => $map))) { $this->json('您已经点过赞了', 0); } else { if ($model->insert($map)) { $this->json('点赞成功'); } else { $this->json('点赞失败', 0); } } } }