// pages/jobHistory/index.js const app = getApp(); const commonUtil = require("../../utils/commonUtil.js"); Page({ /** * 页面的初始数据 */ data: { date: '2016-09-01', // multiArray: [['2000年', '2001年'], ['01月', '02月', '03月', '04月', '05月'], ['-'],['2000年', '2001年'], ['01月', '02月', '03月', '04月', '05月']], multiArray: commonUtil.getDateArrayOfScope(), multiIndex: [0, 0, 0,0,0], id: '', userExperienceDetails: {}, }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { var that = this; // options['id'] = 8; var date=new Date; var yearIndex = that.data.multiArray[0].length - 1; var monthIndex = date.getMonth(); that.data.multiIndex[0] = yearIndex; that.data.multiIndex[1] = monthIndex; that.data.multiIndex[3] = yearIndex; that.data.multiIndex[4] = monthIndex; if (app.isNotEmptyCheck(options.id)) { that.data.id = options.id; that.getUserExperienceDetails(); } else { that.setData({ multiIndex: that.data.multiIndex }); } }, getUserExperienceDetails: function() { var that = this; wx.request({ url: app.globalData.ip + '/user/experience/getUserExperienceDetails?id=' + that.data.id, data: {}, header: app.globalData.headers, method: "GET", success: function (res) { console.log(res); if (res.data.status == 200) { that.data.userExperienceDetails = res.data.data; if (app.isNotEmptyCheck(that.data.userExperienceDetails.startDate) && app.isNotEmptyCheck(that.data.userExperienceDetails.endDate)) { var startDate = new Date(that.data.userExperienceDetails.startDate); var yearIndex = startDate.getFullYear() - 1990; var monthIndex = startDate.getMonth(); that.data.multiIndex[0] = yearIndex; that.data.multiIndex[1] = monthIndex; var endDate = new Date(that.data.userExperienceDetails.endDate); yearIndex = endDate.getFullYear() - 1990; monthIndex = endDate.getMonth(); that.data.multiIndex[3] = yearIndex; that.data.multiIndex[4] = monthIndex; } that.setData({ id: that.data.id, userExperienceDetails: that.data.userExperienceDetails, multiIndex: that.data.multiIndex, }); } else if (res.data.status == 9999) { // app.dialogNotLogin(); } else { app.showTips(that, res.data.msg); } } }) }, deleteRecord:function(e){ var that = this; wx.showModal({ title: '提示', content: '确定要删除该工作经历吗?', cancelColor:"#666666", confirmColor:"#027AFF", success (res) { if (res.confirm) { console.log('用户点击确定') that.deleteUserExperience(); } else if (res.cancel) { console.log('用户点击取消') } } }) }, deleteUserExperience: function() { var that = this; wx.request({ url: app.globalData.ip + '/user/experience/deleteUserExperience?id=' + that.data.id, data: {}, header: app.globalData.headers, method: "GET", success: function (res) { console.log(res); if (res.data.status == 200) { wx.showToast({ title: '删除成功', icon: 'success', image: '', duration: 1500, mask: true, success: function(res) { wx.navigateBack({ delta: 1 }) }, fail: function(res) { wx.hideLoading(); }, complete: function(res) {}, }) } else if (res.data.status == 9999) { // app.dialogNotLogin(); } else { app.showTips(that, res.data.msg); } } }) }, onSubmit: function (e) { var that = this; var formData = e.detail.value; console.log(formData); formData['id'] = that.data.id; var startDate = that.data.multiArray[0][that.data.multiIndex[0]].replace('年', '-') + that.data.multiArray[1][that.data.multiIndex[1]].replace('月', '-') + '01'; var endDate = that.data.multiArray[3][that.data.multiIndex[3]].replace('年', '-') + that.data.multiArray[4][that.data.multiIndex[4]].replace('月', '-') + '01'; formData['startDate'] = startDate; formData['endDate'] = endDate; console.log(formData); wx.request({ url: app.globalData.ip + '/user/experience/addOrUpdateUserExperience', data: formData, header: app.globalData.headers, method: "POST", success: function (res) { console.log(res); if (res.data.status == 200) { wx.showToast({ title: '保存成功', icon: 'success', image: '', duration: 1500, mask: true, success: function(res) { wx.navigateBack({ delta: 1 }) }, fail: function(res) { wx.hideLoading(); }, complete: function(res) {}, }) } else if (res.data.status == 9999) { // app.dialogNotLogin(); } else { app.showTips(that, res.data.msg); } } }) }, bindMultiPickerChange: function (e) { console.log('picker发送选择改变,携带值为', e.detail.value) this.setData({ multiIndex: e.detail.value }) }, bindDateChange: function(e) { console.log('picker发送选择改变,携带值为', e.detail.value) this.setData({ date: e.detail.value }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })