|  |  |  | 
|---|
|  |  |  | import { getCustomerList, getCrmAuthUrl, batchAddLike } from '../../api/index' | 
|---|
|  |  |  | const { HYEventBus } = require('hy-event-store') | 
|---|
|  |  |  | import { | 
|---|
|  |  |  | getCustomerList, | 
|---|
|  |  |  | getCrmAuthUrl, | 
|---|
|  |  |  | batchAddLike | 
|---|
|  |  |  | } from '../../api/index' | 
|---|
|  |  |  | const { | 
|---|
|  |  |  | HYEventBus | 
|---|
|  |  |  | } = require('hy-event-store') | 
|---|
|  |  |  | const eventBus = new HYEventBus() | 
|---|
|  |  |  | Page({ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | bottomLift: app.bottomLift | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | this.getList() | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }, | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | handleSub() { | 
|---|
|  |  |  | const { customer } = this.data | 
|---|
|  |  |  | const { | 
|---|
|  |  |  | customer | 
|---|
|  |  |  | } = this.data | 
|---|
|  |  |  | const enjoyList = wx.getStorageSync('enjoyList') || [] | 
|---|
|  |  |  | if(!customer.userId) return wx.showToast({ | 
|---|
|  |  |  | title: '请先选择要关联的客户', icon: 'none' | 
|---|
|  |  |  | if (!customer.userId) return wx.showToast({ | 
|---|
|  |  |  | title: '请先选择要关联的客户', | 
|---|
|  |  |  | icon: 'none' | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | batchAddLike({ | 
|---|
|  |  |  | articleIds: enjoyList.filter(i => i.checked).map(i => i.id).join(','), | 
|---|
|  |  |  | customerId: customer.userId | 
|---|
|  |  |  | customerId: customer.platSourceId, | 
|---|
|  |  |  | platSourceId: customer.platSourceId, | 
|---|
|  |  |  | platSource: customer.platSource | 
|---|
|  |  |  | }).then(res => { | 
|---|
|  |  |  | setTimeout(() => { | 
|---|
|  |  |  | wx.showToast({ | 
|---|
|  |  |  | title: '绑定成功',icon: 'none' | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | }, 500) | 
|---|
|  |  |  | this.setData({ | 
|---|
|  |  |  | customer: {} | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | this.setData({ | 
|---|
|  |  |  | total: 0, | 
|---|
|  |  |  | dataList: [], | 
|---|
|  |  |  | page: 1 | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | this.getList() | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | tabsClick(e) { | 
|---|
|  |  |  | const flag = e.currentTarget.dataset.tab | 
|---|
|  |  |  | this.setData({flag}) | 
|---|
|  |  |  | this.setData({total: 0,dataList: [], page: 1, customer: {}}) | 
|---|
|  |  |  | this.setData({ | 
|---|
|  |  |  | flag | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | this.setData({ | 
|---|
|  |  |  | total: 0, | 
|---|
|  |  |  | dataList: [], | 
|---|
|  |  |  | page: 1, | 
|---|
|  |  |  | customer: {} | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | this.getList() | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | itemCheck(e) { | 
|---|
|  |  |  | const item = e.currentTarget.dataset.item | 
|---|
|  |  |  | console.log('item', item); | 
|---|
|  |  |  | this.setData({ customer: item }) | 
|---|
|  |  |  | this.setData({ | 
|---|
|  |  |  | customer: item | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | reloadList() { | 
|---|
|  |  |  | this.setData({total: 0,dataList: [], page: 1}) | 
|---|
|  |  |  | 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 }) | 
|---|
|  |  |  | const { | 
|---|
|  |  |  | total, | 
|---|
|  |  |  | dataList, | 
|---|
|  |  |  | page | 
|---|
|  |  |  | } = this.data | 
|---|
|  |  |  | if (total > dataList.length) { | 
|---|
|  |  |  | this.setData({ | 
|---|
|  |  |  | page: page + 1 | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | this.getList() | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | wx.showToast({ | 
|---|
|  |  |  | title: '暂无更多数据', | 
|---|
|  |  |  | icon: 'none' | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | getList() { | 
|---|
|  |  |  | const { flag, page, pageSize, keyWords } = this.data | 
|---|
|  |  |  | const { | 
|---|
|  |  |  | flag, | 
|---|
|  |  |  | page, | 
|---|
|  |  |  | pageSize, | 
|---|
|  |  |  | keyWords | 
|---|
|  |  |  | } = this.data | 
|---|
|  |  |  | getCustomerList({ | 
|---|
|  |  |  | flag, page, pageSize, keyWords | 
|---|
|  |  |  | flag, | 
|---|
|  |  |  | page, | 
|---|
|  |  |  | pageSize, | 
|---|
|  |  |  | keyWords | 
|---|
|  |  |  | }).then(res => { | 
|---|
|  |  |  | if(res.data){ | 
|---|
|  |  |  | 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 | 
|---|
|  |  |  | jumpClient() { | 
|---|
|  |  |  | getCrmAuthUrl({ | 
|---|
|  |  |  | type: 1 | 
|---|
|  |  |  | }).then(res => { | 
|---|
|  |  |  | this.setData({ | 
|---|
|  |  |  | url: res.data | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | const url = res.data | 
|---|
|  |  |  | wx.navigateTo({ | 
|---|
|  |  |  | url: '/pages/webView/index', | 
|---|
|  |  |  | success: function(res1) { | 
|---|
|  |  |  | success: function (res1) { | 
|---|
|  |  |  | // 通过eventChannel向被打开页面传送数据 | 
|---|
|  |  |  | console.log(url) | 
|---|
|  |  |  | res1.eventChannel.emit('data',{link:url} ); | 
|---|
|  |  |  | res1.eventChannel.emit('data', { | 
|---|
|  |  |  | link: url | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | onReady() { | 
|---|
|  |  |  |  | 
|---|