123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908 |
- // 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
- })
- }
- }
- })
- }
- }
- })
|