-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit faa8b86
Showing
365 changed files
with
69,713 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Uploads/ | ||
*/config.php | ||
cache/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<IfModule mod_rewrite.c> | ||
Options +FollowSymlinks | ||
RewriteEngine On | ||
|
||
RewriteCond %{REQUEST_FILENAME} !-d | ||
RewriteCond %{REQUEST_FILENAME} !-f | ||
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] | ||
</IfModule> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
function vaild_sk($sk){ | ||
if(!S($sk)){ | ||
$result['status'] = -1; | ||
$result['msg'] = '登录已过期'; | ||
exit(json_encode($result)); | ||
} | ||
return S($sk); | ||
} | ||
|
||
function msg($type,$uid,$fid,$content,$url) //发送消息 | ||
{ | ||
$data['type'] = $type; | ||
$data['uid'] = $uid; | ||
$data['fid'] = $fid; | ||
$data['content'] = $content; | ||
$data['url'] = $url; | ||
$data['time'] = time(); | ||
return M('msg')->add($data); | ||
} | ||
|
||
function sendMessage($data){ | ||
|
||
$url = 'https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token='.getToken(); | ||
\Think\Log::record(json_encode($data).'##'.json_encode(http_post_data($url,json_encode($data)))); | ||
|
||
} | ||
|
||
function http_post_data($url, $data_string) { | ||
|
||
$ch = curl_init(); | ||
curl_setopt($ch, CURLOPT_POST, 1); | ||
curl_setopt($ch, CURLOPT_URL, $url); | ||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); | ||
curl_setopt($ch, CURLOPT_HTTPHEADER, array( | ||
'Content-Type: application/json; charset=utf-8', | ||
'Content-Length: ' . strlen($data_string)) | ||
); | ||
ob_start(); | ||
curl_exec($ch); | ||
$return_content = ob_get_contents(); | ||
ob_end_clean(); | ||
|
||
$return_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); | ||
return array($return_code, $return_content); | ||
} | ||
|
||
function getToken(){ | ||
$url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.C('APPID').'&secret='.C('AppSecret'); | ||
$data = json_decode(file_get_contents($url),true); | ||
return $data['access_token']; | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
return array( | ||
//'配置项'=>'配置值' | ||
'APPID' => '', | ||
'AppSecret' => '', | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
return array( | ||
//'配置项'=>'配置值' | ||
'APPID' => 'wxac6f7972118d9e2f', | ||
'AppSecret' => '6136f372c6760ec2310d24c50932192b', | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
<?php | ||
namespace Api\Controller; | ||
use Think\Controller; | ||
class AppointmentController extends Controller { | ||
|
||
public function add(){ | ||
$u = D('User'); | ||
$user = $u->getUserInfo(vaild_sk(I('sk'))); | ||
$data['uid'] = $user['id']; | ||
$data['iid'] = I('iid',''); | ||
$data['name'] = I('name',''); | ||
$data['phone'] = I('phone',''); | ||
$data['surplus'] = I('surplus',''); | ||
$data['time'] = time(); | ||
|
||
$rules = array( | ||
array('name','require','请输入姓名'), | ||
array('phone','require','请输入手机号码'), | ||
array('phone','/^1[34578]\d{9}$/','手机号码格式错误'), | ||
array('surplus','require','请选择人数') | ||
); | ||
|
||
$where['uid'] = $data['uid']; | ||
$where['iid'] = $data['iid']; | ||
$info = M('appointment')->where($where)->find(); | ||
if(!empty($info)){ | ||
$result['status'] = 0; | ||
$result['msg'] = '请不要重复预约'; | ||
exit(json_encode($result)); | ||
} | ||
|
||
if($id = M('appointment')->validate($rules)->add($data)){ | ||
$infoObj = D('Info'); | ||
$info = $infoObj->field('info.*,user.openId')->table('__INFO__ info,__USER__ user')->where('info.uid=user.id and info.id = "'.$data['iid'].'"')->find(); | ||
|
||
$postData['touser'] = $info['openId']; | ||
$postData['template_id'] = 'l5gcjhy3C_Tu-mjhoCNHOrbW4P7xlRw72dzu3iZ5tVw'; | ||
$postData['page'] = '/pages/appointment/index?id='.$id; | ||
$postData['form_id'] = i('form_id'); | ||
$postData['data']['keyword1']['value'] = $data['name']; | ||
$postData['data']['keyword2']['value'] = $data['phone']; | ||
$postData['data']['keyword3']['value'] = $info['destination']; | ||
$postData['data']['keyword4']['value'] = $info['departure']; | ||
$postData['data']['keyword5']['value'] = date('Y-m-d H:i',$info['time']); | ||
sendMessage($postData); | ||
msg('notice',$info['uid'],'10000',$data['name'].'预约了您发布的拼车信息,请及时处理',$postData['page']); | ||
$result['status'] = 1; | ||
$result['msg'] = '预约成功'; | ||
|
||
}else{ | ||
$result['status'] = 0; | ||
$result['msg'] = '预约失败'; | ||
} | ||
exit(json_encode($result)); | ||
|
||
} | ||
|
||
public function my(){ | ||
$u = D('User'); | ||
$user = $u->getUserInfo(vaild_sk(I('sk'))); | ||
$infoObj = D('Info'); | ||
$info = $infoObj->field('info.id,appointment.*')->table('__INFO__ info')->join('__APPOINTMENT__ appointment on info.id=appointment.iid','RIGHT')->where('info.uid = "'.$user['id'].'"')->order('appointment.time desc')->select(); | ||
$result['status'] = 1; | ||
$result['msg'] = '获取成功'; | ||
$result['data'] = $info; | ||
exit(json_encode($result)); | ||
} | ||
|
||
public function mycount(){ | ||
$u = D('User'); | ||
$user = $u->getUserInfo(vaild_sk(I('sk'))); | ||
$infoObj = D('Info'); | ||
$info = $infoObj->table('__INFO__ info')->join('__APPOINTMENT__ appointment on info.id=appointment.iid','RIGHT')->where('info.uid = "'.$user['id'].'" and appointment.status = 0')->count(); | ||
$result['status'] = 1; | ||
$result['msg'] = '获取成功'; | ||
$result['data'] = $info; | ||
exit(json_encode($result)); | ||
} | ||
|
||
public function getPassenger(){ | ||
$u = D('User'); | ||
$user = $u->getUserInfo(vaild_sk(I('sk'))); | ||
$infoObj = D('Info'); | ||
$info = $infoObj->field('info.id,info.phone,info.departure,info.destination,info.time,appointment.status')->table('__INFO__ info')->join('__APPOINTMENT__ appointment on info.id=appointment.iid','RIGHT')->where('appointment.uid = "'.$user['id'].'"')->order('appointment.time desc')->select(); | ||
$result['status'] = 1; | ||
$result['msg'] = '获取成功'; | ||
$result['data'] = $info; | ||
exit(json_encode($result)); | ||
} | ||
|
||
|
||
public function detail(){ | ||
$u = D('User'); | ||
$user = $u->getUserInfo(vaild_sk(I('sk'))); | ||
$infoObj = D('Info'); | ||
$info = $infoObj->field('info.id,info.departure,info.destination,info.time,appointment.*')->table('__INFO__ info')->join('__APPOINTMENT__ appointment on info.id=appointment.iid','RIGHT')->where('appointment.id = "'.I('id').'" and info.uid = "'.$user['id'].'"')->find(); | ||
$result['status'] = 1; | ||
$result['msg'] = '获取成功'; | ||
$result['data'] = $info; | ||
exit(json_encode($result)); | ||
} | ||
|
||
public function submit(){ | ||
$u = D('User'); | ||
$user = $u->getUserInfo(vaild_sk(I('sk'))); | ||
$infoObj = D('Info'); | ||
$app['status'] = I('type'); | ||
$info = $infoObj->field('info.*,appointment.uid as aid')->table('__INFO__ info')->join('__APPOINTMENT__ appointment on info.id=appointment.iid','RIGHT')->where('appointment.id = "'.I('id').'" and info.uid = "'.$user['id'].'"')->find(); | ||
if(empty($info)){ | ||
$result['status'] = 0; | ||
$result['msg'] = '信息错误'; | ||
}else{ | ||
$where['id'] = I('id'); | ||
|
||
if(M('appointment')->where($where)->save($app)){ | ||
$user = M('User')->find($info['aid']); | ||
$postData['touser'] = $user['openId']; | ||
$postData['form_id'] = i('form_id'); | ||
$postData['page'] = '/pages/info/index?id='.$info['id']; | ||
if($app['status'] == 1){ | ||
$postData['template_id'] = 'rIfea-FXQNJa9Jh05jGyZO4-v-UfHjWJn0vNGwjSivc'; | ||
$postData['data']['keyword1']['value'] = date('Y-m-d H:i',$info['time']); | ||
$postData['data']['keyword2']['value'] = $info['departure']; | ||
$postData['data']['keyword3']['value'] = $info['name']; | ||
$postData['data']['keyword4']['value'] = $info['phone']; | ||
$content = $info['name'].'同意了您的拼车请求,请及时与车主('.$info['phone'].')取得联系'; | ||
}else{ | ||
$postData['template_id'] = 'ZuLTdhAVhXd7MTV0-TUyQjLSoF5taZVYM0IHalqZmJ4'; | ||
$postData['data']['keyword1']['value'] = $info['departure'].' -> '.$info['destination']; | ||
$postData['data']['keyword2']['value'] = date('Y-m-d H:i',$info['time']); | ||
$postData['data']['keyword3']['value'] = '拼车人数已满'; | ||
$postData['data']['keyword4']['value'] = '建议选择其他时间拼车'; | ||
$content = $info['name'].'拒绝了您的拼车请求,原因是拼车人数已满,建议选择其他时间拼车'; | ||
} | ||
sendMessage($postData); | ||
msg('notice',$info['aid'],'10000',$content,$postData['page']); | ||
|
||
$result['status'] = 1; | ||
$result['msg'] = '操作成功'; | ||
}else{ | ||
$result['status'] = 0; | ||
$result['msg'] = '操作失败'; | ||
} | ||
} | ||
|
||
exit(json_encode($result)); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?php | ||
namespace Api\Controller; | ||
use Think\Controller; | ||
class CommentController extends Controller { | ||
|
||
public function get() //获取评论 | ||
{ | ||
$C = D('Comment'); | ||
$where['iid'] = I('id'); | ||
$where['type'] = I('type'); | ||
|
||
$page = I('page','1'); | ||
$page_count = 20; | ||
$limit = ($page-1)*$page_count; | ||
$data = $C->getComment($where,$limit,$page_count); | ||
$result['status'] = 1; | ||
$result['msg'] = '评论加载成功'; | ||
$result['data'] = $data; | ||
exit(json_encode($result)); | ||
} | ||
|
||
public function get_count(){ | ||
$C = D('Comment'); | ||
$where['iid'] = I('id'); | ||
$where['type'] = I('type'); | ||
$data = $C->where($where)->count(); | ||
$result['status'] = 1; | ||
$result['msg'] = '评论总数加载成功'; | ||
$result['data'] = $data; | ||
exit(json_encode($result)); | ||
} | ||
|
||
|
||
public function add() //添加评论 | ||
{ | ||
$u = D('User'); | ||
$user = $u->getUserInfo(vaild_sk(I('sk'))); | ||
$data['uid'] = $user['id']; | ||
$data['iid'] = I('iid'); | ||
$data['type'] = I('type','info'); | ||
$data['content'] = I('content',''); | ||
$data['reply'] = I('reply',''); | ||
$data['img'] = htmlspecialchars_decode(I('img','')); | ||
$C = D('Comment'); | ||
if($id = $C->addComment($data)){ | ||
$result['status'] = 1; | ||
$result['msg'] = '评论成功'; | ||
$result['id'] = $id; | ||
|
||
$i = D('Info'); | ||
$info = $i->getInfo(I('iid')); | ||
if($info['uid'] != $user['id']){ | ||
msg('comment',$info['uid'],$user['id'],'回复了您的信息 :'.$data['content'],'/pages/'.$data['type'].'/index?id='.$data['iid']); | ||
} | ||
}else{ | ||
$result['status'] = 0; | ||
$result['msg'] = '评论失败'; | ||
} | ||
exit(json_encode($result)); | ||
} | ||
|
||
|
||
public function zan() | ||
{ | ||
$u = D('User'); | ||
$user = $u->getUserInfo(vaild_sk(I('sk'))); | ||
$data['uid'] = $user['id']; | ||
$data['cid'] = I('cid'); | ||
$zanObj = M('zan'); | ||
$zanData = $zanObj->where($data)->find(); | ||
if(empty($zanData)){ | ||
$data['time'] = time(); | ||
$zanObj->add($data); //写入赞的数据表 | ||
$C = D('Comment'); | ||
$com['id'] = $data['cid']; | ||
$C->where($com)->setInc('zan'); //评论赞+1 | ||
$data = $C->where($com)->find(); | ||
if($data['uid'] != $user['id']){ | ||
msg('zan',$data['uid'],$user['id'],'赞了你的评论:'.$data['content'],'/pages/info/index?id='.$data['iid']); | ||
} | ||
$result['status'] = 1; | ||
$result['msg'] = '点赞成功'; | ||
$result['zan'] = $data['zan']; | ||
}else{ | ||
$result['status'] = 0; | ||
$result['msg'] = '你已经赞过了'; | ||
} | ||
|
||
exit(json_encode($result)); | ||
} | ||
|
||
public function test() | ||
{ | ||
textEncode('H。'); | ||
} | ||
} | ||
?> |
Oops, something went wrong.