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