diff --git a/core/routes/index.js b/core/routes/index.js index 5dfbcbb29b8816f71b2fafb185243ee68c02c211..2042f7a23008bcfb16624ee853dd185e815e77d7 100644 --- a/core/routes/index.js +++ b/core/routes/index.js @@ -98,6 +98,35 @@ router.get('/getUserInfo', async (req, res) => { data: user[0], }) }) + +// 验证码校验 +router.post('/checkCode', async (req, res) => { + let checkCode = req.body + + if (checkCode.code) { + let codeObj = CodeArr.find(obj => obj.phone == checkCode.phone && obj.code == checkCode.code) + if (codeObj) { + res.send({ + code: 200, + msg: '验证码正确', + }) + } else { + res.send({ + code: 201, + msg: '验证码错误', + }) + } + } else { + res.send({ + code: 203, + msg: '信息有误 请重新输入', + }) + } + +}) + + +// 登录 router.post('/login', async (req, res) => { let { phone, value, codeOrword } = req.body console.log(phone, value, codeOrword) @@ -345,7 +374,16 @@ router.post('/updateUserAvatar', async (req, res) => { msg: '修改成功', }) }) - +// 根据id修改用户密码 +router.post('/updateUserPassword', async (req, res) => { + let { id, password } = req.body + console.log(id,password) + await UserModel.updateOne({ _id: id }, { password: password }) + res.send({ + code: 200, + msg: '修改成功', + }) +}) //获取img路径 @@ -360,17 +398,33 @@ router.post('/getImg', (req, res) => { }) }) }) - -router.post('/deleteUser', async(req, res) => { +// 注销用户 +router.post('/deleteUser', async (req, res) => { let { id } = req.query console.log(id) // 根据id删除用户 await UserModel.deleteOne({ _id: id }) res.send({ - code:200 + code: 200 }) }) - +// 设置新手机号 +router.post('/updateUserPhone', async (req, res) => { + let data = req.body + // 通过id修改手机号 + let date = await UserModel.updateOne({ _id: data.id }, { phone: data.phone }) + if (date) { + res.send({ + code: 200, + msg: '修改成功', + }) + } else { + res.send({ + code: 500, + msg: '修改失败', + }) + } +}) //合并分片 diff --git a/core/upload/BmxGyhay1aOj4qycLgBTawwg.jpg b/core/upload/BmxGyhay1aOj4qycLgBTawwg.jpg new file mode 100644 index 0000000000000000000000000000000000000000..6b4321c59d0ff1a23dfa2d940c62d766fa07cd44 Binary files /dev/null and b/core/upload/BmxGyhay1aOj4qycLgBTawwg.jpg differ diff --git a/core/upload/GEIDikUn7v24oGM4y_iYYhWW.jpg b/core/upload/GEIDikUn7v24oGM4y_iYYhWW.jpg new file mode 100644 index 0000000000000000000000000000000000000000..db0b3ba9776dcff42db22491ee2d098376bc217d Binary files /dev/null and b/core/upload/GEIDikUn7v24oGM4y_iYYhWW.jpg differ diff --git a/core/upload/VD2cD0JmV43qtWN2i9ySDRc_.jpg b/core/upload/VD2cD0JmV43qtWN2i9ySDRc_.jpg new file mode 100644 index 0000000000000000000000000000000000000000..1a3443bb9ffbbbe6448e2ad3c55eb0c1f45e5f4a Binary files /dev/null and b/core/upload/VD2cD0JmV43qtWN2i9ySDRc_.jpg differ diff --git a/yunyou_pavilion/src/router/index.js b/yunyou_pavilion/src/router/index.js index 0e42bc0444a4d1f8e1d3dcdff02cf44fd7f269f8..c70ea9d516256535697f09012981c7b9df0f7833 100644 --- a/yunyou_pavilion/src/router/index.js +++ b/yunyou_pavilion/src/router/index.js @@ -174,6 +174,15 @@ const router = createRouter({ name: 'setpassword', component: () => import('../views/SetUser/setPasswoed.vue') }, + { + path: '/setphone', + name: 'setphone', + component: () => import('../views/SetUser/setPhone.vue') + },{ + path: '/uploadphone', + name: 'uploadphone', + component: () => import('../views/SetUser/uploadPhone.vue') + }, { path: '/', component: () => import('../views/TabberAll.vue'), diff --git a/yunyou_pavilion/src/views/SetUser/AccountSecurity.vue b/yunyou_pavilion/src/views/SetUser/AccountSecurity.vue index 55de833e82b9318c8580aa05287f1110285605d8..37f370e9509c8cfd9c2a5c600cfededf2085caba 100644 --- a/yunyou_pavilion/src/views/SetUser/AccountSecurity.vue +++ b/yunyou_pavilion/src/views/SetUser/AccountSecurity.vue @@ -11,7 +11,13 @@
账号设置 - +
@@ -39,16 +45,21 @@ import { ref, onMounted } from "vue"; import { UserAPI, deleteUserAPI } from "../myserver/user"; import { getUser_id } from "@/hooks/getLocation"; import { useRouter } from "vue-router"; +import { showConfirmDialog } from "vant"; const router = useRouter(); // 加密手机号与密码 const phones = ref(); +const phone = ref(); const passwords = ref(); +const password = ref(); // 获取用户信息 const userInfo = ref({}); const UserData = async () => { let data = await UserAPI(getUser_id()); userInfo.value = data; + phone.value = data.phone; + password.value = data.password; await PassWords(); // passwords.value = userInfo.value.password; }; @@ -71,16 +82,38 @@ const PassWords = () => { // 注销账户 const DeleteUser = async () => { - // let data = await deleteUserAPI(getUser_id()); - console.log(data); - // if (data.code == 200) { - // localStorage.clear(); - // router.push("/login"); - // } + showConfirmDialog({ + title: "您确定注销账号吗", + message: "三思三思三思三思三思三思三思三思。", + }) + .then(async () => { + let data = await deleteUserAPI(getUser_id()); + if (data.code == 200) { + localStorage.clear(); + router.push("/login"); + } + }) + .catch(() => {}); }; // 跳转修改密码 const toSetPassWord = () => { - router.push("/setpassword"); + router.push({ + path: "/setpassword", + query: { + id: getUser_id(), + password: password.value, + }, + }); +}; +// 跳转修改手机号页 +const toSetPhone = () => { + router.push({ + path: "/setphone", + query: { + phones: phones.value, + phone: phone.value, + }, + }); }; onMounted(() => { UserData(); diff --git a/yunyou_pavilion/src/views/SetUser/SetUser.vue b/yunyou_pavilion/src/views/SetUser/SetUser.vue index 233a35efc41ef2a8538d9904ffd376148644de06..d21ed40252459d7226b8fdf1fbcb2bfddc969cbe 100644 --- a/yunyou_pavilion/src/views/SetUser/SetUser.vue +++ b/yunyou_pavilion/src/views/SetUser/SetUser.vue @@ -9,8 +9,13 @@ @click-left="$router.back()" /> - - + + @@ -23,14 +28,25 @@ + diff --git a/yunyou_pavilion/src/views/SetUser/uploadPhone.vue b/yunyou_pavilion/src/views/SetUser/uploadPhone.vue new file mode 100644 index 0000000000000000000000000000000000000000..f7031fcd8106e33f71f85be92dcf1dde370c1b11 --- /dev/null +++ b/yunyou_pavilion/src/views/SetUser/uploadPhone.vue @@ -0,0 +1,199 @@ + + + + \ No newline at end of file diff --git a/yunyou_pavilion/src/views/myserver/user.js b/yunyou_pavilion/src/views/myserver/user.js index e1d0efc0f72ab3d83581c602de1039fc88144df7..2847e061492b82ae06b4fe17f571f787d48acfb4 100644 --- a/yunyou_pavilion/src/views/myserver/user.js +++ b/yunyou_pavilion/src/views/myserver/user.js @@ -3,6 +3,7 @@ import axios from 'axios' // 获取用户信息 export const UserAPI = async (id) => { + console.log(id) let { data } = await axios.get(`/getUserInfo?id=${id}`) return data } @@ -28,4 +29,20 @@ export const deleteUserAPI = async (id) => { console.log(id) let data = await axios.post(`/deleteUser?id=${id}`) return data +} +// 验证码校验 +export const checkCodeAPI = async (obj) => { + let data = await axios.post(`/checkCode`,obj) + return data +} +// 修改手机号 +export const setUserPhoneAPI = async (obj) => { + console.log(obj) + let data = await axios.post(`/updateUserPhone`,obj) + return data +} +// 根据用户id修改密码 +export const setUserPasswordAPI = async (obj) => { + let data = await axios.post(`/updateUserPassword`,obj) + return data } \ No newline at end of file