update
This commit is contained in:
@@ -5,7 +5,7 @@ import BulletChat from "../login/BulletChat.vue";
|
||||
import XInput from "../../components/XInput.vue";
|
||||
import SendMsg from "../../components/SendMsg.vue";
|
||||
import Api from "../../api/index.js";
|
||||
import {showToast} from "../../utils/uils.js";
|
||||
import {showToast, verifyForm} from "../../utils/uils.js";
|
||||
|
||||
const form = reactive({
|
||||
mobile: null,
|
||||
@@ -15,7 +15,16 @@ const form = reactive({
|
||||
invite: null,
|
||||
});
|
||||
|
||||
const rules = {
|
||||
mobile: {
|
||||
reg: /^1[3-9]\d{9}$/,
|
||||
msg: '手机号错误'
|
||||
},
|
||||
wechat: {}
|
||||
};
|
||||
|
||||
const success = async () => {
|
||||
verifyForm(form, rules);
|
||||
const {msg} = await Api.system.register(form);
|
||||
showToast(msg);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -10,9 +10,9 @@ export default defineConfig({
|
||||
defineModel: true,
|
||||
}
|
||||
}),
|
||||
UnifiedViteWeappTailwindcssPlugin({
|
||||
rem2rpx: true,
|
||||
})
|
||||
// UnifiedViteWeappTailwindcssPlugin({
|
||||
// rem2rpx: true,
|
||||
// })
|
||||
],
|
||||
css: {
|
||||
postcss: {
|
||||
|
||||
Reference in New Issue
Block a user