348 lines
8.5 KiB
TypeScript
348 lines
8.5 KiB
TypeScript
// pages/certification/certification.ts
|
|
import { informationAdd } from '../../apis/information'
|
|
|
|
// import { uploadImg } from "../../apis/upload";
|
|
const app = getApp<IAppOption>()
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
// date: '',
|
|
now: new Date(),
|
|
formName: '',
|
|
// form: {
|
|
startDate: '',
|
|
endDate: '',
|
|
jyjg: '',
|
|
bq: '',
|
|
zymc: '',
|
|
// zybh: '',
|
|
zycc: '',
|
|
xz: '',
|
|
sfqrz: '',
|
|
jyjg1: '',
|
|
zyms: '',
|
|
fj: '',
|
|
// 非学历额外
|
|
jycp: '',
|
|
// cpbh: '',
|
|
cpms: '',
|
|
jgms: '',
|
|
//
|
|
dwmc: '',
|
|
dwjs: '',
|
|
// },
|
|
fileList: [],
|
|
countPic: 9,//上传图片最大数量
|
|
showImgUrl: "", //路径拼接,一般上传返回的都是文件名,
|
|
uploadImgUrl: '',//图片的上传的路径,
|
|
options: [{ name: '全日制' }, { name: '非全日制' }],
|
|
zyccOptions: [{ name: '专科' }, { name: '本科' }, { name: '硕士研究生' }, { name: '博士研究生' }],
|
|
jyjgOptions: [{ name: '在读' }, { name: '结业' }, { name: '毕业' }, { name: '肄业' }],
|
|
xzOptions: [{ name: '二年制' }, { name: '三年制' }, { name: '四年制' }, { name: '五年制' }],
|
|
endDateTyeps: [{ name: '当天', value: 0 }, { name: '至今', value: 1 }, { name: '时间选择', value: 2 }],
|
|
endDateType: '',
|
|
// businessNameAuthenticationTag: undefined
|
|
},
|
|
bindDateChange(e) {
|
|
this.setData({
|
|
[e.currentTarget.dataset.key]: e.detail.value
|
|
})
|
|
},
|
|
radioChange(e) {
|
|
console.log(e);
|
|
const value = Number(e.detail.value)
|
|
switch (value) {
|
|
case 0:
|
|
this.setData({
|
|
endDate: '当天',
|
|
endDateType: value
|
|
})
|
|
break;
|
|
case 1:
|
|
this.setData({
|
|
endDate: '至今',
|
|
endDateType: value
|
|
})
|
|
break;
|
|
case 2:
|
|
this.setData({
|
|
endDate: '',
|
|
endDateType: value
|
|
})
|
|
break;
|
|
}
|
|
|
|
},
|
|
// bindSfqrzChange(e: WechatMiniprogram.CustomEvent) {
|
|
// this.setData({
|
|
// value: this.data.options[e.detail.value].name
|
|
// })
|
|
// },
|
|
bindZyccChange(e: WechatMiniprogram.CustomEvent) {
|
|
this.setData({
|
|
zycc: this.data.zyccOptions[e.detail.value].name
|
|
})
|
|
},
|
|
bindJyjgChange(e: WechatMiniprogram.CustomEvent) {
|
|
this.setData({
|
|
jyjg1: this.data.jyjgOptions[e.detail.value].name
|
|
})
|
|
},
|
|
xzChange(e: WechatMiniprogram.CustomEvent) {
|
|
this.setData({
|
|
xz: this.data.xzOptions[e.detail.value].name
|
|
})
|
|
},
|
|
handleCreate() {
|
|
// console.log(this.data);
|
|
// console.log('handleCreate');
|
|
|
|
let { startDate, endDate, bq, zymc, zycc, xz, sfqrz, jyjg, jyjg1, zyms, fj, fileList
|
|
, jycp, cpms, jgms
|
|
, dwmc, dwjs, formName, educationStage } = this.data
|
|
|
|
if (formName === '职业经历') {
|
|
if (!dwmc) {
|
|
wx.showToast({
|
|
icon: 'none',
|
|
title: `请输入单位名称`
|
|
})
|
|
return
|
|
}
|
|
}
|
|
if (!startDate) {
|
|
// console.log('请选择开始时间');
|
|
|
|
wx.showToast({
|
|
icon: 'none',
|
|
title: `请选择开始时间`
|
|
})
|
|
return
|
|
}
|
|
if (!endDate) {
|
|
wx.showToast({
|
|
icon: 'none',
|
|
title: `请选择结束时间`
|
|
})
|
|
return
|
|
}
|
|
if (new Date(startDate).getTime() > new Date(endDate).getTime()) {
|
|
wx.showToast({
|
|
icon: 'none',
|
|
title: `时间范围不正确`
|
|
})
|
|
return
|
|
}
|
|
if (formName === '学历教育' || formName === '非学历教育') {
|
|
console.log(this.data);
|
|
|
|
if (!jyjg) {
|
|
wx.showToast({
|
|
icon: 'none',
|
|
title: `请输入教育机构`
|
|
})
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
let payload = {}
|
|
if (this.data.formName === '学历教育') {
|
|
// payload = {
|
|
// '学历教育': [{
|
|
// '教育机构': jyjg,
|
|
// '时间': startDate + (endDate ? ',' + endDate : ''),
|
|
// '班期': bq,
|
|
// '专业名称': zymc,
|
|
// '专业层次': zycc,
|
|
// '学制': xz,
|
|
// '是否全日制': sfqrz,
|
|
// '教育结果': jyjg1,
|
|
// '专业描述': zyms,
|
|
// '附件': fileList.map(item => item.url).toString()
|
|
// }]
|
|
// }
|
|
payload = {
|
|
// businessNameAuthenticationName: '',
|
|
// businessNameAuthenticationTag: '',
|
|
educationStage,
|
|
jsonObject: {
|
|
'学历教育': [{
|
|
'教育机构': jyjg,
|
|
'时间': startDate + (endDate ? ',' + endDate : ''),
|
|
'班期': bq,
|
|
'专业名称': zymc,
|
|
'专业层次': zycc,
|
|
'学制': xz,
|
|
'是否全日制': sfqrz,
|
|
'教育结果': jyjg1,
|
|
'专业描述': zyms,
|
|
'附件': fileList.map(item => item.url).toString()
|
|
}]
|
|
}
|
|
}
|
|
if (this.data.businessNameAuthenticationTag !== undefined) {
|
|
payload.businessNameAuthenticationName = jyjg
|
|
payload.businessNameAuthenticationTag = this.data.businessNameAuthenticationTag
|
|
}
|
|
console.log(payload);
|
|
|
|
|
|
} else if (this.data.formName === '非学历教育') {
|
|
payload = {
|
|
jsonObject: {
|
|
'非学历教育': [{
|
|
'教育机构': jyjg,
|
|
'时间': startDate + (endDate ? ',' + endDate : ''),
|
|
'班期': bq,
|
|
'教育产品': jycp,
|
|
'教育结果': jyjg1,
|
|
'产品描述': cpms,
|
|
'机构描述': jgms,
|
|
'附件': fileList.map(item => item.url).toString()
|
|
}]
|
|
}
|
|
}
|
|
if (this.data.businessNameAuthenticationTag !== undefined) {
|
|
payload.businessNameAuthenticationName = jyjg
|
|
payload.businessNameAuthenticationTag = this.data.businessNameAuthenticationTag
|
|
}
|
|
|
|
} else if (this.data.formName === '职业经历') {
|
|
payload = {
|
|
jsonObject: {
|
|
'职业经历': [{
|
|
'单位名称': dwmc,
|
|
'时间': startDate + (endDate ? ',' + endDate : ''),
|
|
'单位介绍': cpms,
|
|
'附件': fileList.map(item => item.url).toString()
|
|
}]
|
|
}
|
|
}
|
|
if (this.data.businessNameAuthenticationTag !== undefined) {
|
|
payload.businessNameAuthenticationName = dwmc
|
|
payload.businessNameAuthenticationTag = this.data.businessNameAuthenticationTag
|
|
}
|
|
}
|
|
// console.log(payload);
|
|
|
|
informationAdd(payload).then((res: any) => {
|
|
if (res.c === 200) {
|
|
wx.reLaunch({
|
|
url: '/pages/information/information',
|
|
})
|
|
}
|
|
})
|
|
},
|
|
optionsChange(e: WechatMiniprogram.CustomEvent) {
|
|
console.log(e);
|
|
|
|
this.setData({
|
|
sfqrz: this.data.options[e.detail.value].name
|
|
})
|
|
},
|
|
zyccChange(e: WechatMiniprogram.CustomEvent) {
|
|
console.log(e);
|
|
|
|
this.setData({
|
|
zycc: this.data.zyccOptions[e.detail.value].name
|
|
})
|
|
},
|
|
|
|
handleDeleteFile(e: WechatMiniprogram.CustomEvent) {
|
|
console.log(e);
|
|
|
|
let { fileList } = this.data
|
|
fileList.splice(e.currentTarget.dataset.index, 1)
|
|
this.setData({
|
|
fileList
|
|
})
|
|
},
|
|
//监听组件事件,返回的结果
|
|
myEventListener: function (e: WechatMiniprogram.CustomEvent) {
|
|
console.log("上传的图片结果集合")
|
|
console.log(e.detail.picsList)
|
|
this.setData({
|
|
fileList: e.detail.picsList
|
|
})
|
|
},
|
|
jumpAddAuthName(e) {
|
|
wx.navigateTo({
|
|
url: `/pages/addAuthName/addAuthName?formName=${e.currentTarget.dataset.key}`
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad() {
|
|
this.setData({
|
|
formName: wx.getStorageSync('informationName'),
|
|
educationStage:wx.getStorageSync('educationStage')
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow() {
|
|
// console.log('onshow');
|
|
// console.log(this.data.jyjg, this.data.businessNameAuthenticationTag)
|
|
|
|
// let pages = getCurrentPages();
|
|
// let currPage = pages[pages.length - 1];
|
|
// console.log(currPage.data);
|
|
// if (currPage.data.jyjg) {
|
|
// this.setData({
|
|
// //将携带的参数赋值
|
|
// jyjg: currPage.data.jyjg,
|
|
// businessNameAuthenticationTag: currPage.data.courseid,
|
|
// });
|
|
// }
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage() {
|
|
|
|
}
|
|
}) |