This commit is contained in:
2025-06-13 11:25:24 +08:00
parent 85d4d412ba
commit 3929c639e5
9 changed files with 121 additions and 20 deletions

View File

@@ -17,6 +17,7 @@ const OpenTypeFun = async (options) => {
break;
}
case 3: { // 微信连接
window.open(url);
break;
}
case 4: { // 外部连接

View File

@@ -4,7 +4,7 @@ import XNav from "../../components/XNav.vue";
import XLink from "../../components/XLink.vue";
import XInput from "../../components/XInput.vue";
import Api from "../../api/index.js";
import {backPage, showToast} from "../../utils/uils.js";
import {backPage, showToast, verifyForm} from "../../utils/uils.js";
import SendMsg from "../../components/SendMsg.vue";
const form = reactive({
@@ -12,8 +12,28 @@ const form = reactive({
captcha: null,
password: null,
});
const rules = {
mobile: {
reg: /^1[3-9]\d{9}$/,
title: '手机号',
msg: '手机号错误',
required: true,
},
captcha: {
reg: /^\d{6}$/,
title: '验证码',
msg: '验证码错误',
required: true,
},
password: {
title: '密码',
msg: '密码错误',
required: true,
}
}
const success = async () => {
verifyForm(form, rules);
const {msg} = await Api.system.editPassword(form);
showToast(msg);
backPage();

View File

@@ -2,7 +2,7 @@
import {reactive} from "vue";
import XInput from "../../components/XInput.vue";
import XLink from "../../components/XLink.vue";
import {showToast, toPage} from "../../utils/uils.js";
import {showToast, toPage, verifyForm} from "../../utils/uils.js";
import Api from "../../api/index.js";
import {useUserStore} from "../../pinia/UserStore/index.js";
@@ -12,8 +12,22 @@ const form = reactive({
mobile: '17502997128',
password: '123456',
});
const rules = {
mobile: {
reg: /^1[3-9]\d{9}$/,
title: '手机号',
msg: '手机号错误',
required: true,
},
password: {
title: '密码',
msg: '密码错误',
required: true,
}
};
const success = async () => {
verifyForm(form, rules);
const {msg, data} = await Api.system.accountLogin(form);
showToast(msg);
UserStore.isLogin = true;

View File

@@ -1,7 +1,7 @@
<script setup>
import {reactive} from "vue";
import XInput from "../../components/XInput.vue";
import {showToast, toPage} from "../../utils/uils.js";
import {showToast, toPage, verifyForm} from "../../utils/uils.js";
import SendMsg from "../../components/SendMsg.vue";
import {useUserStore} from "../../pinia/UserStore/index.js";
import Api from "../../api/index.js";
@@ -12,8 +12,23 @@ const form = reactive({
mobile: null,
captcha: null,
});
const rules = {
mobile: {
reg: /^1[3-9]\d{9}$/,
title: '手机号',
msg: '手机号错误',
required: true,
},
captcha: {
reg: /^\d{6}$/,
title: '验证码',
msg: '验证码错误',
required: true,
}
};
const success = async () => {
verifyForm(form, rules);
const {msg, data} = await Api.system.accountLogin(form);
showToast(msg);
UserStore.isLogin = true;

View File

@@ -6,6 +6,7 @@ import {ref} from "vue";
import AccountLogin from "./AccountLogin.vue";
import PhoneLogin from "./PhoneLogin.vue";
import WXOfficialAccount from "../../components/WXOfficialAccount.vue";
import {onLoad} from "@dcloudio/uni-app";
const currentTab = ref(0);
const showWX = ref(false);
@@ -17,6 +18,11 @@ const tabs = [
name: '账号密码登录',
},
];
onLoad((options) => {
const {showWX: _showWX} = options;
showWX.value = _showWX === '1';
});
</script>
<template>

View File

@@ -5,28 +5,47 @@ 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, verifyForm} from "../../utils/uils.js";
import {showToast, toPage, verifyForm} from "../../utils/uils.js";
const form = reactive({
mobile: null,
wechat: null,
mobile: null,
captcha: null,
password: null,
invite: null,
});
const rules = {
wechat: {
reg: /^[a-zA-Z0-9_-]{1,19}$/,
msg: '微信号错误',
title: '微信号',
required: true,
},
mobile: {
reg: /^1[3-9]\d{9}$/,
msg: '手机号错误'
title: '手机号',
msg: '手机号错误',
required: true,
},
wechat: {}
captcha: {
reg: /^\d{6}$/,
title: '验证码',
msg: '验证码错误',
required: true,
},
password: {
title: '密码',
msg: '密码错误',
required: true,
}
};
const success = async () => {
verifyForm(form, rules);
const {msg} = await Api.system.register(form);
showToast(msg);
await toPage(`/pages/login/index?showWX=1`);
}
</script>

View File

@@ -5,6 +5,8 @@ import Avatar from "../../static/images/Avatar.png";
import XNav from "../../components/XNav.vue";
import {useUserStore} from "../../pinia/UserStore/index.js";
import {onShow} from "@dcloudio/uni-app";
import {showToast, uploadFile} from "../../utils/uils.js";
import Api from "../../api/index.js";
// #ifdef APP-PLUS
import EditNickName from './components/EditNickName.vue';
@@ -51,6 +53,14 @@ const openTools = (key) => {
onShow(() => {
UserStore.getUserInfo();
})
const updateAvatar = async () => {
const [res] = await uploadFile({count: 1});
const {data} = res;
const {msg} = await Api.system.saveInfo({avatar: data});
showToast(msg);
await UserStore.getUserInfo();
}
</script>
<template>
@@ -58,9 +68,10 @@ onShow(() => {
<x-nav></x-nav>
<view class="bg-[#fff] !mt-[20rpx]">
<view class="!flex items-center h-[108rpx] px-[32rpx]">
<view class="!flex items-center h-[108rpx] px-[32rpx]" @click="updateAvatar">
<view class="title">头像</view>
<image class="!size-[64rpx] !ml-auto" mode="aspectFill" :src="Avatar"></image>
<image class="!size-[64rpx] !ml-auto rounded-[50%]" mode="aspectFill"
:src="UserStore?.userInfo?.avatar"></image>
<image class="!w-[16rpx] !ml-[16rpx]" mode="widthFix" :src="Right"></image>
</view>
<view class="h-[3rpx] w-full bg-[rgb(229,230,235)] !ml-[32rpx]"></view>

View File

@@ -175,9 +175,20 @@ export const uploadFile = ({count}) => {
}
export const verifyForm = (model, rules) => {
console.log('进来了')
Object.entries(model).forEach(([key, value]) => {
console.log(rules[key], key)
if (rules[key] && !rules[key].reg.test(value)) {
console.log(rules[key], key, value)
if (rules[key]) {
if (rules[key].required && !value) {
showToast({
icon: 'error',
mask: true,
title: `${rules[key].title}不能为空`,
});
throw new Error(rules[key].msg);
}
if (rules[key].reg) {
if (!rules[key].reg.test(value)) {
showToast({
icon: 'error',
mask: true,
@@ -185,5 +196,7 @@ export const verifyForm = (model, rules) => {
});
throw new Error(rules[key].msg);
}
}
}
});
}

View File

@@ -10,9 +10,11 @@ export default defineConfig({
defineModel: true,
}
}),
// UnifiedViteWeappTailwindcssPlugin({
// rem2rpx: true,
// })
// #ifdef MP-WEIXIN
UnifiedViteWeappTailwindcssPlugin({
rem2rpx: true,
})
// #endif
],
css: {
postcss: {