// pages/myAgent/index.js const app = getApp(); import dateUtil from "../../utils/dateUtil"; Page({ /** * 页面的初始数据 */ data: { pageBean: {}, inputShowed: false, inputVal: "", recordList: [], currIndex: '0', phoneDialog:false, searchParam: { pageNum: 1, pageSize:20, del: 0, keys: '', status: 10, channelId: 19 }, hasReadAll: true, isLoading: true, hasMoreData: false, }, changeMenu(e) { var that = this; wx.showLoading({ title: '加载中...', }); that.data.searchParam.pageNum = 1; that.data.searchParam.searchTag = e.currentTarget.dataset.id; this.setData({ currIndex: e.currentTarget.dataset.id, }) this.getList(); }, showInput: function () { this.setData({ inputShowed: true }); }, hideInput: function () { this.setData({ inputVal: "", inputShowed: false }); }, clearInput: function () { console.log(123); this.setData({ inputVal: "" }); this.data.searchParam.keys = ''; this.data.searchParam.pageNum = 1; this.getList(); }, inputTyping: function (e) { console.log(e.detail.value); this.setData({ inputVal: e.detail.value }); this.data.searchParam.keys = e.detail.value; this.data.searchParam.pageNum = 1; this.getList(); }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { //this.getLocation(); var that = this; console.log(options.type) if(options.type == 'xrzn'){ that.data.searchParam.channelId = 22; wx.setNavigationBarTitle({ title: '新人指南', }) }else{ that.data.searchParam.channelId = 21; wx.setNavigationBarTitle({ title: '公司政策', }) } that.setData({ searchParam: that.data.searchParam }); }, goDetail:function(e){ var that = this; console.log(e); console.log(e); var id = e.currentTarget.dataset.info.id; if(e.currentTarget.dataset.info.articleUrl){ wx.downloadFile({ // 示例 url,并非真实存在 url: e.currentTarget.dataset.info.articleUrl, success: function (res) { const filePath = res.tempFilePath console.log(res); wx.openDocument({ filePath: filePath, success: function (res) { console.log('打开文档成功') wx.request({ url: app.globalData.ip + "/msg/read/cms/" + id, header: app.globalData.header, method: "GET", success: function (res) { console.log(res); console.log(res.data.data); app.globalData.read = res.data.data; if(res.data.data == 1){ } }, }); }, }) }, fail:function(err){ console.log(err); }, }) } else { wx.request({ url: app.globalData.ip + "/msg/read/cms/" + id, header: app.globalData.header, method: "GET", success: function (res) { console.log(res); console.log(res.data.data); app.globalData.read = res.data.data; if(res.data.data == 1){ } }, }); setTimeout(function(){ wx.navigateTo({ url:'/pages/noticeDetail/index?workOrderId=' + id }) }, 100); } }, loadMoreData:function(){ this.data.searchParam.pageNum = this.data.searchParam.pageNum + 1; this.getList(); }, getList: function () { var that = this; that.setData({ isLoading: true }); wx.request({ url: app.globalData.ip + '/cms/article/getArticleList', data: that.data.searchParam, header: app.globalData.header, method: "GET", success: function (res) { console.log(res.data); that.data.hasReadAll = true; if (res.data.status == 200) { that.setData({ isLoading: false }); if (res.data.data.pageBean.recordList != null && res.data.data.pageBean.recordList.length > 0) { res.data.data.pageBean.recordList.forEach(item => { item['updateTimeStr'] = dateUtil.timeShowXXX(item.updateTime); }); } that.setData({ recordList: res.data.data.pageBean.recordList, isLoading: false, }); if (res.data.data.pageBean.recordList != null && res.data.data.pageBean.recordList.length < 20) { that.setData({ hasMoreData: false }); } else { that.setData({ hasMoreData: true }); } wx.hideLoading(); } else { app.showTips(that, res.data.msg); } }, fail: function (res) { console.log(res); } }) }, close: function () { this.setData({ phoneDialog:false, }) }, makePhone:function(e){ var that = this; console.log(e); that.setData({ phoneDialog:true, phone:e.currentTarget.dataset.phone }) // wx.makePhoneCall({ // phoneNumber: e.currentTarget.dataset.phone // }); }, makePhoneCall:function(e){ var that = this; wx.makePhoneCall({ phoneNumber: that.data.phone }); }, bindCode:function(e){ console.log(e) wx.navigateToMiniProgram({ appId: 'wxb1f7c694803f6f00', //appid path: '/pages/scanQrcode/index?agencyUserId=' + e.currentTarget.dataset.userid,//path extraData: { //参数 agencyUserId: e.currentTarget.dataset.userid }, envVersion: 'release', //develop 开发版 trial 体验版 release 正式版 success(res) { console.log('成功') // 打开成功 } }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { this.getList(); }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })