You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

167 lines
3.1 KiB
JavaScript

// pages/editPolicy/index.js
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
policy:'',
orderId:'',
name:'',
url:app.globalData.ip + "/user/apply/order/updateInfo"
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
var that = this;
console.log(options.orderId);
// console.log(options.policy);
this.setData({
policy:options.policy,
orderId:options.orderId,
name:options.name
})
if(options.name == 'policy'){
wx.setNavigationBarTitle({
title: '代理政策',
})
}else if(options.name == 'employeeSalary'){
wx.getStorage({
key: 'employeeSalary',
success (res) {
that.setData({
policy:res.data
})
}
})
// console.log(localStorage.getItem('employeeSalary'))
wx.setNavigationBarTitle({
title: '员工薪资',
})
}else if(options.name == 'totalProfit'){
wx.setNavigationBarTitle({
title: '总利润',
})
}else if(options.name == 'interviewDesp'){
wx.setNavigationBarTitle({
title: '面试说明',
})
}
},
cancelForm(){
wx.navigateBack({
delta: -1,
})
},
formSubmit(e) {
var that = this;
wx.showLoading({
title: '提交中...',
})
console.log(e.detail);
if(app.isEmptyCheck(e.detail.value.textarea)){
wx.showToast({
title: '内容不能为空',
icon: 'error',
duration: 1000
})
wx.hideLoading();
return
}
let currData = {};
currData["fieldName"] = that.data.name;
currData["fieldValue"] = e.detail.value.textarea;
// if(this.data.name == 'policy'){
// currData["policy"] = e.detail.value.textarea;
// }else{
// currData["employeeSalary"] = e.detail.value.textarea;
// }
currData["orderId"] = that.data.orderId;
wx.request({
url: that.data.url,
header: app.globalData.header,
method: "POST",
data: currData,
success: function (res) {
wx.showToast({
title: '修改成功',
icon: 'success',
duration: 1000
})
setTimeout(() => {
wx.navigateBack({
delta: 1,
})
},1000)
wx.hideLoading();
},
fail:function(res){
console.log(app.globalData.ip);
console.log(res);
wx.showToast({
title: '修改失败',
icon: 'success',
duration: 1000
})
wx.hideLoading();
}
});
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})