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.

140 lines
4.6 KiB
JavaScript

// pages/configAnnunciate/index.js
const app = getApp();
import { customRequest } from '../../utils/request.js';
Page({
/**
* 页面的初始数据
*/
data: {
annunciateList: [],
noData: false,
userInfo: {},
},
/**
* 生命周期函数--监听页面加载
*/
onLoad (options) { },
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady () { },
/**
* 生命周期函数--监听页面显示
*/
onShow () {
let that = this;
setTimeout(() => {
that.setData({
userInfo: app.globalData.loginUserInfo,
serviceInfo: app.globalData.serviceInfo,
});
console.log(that.data.userInfo);
that.getList();
}, 100);
console.log(app.globalData.loginUserInfo);
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide () { },
/**
* 生命周期函数--监听页面卸载
*/
onUnload () { },
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh () { },
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom () { },
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
return app.sharePageImage()
},
/**
* 通告信息修改
*
*
*/
editAnnunciate (e) {
console.log(e);
wx.navigateTo({
url: `../configAnnunciateAddContact/index?info=${JSON.stringify(e.currentTarget.dataset.info)}`,
});
},
addContact () {
wx.navigateTo({
url: `../configAnnunciateAddContact/index`,
});
},
getList () {
let that = this;
customRequest("/agency/getContactCfg", { header: 'headers', method: 'GET', data: {} }).then((res) => {
if (res.data.data.ContactCfgs) {
// console.log('ContactCfgs');
if (res.data.data.ContactCfgs.length > 0) {
res.data.data.ContactCfgs.forEach((item, index) => {
item.index = index + 1;
});
that.setData({
annunciateList: res.data.data.ContactCfgs,
noData: false,
});
} else {
that.setData({
annunciateList: [{ tel: that.data.userInfo.agencyStatus == 1 ? that.data.userInfo.tel : that.data.serviceInfo.workPhone ? that.data.serviceInfo.workPhone : "-", title: that.data.userInfo.agencyStatus == 1 ? (that.data.userInfo.noticeEndStr ? that.data.userInfo.noticeEndStr : "详情咨询") : "详情咨询", userName: that.data.userInfo.agencyStatus == 1 ? "" : that.data.serviceInfo.userName }],
noData: true,
});
}
} else {
that.setData({
annunciateList: [{ tel: that.data.userInfo.agencyStatus == 1 ? that.data.userInfo.tel : that.data.serviceInfo.workPhone ? that.data.serviceInfo.workPhone : "-", title: that.data.userInfo.agencyStatus == 1 ? (that.data.userInfo.noticeEndStr ? that.data.userInfo.noticeEndStr : "详情咨询") : "详情咨询", userName: that.data.userInfo.agencyStatus == 1 ? "" : that.data.serviceInfo.userName }],
noData: true,
});
}
})
// wx.request({
// url: app.globalData.ip + "/agency/getContactCfg",
// method: "get",
// header: app.globalData.headers,
// success: function (res) {
// console.log(res);
// if (res.data.data.ContactCfgs) {
// // console.log('ContactCfgs');
// if (res.data.data.ContactCfgs.length > 0) {
// res.data.data.ContactCfgs.forEach((item, index) => {
// item.index = index + 1;
// });
// that.setData({
// annunciateList: res.data.data.ContactCfgs,
// noData: false,
// });
// } else {
// that.setData({
// annunciateList: [{ tel: that.data.userInfo.agencyStatus == 1 ? that.data.userInfo.tel : that.data.serviceInfo.workPhone ? that.data.serviceInfo.workPhone : "-", title: that.data.userInfo.agencyStatus == 1 ? (that.data.userInfo.noticeEndStr ? that.data.userInfo.noticeEndStr : "详情咨询") : "详情咨询", userName: that.data.userInfo.agencyStatus == 1 ? "" : that.data.serviceInfo.userName }],
// noData: true,
// });
// }
// } else {
// that.setData({
// annunciateList: [{ tel: that.data.userInfo.agencyStatus == 1 ? that.data.userInfo.tel : that.data.serviceInfo.workPhone ? that.data.serviceInfo.workPhone : "-", title: that.data.userInfo.agencyStatus == 1 ? (that.data.userInfo.noticeEndStr ? that.data.userInfo.noticeEndStr : "详情咨询") : "详情咨询", userName: that.data.userInfo.agencyStatus == 1 ? "" : that.data.serviceInfo.userName }],
// noData: true,
// });
// }
// },
// });
},
});