This commit is contained in:
2025-06-13 10:35:17 +08:00
parent 9cc71494f0
commit 85d4d412ba
3 changed files with 27 additions and 4 deletions

View File

@@ -5,7 +5,7 @@ import BulletChat from "../login/BulletChat.vue";
import XInput from "../../components/XInput.vue"; import XInput from "../../components/XInput.vue";
import SendMsg from "../../components/SendMsg.vue"; import SendMsg from "../../components/SendMsg.vue";
import Api from "../../api/index.js"; import Api from "../../api/index.js";
import {showToast} from "../../utils/uils.js"; import {showToast, verifyForm} from "../../utils/uils.js";
const form = reactive({ const form = reactive({
mobile: null, mobile: null,
@@ -15,7 +15,16 @@ const form = reactive({
invite: null, invite: null,
}); });
const rules = {
mobile: {
reg: /^1[3-9]\d{9}$/,
msg: '手机号错误'
},
wechat: {}
};
const success = async () => { const success = async () => {
verifyForm(form, rules);
const {msg} = await Api.system.register(form); const {msg} = await Api.system.register(form);
showToast(msg); showToast(msg);
} }

View File

@@ -173,3 +173,17 @@ export const uploadFile = ({count}) => {
}); });
}); });
} }
export const verifyForm = (model, rules) => {
Object.entries(model).forEach(([key, value]) => {
console.log(rules[key], key)
if (rules[key] && !rules[key].reg.test(value)) {
showToast({
icon: 'error',
mask: true,
title: rules[key].msg,
});
throw new Error(rules[key].msg);
}
});
}

View File

@@ -10,9 +10,9 @@ export default defineConfig({
defineModel: true, defineModel: true,
} }
}), }),
UnifiedViteWeappTailwindcssPlugin({ // UnifiedViteWeappTailwindcssPlugin({
rem2rpx: true, // rem2rpx: true,
}) // })
], ],
css: { css: {
postcss: { postcss: {