//index.js //获取应用实例 // const app = require('../../utils/util.js'); const tools = require('../../utils/tools.js'); const app = require('../../utils/util.js'); Page({ data: { nameIsTrue: false, //名字是否填写 cultureIsTrue: false, //文化是否填写 graduationIsTrue: false, //毕业学校 majorIsTrue: false, //所有专业 postIsTrue: false, //现任职务 renzhishijianIsTrue: false, phoneIsTrue: false, //电话 peixunshijianTrue: false, // 培训时间 nameMessage: '', tenure: '', //在线时间 peixunTime: '', //培训时间 headmasterText: '请选择任职时间', // peixunText: '请选择培训时间', radio: '1', username: 'asdsadsad', info: {}, parameter: [{ id: 1, name: '男', value: '1', checked: false }, { id: 2, name: '女', checked: false, value: '0', }], renzhiDate: '', postshow: false, postshow1: false, errorIsTrue: false, currentDate: new Date().getTime(), currentDate1: new Date().getTime(), minDate: new Date().getTime, formatter(type, value) { if (type === 'year') { return `${value}年`; } else if (type === 'month') { return `${value}月`; } return value; }, }, onChange(event) { this.setData({ radio: event.detail, }); }, share() { this.setData({ show: true }); }, onClose() { console.log("11111111111111"); this.setData({ postshow: false }); }, onClose1() { console.log("11111111111111"); this.setData({ postshow1: false }); }, onInput(event) { console.log("000"); this.setData({ currentDate: event.detail, }); }, onInput1(event) { console.log("000"); this.setData({ currentDate1: event.detail, }); }, formatDate(date) { date = new Date(date); return `${date.getFullYear()-1}/${date.getMonth() + 1}/${date.getDate()}`; }, share1() { this.setData({ postshow: true }); }, share() { this.setData({ postshow1: true }); }, formatDate(date) { date = new Date(date); return `${date.getFullYear()-1}/${date.getMonth() + 1}/${date.getDate()}`; }, onConfirm(event) { console.log(event, "0000"); let timeValue = this.timeFormat(new Date(event.detail), "yyyy-MM-dd"); this.setData({ tenure: timeValue, postshow: false, headmasterText: '' }); }, onConfirm1(event) { console.log(event, "0000"); let timeValue = this.timeFormat(new Date(event.detail), "yyyy-MM-dd"); this.setData({ peixunTime: timeValue, postshow1: false, peixunText: '' }); }, parameterTap: function (e) { //e是获取e.currentTarget.dataset.id所以是必备的,跟前端的data-id获取的方式差不多 let that = this let this_checked = e.currentTarget.dataset.id let parameterList = this.data.parameter //获取Json数组 for (let i = 0; i < parameterList.length; i++) { if (parameterList[i].id == this_checked) { parameterList[i].checked = true; //当前点击的位置为true即选中 } else { parameterList[i].checked = false; //其他的位置为false } } that.setData({ parameter: parameterList }) }, formSubmit(e) { console.log(e.detail.value, "000000000000000"); if (!e.detail.value.username) { this.setData({ nameIsTrue: true }) } else { this.setData({ nameIsTrue: false }) } let sex = ''; if (this.data.parameter[0].checked) { sex = this.data.parameter[0].name this.setData({ errorIsTrue: false }) } else if (this.data.parameter[1].checked) { sex = this.data.parameter[1].name this.setData({ errorIsTrue: false }) } else { this.setData({ errorIsTrue: true }) } if (!e.detail.value.work) { this.setData({ workIsTrue: true }) } else { this.setData({ workIsTrue: false }) } if (!e.detail.value.culture) { this.setData({ cultureIsTrue: true }) } else { this.setData({ cultureIsTrue: false }) } if (!e.detail.value.graduation) { this.setData({ graduationIsTrue: true }) } else { this.setData({ graduationIsTrue: false }) } if (!e.detail.value.major) { this.setData({ majorIsTrue: true }) } else { this.setData({ majorIsTrue: false }) } if (!e.detail.value.post) { this.setData({ postIsTrue: true }) } else { this.setData({ postIsTrue: false }) } if (!e.detail.value.phone) { this.setData({ phoneIsTrue: true }) } else { this.setData({ phoneIsTrue: false }) } if (!this.data.tenure) { this.setData({ renzhishijianIsTrue: true }) } else { this.setData({ renzhishijianIsTrue: false }) } if (!this.data.peixunTime) { this.setData({ peixunshijianTrue: true }) } else { this.setData({ peixunshijianTrue: false }) } console.log(this.data.tenure, "在职时间000"); console.log(this.data.peixunTime, "培训时间000"); console.log(sex, "性别的"); e.detail.value.tenure = this.data.tenure; e.detail.value.sessionKey = this.data.sessionKey; console.log(e.detail.value, "我是合并后的锕"); let aa = e.detail.value wx.request({ url: app.globalData.publicUrl + '/wx/upStudent/upStudent', method: "post", data: { studentDept: aa.studentDept, culture: aa.culture, school: aa.school, studentDuty:aa.studentDuty, tenure:aa.tenure, studentPhone:aa.studentPhone, sessionKey: this.data.sessionKey, major:aa.major, }, success: (res) => { console.log(res); } }) }, timeFormat(date, fmt) { let o = { "M+": date.getMonth() + 1, //月份    "d+": date.getDate(), //日 "h+": date.getHours(), //小时    "m+": date.getMinutes(), //分    "s+": date.getSeconds(), //秒    "q+": Math.floor((date.getMonth() + 3) / 3), //季度    "S": date.getMilliseconds() //毫秒    }; if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length)); for (let k in o) if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); return fmt; }, onReady: function () {}, async onLoad() { const sessionKey = await tools.checkSessionAndLogin(); console.log(sessionKey, "000000"); this.setData({ sessionKey: sessionKey }) this.getBanner(sessionKey); }, getBanner(sessionKey) { console.log(sessionKey, "sessionKey"); wx.request({ url: app.globalData.publicUrl + '/wx/student/selStudentSessionKeyEcho', method: "post", data: { sessionKey: sessionKey, }, success: (res) => { if (res.data.code == 0) { console.log(res, "suoyoude"); this.data.parameter.forEach(item => { if (item.value == res.data.data.studentSex) { item.checked = true; } }) console.log(this.data.parameter); this.setData({ info: res.data.data, parameter: this.data.parameter }) } } }) }, })