feat : 新增编辑,添加,删除工作经历功能, 修改我的简历页,

perf : 全局navTo方法新增延迟(更好的表现动画)
This commit is contained in:
2025-11-11 15:10:39 +08:00
parent e19230dae5
commit fa267c9796
10 changed files with 642 additions and 25 deletions

View File

@@ -67,7 +67,7 @@ html {
} }
.btn-feel { .btn-feel {
transition: transform 0.2s ease; transition: transform 0.18s ease;
transform-style: preserve-3d; transform-style: preserve-3d;
} }

View File

@@ -51,6 +51,7 @@ const prePage = () => {
/** /**
* 页面跳转封装,支持 query 参数传递和返回回调 * 页面跳转封装,支持 query 参数传递和返回回调
* @param {string} url - 跳转路径 * @param {string} url - 跳转路径
@@ -59,17 +60,22 @@ const prePage = () => {
* @param {object} options.query - 携带参数 * @param {object} options.query - 携带参数
* @param {function} options.onBack - 页面返回时的回调(目标页调用 uni.navigateBack 时传递数据) * @param {function} options.onBack - 页面返回时的回调(目标页调用 uni.navigateBack 时传递数据)
*/ */
let isJumping = false
export const navTo = function(url, { export const navTo = function(url, {
needLogin = false, needLogin = false,
query = {}, query = {},
onBack = null onBack = null
} = {}) { } = {}) {
const userStore = useUserStore(); const userStore = useUserStore();
if(isJumping) return
isJumping=true
if (needLogin && !userStore.hasLogin) { if (needLogin && !userStore.hasLogin) {
uni.navigateTo({ setTimeout(() => {
url: '/pages/login/login' uni.navigateTo({
}); url: '/pages/login/login'
});
isJumping=false
}, 190);
return; return;
} }
@@ -84,9 +90,12 @@ export const navTo = function(url, {
currentPage.__onBackCallback__ = onBack; currentPage.__onBackCallback__ = onBack;
} }
uni.navigateTo({ setTimeout(() => {
url: finalUrl uni.navigateTo({
}); url: finalUrl
});
isJumping=false
}, 190);
}; };
export const navBack = function({ export const navBack = function({

View File

@@ -0,0 +1,327 @@
<template>
<uni-popup
ref="popup"
type="bottom"
borderRadius="10px 10px 0 0"
background-color="#FFFFFF"
:mask-click="maskClick"
>
<view class="popup-content">
<view class="popup-header">
<view class="btn-cancel" @click="cancel">取消</view>
<view class="title">{{ title }}</view>
<view class="btn-confirm" @click="confirm">确认</view>
</view>
<view class="popup-list">
<picker-view
indicator-style="height: 84rpx;"
:value="selectedIndex"
@change="bindChange"
class="picker-view"
>
<picker-view-column>
<view
v-for="(year, index) in years"
:key="index"
class="item"
:class="{ 'item-active': selectedIndex[0] === index }"
>
<text>{{ year }}</text>
<text></text>
</view>
</picker-view-column>
<picker-view-column>
<view
v-for="(month, index) in months"
:key="index"
class="item"
:class="{ 'item-active': selectedIndex[1] === index }"
>
<text>{{ month }}</text>
<text></text>
</view>
</picker-view-column>
<picker-view-column>
<view
v-for="(day, index) in days"
:key="index"
class="item"
:class="{ 'item-active': selectedIndex[2] === index }"
>
<text>{{ day }}</text>
<text></text>
</view>
</picker-view-column>
</picker-view>
</view>
</view>
</uni-popup>
</template>
<script>
export default {
name: 'datePicker',
data() {
return {
maskClick: false,
title: '选择日期',
confirmCallback: null,
cancelCallback: null,
changeCallback: null,
selectedIndex: [0, 0, 0],
selectedDate: '',
// 日期数据
years: [],
months: [],
days: [],
// 配置
startYear: 0,
endYear: 0,
};
},
created() {
this.initDateData();
},
methods: {
// 初始化日期数据
initDateData() {
const currentYear = new Date().getFullYear();
this.startYear = currentYear - 50; // 往前50年
this.endYear = currentYear + 10; // 往后10年
// 生成年份
this.years = [];
for (let i = this.startYear; i <= this.endYear; i++) {
this.years.push(i);
}
// 生成月份
this.months = [];
for (let i = 1; i <= 12; i++) {
this.months.push(i);
}
// 初始天数(默认当前年月)
this.updateDays(this.years[0], this.months[0]);
},
// 根据年月更新天数
updateDays(year, month) {
const daysInMonth = new Date(year, month, 0).getDate();
this.days = [];
for (let i = 1; i <= daysInMonth; i++) {
this.days.push(i);
}
},
open(config = {}) {
const {
title = '选择日期',
success,
cancel,
change,
maskClick = false,
defaultDate = '',
} = config;
this.reset();
this.title = title;
if (typeof success === 'function') this.confirmCallback = success;
if (typeof cancel === 'function') this.cancelCallback = cancel;
if (typeof change === 'function') this.changeCallback = change;
this.maskClick = maskClick;
// 设置默认选中
this.setDefaultDate(defaultDate);
this.$nextTick(() => {
this.$refs.popup.open();
});
},
close() {
this.$refs.popup.close();
},
// 设置默认日期
setDefaultDate(dateStr) {
if (!dateStr) {
// 没有默认日期,使用当前日期
const now = new Date();
const year = now.getFullYear();
const month = now.getMonth() + 1;
const day = now.getDate();
this.selectedIndex = [
this.years.findIndex(y => y === year),
this.months.findIndex(m => m === month),
this.days.findIndex(d => d === day)
];
} else {
// 解析日期字符串 (支持 YYYY-MM-DD 格式)
const [year, month, day] = dateStr.split('-').map(Number);
this.selectedIndex = [
this.years.findIndex(y => y === year),
this.months.findIndex(m => m === month),
this.days.findIndex(d => d === day)
];
}
// 确保索引有效
this.selectedIndex = this.selectedIndex.map((index, i) =>
index === -1 ? 0 : index
);
this.updateSelectedDate();
},
bindChange(e) {
this.selectedIndex = e.detail.value;
// 检查是否需要更新天数
const oldDaysLength = this.days.length;
const selectedYear = this.years[this.selectedIndex[0]];
const selectedMonth = this.months[this.selectedIndex[1]];
this.updateDays(selectedYear, selectedMonth);
// 如果天数变化且当前选择的日期超过新月份的天数,调整日期索引
if (this.days.length !== oldDaysLength && this.selectedIndex[2] >= this.days.length) {
this.selectedIndex[2] = this.days.length - 1;
}
this.updateSelectedDate();
// 触发change回调
this.changeCallback && this.changeCallback(this.selectedDate, this.selectedIndex);
},
// 更新选中的日期字符串
updateSelectedDate() {
const year = this.years[this.selectedIndex[0]];
const month = this.months[this.selectedIndex[1]].toString().padStart(2, '0');
const day = this.days[this.selectedIndex[2]].toString().padStart(2, '0');
this.selectedDate = `${year}-${month}-${day}`;
},
cancel() {
this.clickCallback(this.cancelCallback);
},
confirm() {
this.clickCallback(this.confirmCallback);
},
async clickCallback(callback) {
if (typeof callback !== 'function') {
this.$refs.popup.close();
return;
}
try {
const result = await callback(this.selectedDate, this.selectedIndex);
if (result !== false) {
this.$refs.popup.close();
}
} catch (error) {
console.error('callback 执行出错:', error);
}
},
reset() {
this.maskClick = false;
this.confirmCallback = null;
this.cancelCallback = null;
this.changeCallback = null;
this.selectedIndex = [0, 0, 0];
this.selectedDate = '';
this.title = '选择日期';
},
// 设置日期范围
setDateRange(startYear, endYear) {
this.startYear = startYear;
this.endYear = endYear;
// 重新生成年份
this.years = [];
for (let i = this.startYear; i <= this.endYear; i++) {
this.years.push(i);
}
// 重置选中索引
this.selectedIndex[0] = 0;
this.updateDays(this.years[0], this.months[0]);
},
},
};
</script>
<style lang="scss" scoped>
.popup-content {
color: #000000;
height: 50vh;
}
.popup-list {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
justify-content: space-evenly;
flex: 1;
overflow: hidden;
.picker-view {
width: 100%;
height: calc(50vh - 100rpx);
margin-top: 20rpx;
.uni-picker-view-mask {
background: rgba(0, 0, 0, 0);
}
.item {
line-height: 84rpx;
height: 84rpx;
text-align: center;
font-weight: 400;
font-size: 32rpx;
color: #cccccc;
display: flex;
align-items: center;
justify-content: center;
gap: 8rpx;
}
.item-active {
color: #333333;
}
.uni-picker-view-indicator:after {
border-color: #e3e3e3;
}
.uni-picker-view-indicator:before {
border-color: #e3e3e3;
}
}
}
.popup-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 40rpx 40rpx 10rpx 40rpx;
.title {
font-weight: 500;
font-size: 36rpx;
color: #333333;
text-align: center;
}
.btn-cancel {
font-weight: 400;
font-size: 32rpx;
color: #666d7f;
line-height: 38rpx;
}
.btn-confirm {
font-weight: 400;
font-size: 32rpx;
color: #256bfa;
}
}
</style>

View File

@@ -206,6 +206,9 @@ function getFormCompletionPercent(form) {
height: 80rpx; height: 80rpx;
border-bottom: 2rpx solid #EBEBEB border-bottom: 2rpx solid #EBEBEB
position: relative; position: relative;
.triangle {
pointer-events: none;
}
.triangle::before .triangle::before
position: absolute; position: absolute;
right: 20rpx; right: 20rpx;

View File

@@ -39,12 +39,10 @@
<view class="mys-line"> <view class="mys-line">
<view class="line"></view> <view class="line"></view>
</view> </view>
<view class="mys-info"> <view class="mys-info btn-feel">
<view class="mys-h4"> <view class="mys-h4">
<text>求职期望</text> <view>求职期望</view>
<view class="mys-edit-icon"> <image class="icon " src="@/static/icon/edit1.png" @click="navTo('/packageA/pages/jobExpect/jobExpect')"></image>
<image class="button-click" src="@/static/icon/edit1.png" @click="navTo('/packageA/pages/jobExpect/jobExpect')"></image>
</view>
</view> </view>
<view class="mys-text"> <view class="mys-text">
<text>期望薪资</text> <text>期望薪资</text>
@@ -64,15 +62,17 @@
</view> </view>
<view class="card-top" style="margin-top: 24rpx"> <view class="card-top" style="margin-top: 24rpx">
<view class="mys-info" style="padding: 0"> <view class="mys-info" style="padding: 0">
<view class="mys-h4"> <view class="mys-h4 btn-feel">
<text>工作经历</text> <text>工作经历</text>
<view class="mys-edit-icon"> <view class="mys-edit-icon btn-feel" @click="navTo('/packageA/pages/workExp/workExp')">
<image class="button-click" src="@/static/icon/edit1.png" @click="navTo('/packageA/pages/jobExpect/jobExpect')"></image> <image class=" icon button-click btn-feel" src="@/static/icon/plus.png" ></image>
<view class="txt">添加</view>
</view> </view>
</view> </view>
<view class="exp-item" v-for="item in userInfo.workExp" :key="item.id"> <view class="exp-item btn-feel" v-for="item in userInfo.workExp" :key="item.id">
<view class="fl_box fl_justbet mar_top10"> <view class="fl_box fl_justbet mar_top15">
<text class="fs_16">{{ item.company }}</text> <view class="fs_16">{{ item.company }}</view>
<image class="icon btn-feel" src="@/static/icon/edit1.png" @click="navTo(`/packageA/pages/workExp/workExp?id=${item.id}`)"></image>
</view> </view>
<view class="mys-text fl_box fl_justbet"> <view class="mys-text fl_box fl_justbet">
<text class="color_333333 fs_14">{{ item.position }}</text> <text class="color_333333 fs_14">{{ item.position }}</text>
@@ -87,7 +87,7 @@
</view> </view>
<template #footer> <template #footer>
<view class="footer-container"> <view class="footer-container">
<view class="footer-button">上传简历</view> <view class="footer-button btn-feel">上传简历</view>
</view> </view>
</template> </template>
</AppLayout> </AppLayout>
@@ -212,10 +212,25 @@ image{
display: flex; display: flex;
justify-content: space-between justify-content: space-between
align-items: center align-items: center
.mys-edit-icon{ .icon{
display: inline-block
width: 40rpx; width: 40rpx;
height: 40rpx height: 40rpx
}
.mys-edit-icon{
display: flex;
align-items: center;
.txt{
font-size: 26rpx;
color: #444;
font-weight: 400;
}
.icon{
width: 28rpx;
height: 28rpx
margin-right: 5rpx;
margin-top: 2rpx
vertical-align: bottom;
}
} }
} }
.datetext{ .datetext{
@@ -247,7 +262,10 @@ image{
.exp-item{ .exp-item{
padding-bottom: 28rpx; padding-bottom: 28rpx;
border-bottom: 2rpx dashed #EEEEEE; border-bottom: 2rpx dashed #EEEEEE;
.icon{
width 40rpx;
height 40rpx
}
} }
.exp-item:nth-last-child(1){ .exp-item:nth-last-child(1){
border-bottom: none; border-bottom: none;

View File

@@ -250,8 +250,15 @@ function selectAvatar() {
sourceType: ["album", "camera"], sourceType: ["album", "camera"],
count: 1, count: 1,
success: ({ tempFilePaths, tempFiles }) => { success: ({ tempFilePaths, tempFiles }) => {
console.log(`选择的图片:${tempFilePaths}`); $api
console.warn("没有做后续上传逻辑!!!!!!!"); .uploadFile(tempFilePaths[0], true)
.then((res) => {
res = JSON.parse(res);
if (res.msg) fromValue.avatar = res.msg;
})
.catch((err) => {
$api.msg("上传失败");
});
}, },
fail: (error) => {}, fail: (error) => {},
}); });
@@ -284,6 +291,7 @@ function selectAvatar() {
.avatar{ .avatar{
width:110rpx; width:110rpx;
height: 110rpx; height: 110rpx;
border-radius: 50%;
} }
} }
.content-input .content-input

View File

@@ -0,0 +1,245 @@
<template>
<AppLayout title="工作经历" border back-gorund-color="#ffffff" :show-bg-image="false">
<template #headerleft>
<view class="btn mar_le20 button-click" @click="navBack">取消</view>
</template>
<template #headerright>
<view class="btn mar_ri20 button-click blue" @click="confirm">确认</view>
</template>
<view class="content">
<view class="content-input">
<view class="input-titile">公司</view>
<input class="input-con" v-model="fromValue.company" placeholder="请输入公司名称" />
</view>
<view class="content-input">
<view class="input-titile">岗位</view>
<input class="input-con" v-model="fromValue.position" placeholder="请输入岗位" />
</view>
<view class="content-input">
<view class="input-titile">时间</view>
<view class="flex-box">
<view class="input-box btn-feel" @click="changestartTime">
<input v-model="fromValue.startTime" class="input-con triangle" disabled placeholder="开始时间" />
<image class="icon" src="@/static/icon/arrow-down.png" />
</view>
<view class="gap">-</view>
<view class="input-box btn-feel" @click="changeendTime">
<input v-model="fromValue.endTime" class="input-con triangle" disabled placeholder="至今" />
<image class="icon" src="@/static/icon/arrow-down.png" />
</view>
</view>
</view>
<view class="content-input">
<view class="input-titile">工作内容</view>
<textarea class="text-area" placeholder="请输入工作内容" v-model="fromValue.duty"></textarea>
</view>
</view>
<!-- 时间选择器组件 -->
<DatePicker ref="datePicker" />
<template #footer v-if="fromValue.id">
<view class="footer-container">
<view class="footer-button btn-feel" @click="delCurrent">删除该工作经历</view>
</view>
</template>
</AppLayout>
</template>
<script setup>
import { reactive, inject, watch, ref, onMounted, computed } from "vue";
import { onLoad, onShow } from "@dcloudio/uni-app";
const { $api, navTo, navBack } = inject("globalFunction");
import { storeToRefs } from "pinia";
import useUserStore from "@/stores/useUserStore";
import useDictStore from "@/stores/useDictStore";
import DatePicker from "@/components/DatePicker/DatePicker.vue";
const { userInfo } = storeToRefs(useUserStore());
const { getUserResume } = useUserStore();
const { dictLabel, oneDictData } = useDictStore();
// 初始化数据
const fromValue = reactive({
position: "",
company: "",
startTime: "",
endTime: "",
duty: "",
id: undefined,
});
// 获取时间选择器组件的引用
const datePicker = ref();
onLoad((e) => {
initLoad(e?.id);
});
const confirm = async () => {
// 验证必填字段
if (!fromValue.company) {
return $api.msg("请输入公司名称");
}
if (!fromValue.position) {
return $api.msg("请输入岗位");
}
if (!fromValue.startTime) {
return $api.msg("请选择开始时间");
}
// 验证时间逻辑:结束时间不能早于开始时间
if (fromValue.endTime && new Date(fromValue.endTime) < new Date(fromValue.startTime)) {
return $api.msg("结束时间不能早于开始时间");
}
let res;
try {
if (fromValue.id) {
res = await $api.createRequest("/app/user/experience/edit", fromValue, "post");
} else {
res = await $api.createRequest("/app/user/experience/save", fromValue, "post");
}
$api.msg("保存成功");
getUserResume().then(() => {
navBack();
});
} catch (error) {
$api.msg("保存失败");
}
};
function delCurrent() {
uni.showModal({
title: "提示",
content: "确认要删除此条工作经历吗?",
showCancel: true,
success: async ({ confirm, cancel }) => {
if (confirm) {
await $api.createRequest("/app/user/experience/delete", { id: fromValue.id }, "post");
$api.msg("删除成功");
getUserResume().then(() => {
navBack();
});
}
},
});
}
function initLoad(id) {
if (!id) return;
$api
.createRequest(`/app/user/experience/getSingle/${id}`, {}, "get")
.then((res) => {
Object.assign(fromValue, res.data);
})
.catch((err) => {
console.error("获取工作经历失败:", err);
});
}
// 选择开始时间
const changestartTime = () => {
console.log(1);
datePicker.value.open({
title: "选择开始时间",
defaultDate: fromValue.startTime,
success: (selectedDate) => {
fromValue.startTime = selectedDate;
},
});
};
// 选择结束时间
const changeendTime = () => {
datePicker.value.open({
title: "选择结束时间",
defaultDate: fromValue.endTime,
success: (selectedDate) => {
fromValue.endTime = selectedDate;
// 如果结束时间早于新的开始时间,清空结束时间
if (fromValue.startTime && new Date(fromValue.startTime) > new Date(selectedDate)) {
fromValue.endTime = "";
$api.msg("结束时间不能小于开始时间!");
}
},
});
};
</script>
<style lang="scss" scoped>
.btn.blue {
color: #1677ff;
}
.content {
padding: 28rpx;
display: flex;
flex-direction: column;
justify-content: flex-start;
height: calc(100% - 120rpx);
}
.flex-box {
display: flex;
align-items: center;
.gap {
font-size: 40rpx;
font-weight: bold;
flex: 0.25;
text-align: center;
}
.icon {
width: 75rpx;
height: 50rpx;
}
.input-box {
flex: 0.375;
display: flex;
align-items: center;
}
}
.content-input {
margin-bottom: 48rpx;
padding-bottom: 20rpx;
border-bottom: 2rpx solid #ebebeb;
&:nth-last-of-type(1) {
border-bottom: none;
}
.input-titile {
font-weight: 400;
font-size: 28rpx;
color: #6a6a6a;
margin-bottom: 10rpx;
}
.input-con {
font-weight: 400;
font-size: 32rpx;
color: #333333;
line-height: 80rpx;
height: 80rpx;
position: relative;
}
.triangle {
pointer-events: none;
}
.text-area {
width: 100%;
height: 700rpx;
background: #f5f5f5;
padding: 20rpx;
box-sizing: border-box;
}
}
.footer-container {
background: #ffffff;
box-shadow: 0rpx -4rpx 24rpx 0rpx rgba(11, 44, 112, 0.12);
border-radius: 0rpx 0rpx 0rpx 0rpx;
padding: 40rpx 28rpx 20rpx 28rpx;
.footer-button {
width: 100%;
height: 90rpx;
background: #f93a4a;
border-radius: 8rpx;
color: #ffffff;
line-height: 90rpx;
text-align: center;
}
}
</style>

View File

@@ -175,6 +175,13 @@
"navigationStyle": "custom" "navigationStyle": "custom"
} }
}, },
{
"path": "pages/workExp/workExp",
"style": {
"navigationBarTitleText": "工作经历",
"navigationStyle": "custom"
}
},
{ {
"path": "pages/reservation/reservation", "path": "pages/reservation/reservation",
"style": { "style": {

BIN
static/icon/arrow-down.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 341 B

BIN
static/icon/plus.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 B