|
@@ -12,141 +12,110 @@ class Index extends Api
|
|
|
protected $noNeedLogin = ['index'];
|
|
|
protected $noNeedRight = ['*'];
|
|
|
|
|
|
+
|
|
|
+
|
|
|
public function index(){
|
|
|
echo 'apisuccess';
|
|
|
exit;
|
|
|
}
|
|
|
|
|
|
+ //附近
|
|
|
+ //是vip,且开启了隐身的,不能在内
|
|
|
public function fujin(){
|
|
|
- //是vip,且开启了隐身的,不能在内
|
|
|
+ $cityname = input('cityname',$this->auth->cityname);
|
|
|
+
|
|
|
+ $where = [
|
|
|
+ 'user.id' => ['neq',$this->auth->id],
|
|
|
+ 'user.status' => 1,
|
|
|
+ 'user.photo_images' => ['neq',''],
|
|
|
+ 'user.cityname' => $cityname,
|
|
|
+ 'power.yinshen' => 0,
|
|
|
+ ];
|
|
|
+ //性别
|
|
|
+ $gender = input('gender','all');
|
|
|
+ if($gender != 'all'){
|
|
|
+ $where['user.gender'] = $gender;
|
|
|
+ }
|
|
|
+ //属性
|
|
|
+ $attribute = input('attribute','all');
|
|
|
+ if($attribute != 'all' && $attribute != 'BOTH'){
|
|
|
+ $where['user.attribute'] = $attribute;
|
|
|
+ }
|
|
|
+ //排除黑名单的
|
|
|
+ $black_ids = Db::name('user_black')->where(['uid'=>$this->auth->id])->column('black_uid');
|
|
|
+ if(!empty($black_ids)){
|
|
|
+ $where['user.id'] = ['NOTIN',$black_ids];
|
|
|
+ }
|
|
|
+ //年龄
|
|
|
+ $agemin = input('agemin',18);
|
|
|
+ if($agemin > 18){
|
|
|
+ $where['user.birthday'] = ['lt',time()-$agemin*31536000];
|
|
|
+ }
|
|
|
+ $agemax = input('agemax',100);
|
|
|
+ if($agemax < 100){
|
|
|
+ $where['user.birthday'] = ['gt',time()-$agemax*31536000];
|
|
|
+ }
|
|
|
+ if($agemin > 18 && $agemax < 100){
|
|
|
+ $where['user.birthday'] = ['between',[time()-$agemax*31536000,time()-$agemin*31536000]];
|
|
|
+ }
|
|
|
+ //距离
|
|
|
+ $distancemin = input('distancemin',0);
|
|
|
+ if($distancemin > 0){
|
|
|
+ $where['distance'] = ['gt',$distancemin];
|
|
|
+ }
|
|
|
+ $distancemax = input('distancemax',0);
|
|
|
+ if($distancemax > 0){
|
|
|
+ $where['distance'] = ['lt',$distancemax];
|
|
|
+ }
|
|
|
+ if($distancemin > 0 && $distancemax > 0){
|
|
|
+ $where['distance'] = ['between',[$distancemin,$distancemax]];
|
|
|
+ }
|
|
|
+
|
|
|
+ $field = [
|
|
|
+ 'user.id',
|
|
|
+ 'user.username',
|
|
|
+ 'user.nickname',
|
|
|
+ 'user.avatar',
|
|
|
+ 'user.photo_images',
|
|
|
+ 'user.gender',
|
|
|
+ 'user.birthday',
|
|
|
+ 'user.cityname',
|
|
|
+ 'user.attribute',
|
|
|
+ 'user.is_active',
|
|
|
+ 'user.longitude',
|
|
|
+ 'user.latitude',
|
|
|
+ 'user.cityname',
|
|
|
+ 'user.attribute',
|
|
|
+
|
|
|
+ 'wallet.vip_endtime',
|
|
|
+ '(st_distance(point (' . $this->auth->longitude . ', ' . $this->auth->latitude . '),point(user.longitude,user.latitude))*111195) as distance',
|
|
|
+ ];
|
|
|
+ $list = Db::name('user')->alias('user')->field($field)
|
|
|
+ ->join('user_wallet wallet','user.id = wallet.user_id','LEFT')
|
|
|
+ ->join('user_power power' ,'user.id = power.user_id','LEFT')
|
|
|
+ ->where($where)
|
|
|
+ ->order('distance asc')
|
|
|
+ ->autopage()
|
|
|
+ ->select();
|
|
|
+ $list = list_domain_image($list,['avatar','photo_images']);
|
|
|
+ foreach($list as $key => &$val){
|
|
|
+ $val['age'] = birthtime_to_age($val['birthday']);
|
|
|
+ $val['photo_images'] = explode(',',$val['photo_images'])[0];
|
|
|
+ $val['is_vip'] = $val['vip_endtime'] > time() ? 1 : 0;
|
|
|
+
|
|
|
+ $val['distance'] = bcdiv(intval($val['distance']),1000,2).'km';
|
|
|
+ }
|
|
|
|
|
|
+ $this->success(1,$list);
|
|
|
}
|
|
|
- public function tuijian(){}
|
|
|
|
|
|
+ public function tuijian(){}
|
|
|
|
|
|
- /**
|
|
|
- * 获取邀请图片
|
|
|
- */
|
|
|
- public function getInviteImg() {
|
|
|
- $plat = $this->request->request("plat",1); //平台:1=小程序,2=app
|
|
|
- if(!in_array($plat,[1,2])) $this->error("参数错误");
|
|
|
- // 获取用户的邀请码
|
|
|
- $invitecode = \app\common\model\User::where(["id"=>$this->auth->id])->value("invite_no");
|
|
|
-
|
|
|
- // 文字图片合成
|
|
|
- $bigImgPath = $this->httpurlLocal('/assets/img/inviteimg.jpeg');
|
|
|
- $img = imagecreatefromstring(file_get_contents($bigImgPath));
|
|
|
- //字体文件
|
|
|
- $font = realpath('./assets/fonts/lato/lato-black.ttf');
|
|
|
-
|
|
|
- //字体颜色(RGB)
|
|
|
- $black = imagecolorallocate($img, 217, 76, 41);
|
|
|
- //字体大小
|
|
|
- $fontSize = 30;
|
|
|
- //旋转角度
|
|
|
- $circleSize = 0;
|
|
|
- //左边距
|
|
|
- $left = 275;
|
|
|
- //上边距
|
|
|
- $top = 540;
|
|
|
- imagefttext($img, $fontSize, $circleSize, $left, $top, $black, $font, $invitecode);
|
|
|
- $filename = date("YmdH").".jpeg";
|
|
|
- $path = "/uploads/qrcode/".$filename;
|
|
|
- $file = $_SERVER['DOCUMENT_ROOT'] . $path;//打开文件准备写入
|
|
|
- list($bgWidth, $bgHight, $bgType) = getimagesize($bigImgPath);
|
|
|
- switch ($bgType) {
|
|
|
- case 1://gif
|
|
|
- header('Content-Type:image/gif');
|
|
|
- imagegif($img,$file);
|
|
|
- break;
|
|
|
- case 2://jpg
|
|
|
- header('Content-Type:image/jpg');
|
|
|
- imagejpeg($img,$file);
|
|
|
- break;
|
|
|
- case 3://jpg
|
|
|
- header('Content-Type:image/png');
|
|
|
- imagepng($img,$file);
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
- //销毁照片
|
|
|
- imagedestroy($img);
|
|
|
-
|
|
|
- // 图片和二维码合成
|
|
|
- $qrcode = $plat == 1 ? config("site.miniqrcode"):config("site.qrcode");
|
|
|
-
|
|
|
-
|
|
|
- $background = $file;
|
|
|
- $target = $this->httpurl($qrcode);
|
|
|
-
|
|
|
- $background_iamge = imagecreatefromstring(file_get_contents($background));
|
|
|
- $target_image = imagecreatefromstring(file_get_contents($target));
|
|
|
- list($target_width, $target_height, $target_type) = getimagesize($target);
|
|
|
- imagecopymerge($background_iamge , $target_image , 250, 700, 0, 0, $target_width, $target_height, 100);
|
|
|
- list($background_width, $background_height, $background_type) = getimagesize($background);
|
|
|
- switch ($background_type) {
|
|
|
- case 1://gif
|
|
|
- header('Content-Type:image/gif');
|
|
|
- imagegif($background_iamge,$file);
|
|
|
- break;
|
|
|
- case 2://jpg
|
|
|
- header('Content-Type:image/jpg');
|
|
|
- imagejpeg($background_iamge,$file);
|
|
|
- break;
|
|
|
- case 3://jpg
|
|
|
- header('Content-Type:image/png');
|
|
|
- imagepng($background_iamge,$file);
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
- $savepath = $this->httpurlLocal($path);
|
|
|
|
|
|
- $this->success("获取成功!",$savepath);
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * 评论时间转换
|
|
|
- * @param null $time
|
|
|
- * @return false|string
|
|
|
- */
|
|
|
- private function get_last_time($time = NULL) {
|
|
|
- $text = '';
|
|
|
- $time = $time === NULL || $time > time() ? time() : intval($time);
|
|
|
- $t = time() - $time; //时间差 (秒)
|
|
|
- $y = date('Y', $time)-date('Y', time());//是否跨年
|
|
|
- switch($t){
|
|
|
- case $t == 0:
|
|
|
- $text = '刚刚';
|
|
|
- break;
|
|
|
- case $t < 60:
|
|
|
- $text = $t . '秒前'; // 一分钟内
|
|
|
- break;
|
|
|
- case $t < 60 * 60:
|
|
|
- $text = floor($t / 60) . '分钟前'; //一小时内
|
|
|
- break;
|
|
|
- case $t < 60 * 60 * 24:
|
|
|
- $text = floor($t / (60 * 60)) . '小时前'; // 一天内
|
|
|
- break;
|
|
|
- case $t < 60 * 60 * 24 * 3:
|
|
|
- $text = floor($time/(60*60*24)) ==1 ?'昨天 ' . date('H:i', $time) : '前天 ' . date('H:i', $time) ; //昨天和前天
|
|
|
- break;
|
|
|
- case $t < 60 * 60 * 24 * 30:
|
|
|
- $text = date('m月d日 H:i', $time); //一个月内
|
|
|
- break;
|
|
|
- case $t < 60 * 60 * 24 * 365&&$y==0:
|
|
|
- $text = date('m月d日', $time); //一年内
|
|
|
- break;
|
|
|
- default:
|
|
|
- $text = date('Y年m月d日', $time); //一年以前
|
|
|
- break;
|
|
|
- }
|
|
|
|
|
|
- return $text;
|
|
|
- }
|
|
|
|
|
|
}
|