// customer/pages/broker/broker.js var App = getApp(); var utils = require("../../../utils/http"); var nowtimestamp = 0, stoptime = 0; let loginnum = 1; let page = 1; Page({ data: { top: App.globalData.statusBarHeight, hgt: App.globalData.titleBarHeight, imgUrl: App.globalData.imgUrl, personobj: App.globalData.personMsg, signflag: false, instructionsflag: false, num: 0, unlogin: false, clientTotal: {}, intregralTotal: {}, userflag: true,//true是有个人信息,false没有个人信息, permiss: true, unfutureflag: false, companyname: App.globalData.companyname, sourceShow: true, stateShow: true, datashow: false, date: '', keyword: '', clientType: '', clientState: '', curType: '全部客户', showCompany: false, hiddenSearch: true, brokerClientlist: [], companylist: [], stateArr: [{ id: '', text: '全部客户', show: 1 }, { id: 1, text: "未联系", show: 1, }, { id: 2, text: "已到店", show: 1, }, { id: 5, text: "已交定", show: 1, }, { id: 6, text: "已签单", show: 1, } ], }, onLoad: function () { page = 1; var that = this; wx.showLoading({ title: '加载中......', }) that.setData({ top: App.globalData.statusBarHeight, hgt: App.globalData.titleBarHeight, companyname: App.globalData.companyname, clientType: App.globalData.clientype }) that.setData({ personobj: App.globalData.personMsg, }) this.intregral_total(); }, onReady: function () { }, jumpMinePage: function() { wx.reLaunch({ url: '/customer/pages/brokerindex/brokerindex', }) }, jumpRankPage: function() { wx.reLaunch({ url: '/customer/pages/brokerindex/brokerindex?type=rank', }) }, bindDateChange(e) { this.setData({ date: e.detail.value }) this.getBrokerClient() }, searchlist(e) { page = 1; let text = e.currentTarget.dataset.text; let type = text == '全部客户'? '': text == '未联系' ? '待确认' : text; this.setData({ clientState: type, curType: text }) this.getBrokerClient() }, viewIntegral() { wx.navigateTo({ url: '/pages/other/other?type=2277', }) }, goidxtap: function () { wx.navigateTo({ url: '/index/pages/activity/activity?type=broker', }) }, closetap: function () { this.setData({ unfutureflag: false }) }, setap: function () { wx.navigateTo({ url: '/mycustomer/pages/set/set' }) }, switchCompany() { this.setData({ showCompany: true }) }, switchCompanyType(e) { let company = e.currentTarget.dataset.company; App.globalData.clientype = company; this.setData({ showCompany: false }) setTimeout(() => { this.getBrokerClient(); this.clientStatistics(); this.getCompanylist(); this.intregral_total(); }, 1000) }, closeDialog() { this.setData({ showCompany: false }) }, onChange(e) { this.setData({ keyword: e.detail.value }) }, onSearch() { page = 1; this.getBrokerClient(); }, showSearchIpt() { let showState = !this.data.hiddenSearch; this.setData({ hiddenSearch: showState }) }, arrfun: function (str) { var that = this; let arr = str.split(','); return arr; }, logintap: function () { this.loginbox = this.selectComponent("#loginbox"); this.loginbox.loginfun(); }, /** * 获取公司列表 */ getCompanylist() { let that = this; utils.$post({ url: App.globalData.webUrl + 'api/agents_work/company', header: { 'Authorization': 'bearer ' + App.globalData.token }, data: {}, success: function (res) { if (res.data.code == '0') { that.setData({ companylist: res.data.data }) } } }) }, /** * 经纪人客户列表 */ getBrokerClient() { let that = this; utils.$post({ url: App.globalData.webUrl + 'api/agents_work/customer_list', header: { 'Authorization': 'bearer ' + App.globalData.token }, data: { page: page, limit: 10, state: that.data.clientState, keyword: that.data.keyword }, success: function (res) { if (res.data.code == '0') { that.setData({ datashow: true, brokerClientlist: res.data.data.list }) that.clientStatistics(); } } }) }, /** * 客户数据统计 */ clientStatistics: function (text) { var that = this; wx.hideLoading() utils.$post({ url: App.globalData.webUrl + 'api/agents_work/agt_crm_count', header: { 'Authorization': 'bearer ' + App.globalData.token }, data: {}, success: function (res) { if (res.data.code == '0') { that.setData({ clientTotal: res.data.data }) } } }) }, /** * 我的积分数据 */ intregral_total: function (text) { var that = this; wx.hideLoading() utils.$post({ url: App.globalData.webUrl + 'api/agents_work/intregral_total', header: { 'Authorization': 'bearer ' + App.globalData.token }, data: {}, success: function (res) { if (res.data.code == '0') { that.setData({ intregralTotal: res.data.data }) } } }) }, dothis() { this.data.stateShow = true; this.data.sourceShow = true; this.setData({ stateShow: this.data.stateShow, sourceShow: this.data.sourceShow }) }, managemenTap: function () { this.setData({ unfutureflag: true }) }, ranktap: function () { var that = this; this.$route('/mycustomer/pages/rankbox/rankbox') }, informTap: function (e) { var that = this; wx.navigateTo({ url: '/mycustomer/pages/information/information', }) }, onShow: function (e) { var that = this; loginnum = loginnum + 1; that.setData({ top: App.globalData.statusBarHeight, hgt: App.globalData.titleBarHeight, companyname: App.globalData.companyname }) that.setData({ tokenflag: App.globalData.tokenflag, }) this.setData({ personMsg: App.globalData.personMsg }) this.getBrokerClient(); this.getCompanylist(); }, onAwake: function (t) { // console.log('[pages/index] 程序被唤醒:', t) }, /** * 置顶客户 */ handleTopping: function (e) { let that = this; let cid = e.currentTarget.dataset.cid; utils.$post({ url: App.globalData.webUrl + 'api/agents_work/set_top', header: { 'Authorization': 'bearer ' + App.globalData.token }, data: { customer_id: cid }, success: function (res) { if (res.data.code == '0') { page = 1; that.getBrokerClient(); } } }) }, backTap: function () { wx.navigateBack(); }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { var timearr = App.globalData.timearr, flag = false; for (var i = 0; i < timearr.length; i++) { if (timearr[i].type == 'index') { timearr[i].time = timearr[i].time * 1 + stoptime * 1; flag = true; } } if (!flag) { var obj = { type: 'index', time: stoptime }; App.globalData.timearr.push(obj); } else { App.globalData.timearr = timearr; } }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { var that = this; setTimeout(function () { wx.stopPullDownRefresh(); }, 500) page = 1; utils.$post({ url: App.globalData.webUrl + 'api/agents_work/customer_list', header: { 'Authorization': 'bearer ' + App.globalData.token }, data: { page: page, limit: 10, state: that.data.clientState, keyword: that.data.keyword }, success: function (res) { if (res.data.code == '0') { that.setData({ brokerClientlist: res.data.data.list }) that.clientStatistics(); } } }) }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { page = page + 1; var that = this; utils.$post({ url: App.globalData.webUrl + 'api/agents_work/customer_list', header: { 'Authorization': 'bearer ' + App.globalData.token }, data: { page: page, limit: 10, state: that.data.clientState, keyword: that.data.keyword }, success: function (res) { if (res.data.code == '0') { let list = that.data.brokerClientlist.concat(res.data.data.list); that.setData({ brokerClientlist: list }) } } }) } })