公寓小程序端前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

340 lines
8.7 KiB

import { getUserInfo, bindIdCard } from "../../../api/user";
import { dictDataList, getDetailByGraduateId, graduateInfoCollection,getPostListByType } from "../../../api/index";
// import { checkContentStatus } from "../../../../api/audit";
// const QQMapWX = require("../../../../utils/qqmap-wx-jssdk");
// const config = require("../../../../utils/config");
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
name: '',
nickName: "微信用户",
idCard: null,
mobile: null,
remainingDays: null,
fileList: [
// {
// url: "https://elink-esua-epdc.oss-cn-qingdao.aliyuncs.com/epmet/test/20240830/de2ccb0304eb4bab9513d11472fb3454.png",
// type: "image",
// name: "image",
// },
],
areaOptions: [],
industryOptions: [],
positionOptions: [],
salaryOptions: [],
showArea: false,
showIndustry: false,
showPosition: false,
showSalary: false,
areaValue: '',
industryValue: '',
positionValue: '',
salaryValue: '',
areaName: '',
industryName: '',
positionName: '',
salaryName: '',
form: {},
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.getDictData();
},
async getDictData() {
try {
const res1 = await dictDataList({ dictType: 'sys_career' });
if (res1.code === 200) {
this.setData({
industryOptions: [
{ text: '行业', value: '' },
...res1.rows.map(item => ({
text: item.dictLabel,
value: item.dictValue,
...item
}))
]
});
}
const res2 = await dictDataList({ dictType: 'sys_salary' });
if (res2.code === 200) {
this.setData({
salaryOptions: [
{ text: '薪资', value: '' },
...res2.rows.map(item => ({
text: item.dictLabel,
value: item.dictValue,
...item
}))
]
});
}
const res3 = await dictDataList({ dictType: 'working_place' });
if (res3.code === 200) {
this.setData({
areaOptions: [
{ text: '区域', value: '' },
...res3.rows.map(item => ({
text: item.dictLabel,
value: item.dictValue,
...item
}))
]
});
}
this.getUserInfo();
} catch (error) {
console.error('获取字典数据失败:', error);
}
},
async getPostListByType() {
const res = await getPostListByType({ type: this.data.industryName });
if (res.code === 200) {
// 重置岗位选项,确保"岗位"选项在最前面
const basePositionOptions = [{ text: '岗位', value: '' }];
const newPositionOptions = res.data.map(item => ({
text: item,
value: item,
}));
this.setData({
positionOptions: [
...basePositionOptions,
...newPositionOptions
],
});
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() { },
/**
* 生命周期函数--监听页面显示
*/
onShow() { },
/**
* 生命周期函数--监听页面隐藏
*/
onHide() { },
/**
* 生命周期函数--监听页面卸载
*/
onUnload() { },
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() { },
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() { },
chooseAvatar() {
wx.chooseMedia({
count: 1, // 最多选择 1 张图片
mediaType: ["image"], // 只选择图片
success: (res) => {
if (res.tempFiles.length > 0) {
const tempFilePath = res.tempFiles[0].tempFilePath;
this.setData({
avatarUrl: tempFilePath,
});
// 如果你需要将图片上传到服务器,可以在这里添加上传逻辑
// wx.uploadFile({
// url: 'your_upload_url',
// filePath: tempFilePath,
// name: 'avatar',
// success: (uploadRes) => {
// console.log('上传成功', uploadRes);
// },
// fail: (err) => {
// console.error('上传失败', err);
// }
// });
}
},
fail: (err) => {
console.error("选择图片失败", err);
},
});
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() { },
getUserInfo() {
getUserInfo().then((res) => {
this.setData({
nickName: res.data.nickName,
idCard: res.data.idCard,
name: res.data.name || '',
mobile: res.data.phone,
remainingDays: res.data.leftQuota,
});
});
getDetailByGraduateId({ graduateId: app.globalData.userInfo.graduateId }).then((res) => {
if (res.code === 200) {
this.setData({
areaName: this.data.areaOptions.find(item => item.dictValue == res.data.hopeWorkAddress)?.text || '',
industryName: this.data.industryOptions.find(item => item.dictValue == res.data.hopeCareer)?.text || '',
positionName: res.data.hopePosition || '',
positionValue: res.data.hopePosition ||'',
salaryName: this.data.salaryOptions.find(item => item.dictValue == res.data.hopeSalary)?.text || '',
form: res.data,
areaValue: res.data.hopeWorkAddress,
industryValue: res.data.hopeCareer,
salaryValue: res.data.hopeSalary,
});
if(this.data.industryName){
this.getPostListByType();
}
}
}).catch(err=>{
if(err.data){
this.setData({
areaName: this.data.areaOptions.find(item => item.dictValue == err.data.hopeWorkAddress)?.text || '',
industryName: this.data.industryOptions.find(item => item.dictValue == err.data.hopeCareer)?.text || '',
positionName: res.data.hopePosition || '',
positionValue: err.data.hopePosition ||'',
salaryName: this.data.salaryOptions.find(item => item.dictValue == err.data.hopeSalary)?.text || '',
form: err.data,
areaValue: err.data.hopeWorkAddress,
industryValue: err.data.hopeCareer,
salaryValue: err.data.hopeSalary,
});
if(this.data.industryName){
this.getPostListByType();
}
}
});
},
onsubmit() {
if (this.data.idCard.length !== 18) {
wx.showToast({
title: '请确认身份证号',
icon: 'none'
})
return false
}
bindIdCard({
idCard: this.data.idCard,
name: this.data.name,
phone: this.data.mobile,
}).then((res) => {
if (res.code == 200) {
let parm = {
hopeCareer : this.data.industryValue,
hopeSalary : this.data.salaryValue,
hopeWorkAddress : this.data.areaValue,
hopePosition : this.data.positionValue,
id:this.data.form.id,
graduateId:this.data.form.graduateId,
}
graduateInfoCollection(parm).then((res) => {
if (res.code == 200) {
wx.showToast({
title: res.msg,
});
}
}).catch(err=>{
wx.showToast({
title: err.msg,
icon:"none"
});
});
}
});
},
onChangeArea() {
this.setData({
showArea: true,
});
},
onChangeIndustry() {
this.setData({
showIndustry: true,
});
},
onChangePosition() {
this.setData({
showPosition: true,
});
},
onChangeSalary() {
this.setData({
showSalary: true,
});
},
confirmArea(e) {
this.setData({
areaValue: e.detail.value.value,
showArea: false,
areaName: e.detail.value.text,
});
},
confirmIndustry(e) {
this.setData({
industryValue: e.detail.value.value,
showIndustry: false,
industryName: e.detail.value.text,
});
this.getPostListByType();
},
confirmPosition(e) {
this.setData({
positionValue: e.detail.value.value,
showPosition: false,
positionName: e.detail.value.text,
});
},
confirmSalary(e) {
this.setData({
salaryValue: e.detail.value.value,
showSalary: false,
salaryName: e.detail.value.text,
});
},
onCancelArea() {
this.setData({
showArea: false,
areaName: '',
areaValue: '',
});
},
onCancelIndustry() {
this.setData({
showIndustry: false,
industryName: '',
industryValue: '',
industryValue: '',
});
},
onCancelPosition() {
this.setData({
showPosition: false,
positionName: '',
positionValue: '',
});
},
onCancelSalary() {
this.setData({
showSalary: false,
salaryName: '',
salaryValue: '',
});
},
});