Initial commit
This commit is contained in:
@@ -0,0 +1,181 @@
|
||||
|
||||
// pages/developer/join/index.js
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
languageLabels: [],
|
||||
frontLabels: [],
|
||||
backendLabels: [],
|
||||
languageSelected: [],
|
||||
frontSelected: [],
|
||||
backendSelected: [],
|
||||
desc: '',
|
||||
job: '',
|
||||
workYears: 0,
|
||||
contact: '',
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取基础配置
|
||||
*/
|
||||
getConfig() {
|
||||
wx.$util.request(wx.$api.CommonGetMiniConfig, {}, 'GET').then(res => {
|
||||
if (res.code === 1) {
|
||||
this.setData({
|
||||
languageLabels: res.data.languageLabels,
|
||||
frontLabels: res.data.frontLabels,
|
||||
backendLabels: res.data.backendLabels,
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
handleGroupChange(event) {
|
||||
console.log('group', event.detail.value);
|
||||
const { field } = event.currentTarget.dataset; // 获取 data-field 的值
|
||||
console.log(field);
|
||||
this.setData({
|
||||
[field + 'Selected']: event.detail.value, // 动态设置对应的Selected数组
|
||||
});
|
||||
},
|
||||
|
||||
onInputChange(e) {
|
||||
console.log(e)
|
||||
const value = e.detail.value;
|
||||
const { field } = e.currentTarget.dataset; // 获取 data-field 的值
|
||||
console.log(value)
|
||||
console.log(field)
|
||||
this.setData({
|
||||
[field]: value // 使用动态属性名设置值
|
||||
});
|
||||
},
|
||||
onSubmit() {
|
||||
const { backendSelected, frontSelected, languageSelected, contact, job, workYears, desc } = this.data;
|
||||
|
||||
const validations = [
|
||||
{
|
||||
condition: !backendSelected.length && !frontSelected.length && !languageSelected.length,
|
||||
message: '技能不能为空'
|
||||
},
|
||||
{
|
||||
condition: !job.trim(),
|
||||
message: '职称不能为空'
|
||||
},
|
||||
{
|
||||
condition: workYears == 0,
|
||||
message: '年限不能为空'
|
||||
},
|
||||
{
|
||||
condition: !contact.trim(),
|
||||
message: '请填写联系方式'
|
||||
},
|
||||
{
|
||||
condition: !desc.trim(),
|
||||
message: '简介不能为空'
|
||||
}
|
||||
];
|
||||
|
||||
for (const validation of validations) {
|
||||
if (validation.condition) {
|
||||
wx.showToast({
|
||||
title: validation.message,
|
||||
icon: 'error',
|
||||
duration: 2000
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
wx.requestSubscribeMessage({
|
||||
tmplIds: ['ctqgNLWaHJ7RRnu9LwWTxu_g21lKil5v5Gv-Pg7XOE8'],
|
||||
complete: (re) => {
|
||||
wx.$util.request(wx.$api.DeveloperSubmit, {
|
||||
backendSelected: backendSelected,
|
||||
frontSelected: frontSelected,
|
||||
languageSelected: languageSelected,
|
||||
job: job,
|
||||
contact: contact,
|
||||
work_years: workYears,
|
||||
desc: desc,
|
||||
}, 'POST').then(res => {
|
||||
if (res.code === 1) {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
showCancel: false,
|
||||
content: res.msg || '提交成功',
|
||||
success: (res2) => {
|
||||
if (res2.confirm) {
|
||||
wx.navigateBack({ delta: 1 });
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
wx.showToast({
|
||||
title: res.msg || '提交失败',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
this.getConfig();
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user