@@ -67,4 +67,28 @@ class User extends Controller
}
+ /**
+ * 设置支付密码
+ * @return array
+ * @throws \app\common\exception\BaseException
+ * @throws \think\exception\DbException
+ */
+ public function setProfile()
+ {
+ try {
+ $userInfo = $this->getUser();
+ if(empty($userInfo)){
+ throw new Exception('用户信息不存在或未注册');
+ }
+ $post = input();
+ if(\app\api\service\User::setProfile($userInfo['user_id'], $post)){
+ return $this->renderSuccess([],$userInfo['status']==1? '设置成功':'设置成功,请耐心等候审核');
+ }else{
+ return $this->renderError('设置失败');
+ }catch (\Exception $exception){
+ return $this->renderError($exception->getMessage()?:'设置失败');
+
@@ -63,6 +63,28 @@ class User
/**
+ * 设置修改资料
+ * @param $userId
+ * @param $post
+ * @return UserModel
+ * @throws Exception
+ public static function setProfile($userId, $post)
+ $nickname = isset($post['nickname'])? trim($post['nickname']) : '';
+ if(empty($password)){
+ throw new Exception('请输入6位数字密码');
+ $mobile = isset($post['mobile'])? trim($post['mobile']) : '';
+ if(empty($mobile) || !isMobile($mobile)){
+ throw new Exception('请输入正确的手机号码');
+ return UserModel::where('user_id', $userId)->update(['nickName'=>$nickname,'mobile'=>$mobile,'update_time'=>time()]);
* 用户升级
* @param $user_id
* @param int $wxapp_id
@@ -212,4 +234,6 @@ class User
return true;
@@ -356,3 +356,14 @@ function makePassword($password)
{
return md5(md5($password.mb_substr($password,1,3,'utf-8')));
+/**
+ * 是否是手机号
+ * @param $mobile
+ * @return string
+function isMobile($mobile)
+{
+ return preg_match("/^((0\d{2,3}-\d{7,8})|(1[2-9]\d{9}))$/", $mobile);
+}