|
|
@@ -1,39 +1,51 @@
|
|
|
<template>
|
|
|
<view class="container">
|
|
|
<!-- 手机号码输入框 -->
|
|
|
- <view class="input-group">
|
|
|
+ <!-- <view class="input-group">
|
|
|
<text>手机号码:</text>
|
|
|
- <input type="number" maxlength="11" v-model="userInfo.phone" placeholder="请输入手机号码" />
|
|
|
- </view>
|
|
|
+ <input type="number" maxlength="11" v-model="userInfo.desktopPhone" placeholder="请输入手机号码" />
|
|
|
+ </view> -->
|
|
|
|
|
|
<!-- 邮箱输入框 -->
|
|
|
- <view class="input-group">
|
|
|
+ <!-- <view class="input-group">
|
|
|
<text>邮箱:</text>
|
|
|
- <input type="text" v-model="userInfo.email" placeholder="请输入邮箱地址" />
|
|
|
+ <input type="text" v-model="userInfo.mail" placeholder="请输入邮箱地址" />
|
|
|
+ </view> -->
|
|
|
+
|
|
|
+ <!-- qq输入框 -->
|
|
|
+ <view class="input-group">
|
|
|
+ <text>qq:</text>
|
|
|
+ <input type="text" v-model="userInfo.qq" placeholder="请输入qq" />
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <!-- msn输入框 -->
|
|
|
+ <view class="input-group">
|
|
|
+ <text>msn:</text>
|
|
|
+ <input type="text" v-model="userInfo.msn" placeholder="请输入msn" />
|
|
|
</view>
|
|
|
|
|
|
<!-- 用户生日输入框 -->
|
|
|
- <view class="input-group">
|
|
|
+ <!-- <view class="input-group">
|
|
|
<text>用户生日:</text>
|
|
|
<view class="example-body">
|
|
|
<uni-datetime-picker type="date" :clear-icon="false" v-model="userInfo.birthday" @maskClick="maskClick" />
|
|
|
</view>
|
|
|
- </view>
|
|
|
+ </view> -->
|
|
|
|
|
|
<!-- 性别选择器 -->
|
|
|
- <view class="gender-selector">
|
|
|
+ <!-- <view class="sex-selector">
|
|
|
<radio-group @change="handleGenderChange">
|
|
|
<text>性别:</text>
|
|
|
- <view class="genderLabel">
|
|
|
+ <view class="sexLabel">
|
|
|
<label>
|
|
|
- <radio value="male" :checked="userInfo.gender === 'male' " />男
|
|
|
+ <radio value="M" :checked="userInfo.sex === 'M' " />男
|
|
|
</label>
|
|
|
<label>
|
|
|
- <radio value="female" :checked="userInfo.gender === 'female'" />女
|
|
|
+ <radio value="F" :checked="userInfo.sex === 'F'" />女
|
|
|
</label>
|
|
|
</view>
|
|
|
</radio-group>
|
|
|
- </view>
|
|
|
+ </view> -->
|
|
|
|
|
|
<!-- 提交按钮 -->
|
|
|
<view class="primaryBtn">
|
|
|
@@ -45,54 +57,70 @@
|
|
|
<script setup>
|
|
|
import {
|
|
|
ref,
|
|
|
- reactive
|
|
|
+ reactive,
|
|
|
+ onMounted
|
|
|
} from 'vue';
|
|
|
+ import { useUserStore } from '@/store/user';
|
|
|
+ import { ModifyMe } from '@/api/mine';
|
|
|
+ import $modal from '@/plugins/modal.js'
|
|
|
// 定义用户信息的响应式对象
|
|
|
- const userInfo = reactive({
|
|
|
- phone: '13145672389',
|
|
|
- email: '',
|
|
|
- gender: 'male',
|
|
|
- birthday: '2000-01-10'
|
|
|
+ const thisUser=useUserStore().user;
|
|
|
+ let userInfo = reactive({
|
|
|
+ staffId:thisUser.useId,
|
|
|
+ // desktopPhone: thisUser.desktopPhone,
|
|
|
+ // mail: thisUser.email,
|
|
|
+ // sex: thisUser.sex,
|
|
|
+ // birthday: thisUser.birthday,
|
|
|
+ qq:thisUser.qqnum,
|
|
|
+ msn:thisUser.msnnum
|
|
|
});
|
|
|
|
|
|
- function handleGenderChange(event) {
|
|
|
- userInfo.gender = event.detail.value; // 更新性别
|
|
|
- };
|
|
|
|
|
|
- // 校验手机号码格式
|
|
|
- function validatePhone(phone) {
|
|
|
- const phoneRegex = /^1[3-9]\d{9}$/; // 手机号码格式正则(以1开头,11位数字)
|
|
|
- return phoneRegex.test(phone);
|
|
|
- }
|
|
|
+ // function handleGenderChange(event) {
|
|
|
+ // userInfo.sex = event.detail.value; // 更新性别
|
|
|
+ // };
|
|
|
+
|
|
|
+ // // 校验手机号码格式
|
|
|
+ // function validatePhone(desktopPhone) {
|
|
|
+ // const desktopPhoneRegex = /^1[3-9]\d{9}$/; // 手机号码格式正则(以1开头,11位数字)
|
|
|
+ // return desktopPhoneRegex.test(desktopPhone);
|
|
|
+ // }
|
|
|
|
|
|
- // 校验邮箱格式
|
|
|
- function validateEmail(email) {
|
|
|
- const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/; // 邮箱格式正则
|
|
|
- return emailRegex.test(email);
|
|
|
- }
|
|
|
+ // // 校验邮箱格式
|
|
|
+ // function validateEmail(mail) {
|
|
|
+ // const mailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/; // 邮箱格式正则
|
|
|
+ // return mailRegex.test(mail);
|
|
|
+ // }
|
|
|
|
|
|
// 处理提交事件
|
|
|
function handleSubmit() {
|
|
|
- if (!validatePhone(userInfo.phone)) {
|
|
|
- uni.showToast({
|
|
|
- title: '手机号码格式不正确',
|
|
|
- icon: 'none'
|
|
|
- });
|
|
|
- return; // 终止提交
|
|
|
- }
|
|
|
+ // if (!validatePhone(userInfo.desktopPhone)) {
|
|
|
+ // uni.showToast({
|
|
|
+ // title: '手机号码格式不正确',
|
|
|
+ // icon: 'none'
|
|
|
+ // });
|
|
|
+ // return; // 终止提交
|
|
|
+ // }
|
|
|
|
|
|
- if (!validateEmail(userInfo.email)) {
|
|
|
- uni.showToast({
|
|
|
- title: '邮箱格式不正确',
|
|
|
- icon: 'none'
|
|
|
- });
|
|
|
- return; // 终止提交
|
|
|
- }
|
|
|
+ // if (!validateEmail(userInfo.mail)) {
|
|
|
+ // uni.showToast({
|
|
|
+ // title: '邮箱格式不正确',
|
|
|
+ // icon: 'none'
|
|
|
+ // });
|
|
|
+ // return; // 终止提交
|
|
|
+ // }
|
|
|
+ ModifyMe(userInfo).then(res=>{
|
|
|
+ // console.log(res);
|
|
|
+ if("success"==res.returnMsg){
|
|
|
+ $modal.showToast('修改成功');
|
|
|
+ useUserStore().GetInfo().then(res=>{
|
|
|
+ console.log("GetInfo",res);
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
|
|
|
- uni.showToast({
|
|
|
- title: '提交成功',
|
|
|
- icon: 'none'
|
|
|
- });
|
|
|
+
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
@@ -107,7 +135,7 @@
|
|
|
}
|
|
|
|
|
|
.input-group input,
|
|
|
- .genderLabel {
|
|
|
+ .sexLabel {
|
|
|
padding-left: 20rpx;
|
|
|
margin: 20rpx auto;
|
|
|
height: 70rpx;
|
|
|
@@ -123,7 +151,7 @@
|
|
|
margin-bottom: 20rpx;
|
|
|
}
|
|
|
|
|
|
- .gender-selector label {
|
|
|
+ .sex-selector label {
|
|
|
margin-right: 15rpx;
|
|
|
}
|
|
|
|