broker.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. // customer/pages/broker/broker.js
  2. var App = getApp();
  3. var utils = require("../../../utils/http");
  4. var nowtimestamp = 0, stoptime = 0;
  5. let loginnum = 1;
  6. let page = 1;
  7. Page({
  8. data: {
  9. top: App.globalData.statusBarHeight,
  10. hgt: App.globalData.titleBarHeight,
  11. imgUrl: App.globalData.imgUrl,
  12. personobj: App.globalData.personMsg,
  13. signflag: false,
  14. instructionsflag: false,
  15. num: 0,
  16. unlogin: false,
  17. clientTotal: {},
  18. intregralTotal: {},
  19. userflag: true,//true是有个人信息,false没有个人信息,
  20. permiss: true,
  21. unfutureflag: false,
  22. companyname: App.globalData.companyname,
  23. sourceShow: true,
  24. stateShow: true,
  25. datashow: false,
  26. date: '',
  27. keyword: '',
  28. clientType: '',
  29. clientState: '',
  30. curType: '全部客户',
  31. showCompany: false,
  32. hiddenSearch: true,
  33. brokerClientlist: [],
  34. companylist: [],
  35. stateArr: [{
  36. id: '',
  37. text: '全部客户',
  38. show: 1
  39. },
  40. {
  41. id: 1,
  42. text: "未联系",
  43. show: 1,
  44. },
  45. {
  46. id: 2,
  47. text: "已到店",
  48. show: 1,
  49. },
  50. {
  51. id: 5,
  52. text: "已交定",
  53. show: 1,
  54. },
  55. {
  56. id: 6,
  57. text: "已签单",
  58. show: 1,
  59. }
  60. ],
  61. },
  62. onLoad: function () {
  63. page = 1;
  64. var that = this;
  65. wx.showLoading({
  66. title: '加载中......',
  67. })
  68. that.setData({
  69. top: App.globalData.statusBarHeight,
  70. hgt: App.globalData.titleBarHeight,
  71. companyname: App.globalData.companyname,
  72. clientType: App.globalData.clientype
  73. })
  74. that.setData({
  75. personobj: App.globalData.personMsg,
  76. })
  77. this.intregral_total();
  78. },
  79. onReady: function () {
  80. },
  81. jumpMinePage: function() {
  82. wx.reLaunch({
  83. url: '/customer/pages/brokerindex/brokerindex',
  84. })
  85. },
  86. jumpRankPage: function() {
  87. wx.reLaunch({
  88. url: '/customer/pages/brokerindex/brokerindex?type=rank',
  89. })
  90. },
  91. bindDateChange(e) {
  92. this.setData({
  93. date: e.detail.value
  94. })
  95. this.getBrokerClient()
  96. },
  97. searchlist(e) {
  98. page = 1;
  99. let text = e.currentTarget.dataset.text;
  100. let type = text == '全部客户'? '': text == '未联系' ? '待确认' : text;
  101. this.setData({
  102. clientState: type,
  103. curType: text
  104. })
  105. this.getBrokerClient()
  106. },
  107. viewIntegral() {
  108. wx.navigateTo({
  109. url: '/pages/other/other?type=2277',
  110. })
  111. },
  112. goidxtap: function () {
  113. wx.navigateTo({
  114. url: '/index/pages/activity/activity?type=broker',
  115. })
  116. },
  117. closetap: function () {
  118. this.setData({
  119. unfutureflag: false
  120. })
  121. },
  122. setap: function () {
  123. wx.navigateTo({
  124. url: '/mycustomer/pages/set/set'
  125. })
  126. },
  127. switchCompany() {
  128. this.setData({
  129. showCompany: true
  130. })
  131. },
  132. switchCompanyType(e) {
  133. let company = e.currentTarget.dataset.company;
  134. App.globalData.clientype = company;
  135. this.setData({
  136. showCompany: false
  137. })
  138. setTimeout(() => {
  139. this.getBrokerClient();
  140. this.clientStatistics();
  141. this.getCompanylist();
  142. this.intregral_total();
  143. }, 1000)
  144. },
  145. closeDialog() {
  146. this.setData({
  147. showCompany: false
  148. })
  149. },
  150. onChange(e) {
  151. this.setData({
  152. keyword: e.detail.value
  153. })
  154. },
  155. onSearch() {
  156. page = 1;
  157. this.getBrokerClient();
  158. },
  159. showSearchIpt() {
  160. let showState = !this.data.hiddenSearch;
  161. this.setData({
  162. hiddenSearch: showState
  163. })
  164. },
  165. arrfun: function (str) {
  166. var that = this;
  167. let arr = str.split(',');
  168. return arr;
  169. },
  170. logintap: function () {
  171. this.loginbox = this.selectComponent("#loginbox");
  172. this.loginbox.loginfun();
  173. },
  174. /**
  175. * 获取公司列表
  176. */
  177. getCompanylist() {
  178. let that = this;
  179. utils.$post({
  180. url: App.globalData.webUrl + 'api/agents_work/company',
  181. header: {
  182. 'Authorization': 'bearer ' + App.globalData.token
  183. },
  184. data: {},
  185. success: function (res) {
  186. if (res.data.code == '0') {
  187. that.setData({
  188. companylist: res.data.data
  189. })
  190. }
  191. }
  192. })
  193. },
  194. /**
  195. * 经纪人客户列表
  196. */
  197. getBrokerClient() {
  198. let that = this;
  199. utils.$post({
  200. url: App.globalData.webUrl + 'api/agents_work/customer_list',
  201. header: {
  202. 'Authorization': 'bearer ' + App.globalData.token
  203. },
  204. data: {
  205. page: page,
  206. limit: 10,
  207. state: that.data.clientState,
  208. keyword: that.data.keyword
  209. },
  210. success: function (res) {
  211. if (res.data.code == '0') {
  212. that.setData({
  213. datashow: true,
  214. brokerClientlist: res.data.data.list
  215. })
  216. that.clientStatistics();
  217. }
  218. }
  219. })
  220. },
  221. /**
  222. * 客户数据统计
  223. */
  224. clientStatistics: function (text) {
  225. var that = this;
  226. wx.hideLoading()
  227. utils.$post({
  228. url: App.globalData.webUrl + 'api/agents_work/agt_crm_count',
  229. header: {
  230. 'Authorization': 'bearer ' + App.globalData.token
  231. },
  232. data: {},
  233. success: function (res) {
  234. if (res.data.code == '0') {
  235. that.setData({
  236. clientTotal: res.data.data
  237. })
  238. }
  239. }
  240. })
  241. },
  242. /**
  243. * 我的积分数据
  244. */
  245. intregral_total: function (text) {
  246. var that = this;
  247. wx.hideLoading()
  248. utils.$post({
  249. url: App.globalData.webUrl + 'api/agents_work/intregral_total',
  250. header: {
  251. 'Authorization': 'bearer ' + App.globalData.token
  252. },
  253. data: {},
  254. success: function (res) {
  255. if (res.data.code == '0') {
  256. that.setData({
  257. intregralTotal: res.data.data
  258. })
  259. }
  260. }
  261. })
  262. },
  263. dothis() {
  264. this.data.stateShow = true;
  265. this.data.sourceShow = true;
  266. this.setData({
  267. stateShow: this.data.stateShow,
  268. sourceShow: this.data.sourceShow
  269. })
  270. },
  271. managemenTap: function () {
  272. this.setData({
  273. unfutureflag: true
  274. })
  275. },
  276. ranktap: function () {
  277. var that = this;
  278. this.$route('/mycustomer/pages/rankbox/rankbox')
  279. },
  280. informTap: function (e) {
  281. var that = this;
  282. wx.navigateTo({
  283. url: '/mycustomer/pages/information/information',
  284. })
  285. },
  286. onShow: function (e) {
  287. var that = this;
  288. loginnum = loginnum + 1;
  289. that.setData({
  290. top: App.globalData.statusBarHeight,
  291. hgt: App.globalData.titleBarHeight,
  292. companyname: App.globalData.companyname
  293. })
  294. that.setData({
  295. tokenflag: App.globalData.tokenflag,
  296. })
  297. this.setData({
  298. personMsg: App.globalData.personMsg
  299. })
  300. this.getBrokerClient();
  301. this.getCompanylist();
  302. },
  303. onAwake: function (t) {
  304. // console.log('[pages/index] 程序被唤醒:', t)
  305. },
  306. /**
  307. * 置顶客户
  308. */
  309. handleTopping: function (e) {
  310. let that = this;
  311. let cid = e.currentTarget.dataset.cid;
  312. utils.$post({
  313. url: App.globalData.webUrl + 'api/agents_work/set_top',
  314. header: {
  315. 'Authorization': 'bearer ' + App.globalData.token
  316. },
  317. data: {
  318. customer_id: cid
  319. },
  320. success: function (res) {
  321. if (res.data.code == '0') {
  322. page = 1;
  323. that.getBrokerClient();
  324. }
  325. }
  326. })
  327. },
  328. backTap: function () {
  329. wx.navigateBack();
  330. },
  331. /**
  332. * 生命周期函数--监听页面隐藏
  333. */
  334. onHide: function () {
  335. var timearr = App.globalData.timearr, flag = false;
  336. for (var i = 0; i < timearr.length; i++) {
  337. if (timearr[i].type == 'index') {
  338. timearr[i].time = timearr[i].time * 1 + stoptime * 1;
  339. flag = true;
  340. }
  341. }
  342. if (!flag) {
  343. var obj = {
  344. type: 'index',
  345. time: stoptime
  346. };
  347. App.globalData.timearr.push(obj);
  348. } else {
  349. App.globalData.timearr = timearr;
  350. }
  351. },
  352. /**
  353. * 生命周期函数--监听页面卸载
  354. */
  355. onUnload: function () {
  356. },
  357. /**
  358. * 页面相关事件处理函数--监听用户下拉动作
  359. */
  360. onPullDownRefresh: function () {
  361. var that = this;
  362. setTimeout(function () {
  363. wx.stopPullDownRefresh();
  364. }, 500)
  365. page = 1;
  366. utils.$post({
  367. url: App.globalData.webUrl + 'api/agents_work/customer_list',
  368. header: {
  369. 'Authorization': 'bearer ' + App.globalData.token
  370. },
  371. data: {
  372. page: page,
  373. limit: 10,
  374. state: that.data.clientState,
  375. keyword: that.data.keyword
  376. },
  377. success: function (res) {
  378. if (res.data.code == '0') {
  379. that.setData({
  380. brokerClientlist: res.data.data.list
  381. })
  382. that.clientStatistics();
  383. }
  384. }
  385. })
  386. },
  387. /**
  388. * 页面上拉触底事件的处理函数
  389. */
  390. onReachBottom: function () {
  391. page = page + 1;
  392. var that = this;
  393. utils.$post({
  394. url: App.globalData.webUrl + 'api/agents_work/customer_list',
  395. header: {
  396. 'Authorization': 'bearer ' + App.globalData.token
  397. },
  398. data: {
  399. page: page,
  400. limit: 10,
  401. state: that.data.clientState,
  402. keyword: that.data.keyword
  403. },
  404. success: function (res) {
  405. if (res.data.code == '0') {
  406. let list = that.data.brokerClientlist.concat(res.data.data.list);
  407. that.setData({
  408. brokerClientlist: list
  409. })
  410. }
  411. }
  412. })
  413. }
  414. })