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