update: 登陆 忘记密码 我的

This commit is contained in:
admin 2024-04-24 14:35:43 +08:00
parent 0deee4db0c
commit 00ffb5d5d7
11 changed files with 335 additions and 97 deletions

View File

@ -139,17 +139,13 @@ const startSave = () => {
if (model1.formData.id) {
GoodsApi.editReceiveCategory(model1.formData).then((res) => {
if (res.code === 200) {
uni.redirectTo({
url: "/pagesApp/receiveType", //
});
uni.navigateBack()
}
});
} else {
GoodsApi.getStockCardList(model1.formData).then((res) => {
GoodsApi.addReCategory(model1.formData).then((res) => {
if (res.code === 200) {
uni.redirectTo({
url: "/pagesApp/receiveType", //
});
uni.navigateBack()
}
});
}

View File

@ -51,6 +51,7 @@
import { GoodsApi } from "@/services";
import PageView from "@/components/PageView/index.vue";
import SmallModal from "@/components/Modal/smallModal.vue";
import { onShow } from "@dcloudio/uni-app";
const isShowCancelModal = ref(false);
const deleteId = ref(0);
const handleModal = (v: boolean, id: number) => {
@ -132,7 +133,8 @@ const getList = (v?: boolean) => {
});
};
onMounted(() => {
onShow(() => {
resetPageList();
getList();
});
</script>

View File

@ -25,6 +25,7 @@
}"
@focus="handleFocus(item.modelName)"
@blur="handleFocus('')"
@change="(e:any) => {handleInput(e, item.modelName)}"
>
<template #suffix>
<text v-if="item.modelName === 'code'" class="code-btn">
@ -47,13 +48,14 @@
:placeholder="item.placeholder"
:shape="'circle'"
:clearable="true"
:type="item.isShowPwd ? 'text' : 'password'"
:password="!item.isShowPwd"
:customStyle="{
'border-color':
currentFocus === item.modelName ? '#00dcee !important' : '',
}"
@focus="handleFocus(item.modelName)"
@blur="handleFocus('')"
@change="(e:any) => {handleInput(e, item.modelName)}"
>
<template #suffix>
<image
@ -92,12 +94,13 @@
import { ProfileApi } from "@/services/index";
import LoginLayout from "./components/loginLayout.vue";
import valid from "@/utils/validate";
import { validateRegex } from "@/utils";
const loginForm = ref(null);
const model1 = <any>reactive({
userInfo: {
userName: "",
phone: "",
code: "",
passwordNew: "",
newPassword: "",
passwordConfirm: "",
},
});
@ -107,7 +110,7 @@ const currentFocus = ref("");
//
const formAttrList = ref([
{
modelName: "userName",
modelName: "phone",
type: "text",
placeholder: "请输入手机号",
},
@ -117,7 +120,7 @@ const formAttrList = ref([
placeholder: "请输入验证码",
},
{
modelName: "passwordNew",
modelName: "newPassword",
type: "password",
placeholder: "请输入新密码",
isShowPwd: false, //
@ -129,24 +132,51 @@ const formAttrList = ref([
isShowPwd: false, //
},
]);
const handleInput = (e: any, key: string) => {
if (key === "phone") {
const temp = e?.replace(valid.valid_number, "");
setTimeout(() => {
(model1.userInfo as any)[key] = temp;
}, 100);
}
if (key === "code") {
const temp = e?.replace(valid.valid_number, "");
setTimeout(() => {
(model1.userInfo as any)[key] = temp;
}, 100);
}
if (key === "newPassword" || key === "passwordConfirm") {
const temp = e?.replace(valid.valid_no_cn, "");
setTimeout(() => {
(model1.userInfo as any)[key] = temp;
}, 100);
}
};
//
const seconds = ref(0);
const handleCode = () => {
console.log(model1);
if (model1.userInfo === undefined || !model1.userInfo.userName) {
if (model1.userInfo === undefined || !model1.userInfo.phone) {
uni.showToast({
title: "请输入手机号",
icon: "error",
});
return;
}
if (!valid.mobile.pattern.test(model1.userInfo.userName)) {
if (!valid.mobile.pattern.test(model1.userInfo.phone)) {
uni.showToast({
title: "手机号不合法",
title: "请输入正确的手机号",
icon: "error",
});
return;
}
ProfileApi.sendCommonMsg({
phone: model1.userInfo.phone,
type: "forget",
}).then((res) => {
seconds.value = 120;
let countDownTimer = setInterval(() => {
if (seconds.value > 0) {
@ -155,9 +185,10 @@ const handleCode = () => {
clearInterval(countDownTimer);
}
}, 1000);
});
};
const rules = ref({
"userInfo.userName": {
"userInfo.phone": {
type: "string",
required: true,
message: "请输入手机号",
@ -169,11 +200,11 @@ const rules = ref({
message: "请输入验证码",
trigger: ["blur", "change"],
},
"userInfo.passwordNew": {
"userInfo.newPassword": {
type: "string",
required: true,
message: "请输入新密码",
trigger: ["blur", "change"],
message: "请输入新密码"
},
"userInfo.passwordConfirm": {
type: "string",
@ -181,27 +212,56 @@ const rules = ref({
message: "请输入确认密码",
trigger: ["blur", "change"],
},
// "userInfo.sex": {
// type: "string",
// max: 1,
// required: true,
// message: "",
// trigger: ["blur", "change"],
// },
});
// const checkboxChange = (n: any) => {
// console.log("change", n);
// };
const handleFocus = (attr: string) => {
currentFocus.value = attr;
};
const submit = () => {
ProfileApi.loginByAccount({
userName: "cs123",
password: "123",
if (model1.userInfo.phone) {
if (!valid.mobile.pattern.test(model1.userInfo.phone)) {
uni.showToast({ icon: "none", title: "请输入正确的手机号" });
return;
}
}
if (model1.userInfo.newPassword || model1.userInfo.passwordConfirm) {
if (
!validateRegex(
valid.valid_password1.pattern,
model1.userInfo.newPassword
) ||
!validateRegex(
valid.valid_password1.pattern,
model1.userInfo.passwordConfirm
)
) {
uni.showToast({
icon: "none",
title: valid.valid_password.message,
});
return;
}
}
if (model1.userInfo.newPassword !== model1.userInfo.passwordConfirm) {
uni.showToast({ icon: "none", title: "新密码必须和确认密码相同" });
return;
}
(loginForm.value as any).validate().then((res: any) => {
if (res) {
//
ProfileApi.forgetPwd({ ...model1.userInfo, type: "forget" }).then(
(res: any) => {
if (res.code === 200) {
uni.showToast({ title: "密码更新成功" });
uni.navigateBack();
}
}
);
}
});
(loginForm.value as any).validate();
};
</script>

View File

@ -18,8 +18,10 @@
'border-color':
currentFocus === 'userName' ? '#00dcee !important' : '',
}"
type="number"
@focus="handleFocus('userName')"
@blur="handleFocus('')"
@change="(e:any) => {handleInput(e, 'userName')}"
>
</u-input>
</u-form-item>
@ -28,14 +30,16 @@
v-model="model1.userInfo.password"
placeholder="请输入密码"
:shape="'circle'"
:clearable="true"
:type="isShowPwd ? 'text' : 'password'"
type="text"
:password="!isShowPwd"
:customStyle="{
'border-color':
currentFocus === 'password' ? '#00dcee !important' : '',
}"
@focus="handleFocus('password')"
@blur="handleFocus('')"
:clearable="true"
@change="(e:any) => {handleInput(e, 'password')}"
>
<template #suffix>
<image
@ -91,8 +95,14 @@
></u-checkbox>
</u-checkbox-group>
<view>
我已阅读并同意用户 <text class="agree-item"> 服务协议 </text>
<text class="agree-item"> 隐私政策 </text>
我已阅读并同意用户
<text class="agree-item" @click="openDoc('爱梵达用户服务协议')"
> 服务协议 </text
>
<text class="agree-item" @click="openDoc('隐私政策')"
> 隐私政策 </text
>
<view> 未开通服务站点无法登录 </view>
</view>
</view>
@ -104,6 +114,8 @@
import { ProfileApi } from "@/services/index";
import LoginLayout from "./components/loginLayout.vue";
import { useMemberStore } from "@/store/index";
import valid from "@/utils/validate";
import { validateRegex } from "@/utils";
const store = useMemberStore();
const loginForm = ref(null);
const model1 = reactive({
@ -137,13 +149,46 @@ const rules = ref({
},
});
// const checkboxChange = (n: any) => {
// console.log("change", n);
// };
const handleInput = (e: any, key: string) => {
if (key === "userName") {
const temp = e?.replace(valid.valid_number, "");
setTimeout(() => {
(model1.userInfo as any)[key] = temp;
}, 100);
}
if (key === "password") {
const temp = e?.replace(valid.valid_no_cn, "");
setTimeout(() => {
(model1.userInfo as any)[key] = temp;
}, 100);
}
};
const handleFocus = (attr: string) => {
currentFocus.value = attr;
};
const submit = () => {
if (model1.userInfo.userName) {
if (!valid.mobile.pattern.test(model1.userInfo.userName)) {
uni.showToast({ icon: "none", title: "请输入正确的手机号" });
return;
}
}
if (model1.userInfo.password) {
if (!validateRegex(
valid.valid_password1.pattern,
model1.userInfo.password
)) {
uni.showToast({
icon: "none",
title: valid.valid_password.message,
});
return;
}
}
(loginForm.value as any).validate().then((res: any) => {
if (res) {
if (checkGroup.agreeCheck.length === 0) {
@ -169,6 +214,45 @@ const handleForgetPwd = () => {
url: "/pagesLogin/login/forgetPwd", //
});
};
const openDoc = (item: string) => {
//
uni.downloadFile({
url: `https://backend-common.obs.cn-east-3.myhuaweicloud.com/static/pages/login/${item}.docx`,
success: function (res) {
setTimeout(
() =>
uni.openDocument({
filePath: res.tempFilePath,
showMenu: false,
success: function () {
console.log("打开文档成功");
},
fail: function () {
uni.showToast({
title: "暂不支持此类型",
duration: 2000,
icon: "none",
});
},
}),
100
);
},
fail: function (res) {
console.log(res); //
},
});
// uni.openDocument({
// filePath: `https://backend-common.obs.cn-east-3.myhuaweicloud.com/static/pages/login/${item}.docx`,
// showMenu: true,
// success: function (res) {
// uni.showToast({ title: "" });
// },
// });
};
</script>
<style lang="scss" scoped>

View File

@ -38,12 +38,36 @@
</view>
</view>
<TabBar></TabBar>
<SmallModal
:title="'确认退出吗?'"
:content="'退出后将返回至登陆页'"
:okText="'确认退出'"
:isMain="true"
:show="isShowCancelModal"
@handleModal="(v:boolean) => {handleModal(v)}"
@handleOk="handleOk()"
/>
</template>
<script setup lang="ts">
import { ProfileApi } from "@/services/index";
import { reactive } from "vue";
import { useMemberStore } from "@/store/index";
import TabBar from '@/components/TabBar/index.vue'
import SmallModal from "@/components/Modal/smallModal.vue";
const isShowCancelModal = ref(false);
const handleModal = (v: boolean) => {
isShowCancelModal.value = v;
};
const handleOk = () => {
ProfileApi.logOut().then((res: any) => {
if (res.code === 200) {
uni.reLaunch({
url: "/pagesLogin/login/index", //
});
}
});
};
const store = useMemberStore();
const profile = store.profile.userInfo;
const list = reactive([
@ -66,16 +90,7 @@ const list = reactive([
const hanldeClick = (item: any) => {
if (item.name === "退出登录") {
uni.navigateTo({
url: "/pagesLogin/login/index", //
});
ProfileApi.logOut().then((res: any) => {
if (res.code === 200) {
uni.navigateTo({
url: "/pagesLogin/login/index", //
});
}
});
handleModal(true)
}
};
</script>

View File

@ -23,7 +23,8 @@
:customStyle="{}"
:border="index === 2 ? 'none' : 'bottom'"
:value="(model1.userInfo as any)[item.key]"
:type="item.isShowPwd ? 'text' : 'password'"
:password="!item.isShowPwd"
@change="(e:any) => {handleInput(e, item.key)}"
>
<template #suffix>
<image
@ -58,8 +59,16 @@
</template>
<script setup lang="ts">
import { ProfileApi } from "@/services";
import { validateRegex } from "@/utils";
import valid from "@/utils/validate";
const handleInput = (e: any, key: string) => {
const temp = e?.replace(valid.valid_no_cn, "");
setTimeout(() => {
(model1.userInfo as any)[key] = temp;
}, 100);
};
//
const formAttrList = ref([
{
@ -127,27 +136,50 @@ const check = () => {
});
};
const startSave = () => {
console.log( model1.userInfo)
ProfileApi.updateUserPwd({...model1.userInfo}).then(res => {
console.log(model1.userInfo);
ProfileApi.updateUserPwd({ ...model1.userInfo }).then((res) => {
if (res.code === 200) {
uni.showToast({ icon: "none", title: '密码修改成功'});
uni.showToast({ icon: "none", title: "密码修改成功" });
model1.userInfo = {};
setTimeout(() => {
ProfileApi.logOut().then((res: any) => {
if (res.code === 200) {
uni.reLaunch({
url: "/pagesLogin/login/index", //
});
}
})
});
}, 10);
}
});
};
const submit = () => {
// if (!valid.password.pattern.test(model1.userInfo.password) || !valid.password.pattern.test(model1.userInfo.newPassword) || !valid.password.pattern.test(model1.userInfo.passwordConfirm)) {
// uni.showToast({ icon: "none", title: valid.password.message });
// return;
// }
if (model1.userInfo.newPassword || model1.userInfo.passwordConfirm) {
if (
!validateRegex(
valid.valid_password1.pattern,
model1.userInfo.newPassword
) ||
!validateRegex(
valid.valid_password1.pattern,
model1.userInfo.passwordConfirm
)
) {
uni.showToast({
icon: "none",
title: valid.valid_password.message,
});
return;
}
}
if (model1.userInfo.password === model1.userInfo.newPassword) {
uni.showToast({ icon: "none", title: '新密码不能和旧密码相同'});
uni.showToast({ icon: "none", title: "新密码不能和旧密码相同" });
return;
}
if (model1.userInfo.newPassword !== model1.userInfo.passwordConfirm) {
uni.showToast({ icon: "none", title: '新密码必须和确认密码相同' });
uni.showToast({ icon: "none", title: "新密码必须和确认密码相同" });
return;
}
check().then((res) => {

View File

@ -1,7 +1,7 @@
import { http } from '@/utils/http'
// 收货分类新增
export const getStockCardList = (data: any) => {
export const addReCategory = (data: any) => {
return http({
method: 'POST',
url: '/api/recategory/addReCategory',

View File

@ -40,13 +40,12 @@ export const sendMsg = (data: { phone: string }) => {
});
};
// 修改密码
export const updateUserPwd = (data: any) => {
return http({
method: "POST",
url: "/api/user/updateUserPwd",
data
data,
});
};
@ -77,7 +76,7 @@ export const getRoleList = (data: any) => {
return http({
method: "GET",
url: "/api/role/getRoleList",
data
data,
});
};
@ -113,7 +112,7 @@ export const getMenusRole = (data: any) => {
return http<[]>({
method: "GET",
url: "/api/role/getMenusRole",
data
data,
});
};
@ -122,7 +121,7 @@ export const getMenuByPage = (data: any) => {
return http({
method: "GET",
url: "/api/menus/getPage",
data
data,
});
};
@ -131,7 +130,7 @@ export const addMenus = (data: any) => {
return http({
method: "POST",
url: "/api/menus/addMenus",
data
data,
});
};
@ -140,7 +139,7 @@ export const getMenuList = (data: any) => {
return http({
method: "GET",
url: "/api/menus/getList",
data
data,
});
};
@ -149,7 +148,7 @@ export const updateMenus = (data: any) => {
return http({
method: "POST",
url: "/api/menus/updateMenus",
data
data,
});
};
@ -158,7 +157,7 @@ export const getProvinceList = (data: any) => {
return http({
method: "GET",
url: "/api/user/getChinaList",
data
data,
});
};
@ -167,7 +166,7 @@ export const addUser = (data: any) => {
return http({
method: "POST",
url: "/api/user/addUser",
data
data,
});
};
@ -176,7 +175,7 @@ export const getUserListByPage = (data: any) => {
return http<User>({
method: "GET",
url: "/api/user/getUserPage",
data
data,
});
};
@ -193,7 +192,7 @@ export const addUserRole = (data: any) => {
return http({
method: "POST",
url: "/api/user/addUserRole",
data
data,
});
};
// 查询用户列表
@ -212,7 +211,7 @@ export const getInventoryUserPage = (data: any) => {
return http<User>({
method: "GET",
url: "/api/user/getInventoryUserPage",
data
data,
});
};
@ -221,7 +220,7 @@ export const updateUserByIdOffline = (data: any) => {
return http<User>({
method: "POST",
url: "/api/user/updateUserByIdOffline",
data
data,
});
};
// 用户编辑
@ -229,8 +228,25 @@ export const updateUserById = (data: any) => {
return http<User>({
method: "POST",
url: "/api/user/updateUserById",
data
data,
});
};
// 发送验证码(通用)
export const sendCommonMsg = (data: any) => {
return http<User>({
method: "GET",
url: "/api/user/sendCommonMsg",
data,
});
};
// 忘记密码
export const forgetPwd = (data: any) => {
return http<User>({
method: "POST",
url: "/api/user/forgetPwd",
data,
});
};

View File

@ -102,7 +102,7 @@ export const http = <T>(options: UniApp.RequestOptions) => {
title: (res1 as Data<T>).message || "请求失败",
});
store.clearProfile();
uni.navigateTo({
uni.reLaunch({
url: "/pagesLogin/login/index",
});
return;

View File

@ -198,16 +198,16 @@ export function formatMoney(
prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
sep = typeof thousands_sep === "undefined" ? "," : thousands_sep,
dec = typeof dec_point === "undefined" ? "." : dec_point,
s:any = "",
toFixedFix = function (n:any, prec:any) {
s: any = "",
toFixedFix = function (n: any, prec: any) {
var k = Math.pow(10, prec);
return (
"" +
parseFloat(
(Math as any)[roundtag](parseFloat((n * k).toFixed(prec * 2))).toFixed(
prec * 2
)
(Math as any)
[roundtag](parseFloat((n * k).toFixed(prec * 2)))
.toFixed(prec * 2)
) /
k
);
@ -229,3 +229,8 @@ export function formatMoney(
export function countDots(str: any) {
return (str.match(/\./g) || []).length;
}
export function validateRegex(regexValue: string, value: string) {
const regex = new RegExp(regexValue);
return regex.test(value);
}

View File

@ -18,7 +18,8 @@ const valid = {
carNo: {
// /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$/
// /^[\x{4e00}-\x{9fa5}]{1}[A-Z]{1}[A-Z0-9]{5}$/u
pattern: /^([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[a-zA-Z](([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼ABCDEFGHJK]((?![IO])[a-zA-Z0-9](?![IO]))[0-9]{4})|([0-9]{5}[ABCDEFGHJK]))|[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z0-9]{1}[A-Z0-9]{1}[A-Z0-9应]{4,5}[A-Z0-9挂学警港澳领使急]{1})$/,
pattern:
/^([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[a-zA-Z](([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼ABCDEFGHJK]((?![IO])[a-zA-Z0-9](?![IO]))[0-9]{4})|([0-9]{5}[ABCDEFGHJK]))|[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z0-9]{1}[A-Z0-9]{1}[A-Z0-9应]{4,5}[A-Z0-9挂学警港澳领使急]{1})$/,
message: "请输入正确的车牌号",
},
valid_decimal: {
@ -26,8 +27,35 @@ const valid = {
message: "请输入正确的数字",
},
valid_id_card: {
pattern: /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/,
message: '请输入正确的身份证号码'
}
pattern:
/^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/,
message: "请输入正确的身份证号码",
},
/**
* 8
*/
valid_passwordTemp: {
pattern:
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[$@$!%*?&])[A-Za-z\\d$@$!%*?&]{8,}$/,
message: "密码由字母、数字组成,且至少8位",
},
valid_password: {
pattern:
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)[A-Za-z\\d]{8,}$/,
message: "密码由字母、数字组成,且至少8位",
},
valid_password1: {
pattern:
"^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)[A-Za-z\\d]{8,}$",
message: "密码必须由字母、数字组成,区分大小写, 且至少8位",
},
};
export default valid;