// pages/jobDetail/editDetail/index.js const app = getApp(); Page({ /** * 页面的初始数据 */ data: { array: ['时薪', '日薪', '补贴', '返费', '计件', '保底', '面议', '月薪'], index: 0, jobDetail: {}, name: "", defaultValue: "", title: "", timeValue:"" }, bindPickerChange: function (e) { console.log('picker发送选择改变,携带值为', e.detail.value) this.setData({ index: e.detail.value }) }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { this.setData({ jobDetail: wx.getStorageSync('jobDetail') }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { var that = this; var currName = this.data.name console.log(that.data.jobDetail); console.log(that.data.jobDetail.storeJob.minMonthlyPay+"==="+that.data.jobDetail.storeJob.maxMonthlyPay) console.log(that.getRangeName(that.data.jobDetail.storeJob.minMonthlyPay, that.data.jobDetail.storeJob.maxMonthlyPay)); that.setData({ defaultValue: that.getRangeName(that.data.jobDetail.storeJob.minMonthlyPay, that.data.jobDetail.storeJob.maxMonthlyPay), index: that.data.jobDetail.storeJob.salaryClassify, timeValue:that.data.jobDetail.storeJob.salaryClassifyValue / 100 }) console.log(that.data.jobDetail); }, formSubmit(e) { var that = this; wx.showLoading({ title: '提交中...', }) if(app.isEmptyCheck(e.detail.value.MonthlyPay)){ wx.showToast({ title: '综合月薪不能为空', icon: 'none', duration: 1000 }) wx.hideLoading({ success: (res) => {}, }) return } let currData = {}; currData["storeJobId"] = that.data.jobDetail.storeJob.id; if(that.data.index != 4 && that.data.index != 6 && that.data.index != 7){ currData["salaryClassifyValue"] = e.detail.value.salaryClassifyValue * 100; } currData["salaryClassify"] = that.data.index; if (app.isNotEmptyCheck(e.detail.value.MonthlyPay)) { var mrArr = e.detail.value.MonthlyPay.split("-"); if (mrArr.length == 1) { currData["minMonthlyPay"] = mrArr[0] * 100; } else if (mrArr.length == 2) { currData["minMonthlyPay"] = mrArr[0] * 100; currData["maxMonthlyPay"] = mrArr[1] * 100; } } wx.request({ url: app.globalData.ip + "/store/job/updateJobSalary", header: app.globalData.header, data: currData, method: "POST", success: function (res) { // console.log(res.data); // that.setData({ // record: res.data.data, // }); wx.setStorageSync('isLoad', true); wx.showToast({ title: '修改成功', icon: 'success', duration: 1000 }) setTimeout(function () { wx.navigateBack({ delta: 1, }) }, 1000) // debugger; }, fail: function (res) { console.log(res); }, }); wx.hideLoading({ success: (res) => {}, }) }, getRangeName(_min, _max, _fixed = true, _lowName = "最低", _highName = "最高") { if (_fixed) { if (app.isNotEmptyCheck(_min) && app.isNotEmptyCheck(_max)) { return this.moneyToFixed(_min) + "-" + this.moneyToFixed(_max); } else if (!app.isNotEmptyCheck(_min) && app.isNotEmptyCheck(_max)) { return this.moneyToFixed(_max); //return _highName + moneyToFixed(_max); } else if (app.isNotEmptyCheck(_min) && !app.isNotEmptyCheck(_max)) { return this.moneyToFixed(_min); //return _lowName + moneyToFixed(_min); } else { return "-"; } } else { if (app.isNotEmptyCheck(_min) && app.isNotEmptyCheck(_max)) { return _min + "-" + _max; } else if (!app.isNotEmptyCheck(_min) && app.isNotEmptyCheck(_max)) { return _max; // return _highName + _max; } else if (app.isNotEmptyCheck(_min) && !app.isNotEmptyCheck(_max)) { return _min; // return _lowName + _min; } else { return "-"; } } }, moneyToFixed(money, fixed = 2, multiplicator = 1) { if (money != 0 && money != null && money != "" && money != undefined) { return this.cutZero(new Number(money / multiplicator).toFixed(fixed)); } return "0"; }, cutZero(old) { //拷贝一份 返回去掉零的新串 let newstr = old; //循环变量 小数部分长度 var leng = old.length - old.indexOf(".") - 1; //判断是否有效数 if (old.indexOf(".") > -1) { //循环小数部分 for (var i = leng; i > 0; i--) { //如果newstr末尾有0 if (newstr.lastIndexOf("0") > -1 && newstr.substr(newstr.length - 1, 1) == 0) { var k = newstr.lastIndexOf("0"); //如果小数点后只有一个0 去掉小数点 if (newstr.charAt(k - 1) == ".") { return newstr.substring(0, k - 1); } else { //否则 去掉一个0 newstr = newstr.substring(0, k); } } else { //如果末尾没有0 return newstr; } } } return old; }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })