|
|
const app = getApp();
|
|
|
Page({
|
|
|
|
|
|
data: {
|
|
|
information: "## **认证须知**\n1. 根据职业上传相应的证件照:教师(教师证),专业人士(员工证)、学生(学生证),请确保证件照内容完整并且清晰可见,**严禁PS**;\n\n2. 我们将在你提交职业证信息后的24小时(不包含节假日)内完成审核,审核结果将会以系统消息的形式发送给你;\n\n3. 职业认证审核完成后,**无法删除**,请谨慎填写;职业变更请选择重新认证;\n\n4. 职业认证审核完成后,系统将自动发放500个金币作为奖励;\n\n5. 我们会确保你所提供的信息均处于严格的保密状态,不会泄露;\n\n6. 如存在恶意乱填写姓名,学号,及上传与职业证件无关图片者,一经发现将**冻结EduCoder账号**。\n\n7. 非老师身份提交职业认证后系统会自动将状态改为已认证,你将可以体验平台需要职业认证的功能;如果在认证后的使用过程中未通过审核,你将不能继续体验需要认证的功能。\n\n",
|
|
|
imgDir: global.config.imgDir,
|
|
|
identities: [{ value: "teacher", text: "教师" }, { value: "student", text: "学生" }, { value: "professional", text: "专业人士" }],
|
|
|
technicalTitles: {
|
|
|
0: ["教授", "副教授", "讲师", "助教"],
|
|
|
2: ["企业管理者", "部门管理者", "高级工程师", "工程师", "助理工程师"]
|
|
|
}
|
|
|
},
|
|
|
onShow(){
|
|
|
let data = wx.getStorageSync("SET-SCHOOL-DEPARTMENT-KEY");
|
|
|
if (data) {
|
|
|
this.changeSchoolDepartment(data);
|
|
|
wx.setStorageSync("SET-SCHOOL-DEPARTMENT-KEY", '');
|
|
|
}
|
|
|
},
|
|
|
onLoad() {
|
|
|
this.refresh();
|
|
|
},
|
|
|
refresh() {
|
|
|
app.api("users.accounts")()
|
|
|
.then(res => {
|
|
|
let { identity, school_id, school_name, department_id,department_name,id:user_id,student_id} = res;
|
|
|
let identity_index = -1;
|
|
|
let { identities } = this.data;
|
|
|
for (var i = 0; i < identities.length; i++) {
|
|
|
if (identities[i].value == res.identity) {
|
|
|
identity_index = i;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var technical_index = -1;
|
|
|
if (identity_index == 0 || identity_index == 2) {
|
|
|
let technicals = this.data.technicalTitles[identity_index];
|
|
|
for (var i = 0; i < technicals.length; i++) {
|
|
|
if (technicals[i] == res.technical_title) {
|
|
|
technical_index = i;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
this.setData({ identity_index, technical_index, school_id, school_name, department_id, department_name, user_id, student_id});
|
|
|
if(res.school_id)
|
|
|
this.changeSchoolDepartment(res);
|
|
|
})
|
|
|
},
|
|
|
changeSchoolDepartment({ school_name, school_id, department_id, department_name }) {
|
|
|
this.setData({ departments: [], department_id, department_name, school_id, school_name });
|
|
|
app.api("schools.departments.for_option")({ school_id })
|
|
|
.then(res => {
|
|
|
let { departments } = res;
|
|
|
let department_index = -1;
|
|
|
for (var i = 0; i < departments.length; i++) {
|
|
|
if (departments[i].id == department_id) {
|
|
|
department_index = i;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
this.setData({ departments, department_index });
|
|
|
});
|
|
|
},
|
|
|
onIdentityChange(e) {
|
|
|
console.log(e);
|
|
|
let { detail: { value } } = e;
|
|
|
this.setData({ identity_index: value, technical_index: -1 });
|
|
|
},
|
|
|
onTechnicalChange(e) {
|
|
|
console.log(e);
|
|
|
let { detail: { value } } = e;
|
|
|
this.setData({ technical_index: value });
|
|
|
},
|
|
|
onDepartmentChange(e) {
|
|
|
console.log(e);
|
|
|
let { detail: { value } } = e;
|
|
|
this.setData({ department_index: value });
|
|
|
},
|
|
|
onSubmit(e) {
|
|
|
console.log(e);
|
|
|
let { detail: { value } } = e;
|
|
|
if (!this.checkInput(value)) return;
|
|
|
value.attachment_ids[0] = parseInt(value.attachment_ids[0]);
|
|
|
app.api("users.accounts.professional_auth_apply")(value)
|
|
|
.then(res => {
|
|
|
res.message = "职业认证提交成功";
|
|
|
app.showMsg(res);
|
|
|
let db = wx.cloud.database();
|
|
|
db.collection("data").add({
|
|
|
data: {
|
|
|
name: "users.accounts.professional_auth_apply",
|
|
|
res,
|
|
|
createdAt: db.serverDate()
|
|
|
}
|
|
|
});
|
|
|
}).catch(e => {
|
|
|
app.showError(e);
|
|
|
})
|
|
|
},
|
|
|
checkInput(value) {
|
|
|
if (!value.identity)
|
|
|
return wx.showToast({ title: '请选择职业', icon: "none" }) && false;
|
|
|
if (!value.extra)
|
|
|
return wx.showToast({ title:value.identity=='student'?'请输入学号':'请选择职称', icon: "none" }) && false;
|
|
|
if (!value.school_id)
|
|
|
return wx.showToast({ title: value.identity == 'professional' ? '请选择单位' : '请选择学校', icon: "none" }) && false;
|
|
|
if(!value.department_id)
|
|
|
return wx.showToast({ title: value.identity == 'professional' ? '请选择部门' : '请选择院系', icon: "none" }) && false;
|
|
|
if (value.attachment_ids.length == 0)
|
|
|
return wx.showToast({ title: '请上传职业证照片', icon: "none" }) && false;
|
|
|
return true;
|
|
|
},
|
|
|
upload() {
|
|
|
wx.chooseImage({
|
|
|
count: 1,
|
|
|
success: res => {
|
|
|
let file = res.tempFilePaths[0];
|
|
|
wx.showLoading({
|
|
|
title: '上传中',
|
|
|
})
|
|
|
app.api("attachments")({ file, success: wx.hideLoading })
|
|
|
.then(res => {
|
|
|
this.setData({ image_path: file, attachment_id: res.id });
|
|
|
}).catch(e => {
|
|
|
app.showError(e);
|
|
|
})
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
}) |