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.
204 lines
5.1 KiB
JavaScript
204 lines
5.1 KiB
JavaScript
// pages/configAnnunciateAddContact/index.js
|
|
const app = getApp();
|
|
import { customRequest } from '../../utils/request.js';
|
|
Page({
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
contactInfo: {},
|
|
type: "",
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad (options) {
|
|
if (options.info) {
|
|
console.log(JSON.parse(options.info));
|
|
if (JSON.parse(options.info).title == "详情咨询" && !JSON.parse(options.info).index) {
|
|
this.setData({
|
|
contactInfo: JSON.parse(options.info),
|
|
type: "add",
|
|
});
|
|
} else {
|
|
this.setData({
|
|
contactInfo: JSON.parse(options.info),
|
|
type: "update",
|
|
});
|
|
}
|
|
} else {
|
|
this.setData({
|
|
type: "add",
|
|
});
|
|
}
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady () { },
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow () { },
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide () { },
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload () { },
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh () { },
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom () { },
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage() {
|
|
return app.sharePageImage()
|
|
},
|
|
deleteContact () {
|
|
let that = this;
|
|
wx.showModal({
|
|
title: "",
|
|
content: "是否确认删除该联系人?",
|
|
confirmColor: "#1890ff",
|
|
success: function (res) {
|
|
console.log(res);
|
|
if (res.confirm) {
|
|
customRequest("/agency/updateContactCfg", {
|
|
header: 'headers', method: 'post', data: {
|
|
sourceJson: JSON.stringify(that.data.contactInfo),
|
|
targetJson: "",
|
|
type: "update",
|
|
}
|
|
}).then((res) => {
|
|
if (res.data.status == 200) {
|
|
app.globalData.loginUserInfo.noticeEndStr = res.data.data.noticeEndStr;
|
|
wx.showToast({
|
|
title: "删除成功",
|
|
icon: "success",
|
|
duration: 1500,
|
|
});
|
|
setTimeout(() => {
|
|
wx.navigateBack({
|
|
delta: 1,
|
|
});
|
|
}, 1500);
|
|
}
|
|
})
|
|
// wx.request({
|
|
// url: app.globalData.ip + "/agency/updateContactCfg",
|
|
// method: "post",
|
|
// data: {
|
|
// sourceJson: JSON.stringify(that.data.contactInfo),
|
|
// targetJson: "",
|
|
// type: "update",
|
|
// },
|
|
// header: app.globalData.headers,
|
|
// success: function (res) {
|
|
// console.log(res);
|
|
// if (res.data.status == 200) {
|
|
// app.globalData.loginUserInfo.noticeEndStr = res.data.data.noticeEndStr;
|
|
// wx.showToast({
|
|
// title: "删除成功",
|
|
// icon: "success",
|
|
// duration: 1500,
|
|
// });
|
|
// setTimeout(() => {
|
|
// wx.navigateBack({
|
|
// delta: 1,
|
|
// });
|
|
// }, 1500);
|
|
// }
|
|
// },
|
|
// });
|
|
}
|
|
},
|
|
});
|
|
},
|
|
beforeFormSubmit (e) {
|
|
console.log(e);
|
|
let v = e.detail.value;
|
|
if (v.tel == "" || v.title == "" || v.userName == "") {
|
|
wx.showToast({
|
|
title: "请确保信息输入完整",
|
|
icon: "none",
|
|
});
|
|
} else {
|
|
console.log("full");
|
|
this.addContent(v);
|
|
}
|
|
},
|
|
addContent (value) {
|
|
let data;
|
|
let targetJson;
|
|
let sourceJson;
|
|
let type;
|
|
if (this.data.type == "add") {
|
|
targetJson = JSON.stringify(value);
|
|
sourceJson = "";
|
|
type = "add";
|
|
} else {
|
|
targetJson = JSON.stringify(value);
|
|
sourceJson = JSON.stringify(this.data.contactInfo);
|
|
type = "update";
|
|
}
|
|
data = {
|
|
targetJson,
|
|
sourceJson,
|
|
type,
|
|
};
|
|
customRequest("/agency/updateContactCfg", { header: 'headers', method: 'post', data }).then((res) => {
|
|
if (res.data.status == 200) {
|
|
app.globalData.loginUserInfo.noticeEndStr = res.data.data.noticeEndStr;
|
|
wx.showToast({
|
|
title: "保存成功",
|
|
icon: "success",
|
|
duration: 1500,
|
|
});
|
|
setTimeout(() => {
|
|
wx.navigateBack({
|
|
delta: 1,
|
|
});
|
|
}, 1500);
|
|
}
|
|
})
|
|
// wx.request({
|
|
// url: app.globalData.ip + "/agency/updateContactCfg",
|
|
// method: "post",
|
|
// data,
|
|
// header: app.globalData.headers,
|
|
// success: function (res) {
|
|
// console.log(res);
|
|
// if (res.data.status == 200) {
|
|
// app.globalData.loginUserInfo.noticeEndStr = res.data.data.noticeEndStr;
|
|
// wx.showToast({
|
|
// title: "保存成功",
|
|
// icon: "success",
|
|
// duration: 1500,
|
|
// });
|
|
// setTimeout(() => {
|
|
// wx.navigateBack({
|
|
// delta: 1,
|
|
// });
|
|
// }, 1500);
|
|
// }
|
|
// },
|
|
// });
|
|
},
|
|
});
|