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.

178 lines
3.5 KiB
JavaScript

2 years ago
// pages/myAgentInfo/index.js
let app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
checkboxItems: [
{ name: '自营', value:1,checked:false},
{ name: '三方', value:2,checked:false },
],
msg: false,
checkValue: 1,
check: false,
agencyId:'',
checkedValue:2,
record:{},
isFirstIn:true
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
console.log(options.agencyId);
this.setData({
agencyId: options.agencyId
})
},
checkboxChange(e){
var that = this;
console.log('checkbox发生change事件携带value值为', e.detail.value)
that.setData({
checkedValue:e.detail.value
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
if(this.data.isFirstIn){
this.getDetail();
}
},
getDetail() {
var that = this;
wx.request({
url: app.globalData.ip + "/store/project/detail/" + that.data.agencyId,
header: app.globalData.header,
method: "GET",
success: function (res) {
console.log(res.data);
// console.log(that.convertHtmlToText(res.data.data.articleContent));
that.data.checkboxItems.forEach((item,index)=>{
// console.log(item.value);
// console.log(res.data.data.channelItemType);
if(item.value - res.data.data.signType == 0){
item.checked = true
}
})
that.setData({
record: res.data.data,
checkboxItems:that.data.checkboxItems,
checkedValue:res.data.data.signType,
});
// debugger;
},
fail: function (res) {
console.log(res);
},
});
wx.hideLoading({
success: (res) => {},
})
},
formSubmit(e) {
console.log('form发生了submit事件携带数据为', e.detail.value)
var that = this;
if(e.detail.value.projectName == ""){
wx.showToast({
title: '名称不能为空',
icon: 'error',
duration: 1000
})
}else{
let currData = {};
currData["projectId"] = that.data.agencyId;
currData["projectName"] = e.detail.value.projectName;
currData["signType"] = that.data.checkedValue;
wx.request({
url: app.globalData.ip + "/store/project/updateProject",
header: app.globalData.header,
data:currData,
method: "post",
success: function (res) {
console.log(res.data);
wx.showToast({
title: '修改成功',
icon:'success',
duration:1000
})
setTimeout(function(){
wx.navigateBack({
delta: 1,
})
},1000)
// console.log(that.convertHtmlToText(res.data.data.articleContent));
// that.setData({
// agencyStatistics: res.data.data.record,
// });
},
fail: function (res) {
console.log(res);
},
});
}
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})