...
|
...
|
@@ -3,6 +3,7 @@ |
|
|
namespace app\api\controller;
|
|
|
|
|
|
use app\common\controller\Api;
|
|
|
use function fast\e;
|
|
|
use think\Db;
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -105,6 +106,171 @@ class User extends Api |
|
|
|
|
|
/**
|
|
|
* 用户接口
|
|
|
* @ApiTitle (用户接口-开屏页Code)
|
|
|
* @ApiSummary (开屏页Code)
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiRoute (/api/User/OpenCode)
|
|
|
* @ApiParams (name="code", type="integer", required=true, description="Code")
|
|
|
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
|
|
|
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
|
|
|
* @ApiReturn ({
|
|
|
'code':'1',
|
|
|
'msg':'返回成功',
|
|
|
"data": {
|
|
|
"avatar": "https://thirdwx.qlogo.cn/mmopen/vi_32/0wpUDw5m0LRvdDueia3uMWmrYb53GXRaTnYwMWC18kRmX6P6PIaPDgQqarEIfwroicx1z51D6bjQicOV0PibBx2PqQ/132",
|
|
|
"nickname": "Gody",
|
|
|
"token": "3dda6e452f4778fcc72e21178494bbc1",
|
|
|
"mobile": null,
|
|
|
"is_user":1=已注册,0=未注册,
|
|
|
"vip":会员状态:1=会员,0=非会员,
|
|
|
"exptime":会员到期时间,
|
|
|
"type":身份:1=用户,2=找车工,3=洗车工
|
|
|
}
|
|
|
})
|
|
|
*/
|
|
|
public function OpenCode()
|
|
|
{
|
|
|
// 授权登录
|
|
|
$ch = curl_init();
|
|
|
$appid = "wx243943911c16fbfc";
|
|
|
$secret = "297d8f02691bd23a6fb3828a200d5f7e";
|
|
|
$code = input('code');
|
|
|
$url = "https://api.weixin.qq.com/sns/jscode2session?appid=$appid&secret=$secret&js_code=$code&grant_type=authorization_code";
|
|
|
curl_setopt($ch, CURLOPT_URL, $url);
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
|
curl_setopt($ch, CURLOPT_HEADER, 0);
|
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
|
|
$output = curl_exec($ch);
|
|
|
if ($output === FALSE) {
|
|
|
echo "CURL Error:" . curl_error($ch);
|
|
|
}
|
|
|
curl_close($ch);
|
|
|
$curl_result = json_decode($output, true);
|
|
|
$openid = $curl_result['openid'];
|
|
|
$is_open = Db::name('user')->where(['openid' => $openid])->find();
|
|
|
if ($is_open['is_black'] == 1) {
|
|
|
$this->error('您已被拉黑', 0);
|
|
|
die;
|
|
|
}
|
|
|
if (empty($is_open)) {
|
|
|
$type = 0;
|
|
|
$return = [
|
|
|
'is_user' => $type,
|
|
|
'nickname' => '',
|
|
|
'avatar' => '',
|
|
|
'mobile' => '',
|
|
|
'vip' => '',
|
|
|
'exptime' => '',
|
|
|
'type' => '',
|
|
|
'token' => ''
|
|
|
];
|
|
|
} else {
|
|
|
$type = 1;
|
|
|
$token = $this->request->token();
|
|
|
$res = Db::name("user")->where(['openid' => $openid])->update(['token' => $token,]);
|
|
|
if (!$res) {
|
|
|
$this->error('令牌更新失败', 0);
|
|
|
die;
|
|
|
}
|
|
|
$return = [
|
|
|
'is_user' => $type,
|
|
|
'nickname' => $is_open['nickname'],
|
|
|
'avatar' => $is_open['avatar'],
|
|
|
'mobile' => $is_open['mobile'],
|
|
|
'vip' => $is_open['vip'],
|
|
|
'exptime' => $is_open['exptime'],
|
|
|
'type' => $is_open['type'],
|
|
|
'token' => $token
|
|
|
];
|
|
|
}
|
|
|
$this->success('成功', $return);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 用户接口
|
|
|
* @ApiTitle (用户接口-绑定手机)
|
|
|
* @ApiSummary (绑定手机)
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiRoute (/api/User/CheckMobile)
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
* @ApiParams (name="type", type="integer", required=true, description="1=手机号授权,2=验证码授权")
|
|
|
* @ApiParams (name="mobile", type="integer", required=true, description="手机号")
|
|
|
* @ApiParams (name="code", type="integer", required=true, description="验证码")
|
|
|
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
|
|
|
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
|
|
|
* @ApiReturn ({
|
|
|
'code':'1',
|
|
|
'msg':'返回成功',
|
|
|
"data": {
|
|
|
}
|
|
|
})
|
|
|
*/
|
|
|
public function CheckMobile()
|
|
|
{
|
|
|
$user_id = $this->is_token($this->request->header());
|
|
|
$param = $this->request->param();
|
|
|
if ($param['type'] == 2) {
|
|
|
$this->CheckCode($param['mobile'], $param['code']);
|
|
|
}
|
|
|
$res = Db::name('user')->where('id', $user_id)->update(['mobile' => $param['mobile']]);
|
|
|
$this->res($res);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 用户接口
|
|
|
* @ApiTitle (用户接口-完善信息)
|
|
|
* @ApiSummary (完善信息)
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiRoute (/api/User/AddUserCon)
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
* @ApiParams (name="mobile", type="integer", required=true, description="手机号")
|
|
|
* @ApiParams (name="code", type="integer", required=true, description="code")
|
|
|
* @ApiParams (name="car_num", type="integer", required=true, description="车牌号")
|
|
|
* @ApiParams (name="car_type", type="integer", required=true, description="车型")
|
|
|
* @ApiParams (name="color", type="integer", required=true, description="车辆颜色")
|
|
|
* @ApiParams (name="address", type="integer", required=true, description="我的地址")
|
|
|
* @ApiParams (name="address_con", type="integer", required=true, description="详细地址")
|
|
|
* @ApiParams (name="lng", type="integer", required=true, description="经度")
|
|
|
* @ApiParams (name="lat", type="integer", required=true, description="纬度")
|
|
|
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
|
|
|
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
|
|
|
* @ApiReturn ({
|
|
|
'code':'1',
|
|
|
'msg':'返回成功',
|
|
|
"data": {
|
|
|
}
|
|
|
})
|
|
|
*/
|
|
|
public function AddUserCon()
|
|
|
{
|
|
|
$param = $this->request->param();
|
|
|
$user_id = $this->is_token($this->request->header());
|
|
|
$mobile = Db::name('user')->where('id', $user_id)->value('mobile');
|
|
|
$this->CheckCode($mobile, $param['code']);
|
|
|
$data = [
|
|
|
'mobile' => $param['mobile'],
|
|
|
'car_num' => $param['car_num'],
|
|
|
'car_type' => $param['car_type'],
|
|
|
'color' => $param['color'],
|
|
|
'address' => $param['address'],
|
|
|
'address_con' => $param['address_con'],
|
|
|
'lng' => $param['lng'],
|
|
|
'lat' => $param['lat'],
|
|
|
];
|
|
|
$res = Db::name('user')->where('id', $user_id)->update($data);
|
|
|
if (!$res) {
|
|
|
$this->error('请填写完整信息', 0);
|
|
|
die;
|
|
|
}
|
|
|
$this->success('成功', 1);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 用户接口
|
|
|
* @ApiTitle (用户接口-用户协议)
|
|
|
* @ApiSummary (用户协议)
|
|
|
* @ApiMethod (POST)
|
...
|
...
|
@@ -430,4 +596,91 @@ class User extends Api |
|
|
}
|
|
|
$this->success('成功', $list);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 用户接口
|
|
|
* @ApiTitle (用户接口-员工订单详情)
|
|
|
* @ApiSummary (员工订单详情)
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiRoute (/api/User/OrderContent)
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
* @ApiParams (name="id", type="int", required=true, description="ID")
|
|
|
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
|
|
|
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
|
|
|
* @ApiReturn ({
|
|
|
'code':'1',
|
|
|
'msg':'返回成功',
|
|
|
"data": {
|
|
|
"id": 1,
|
|
|
"title": "洗车季卡",
|
|
|
"time": 1599209757,
|
|
|
"mobile": "13292442918",
|
|
|
"address": "河北省唐山市路南区",
|
|
|
"address_con": "万达广场第五棵大杨树旁",
|
|
|
"userlng": "116.39050",
|
|
|
"userlat": "39.89223",
|
|
|
"car_num": "冀B123456",
|
|
|
"car_type": "AE86",
|
|
|
"color": "五颜六色的白",
|
|
|
"zhao_type": 0,
|
|
|
"zhao_images": [],
|
|
|
"car_address": "",
|
|
|
"lat": "",
|
|
|
"lng": "",
|
|
|
"order_sn": "202009031647068127236526",
|
|
|
"xi_type": 0,
|
|
|
"xi_images": [],
|
|
|
"createtime": "2020-09-04 16:55:57",
|
|
|
"times": "2020-09-04 16:55:57",
|
|
|
"user_level": 1
|
|
|
}
|
|
|
})
|
|
|
*/
|
|
|
public function OrderContent()
|
|
|
{
|
|
|
$user_id = $this->is_token($this->request->header());
|
|
|
$id = input('id');
|
|
|
$list = Db::name('renwu')->where('a.id', $id)
|
|
|
->alias('a')
|
|
|
->join('vip v', 'v.id=a.vip_id')
|
|
|
->join('user u', 'u.id=a.user_id')
|
|
|
->field('a.id,v.title,a.createtime as time,u.mobile,u.address,u.address_con,u.lng as userlng,u.lat as userlat,u.car_num,u.car_type,u.color,a.zhao_type,a.zhao_images,a.car_address,a.lat,a.lng,a.order_sn,a.xi_type,a.xi_images')
|
|
|
->find();
|
|
|
if (empty($list)) {
|
|
|
$this->error('参数错误', 0);
|
|
|
die;
|
|
|
}
|
|
|
if (empty($list['zhao_images'])) {
|
|
|
$zhao_images = [];
|
|
|
} else {
|
|
|
if (strstr($list['zhao_images'], ',')) {
|
|
|
$zhao_images = explode(',', $list['zhao_images']);
|
|
|
} else {
|
|
|
$zhao_images = explode(' ', $list['zhao_images']);
|
|
|
}
|
|
|
foreach ($zhao_images as $k => $v) {
|
|
|
$zhao_images[$k] = cdnurl($v);
|
|
|
}
|
|
|
}
|
|
|
if (empty($list['xi_images'])) {
|
|
|
$xi_images = [];
|
|
|
} else {
|
|
|
if (strstr($list['xi_images'], ',')) {
|
|
|
$xi_images = explode(',', $list['xi_images']);
|
|
|
} else {
|
|
|
$xi_images = explode(' ', $list['xi_images']);
|
|
|
}
|
|
|
foreach ($xi_images as $k => $v) {
|
|
|
$xi_images[$k] = cdnurl($v);
|
|
|
}
|
|
|
}
|
|
|
$list['createtime'] = date('Y-m-d H:i:s', $list['time']);
|
|
|
$list['times'] = date('Y-m-d H:i:s', $list['time']);
|
|
|
$list['zhao_images'] = $zhao_images;
|
|
|
$list['xi_images'] = $xi_images;
|
|
|
$user_type = Db::name('user')->where('id', $user_id)->value('type');
|
|
|
$list['user_level'] = $user_type;
|
|
|
$this->success('成功', $list);
|
|
|
}
|
|
|
} |
...
|
...
|
|