|
|
@ -198,14 +198,13 @@ var _default = { |
|
|
name: '', |
|
|
name: '', |
|
|
phone: '', |
|
|
phone: '', |
|
|
sex: '', |
|
|
sex: '', |
|
|
sexText: '', |
|
|
|
|
|
|
|
|
// sexText: '',
|
|
|
area: '', |
|
|
area: '', |
|
|
areaText: '', |
|
|
|
|
|
address: '', |
|
|
address: '', |
|
|
career: '', |
|
|
career: '', |
|
|
careerText: '', |
|
|
|
|
|
|
|
|
// careerText: '',
|
|
|
qualifications: '', |
|
|
qualifications: '', |
|
|
qualificationsText: '', |
|
|
|
|
|
|
|
|
// qualificationsText: '',
|
|
|
skill: '' |
|
|
skill: '' |
|
|
}, |
|
|
}, |
|
|
emergencyData: { |
|
|
emergencyData: { |
|
|
@ -261,14 +260,32 @@ var _default = { |
|
|
areas: [], |
|
|
areas: [], |
|
|
//区
|
|
|
//区
|
|
|
pickerValue: [0, 0, 0], |
|
|
pickerValue: [0, 0, 0], |
|
|
defaultValue: [3442, 1, 2], |
|
|
|
|
|
professionOptions: [['学生', '教师', '医生', '工程师', '设计师', '销售', '服务员', '公务员', '自由职业', '专业技术人员', '其他']], |
|
|
|
|
|
educationOptions: [['高中及以下', '大专', '本科', '硕士', '博士']] |
|
|
|
|
|
|
|
|
defaultValue: [3442, 1, 2] |
|
|
|
|
|
|
|
|
|
|
|
// professionOptions: [[
|
|
|
|
|
|
// '学生', '教师', '医生', '工程师', '设计师', '销售',
|
|
|
|
|
|
// '服务员', '公务员', '自由职业', '专业技术人员', '其他'
|
|
|
|
|
|
// ]],
|
|
|
|
|
|
|
|
|
|
|
|
// educationOptions: [[
|
|
|
|
|
|
// '高中及以下', '大专', '本科', '硕士', '博士'
|
|
|
|
|
|
// ]]
|
|
|
}; |
|
|
}; |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
computed: { |
|
|
computed: { |
|
|
addressList: function addressList() { |
|
|
addressList: function addressList() { |
|
|
return [this.provinces, this.citys, this.areas]; |
|
|
return [this.provinces, this.citys, this.areas]; |
|
|
|
|
|
}, |
|
|
|
|
|
professionOptions: function professionOptions() { |
|
|
|
|
|
return [this.$store.state.careerList.map(function (item) { |
|
|
|
|
|
return item.title; |
|
|
|
|
|
})]; |
|
|
|
|
|
}, |
|
|
|
|
|
educationOptions: function educationOptions() { |
|
|
|
|
|
return [this.$store.state.qualificationList.map(function (item) { |
|
|
|
|
|
return item.title; |
|
|
|
|
|
})]; |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
onLoad: function onLoad(options) { |
|
|
onLoad: function onLoad(options) { |
|
|
@ -279,6 +296,9 @@ var _default = { |
|
|
}, |
|
|
}, |
|
|
created: function created() { |
|
|
created: function created() { |
|
|
this.getAddressData(); |
|
|
this.getAddressData(); |
|
|
|
|
|
// 调试store数据
|
|
|
|
|
|
console.log('Store careerList:', this.$store.state.careerList); |
|
|
|
|
|
console.log('Store qualificationList:', this.$store.state.qualificationList); |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
// 加载已有数据(编辑模式)
|
|
|
// 加载已有数据(编辑模式)
|
|
|
@ -287,14 +307,14 @@ var _default = { |
|
|
name: data.name || '李双欢', |
|
|
name: data.name || '李双欢', |
|
|
phone: data.phone || '15478451233', |
|
|
phone: data.phone || '15478451233', |
|
|
sex: data.sex || '男', |
|
|
sex: data.sex || '男', |
|
|
sexText: data.sex || '男', |
|
|
|
|
|
|
|
|
// sexText: data.sex || '男',
|
|
|
area: data.area || '湖南省长沙市区', |
|
|
area: data.area || '湖南省长沙市区', |
|
|
areaText: data.area || '湖南省长沙市区', |
|
|
areaText: data.area || '湖南省长沙市区', |
|
|
address: data.address || '阳光小区45栋二单元1203', |
|
|
address: data.address || '阳光小区45栋二单元1203', |
|
|
career: data.career || '专业技术人员', |
|
|
career: data.career || '专业技术人员', |
|
|
careerText: data.career || '专业技术人员', |
|
|
|
|
|
|
|
|
// careerText: data.career || '专业技术人员',
|
|
|
qualifications: data.qualifications || '本科', |
|
|
qualifications: data.qualifications || '本科', |
|
|
qualificationsText: data.qualifications || '本科', |
|
|
|
|
|
|
|
|
// qualificationsText: data.qualifications || '本科',
|
|
|
skill: data.skill || '计算机、跑步' |
|
|
skill: data.skill || '计算机、跑步' |
|
|
}; |
|
|
}; |
|
|
this.emergencyData = { |
|
|
this.emergencyData = { |
|
|
@ -308,18 +328,18 @@ var _default = { |
|
|
try { |
|
|
try { |
|
|
// 直接使用导入的地区数据(已简化,只包含name字段)
|
|
|
// 直接使用导入的地区数据(已简化,只包含name字段)
|
|
|
this.provinces = _chinaRegions.default; |
|
|
this.provinces = _chinaRegions.default; |
|
|
console.log('成功加载地区数据,省份数量:', this.provinces.length); |
|
|
|
|
|
|
|
|
// console.log('成功加载地区数据,省份数量:', this.provinces.length);
|
|
|
this.handlePickValueDefault(); |
|
|
this.handlePickValueDefault(); |
|
|
uni.showToast({ |
|
|
|
|
|
title: '地区数据加载成功', |
|
|
|
|
|
icon: 'success' |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
// uni.showToast({
|
|
|
|
|
|
// title: '地区数据加载成功',
|
|
|
|
|
|
// icon: 'success'
|
|
|
|
|
|
// });
|
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
console.error('加载地区数据失败:', error); |
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
title: '地区数据加载失败', |
|
|
|
|
|
icon: 'error' |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
// console.error('加载地区数据失败:', error);
|
|
|
|
|
|
// uni.showToast({
|
|
|
|
|
|
// title: '地区数据加载失败',
|
|
|
|
|
|
// icon: 'error'
|
|
|
|
|
|
// });
|
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
handlePickValueDefault: function handlePickValueDefault() { |
|
|
handlePickValueDefault: function handlePickValueDefault() { |
|
|
@ -360,8 +380,7 @@ var _default = { |
|
|
}, |
|
|
}, |
|
|
// 性别选择确认
|
|
|
// 性别选择确认
|
|
|
onGenderConfirm: function onGenderConfirm(value) { |
|
|
onGenderConfirm: function onGenderConfirm(value) { |
|
|
this.formData.sex = value[0]; |
|
|
|
|
|
this.formData.sexText = value[0]; |
|
|
|
|
|
|
|
|
this.formData.sex = value.value[0]; |
|
|
}, |
|
|
}, |
|
|
// 地区选择变化(三级联动)
|
|
|
// 地区选择变化(三级联动)
|
|
|
onAddressChange: function onAddressChange(e) { |
|
|
onAddressChange: function onAddressChange(e) { |
|
|
@ -390,8 +409,8 @@ var _default = { |
|
|
onAddressConfirm: function onAddressConfirm(e) { |
|
|
onAddressConfirm: function onAddressConfirm(e) { |
|
|
console.log('确认选择的地区:', e); |
|
|
console.log('确认选择的地区:', e); |
|
|
if (e.value && e.value.length >= 3) { |
|
|
if (e.value && e.value.length >= 3) { |
|
|
this.formData.address = "".concat(e.value[0].name, "/").concat(e.value[1].name, "/").concat(e.value[2].name); |
|
|
|
|
|
this.formData.addressText = this.formData.address; |
|
|
|
|
|
|
|
|
var selectedArea = "".concat(e.value[0].name, "/").concat(e.value[1].name, "/").concat(e.value[2].name); |
|
|
|
|
|
this.formData.area = selectedArea; // 给area字段赋值用于表单验证
|
|
|
uni.showToast({ |
|
|
uni.showToast({ |
|
|
icon: 'success', |
|
|
icon: 'success', |
|
|
title: '地区选择成功' |
|
|
title: '地区选择成功' |
|
|
@ -405,13 +424,13 @@ var _default = { |
|
|
}, |
|
|
}, |
|
|
// 职业选择确认
|
|
|
// 职业选择确认
|
|
|
onProfessionConfirm: function onProfessionConfirm(value) { |
|
|
onProfessionConfirm: function onProfessionConfirm(value) { |
|
|
this.formData.career = value[0]; |
|
|
|
|
|
this.formData.careerText = value[0]; |
|
|
|
|
|
|
|
|
console.log('职业选择确认:', value.value[0]); |
|
|
|
|
|
this.formData.career = value.value[0]; |
|
|
}, |
|
|
}, |
|
|
// 学历选择确认
|
|
|
// 学历选择确认
|
|
|
onEducationConfirm: function onEducationConfirm(value) { |
|
|
onEducationConfirm: function onEducationConfirm(value) { |
|
|
this.formData.qualifications = value[0]; |
|
|
|
|
|
this.formData.qualificationsText = value[0]; |
|
|
|
|
|
|
|
|
console.log('学历选择确认:', value.value[0]); |
|
|
|
|
|
this.formData.qualifications = value.value[0]; |
|
|
}, |
|
|
}, |
|
|
// 提交申请
|
|
|
// 提交申请
|
|
|
submitApplication: function submitApplication() { |
|
|
submitApplication: function submitApplication() { |
|
|
@ -449,50 +468,63 @@ var _default = { |
|
|
_context.next = 12; |
|
|
_context.next = 12; |
|
|
return _this.submitVolunteerApplication(); |
|
|
return _this.submitVolunteerApplication(); |
|
|
case 12: |
|
|
case 12: |
|
|
uni.showToast({ |
|
|
|
|
|
title: '申请提交成功', |
|
|
|
|
|
icon: 'success' |
|
|
|
|
|
}); |
|
|
|
|
|
setTimeout(function () { |
|
|
|
|
|
uni.navigateBack(); |
|
|
|
|
|
}, 1500); |
|
|
|
|
|
_context.next = 20; |
|
|
|
|
|
|
|
|
_context.next = 18; |
|
|
break; |
|
|
break; |
|
|
case 16: |
|
|
|
|
|
_context.prev = 16; |
|
|
|
|
|
|
|
|
case 14: |
|
|
|
|
|
_context.prev = 14; |
|
|
_context.t0 = _context["catch"](0); |
|
|
_context.t0 = _context["catch"](0); |
|
|
console.error('提交失败:', _context.t0); |
|
|
console.error('提交失败:', _context.t0); |
|
|
uni.showToast({ |
|
|
uni.showToast({ |
|
|
title: '提交失败,请重试', |
|
|
title: '提交失败,请重试', |
|
|
icon: 'none' |
|
|
icon: 'none' |
|
|
}); |
|
|
}); |
|
|
case 20: |
|
|
|
|
|
_context.prev = 20; |
|
|
|
|
|
|
|
|
case 18: |
|
|
|
|
|
_context.prev = 18; |
|
|
_this.submitting = false; |
|
|
_this.submitting = false; |
|
|
return _context.finish(20); |
|
|
|
|
|
case 23: |
|
|
|
|
|
|
|
|
return _context.finish(18); |
|
|
|
|
|
case 21: |
|
|
case "end": |
|
|
case "end": |
|
|
return _context.stop(); |
|
|
return _context.stop(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}, _callee, null, [[0, 16, 20, 23]]); |
|
|
|
|
|
|
|
|
}, _callee, null, [[0, 14, 18, 21]]); |
|
|
}))(); |
|
|
}))(); |
|
|
}, |
|
|
}, |
|
|
// 提交志愿者申请API
|
|
|
// 提交志愿者申请API
|
|
|
submitVolunteerApplication: function submitVolunteerApplication() { |
|
|
submitVolunteerApplication: function submitVolunteerApplication() { |
|
|
var _this2 = this; |
|
|
var _this2 = this; |
|
|
return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() { |
|
|
return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() { |
|
|
|
|
|
var res; |
|
|
return _regenerator.default.wrap(function _callee2$(_context2) { |
|
|
return _regenerator.default.wrap(function _callee2$(_context2) { |
|
|
while (1) { |
|
|
while (1) { |
|
|
switch (_context2.prev = _context2.next) { |
|
|
switch (_context2.prev = _context2.next) { |
|
|
case 0: |
|
|
case 0: |
|
|
return _context2.abrupt("return", new Promise(function (resolve) { |
|
|
|
|
|
|
|
|
// 要求通过title获取id
|
|
|
|
|
|
_this2.formData.career = _this2.$store.state.careerList.find(function (item) { |
|
|
|
|
|
return item.title === _this2.formData.career; |
|
|
|
|
|
}).id; |
|
|
|
|
|
_this2.formData.qualifications = _this2.$store.state.qualificationList.find(function (item) { |
|
|
|
|
|
return item.title === _this2.formData.qualifications; |
|
|
|
|
|
}).id; |
|
|
|
|
|
_context2.next = 4; |
|
|
|
|
|
return _this2.$api.home.applyVolunteer(_objectSpread(_objectSpread({}, _this2.formData), _this2.emergencyData)); |
|
|
|
|
|
case 4: |
|
|
|
|
|
res = _context2.sent; |
|
|
|
|
|
if (res.code === 200) { |
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
title: "".concat(res.message), |
|
|
|
|
|
icon: 'none' |
|
|
|
|
|
}); |
|
|
setTimeout(function () { |
|
|
setTimeout(function () { |
|
|
console.log('志愿者申请数据:', _objectSpread(_objectSpread({}, _this2.formData), _this2.emergencyData)); |
|
|
|
|
|
resolve(); |
|
|
|
|
|
|
|
|
uni.navigateBack(); |
|
|
}, 1000); |
|
|
}, 1000); |
|
|
})); |
|
|
|
|
|
case 1: |
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
title: res.msg, |
|
|
|
|
|
icon: 'none' |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
case 6: |
|
|
case "end": |
|
|
case "end": |
|
|
return _context2.stop(); |
|
|
return _context2.stop(); |
|
|
} |
|
|
} |
|
|
|