...
|
...
|
@@ -7,6 +7,7 @@ use app\common\library\Sms; |
|
|
use app\common\model\User as UserModel;
|
|
|
use app\common\model\UserAddress;
|
|
|
use app\common\model\UserSize;
|
|
|
use app\common\model\Area;
|
|
|
use app\common\controller\Wechat;
|
|
|
use think\Validate;
|
|
|
|
...
|
...
|
@@ -97,11 +98,29 @@ class User extends Api |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 我的-成为会员(会员介绍)
|
|
|
* @ApiMethod (GET)
|
|
|
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
|
|
|
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
|
|
|
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
|
|
|
* @ApiReturn ({
|
|
|
'code':'1',
|
|
|
'msg':'返回成功'
|
|
|
})
|
|
|
*/
|
|
|
public function memberIntro()
|
|
|
{
|
|
|
$member_intro = str_replace('src="/uploads/', 'src="'.config('upload.cdnurl').'/uploads/', config('site.member_intro'));
|
|
|
$this->success(__('成功'),compact('member_intro'));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 我的-成为会员(绑定手机号)
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
* @ApiParams (name="mobile", type="string", required=true, description="手机号")
|
|
|
* @ApiParams (name="captcha", type="string", required=true, description="验证码")
|
|
|
* @ApiParams (name="area", type="string", required=true, description="所在地区", sample="广东省,广州市,海珠区")
|
|
|
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
|
|
|
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
|
|
|
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
|
...
|
...
|
@@ -114,21 +133,28 @@ class User extends Api |
|
|
{
|
|
|
$mobile = $this->request->request('mobile');
|
|
|
$captcha = $this->request->request('captcha');
|
|
|
if (!$mobile || !$captcha) {
|
|
|
$area = $this->request->request('area');
|
|
|
if (!empty($this->user['mobile'])) {
|
|
|
$this->error(__('您已经成为会员,请勿重复操作'));
|
|
|
}
|
|
|
if (!$mobile || !$captcha || !$area) {
|
|
|
$this->error(__('Invalid parameters'));
|
|
|
}
|
|
|
if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
$this->error(__('Mobile is incorrect'));
|
|
|
}
|
|
|
if (\app\common\model\User::where('mobile', $mobile)->where('id', '<>', $this->user['id'])->find()) {
|
|
|
if (UserModel::where('mobile', $mobile)->where('id', '<>', $this->user['id'])->find()) {
|
|
|
$this->error(__('Mobile already exists'));
|
|
|
}
|
|
|
$result = Sms::check($mobile, $captcha, 'changemobile');
|
|
|
if (!$result) {
|
|
|
$this->error(__('Captcha is incorrect'));
|
|
|
}
|
|
|
$this->user->mobile = $mobile;
|
|
|
$this->user->save();
|
|
|
$area = explode(',', $area);
|
|
|
$province_id = Area::getIdByName($area[0], 1);
|
|
|
$city_id = Area::getIdByName($area[1], 2, $province_id);
|
|
|
$district_id = Area::getIdByName($area[2], 3, $city_id);
|
|
|
$this->user->allowField(true)->save(compact('mobile','province_id', 'city_id', 'district_id'));
|
|
|
|
|
|
Sms::flush($mobile, 'changemobile');
|
|
|
$this->success();
|
...
|
...
|
|