// pages/my/work/work.js const App = getApp(); Page({ /** * 页面的初始数据 */ data: { appAssetsUrl2: App.appAssetsUrl2, id: null, detail: {}, topicList: [], meetList: [], meetQuery: { page: 1, limit: 10, }, meetPage: { totalCount: null, currPage: null, totalPage: null, }, serveObj: {}, items: [ { week: "周一", startTime: "09:00", endTime: "18:00", checked: true, }, { week: "周二", startTime: "09:00", endTime: "18:00", checked: true, }, { week: "周三", startTime: "09:00", endTime: "18:00", checked: true, }, { week: "周四", startTime: "09:00", endTime: "18:00", checked: true, }, { week: "周五", startTime: "09:00", endTime: "18:00", checked: true, }, { week: "周六", startTime: "09:00", endTime: "18:00", checked: true, }, { week: "周日", startTime: "09:00", endTime: "18:00", checked: true, }, ], }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { this.setData({ id: options.id, }); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { this.popup2 = this.selectComponent("#popup2"); }, /** * 生命周期函数--监听页面显示 */ onShow() { this.getDetail(); }, getDetail() { wx.showLoading({ title: "努力加载中...", }); App._get( "expert/infoMember/" + this.data.id, {}, (res) => { if (res.code === 0) { this.setData({ detail: res.expert, items: res.expert.periodBOList || this.data.items, }); wx.hideLoading(); if (res.expert.id) { this.getTopic(res.expert.id); this.getExperience(res.expert.id); this.getServe(res.expert.id); } } }, (err) => { wx.showToast({ icon: "error", title: "服务端异常", }); }, (complete) => {} ); }, // 获取话题 getTopic(expertId) { App._get( "experttopic/list", { expertId: expertId, }, (res) => { if (res.code === 0) { this.setData({ topicList: res.list, }); } } ); }, // 获取心得分享 getExperience(expertId) { if (this.data.meetPage.totalCount > 0) { if (this.data.meetPage.currPage == this.data.meetPage.totalPage) { wx.showToast({ title: "没有更多哦~", icon: "none", }); return false; } } wx.showLoading({ title: "努力加载中...", }); App._get( "meetevaluation/evaluatePage", { ...this.data.meetQuery, expertId: expertId, }, (res) => { if (res.code === 0) { this.setData({ meetList: res.page.list, meetPage: { totalCount: res.page.totalCount, currPage: res.page.currPage, totalPage: res.page.totalPage, }, }); wx.hideLoading(); } }, (err) => { wx.showToast({ icon: "error", title: "服务端异常", }); }, (complete) => {} ); }, // 获取服务统计 getServe(expertId) { App._get( "expert_workbench/myServiceStatistics", { expertId: expertId, }, (res) => { if (res.code === 0) { this.setData({ serveObj: res.data, }); } } ); }, toDetail(e) { wx.navigateTo({ url: `/workbench/work/topic?id=${e.currentTarget.dataset.id}` }) }, checkboxChange(e) { console.log(e); let list = this.data.items; for (let i = 0, lenI = list.length; i < lenI; ++i) { list[i].checked = false; for (let j = 0, lenJ = e.detail.value.length; j < lenJ; ++j) { if (i == e.detail.value[j]) { list[i].checked = true; break; } } } this.setData({ items: list, }); }, bindStartTimeChange(e) { console.log(e); let list = this.data.items; for (let i in list) { if (i == e.currentTarget.dataset.index) { list[i].startTime = e.detail.value; break; } } this.setData({ items: list, }); }, bindEndTimeChange(e) { console.log(e); let list = this.data.items; for (let i in list) { if (i == e.currentTarget.dataset.index) { list[i].endTime = e.detail.value; break; } } this.setData({ items: list, }); }, toGambit(e) { wx.navigateTo({ url: "/workbench/gambit/gambit?id=" + e.currentTarget.dataset.id, }); }, timeHandle() { this.popup2.showPopup(); }, _error() { console.log("返回"); let list = this.data.items; // for (let value of list) { // value.startTime = "09:00"; // value.endTime = "18:00"; // value.checked = true; // } this.setData({ items: list, }); this.popup2.hidePopup(); }, _success() { console.log("查看"); App._put_form( "expert/updatePeriod", "", { id: this.data.detail.id, memberId: this.data.id, periodBOList: this.data.items, }, (res) => { if (res.code === 0) { wx.showToast({ title: "保存成功", icon: "success", }); } } ); this.popup2.hidePopup(); }, lookMore() { wx.navigateTo({ url: "/workbench/myService/myService", }); }, toServerList(e) { console.log(e, 111); wx.navigateTo({ url: "/workbench/myService/myService?status=" + e.currentTarget.dataset.status, }); }, /** * 生命周期函数--监听页面隐藏 */ onHide() {}, /** * 生命周期函数--监听页面卸载 */ onUnload() {}, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() {}, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { this.getExperience(this.data.detail.id); }, /** * 用户点击右上角分享 */ onShareAppMessage() {}, });