import { getCustomerList, getCrmAuthUrl, batchAddLike } from '../../api/index' const { HYEventBus } = require('hy-event-store') const eventBus = new HYEventBus() Page({ /** * 页面的初始数据 */ data: { bottomLift: 0, keyWords: '', dataList: [], customer: {}, total: 0, flag: 0, page: 1, pageSize: 10, }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { var app = getApp().globalData this.setData({ bottomLift: app.bottomLift }) this.getList() }, handleSub() { const { customer } = this.data const enjoyList = wx.getStorageSync('enjoyList') || [] if(!customer.userId) return wx.showToast({ title: '请先选择要关联的客户', icon: 'none' }) batchAddLike({ articleIds: enjoyList.filter(i => i.checked).map(i => i.id).join(','), customerId: customer.userId }) }, tabsClick(e) { const flag = e.currentTarget.dataset.tab this.setData({flag}) this.setData({total: 0,dataList: [], page: 1}) this.getList() }, itemCheck(e) { const item = e.currentTarget.dataset.item console.log('item', item); this.setData({ customer: item }) }, reloadList() { this.setData({total: 0,dataList: [], page: 1}) this.getList() }, scrolltolower() { console.log('触底事件'); const { total, dataList, page } = this.data if(total > dataList.length){ this.setData({ page: page + 1 }) this.getList() }else{ wx.showToast({ title: '暂无更多数据', icon: 'none' }) } }, getList() { const { flag, page, pageSize, keyWords } = this.data getCustomerList({ flag, page, pageSize, keyWords }).then(res => { if(res.data){ this.setData({ total: res.data.total, dataList: [...this.data.dataList, ...res.data.data] }) } }) }, jumpClient() { getCrmAuthUrl({type:1}).then(res => { this.setData({ url: res.data }) const url =res.data wx.navigateTo({ url: '/pages/webView/index', success: function(res1) { // 通过eventChannel向被打开页面传送数据 console.log(url) res1.eventChannel.emit('data',{link:url} ); } }) }) }, onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })