// 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: { agentName: App.globalData.agentName, 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: false, datashow: false, rType: '1', rid: "", date: '', keyword: '', clientType: '', clientState: '', clueStateText: "", clueStateId: "", clueMobileText: "", clueMobileId: "", getDate: "", maxDate: new Date(), curType: '全部客户', showCompany: false, hiddenSearch: true, showClueState: false, showClueMobile: false, showClueRecord: false, shareArticleNew: false, clueRecordlist: [], shareArticledlist: [], shareCluelist: [], brokerClientlist: [], companylist: [], stateArr: [{ id: '', text: '全部', show: 1 }, { id: 1, text: "待确认", show: 1, }, { id: 10, text: "有效", show: 1, }, { id: 2, text: "已到店", show: 1, }, { id: 3, text: "已量房", show: 1, }, { id: 4, text: "已到场", show: 1, }, { id: 5, text: "已签单", show: 1, }, { id: 6, text: "已转单", show: 1, } ], statusArr: [{ text: "全部", id: "" },{ text: "未报备", id: "0" },{ text: "已报备", id: "1" },{ text: "无效", id: "2" }], mobilelist: [{ text: "全部", id: "" },{ text: "有手机号", id: "has" },{ text: "无手机号", id: "hasno" }], }, 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(); this.getBrokerClient(); this.getCompanylist(); }, onReady: function () { }, switchTab: function (e) { page = 1; let type = e.currentTarget.dataset.type; this.setData({ rType: type }) wx.showLoading({ title: '加载中...', }) if (type == 1) { this.getBrokerClient(); } else if (type == 2) { this.getShareCluelist(); } else { this.getShareArticledlist(); } }, jumpMinePage: function () { wx.reLaunch({ url: '/customer/pages/brokerindex/brokerindex', }) }, jumpSharePage: function () { wx.reLaunch({ url: '/customer/pages/brokershare/brokershare', }) }, jumpRankPage: function () { wx.reLaunch({ url: '/customer/pages/brokerindex/brokerindex?type=rank', }) }, jumpscreenshot: function() { wx.reLaunch({ url: '/customer/pages/screenshot/screenshot', }) }, exchangeFunc: function() { wx.navigateTo({ url: '/pages/other/other?type=6709', }) }, jumpShareInfo: function (e) { let type = e.currentTarget.dataset.type; let content_id = e.currentTarget.dataset.contentid; switch (type) { case "AgentArticle": wx.navigateTo({ url: '/customer/pages/brokershareinfo/brokershareinfo?id=' + content_id, }) break; case "MaterialEvidence": wx.navigateTo({ url: '/index/pages/publicpraisemsg/publicpraisemsg?eid=' + content_id + '&ty=b', }) break; case "CompanyStrength": wx.navigateTo({ url: '/index/pages/companystrengthmsg/companystrengthmsg?eid=' + content_id + '&ty=b', }) break; case "Video": wx.navigateTo({ url: '/index/pages/videoshare/videoshare?vid=' + content_id + '&ty=b', }) break; case "Building": wx.navigateTo({ url: '/index/pages/progressdetail/progressdetail?cid=' + content_id + '&ty=b', }) break; case "MaterialCase": wx.navigateTo({ url: '/index/pages/casemsg/casemsg?cid=' + content_id + '&ty=b', }) break; case "Article": wx.navigateTo({ url: '/index/pages/articleshare/articleshare?aid=' + content_id + '&ty=b', }) break; } }, handleCopyText(e) { let data = e.currentTarget.dataset.text; wx.setClipboardData({ data: data, success: function (res) { } }) }, bindDateChange(e) { page = 1; this.setData({ date: e.detail.value }) this.getBrokerClient(); }, bindClueDateChange(e) { page = 1; this.setData({ getDate: e.detail.value }) this.getShareCluelist() }, bingStateChange(e) { this.setData({ stateShow: !this.data.stateShow }) }, handleShowClueState(e) { this.setData({ showClueState: !this.data.showClueState }) }, getStateChange(e) { page = 1; let text = e.currentTarget.dataset.text; this.setData({ clientState: text == '全部' ? "" : text, stateShow: false }) this.getBrokerClient(); }, getStatusChange(e) { page = 1; let data = e.currentTarget.dataset; this.setData({ clueStateId: data.id, clueStateText: data.text, showClueState: false }) this.getShareCluelist(); }, getMobileChange(e) { page = 1; let data = e.currentTarget.dataset; this.setData({ clueMobileText: data.text, clueMobileId: data.id, showClueMobile: false, }); this.getShareCluelist(); }, handleShowClueMobile(e) { this.setData({ showClueMobile: !this.data.showClueMobile }) }, handleSearchAll() { page = 1; this.setData({ clientState: "", date: "", clueStateId: "", clueStateText: "", getDate: "", clueMobileId: "", clueMobileText: "" }) if (this.data.rType == 1) { this.getBrokerClient(); } else if (this.data.rType == 2) { this.getShareCluelist(); } else { this.getShareArticledlist(); } }, 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' }) }, viewFootRecord(e) { let rid = e.currentTarget.dataset.id; this.setData({ rid: rid }) this.getShareClueRecord(); }, switchCompany() { this.setData({ showCompany: true }) }, switchCompanyType(e) { wx.showLoading({ title: '切换中...', }) let company = e.currentTarget.dataset.company; App.globalData.clientype = company; this.setData({ showCompany: false, clientType: company }) setTimeout(() => { wx.hideLoading(); wx.reLaunch({ url: '/pages/index/index', }) }, 1000) }, closeDialog() { this.setData({ stateShow: false, showCompany: false, showClueState: false, showClueMobile: false, showClueRecord: 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 }) } } }) }, getNewShareArticleNum() { let that = this; utils.$post({ url: App.globalData.webUrl + 'api/agentsWork/newShareArticle', header: { 'Authorization': 'bearer ' + App.globalData.token }, data: {}, success: function (res) { if (res.data.code == '0') { that.setData({ shareArticleNew: res.data.new }) } } }) }, /** * 获取线索列表接口 */ getShareCluelist() { let that = this; that.setData({ datashow: false }) utils.$post({ url: App.globalData.webUrl + 'api/agentsWork/clue_list', header: { 'Authorization': 'bearer ' + App.globalData.token }, data: { page: page, limit: 10, getDate: that.data.getDate, state: that.data.clueStateId, phone: that.data.clueMobileId }, success: function (res) { wx.hideLoading(); if (res.data.code == '0') { that.setData({ shareCluelist: res.data.data.data.map(v => { if (v.phone) { v.phonestr = v.phone.substring(0, 3) + "****" + v.phone.substr(v.phone.length-4); } return v; }), datashow: true }) } } }) }, /** * 获取线索足迹 */ getShareClueRecord() { let that = this; utils.$post({ url: App.globalData.webUrl + 'api/agentsWork/footprints', header: { 'Authorization': 'bearer ' + App.globalData.token }, data: { id: that.data.rid, }, success: function (res) { if (res.data.code == '0') { that.setData({ showClueRecord: true, clueRecordlist: res.data.data }) } } }) }, /** * 获取分享内容列表 */ getShareArticledlist() { let that = this; that.setData({ datashow: false }) utils.$post({ url: App.globalData.webUrl + 'api/agentsWork/share_article', header: { 'Authorization': 'bearer ' + App.globalData.token }, data: { from: 'shareLog', page: page, limit: 10 }, success: function (res) { wx.hideLoading(); if (res.data.code == '0') { res.data.data.list = res.data.data.list.map(v => { if (v.type == 'CompanyStrength' || v.type == 'MaterialEvidence') { if (v.difference == 1 && v.type == 'MaterialEvidence') { v.cover = Array.isArray(v.cover)&&v.cover.length?v.cover[0]+'?x-oss-process=video/snapshot,t_100,f_jpg,w_375,m_fast':v.cover } else { v.cover = Array.isArray(v.cover)&&v.cover.length?v.cover[0]:v.cover } return v; } else { return v; } }) that.setData({ shareArticledlist: res.data.data.list, datashow: true }) } } }) }, /** * 装修推荐官客户列表 */ 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 == '已签单' ? '已交定' : that.data.clientState == '已转单'?'已签单': that.data.clientState, keyword: that.data.keyword, addtime: that.data.date }, success: function (res) { wx.hideLoading(); 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() {}, 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 }) }, 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) wx.showLoading({ title: '加载中...', }) page = 1; if (that.data.rType == 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 == '已签单' ? '已交定' : that.data.clientState == '已转单'?'已签单': that.data.clientState, keyword: that.data.keyword }, success: function (res) { wx.hideLoading(); if (res.data.code == '0') { that.setData({ brokerClientlist: res.data.data.list }) that.clientStatistics(); } else { wx.showToast({ title: res.data.msg, icon: "none", duration: 1500 }) } } }) } else if (that.data.rType == 2) { utils.$post({ url: App.globalData.webUrl + 'api/agentsWork/clue_list', header: { 'Authorization': 'bearer ' + App.globalData.token }, data: { page: page, limit: 10 }, success: function (res) { wx.hideLoading(); if (res.data.code == '0') { that.setData({ shareCluelist: res.data.data.data.map(v => { if (v.phone) { v.phonestr = v.phone.substring(0, 3) + "****" + v.phone.substr(v.phone.length-4); } return v; }) }) } else { wx.showToast({ title: res.data.msg, icon: "none", duration: 1500 }) } } }) } else { utils.$post({ url: App.globalData.webUrl + 'api/agentsWork/share_article', header: { 'Authorization': 'bearer ' + App.globalData.token }, data: { from: 'shareLog', page: page, limit: 10 }, success: function (res) { wx.hideLoading(); if (res.data.code == '0') { res.data.data.list = res.data.data.list.map(v => { if (v.type == 'CompanyStrength' || v.type == 'MaterialEvidence') { if (v.difference == 1 && v.type == 'MaterialEvidence') { v.cover = Array.isArray(v.cover)&&v.cover.length?v.cover[0]+'?x-oss-process=video/snapshot,t_100,f_jpg,w_375,m_fast':v.cover } else { v.cover = Array.isArray(v.cover)&&v.cover.length?v.cover[0]:v.cover } return v; } else { return v; } }) that.setData({ shareArticledlist: res.data.data.list }) } else { wx.showToast({ title: res.data.msg, icon: "none", duration: 1500 }) } } }) } }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { page = page + 1; var that = this; wx.showLoading({ title: '加载中...', }) if (that.data.rType == 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 == '已签单' ? '已交定' : that.data.clientState == '已转单'?'已签单': that.data.clientState, keyword: that.data.keyword }, success: function (res) { wx.hideLoading(); if (res.data.code == '0') { let list = that.data.brokerClientlist.concat(res.data.data.list); that.setData({ brokerClientlist: list }) } else { wx.showToast({ title: res.data.msg, icon: "none", duration: 1500 }) } } }) } else if (that.data.rType == 2) { utils.$post({ url: App.globalData.webUrl + 'api/agentsWork/clue_list', header: { 'Authorization': 'bearer ' + App.globalData.token }, data: { page: page, limit: 10 }, success: function (res) { wx.hideLoading(); if (res.data.code == '0') { let arrData = res.data.data.data.map(v => { if (v.phone) { v.phonestr = v.phone.substring(0, 3) + "****" + v.phone.substr(v.phone.length-4); } return v; }) let list = that.data.shareCluelist.concat(arrData); that.setData({ shareCluelist: list }) } else { wx.showToast({ title: res.data.msg, icon: "none", duration: 1500 }) } } }) } else { utils.$post({ url: App.globalData.webUrl + 'api/agentsWork/share_article', header: { 'Authorization': 'bearer ' + App.globalData.token }, data: { from: 'shareLog', page: page, limit: 10 }, success: function (res) { wx.hideLoading(); if (res.data.code == '0') { res.data.data.list = res.data.data.list.map(v => { if (v.type == 'CompanyStrength' || v.type == 'MaterialEvidence') { if (v.difference == 1 && v.type == 'MaterialEvidence') { v.cover = Array.isArray(v.cover)&&v.cover.length?v.cover[0]+'?x-oss-process=video/snapshot,t_100,f_jpg,w_375,m_fast':v.cover } else { v.cover = Array.isArray(v.cover)&&v.cover.length?v.cover[0]:v.cover } return v; } else { return v; } }) let list = that.data.shareArticledlist.concat(res.data.data.list); that.setData({ shareArticledlist: list }) } else { wx.showToast({ title: res.data.msg, icon: "none", duration: 1500 }) } } }) } } })