154 lines
5.8 KiB
PHP
154 lines
5.8 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace app\app\controller;
|
||
|
|
|
||
|
|
use think\Controller;
|
||
|
|
use think\Db;
|
||
|
|
use app\app\controller\Login;
|
||
|
|
|
||
|
|
class Myinformation extends Base{
|
||
|
|
|
||
|
|
|
||
|
|
// 加 bcadd(,,20)
|
||
|
|
// 减 bcsub(,,20)
|
||
|
|
// 乘 bcmul(,,20)
|
||
|
|
// 除 bcdiv(,,20)
|
||
|
|
################################################################接口################################################################
|
||
|
|
################################################################接口################################################################
|
||
|
|
################################################################接口################################################################
|
||
|
|
|
||
|
|
// 获取账号下信息
|
||
|
|
public function get_my_account_msg($data = ['token'=>'0dafb98a10995c98b5a33b7d59d986ca']){
|
||
|
|
if(count(input('post.')) > 0){
|
||
|
|
$data = input('post.');
|
||
|
|
}
|
||
|
|
if(!array_key_exists('token', $data)){
|
||
|
|
return $this->msg(10001);
|
||
|
|
}
|
||
|
|
if($this->token_time_validate($data['token']) === false){
|
||
|
|
return $this->msg(20001);
|
||
|
|
}
|
||
|
|
// unset($data['token']);
|
||
|
|
|
||
|
|
return $this->get_my_account_msg_action($data);
|
||
|
|
}
|
||
|
|
// 修改昵称
|
||
|
|
public function update_my_nickname($data = ['token'=>'0dafb98a10995c98b5a33b7d59d986ca','nickname'=>'']){
|
||
|
|
if(count(input('post.')) > 0){
|
||
|
|
$data = input('post.');
|
||
|
|
}
|
||
|
|
if(!array_key_exists('nickname', $data) || !array_key_exists('token', $data)){
|
||
|
|
return $this->msg(10001);
|
||
|
|
}
|
||
|
|
if($this->token_time_validate($data['token']) === false){
|
||
|
|
return $this->msg(20001);
|
||
|
|
}
|
||
|
|
// unset($data['token']);
|
||
|
|
|
||
|
|
return $this->update_my_nickname_action($data);
|
||
|
|
}
|
||
|
|
// 邮箱/手机绑定
|
||
|
|
public function update_my_account_msg($data = ['token'=>'0dafb98a10995c98b5a33b7d59d986ca','data'=>'tsf3920322@126.com','code'=>'123456']){
|
||
|
|
if(count(input('post.')) > 0){
|
||
|
|
$data = input('post.');
|
||
|
|
}
|
||
|
|
if(!array_key_exists('data', $data) || !array_key_exists('token', $data) || !array_key_exists('code', $data)){
|
||
|
|
return $this->msg(10001);
|
||
|
|
}
|
||
|
|
if($this->token_time_validate($data['token']) === false){
|
||
|
|
return $this->msg(20001);
|
||
|
|
}
|
||
|
|
// unset($data['token']);
|
||
|
|
|
||
|
|
return $this->update_my_account_msg_action($data);
|
||
|
|
}
|
||
|
|
|
||
|
|
// 修改密码
|
||
|
|
public function update_my_password($data = ['token'=>'0dafb98a10995c98b5a33b7d59d986ca','password'=>'ceshi1','c_password'=>'ceshi1']){
|
||
|
|
if(count(input('post.')) > 0){
|
||
|
|
$data = input('post.');
|
||
|
|
}
|
||
|
|
if(!array_key_exists('password', $data) || !array_key_exists('c_password', $data) || !array_key_exists('token', $data)){
|
||
|
|
return $this->msg(10001);
|
||
|
|
}
|
||
|
|
if($this->token_time_validate($data['token']) === false){
|
||
|
|
return $this->msg(20001);
|
||
|
|
}
|
||
|
|
// unset($data['token']);
|
||
|
|
return $this->update_my_password_action($data);
|
||
|
|
}
|
||
|
|
|
||
|
|
################################################################业务################################################################
|
||
|
|
################################################################get_my_account_msg
|
||
|
|
public function get_my_account_msg_action($data){
|
||
|
|
$result = Db::table('app_account_number')->where(['token'=>$data['token'],'is_del'=>0])->find();
|
||
|
|
if($result){
|
||
|
|
return $this->msg([
|
||
|
|
'my_tel'=>$result['tel'],
|
||
|
|
'my_email'=>$result['email'],
|
||
|
|
'create_time'=>$result['create_time'],
|
||
|
|
'token'=>$result['token'],
|
||
|
|
'nickname'=>$result['nickname'],
|
||
|
|
'head_pic'=>$result['head_pic'],
|
||
|
|
'last_update_time'=>$result['update_time'],
|
||
|
|
]);
|
||
|
|
}else{
|
||
|
|
return $this->msg(10002);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
################################################################update_my_nickname
|
||
|
|
public function update_my_nickname_action($data){
|
||
|
|
$result = Db::table('app_account_number')->where(['token'=>$data['token'],'is_del'=>0])->update([
|
||
|
|
'nickname'=>$data['nickname'],
|
||
|
|
'update_time'=>date('Y-m-d H:i:s')
|
||
|
|
]);
|
||
|
|
if($result){
|
||
|
|
return $this->msg([]);
|
||
|
|
}else{
|
||
|
|
return $this->msg(10002);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
################################################################update_my_account_msg
|
||
|
|
public function update_my_account_msg_action($data){
|
||
|
|
$login_action = new Login();
|
||
|
|
$validate_result = $login_action->check_code($data['data'],$data['code']);
|
||
|
|
if($validate_result !== true){
|
||
|
|
return $this->msg(10001,$validate_result);
|
||
|
|
}
|
||
|
|
$montage_data = $this->is_tel_email($data['data']);
|
||
|
|
if($montage_data == false){
|
||
|
|
return $this->msg(10005);
|
||
|
|
}
|
||
|
|
// dump($data);
|
||
|
|
// die;
|
||
|
|
$result = Db::table('app_account_number')->where(['token'=>$data['token'],'is_del'=>0])->update([
|
||
|
|
$montage_data=>$data['data'],
|
||
|
|
'update_time'=>date('Y-m-d H:i:s')
|
||
|
|
]);
|
||
|
|
if($result){
|
||
|
|
return $this->msg([]);
|
||
|
|
}else{
|
||
|
|
return $this->msg(10002);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
################################################################update_my_password
|
||
|
|
public function update_my_password_action($data){
|
||
|
|
if($data['password'] != $data['c_password']){
|
||
|
|
return $this->msg(10003,'两次密码不一致');
|
||
|
|
}
|
||
|
|
if($data['password'] == ''){
|
||
|
|
return $this->msg(10003,'密码不能为空');
|
||
|
|
}
|
||
|
|
$result = Db::table('app_account_number')->where(['token'=>$data['token'],'is_del'=>0])->update([
|
||
|
|
'password'=>$data['password'],
|
||
|
|
'update_time'=>date('Y-m-d H:i:s')
|
||
|
|
]);
|
||
|
|
if($result){
|
||
|
|
return $this->msg([]);
|
||
|
|
}else{
|
||
|
|
return $this->msg(10002);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
}
|