flat: 暂存
This commit is contained in:
@@ -473,3 +473,8 @@ html {
|
||||
.height-100 {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
|
||||
.pointEveNone {
|
||||
pointer-events: none;
|
||||
}
|
||||
@@ -1,5 +1,11 @@
|
||||
<template>
|
||||
<AppLayout title="个人信息" :sub-title="`完成度${percent}`" border back-gorund-color="#ffffff" :show-bg-image="false">
|
||||
<AppLayout
|
||||
title="个人信息"
|
||||
:sub-title="`完成度${percent}`"
|
||||
border
|
||||
back-gorund-color="#ffffff"
|
||||
:show-bg-image="false"
|
||||
>
|
||||
<template #headerleft>
|
||||
<view class="btn mar_le20 button-click" @click="navBack">取消</view>
|
||||
</template>
|
||||
@@ -22,21 +28,40 @@
|
||||
<view class="content-sex">
|
||||
<view class="sex-titile">性别</view>
|
||||
<view class="sext-ri">
|
||||
<view class="sext-box" :class="{ 'sext-boxactive': fromValue.sex === 0 }" @click="changeSex(0)"> 男 </view>
|
||||
<view class="sext-box" :class="{ 'sext-boxactive': fromValue.sex === 1 }" @click="changeSex(1)"> 女 </view>
|
||||
<view class="sext-box" :class="{ 'sext-boxactive': fromValue.sex === 0 }" @click="changeSex(0)">
|
||||
男
|
||||
</view>
|
||||
<view class="sext-box" :class="{ 'sext-boxactive': fromValue.sex === 1 }" @click="changeSex(1)">
|
||||
女
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="content-input" @click="changeDateBirt">
|
||||
<view class="input-titile">出生年月</view>
|
||||
<input class="input-con triangle" v-model="fromValue.birthDate" disabled placeholder="请选择您的出生年月" />
|
||||
<input
|
||||
class="input-con triangle pointEveNone"
|
||||
v-model="fromValue.birthDate"
|
||||
disabled
|
||||
placeholder="请选择您的出生年月"
|
||||
/>
|
||||
</view>
|
||||
<view class="content-input" @click="changeEducation">
|
||||
<view class="input-titile">学历</view>
|
||||
<input class="input-con triangle" v-model="state.educationText" disabled placeholder="请选择您的学历" />
|
||||
<input
|
||||
class="input-con triangle pointEveNone"
|
||||
v-model="state.educationText"
|
||||
disabled
|
||||
placeholder="请选择您的学历"
|
||||
/>
|
||||
</view>
|
||||
<view class="content-input" @click="changePoliticalAffiliation">
|
||||
<view class="input-titile">政治面貌</view>
|
||||
<input class="input-con triangle" v-model="state.politicalAffiliationText" disabled placeholder="请选择您的政治面貌" />
|
||||
<input
|
||||
class="input-con triangle pointEveNone"
|
||||
v-model="state.politicalAffiliationText"
|
||||
disabled
|
||||
placeholder="请选择您的政治面貌"
|
||||
/>
|
||||
</view>
|
||||
<view class="content-input">
|
||||
<view class="input-titile">手机号码</view>
|
||||
@@ -47,29 +72,29 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { reactive, inject, watch, ref, onMounted } from "vue";
|
||||
import { onLoad, onShow } from "@dcloudio/uni-app";
|
||||
const { $api, navTo, navBack, checkingPhoneRegExp } = inject("globalFunction");
|
||||
import { storeToRefs } from "pinia";
|
||||
import useUserStore from "@/stores/useUserStore";
|
||||
import useDictStore from "@/stores/useDictStore";
|
||||
import { reactive, inject, watch, ref, onMounted } from 'vue';
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app';
|
||||
const { $api, navTo, navBack, checkingPhoneRegExp } = inject('globalFunction');
|
||||
import { storeToRefs } from 'pinia';
|
||||
import useUserStore from '@/stores/useUserStore';
|
||||
import useDictStore from '@/stores/useDictStore';
|
||||
const { userInfo } = storeToRefs(useUserStore());
|
||||
const { getUserResume } = useUserStore();
|
||||
const { dictLabel, oneDictData } = useDictStore();
|
||||
const openSelectPopup = inject("openSelectPopup");
|
||||
const openSelectPopup = inject('openSelectPopup');
|
||||
|
||||
const percent = ref("0%");
|
||||
const percent = ref('0%');
|
||||
const state = reactive({
|
||||
educationText: "",
|
||||
politicalAffiliationText: "",
|
||||
educationText: '',
|
||||
politicalAffiliationText: '',
|
||||
});
|
||||
const fromValue = reactive({
|
||||
name: "",
|
||||
name: '',
|
||||
sex: 0,
|
||||
birthDate: "",
|
||||
education: "",
|
||||
politicalAffiliation: "",
|
||||
avatar: "",
|
||||
birthDate: '',
|
||||
education: '',
|
||||
politicalAffiliation: '',
|
||||
avatar: '',
|
||||
});
|
||||
onLoad(() => {
|
||||
initLoad();
|
||||
@@ -92,23 +117,23 @@ function initLoad() {
|
||||
fromValue.politicalAffiliation = userInfo.value.politicalAffiliation;
|
||||
fromValue.avatar = userInfo.value.avatar;
|
||||
// 回显
|
||||
state.educationText = dictLabel("education", userInfo.value.education);
|
||||
state.politicalAffiliationText = dictLabel("affiliation", userInfo.value.politicalAffiliation);
|
||||
state.educationText = dictLabel('education', userInfo.value.education);
|
||||
state.politicalAffiliationText = dictLabel('affiliation', userInfo.value.politicalAffiliation);
|
||||
const result = getFormCompletionPercent(fromValue);
|
||||
percent.value = result;
|
||||
}
|
||||
const confirm = () => {
|
||||
if (!fromValue.name) {
|
||||
return $api.msg("请输入姓名");
|
||||
return $api.msg('请输入姓名');
|
||||
}
|
||||
if (!fromValue.birthDate) {
|
||||
return $api.msg("请选择出生年月");
|
||||
return $api.msg('请选择出生年月');
|
||||
}
|
||||
if (!fromValue.education) {
|
||||
return $api.msg("请选择学历");
|
||||
return $api.msg('请选择学历');
|
||||
}
|
||||
if (!fromValue.politicalAffiliation) {
|
||||
return $api.msg("请选择政治面貌");
|
||||
return $api.msg('请选择政治面貌');
|
||||
}
|
||||
// if (!checkingPhoneRegExp(fromValue.phone)) {
|
||||
// return $api.msg('请输入正确手机号');
|
||||
@@ -117,8 +142,8 @@ const confirm = () => {
|
||||
...fromValue,
|
||||
age: calculateAge(fromValue.birthDate),
|
||||
};
|
||||
$api.createRequest("/app/user/resume", params, "post").then((resData) => {
|
||||
$api.msg("完成");
|
||||
$api.createRequest('/app/user/resume', params, 'post').then((resData) => {
|
||||
$api.msg('完成');
|
||||
state.disbleDate = true;
|
||||
getUserResume().then(() => {
|
||||
navBack();
|
||||
@@ -128,9 +153,13 @@ const confirm = () => {
|
||||
|
||||
const changeDateBirt = () => {
|
||||
const datearray = generateDatePickerArrays();
|
||||
let defaultIndex = [0, 0, 0];
|
||||
if (fromValue.birthDate) {
|
||||
const defaultIndex = getDatePickerIndexes(fromValue.birthDate);
|
||||
}
|
||||
console.log(defaultIndex);
|
||||
openSelectPopup({
|
||||
title: "年龄段",
|
||||
title: '年龄段',
|
||||
maskClick: true,
|
||||
data: datearray,
|
||||
defaultIndex,
|
||||
@@ -140,16 +169,16 @@ const changeDateBirt = () => {
|
||||
if (isValidDate(dateStr)) {
|
||||
fromValue.birthDate = dateStr;
|
||||
} else {
|
||||
$api.msg("没有这一天");
|
||||
$api.msg('没有这一天');
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
const changeEducation = () => {
|
||||
openSelectPopup({
|
||||
title: "学历",
|
||||
title: '学历',
|
||||
maskClick: true,
|
||||
data: [oneDictData("education")],
|
||||
data: [oneDictData('education')],
|
||||
success: (_, [value]) => {
|
||||
fromValue.education = value.value;
|
||||
state.educationText = value.label;
|
||||
@@ -162,9 +191,9 @@ const changeSex = (sex) => {
|
||||
|
||||
const changePoliticalAffiliation = () => {
|
||||
openSelectPopup({
|
||||
title: "政治面貌",
|
||||
title: '政治面貌',
|
||||
maskClick: true,
|
||||
data: [oneDictData("affiliation")],
|
||||
data: [oneDictData('affiliation')],
|
||||
success: (_, [value]) => {
|
||||
fromValue.politicalAffiliation = value.value;
|
||||
state.politicalAffiliationText = value.label;
|
||||
@@ -181,17 +210,17 @@ function generateDatePickerArrays(startYear = 1975, endYear = new Date().getFull
|
||||
years.push(y.toString());
|
||||
}
|
||||
for (let m = 1; m <= 12; m++) {
|
||||
months.push(m.toString().padStart(2, "0"));
|
||||
months.push(m.toString().padStart(2, '0'));
|
||||
}
|
||||
for (let d = 1; d <= 31; d++) {
|
||||
days.push(d.toString().padStart(2, "0"));
|
||||
days.push(d.toString().padStart(2, '0'));
|
||||
}
|
||||
|
||||
return [years, months, days];
|
||||
}
|
||||
|
||||
function isValidDate(dateString) {
|
||||
const [year, month, day] = dateString.split("-").map(Number);
|
||||
const [year, month, day] = dateString.split('-').map(Number);
|
||||
|
||||
const date = new Date(year, month - 1, day); // 月份从0开始
|
||||
return date.getFullYear() === year && date.getMonth() === month - 1 && date.getDate() === day;
|
||||
@@ -218,22 +247,22 @@ function getFormCompletionPercent(form) {
|
||||
|
||||
for (const key in form) {
|
||||
const value = form[key];
|
||||
if (value !== "" && value !== null && value !== undefined) {
|
||||
if (typeof value === "number") {
|
||||
if (value !== '' && value !== null && value !== undefined) {
|
||||
if (typeof value === 'number') {
|
||||
filled += 1;
|
||||
} else if (typeof value === "string" && value.trim() !== "") {
|
||||
} else if (typeof value === 'string' && value.trim() !== '') {
|
||||
filled += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (total === 0) return "0%";
|
||||
if (total === 0) return '0%';
|
||||
const percent = (filled / total) * 100;
|
||||
return percent.toFixed(0) + "%"; // 取整,不要小数点
|
||||
return percent.toFixed(0) + '%'; // 取整,不要小数点
|
||||
}
|
||||
// 主函数
|
||||
function getDatePickerIndexes(dateStr) {
|
||||
const [year, month, day] = dateStr.split("-");
|
||||
const [year, month, day] = dateStr.split('-');
|
||||
|
||||
const [years, months, days] = generateDatePickerArrays();
|
||||
|
||||
@@ -246,18 +275,17 @@ function getDatePickerIndexes(dateStr) {
|
||||
|
||||
function selectAvatar() {
|
||||
uni.chooseImage({
|
||||
sizeType: ["original", "compressed"],
|
||||
sourceType: ["album", "camera"],
|
||||
sizeType: ['original', 'compressed'],
|
||||
sourceType: ['album', 'camera'],
|
||||
count: 1,
|
||||
success: ({ tempFilePaths, tempFiles }) => {
|
||||
$api
|
||||
.uploadFile(tempFilePaths[0], true)
|
||||
$api.uploadFile(tempFilePaths[0], true)
|
||||
.then((res) => {
|
||||
res = JSON.parse(res);
|
||||
if (res.msg) fromValue.avatar = res.msg;
|
||||
})
|
||||
.catch((err) => {
|
||||
$api.msg("上传失败");
|
||||
$api.msg('上传失败');
|
||||
});
|
||||
},
|
||||
fail: (error) => {},
|
||||
|
||||
Reference in New Issue
Block a user