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; break;
} }
case 3: { // 微信连接 case 3: { // 微信连接
window.open(url);
break; break;
} }
case 4: { // 外部连接 case 4: { // 外部连接

View File

@@ -4,7 +4,7 @@ import XNav from "../../components/XNav.vue";
import XLink from "../../components/XLink.vue"; import XLink from "../../components/XLink.vue";
import XInput from "../../components/XInput.vue"; import XInput from "../../components/XInput.vue";
import Api from "../../api/index.js"; 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"; import SendMsg from "../../components/SendMsg.vue";
const form = reactive({ const form = reactive({
@@ -12,8 +12,28 @@ const form = reactive({
captcha: null, captcha: null,
password: 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 () => { const success = async () => {
verifyForm(form, rules);
const {msg} = await Api.system.editPassword(form); const {msg} = await Api.system.editPassword(form);
showToast(msg); showToast(msg);
backPage(); backPage();

View File

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

View File

@@ -1,7 +1,7 @@
<script setup> <script setup>
import {reactive} from "vue"; import {reactive} from "vue";
import XInput from "../../components/XInput.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 SendMsg from "../../components/SendMsg.vue";
import {useUserStore} from "../../pinia/UserStore/index.js"; import {useUserStore} from "../../pinia/UserStore/index.js";
import Api from "../../api/index.js"; import Api from "../../api/index.js";
@@ -12,8 +12,23 @@ const form = reactive({
mobile: null, mobile: null,
captcha: 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 () => { const success = async () => {
verifyForm(form, rules);
const {msg, data} = await Api.system.accountLogin(form); const {msg, data} = await Api.system.accountLogin(form);
showToast(msg); showToast(msg);
UserStore.isLogin = true; UserStore.isLogin = true;

View File

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

View File

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

View File

@@ -5,6 +5,8 @@ import Avatar from "../../static/images/Avatar.png";
import XNav from "../../components/XNav.vue"; import XNav from "../../components/XNav.vue";
import {useUserStore} from "../../pinia/UserStore/index.js"; import {useUserStore} from "../../pinia/UserStore/index.js";
import {onShow} from "@dcloudio/uni-app"; import {onShow} from "@dcloudio/uni-app";
import {showToast, uploadFile} from "../../utils/uils.js";
import Api from "../../api/index.js";
// #ifdef APP-PLUS // #ifdef APP-PLUS
import EditNickName from './components/EditNickName.vue'; import EditNickName from './components/EditNickName.vue';
@@ -51,6 +53,14 @@ const openTools = (key) => {
onShow(() => { onShow(() => {
UserStore.getUserInfo(); 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> </script>
<template> <template>
@@ -58,9 +68,10 @@ onShow(() => {
<x-nav></x-nav> <x-nav></x-nav>
<view class="bg-[#fff] !mt-[20rpx]"> <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> <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> <image class="!w-[16rpx] !ml-[16rpx]" mode="widthFix" :src="Right"></image>
</view> </view>
<view class="h-[3rpx] w-full bg-[rgb(229,230,235)] !ml-[32rpx]"></view> <view class="h-[3rpx] w-full bg-[rgb(229,230,235)] !ml-[32rpx]"></view>

View File

@@ -175,15 +175,28 @@ export const uploadFile = ({count}) => {
} }
export const verifyForm = (model, rules) => { export const verifyForm = (model, rules) => {
console.log('进来了')
Object.entries(model).forEach(([key, value]) => { Object.entries(model).forEach(([key, value]) => {
console.log(rules[key], key) console.log(rules[key], key, value)
if (rules[key] && !rules[key].reg.test(value)) { if (rules[key]) {
showToast({ if (rules[key].required && !value) {
icon: 'error', showToast({
mask: true, icon: 'error',
title: rules[key].msg, mask: true,
}); title: `${rules[key].title}不能为空`,
throw new Error(rules[key].msg); });
throw new Error(rules[key].msg);
}
if (rules[key].reg) {
if (!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,11 @@ export default defineConfig({
defineModel: true, defineModel: true,
} }
}), }),
// UnifiedViteWeappTailwindcssPlugin({ // #ifdef MP-WEIXIN
// rem2rpx: true, UnifiedViteWeappTailwindcssPlugin({
// }) rem2rpx: true,
})
// #endif
], ],
css: { css: {
postcss: { postcss: {