From 5082d6814044db2fe35d1b8df471118f4357bb33 Mon Sep 17 00:00:00 2001 From: ljl Date: Fri, 22 Dec 2023 13:25:04 +0800 Subject: [PATCH] yh --- app/Controller/Payment/AccountController.php | 14 ++++++ config/routes.php | 1 + public/account.html | 46 ++++++++++++++++++++ public/login.html | 4 ++ 4 files changed, 65 insertions(+) diff --git a/app/Controller/Payment/AccountController.php b/app/Controller/Payment/AccountController.php index 8b545d5..a260cc2 100644 --- a/app/Controller/Payment/AccountController.php +++ b/app/Controller/Payment/AccountController.php @@ -93,6 +93,20 @@ class AccountController extends AbstractController return $this->success(['token' => $token]); } + public function updatePassword(RequestInterface $request) + { + $userInfo = $this->checkUser($request); + $oldPassword = $request->input('oldPassword'); + $password = $request->input('password'); + $account = Account::where('id', $userInfo['userId'])->first(); + if (md5($oldPassword . $account->salt) != $account->password) { + throw new BusinessException('旧密码错误'); + } + $account->password = md5($password . $account->salt); + $account->save(); + return $this->success(); + } + public function openAccount(RequestInterface $request) { $userInfo = $this->checkUser($request); diff --git a/config/routes.php b/config/routes.php index ea3b739..98b530d 100644 --- a/config/routes.php +++ b/config/routes.php @@ -48,6 +48,7 @@ Router::addGroup('/account',function () { Router::post('/transfer-pay', [AccountController::class, 'transferPay']); Router::post('/user-info', [AccountController::class, 'getUserInfo']); Router::get('/company-register', [AccountController::class, 'companyRegister']); + Router::post('/update-password', [AccountController::class, 'updatePassword']); }, []); Router::addGroup('/notify',function () { diff --git a/public/account.html b/public/account.html index 7d6a7d8..4409b34 100644 --- a/public/account.html +++ b/public/account.html @@ -16,6 +16,7 @@ {{username}} 退出登录 + 修改 @@ -77,6 +78,25 @@ 确 定 + +
+ + + + + + + + + + + +
+ +
@@ -90,6 +110,7 @@ data() { return { activeName: 'user', + updatePasswordVisible: false, username: '', payForm: { amount: 0 @@ -104,6 +125,11 @@ apply_no: '', is_platform_account: '' }, + updatePasswordForm: { + oldPassword: '', + password: '', + confirm_password: '' + }, bankCard: { id: 0, bank_name: '', @@ -166,6 +192,26 @@ }); console.log('submit!'); }, + updatePassword() { + if (this.registerForm.confirm_password != this.registerForm.password) { + this.$message.error('密码和确认密码不一致'); + return; + } + axios.post('/account/update-password', {token: window.sessionStorage.getItem('token'), oldPassword: this.updatePasswordForm.oldPassword, password: this.updatePasswordForm.password}) + .then( (response) => { + console.log(response); + let result = response.data + if (result.code != 1000) { + return this.$message.error(response.data.message); + } + this.$message.success('修改成功'); + }) + .catch((error) => { + this.$message.error('请求错误'); + console.log(error); + }); + console.log('submit!'); + }, resetPayPassword() { axios.post('/account/reset-pay-password', {token: window.sessionStorage.getItem('token')}) .then( (response) => { diff --git a/public/login.html b/public/login.html index 209549f..bf3ff3f 100644 --- a/public/login.html +++ b/public/login.html @@ -79,6 +79,10 @@ }, methods: { register() { + if (this.registerForm.confirm_password != this.registerForm.password) { + this.$message.error('密码和确认密码不一致'); + return; + } axios.post('/account/register', this.registerForm) .then( (response) => { console.log(response);