achieveList.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. //index.js
  2. //获取应用实例
  3. const app = getApp()
  4. Page({
  5. data: {
  6. word: '昨日新增',
  7. type: 'yesterday',
  8. list: [],
  9. provinceList: [],
  10. province: ''
  11. },
  12. // 事件处理
  13. // 选择省份
  14. provinceChange: function (e) {
  15. this.setData({ "province": this.data.provinceList[e.detail.value].name });
  16. this.getCount(this.data.provinceList[e.detail.value])
  17. },
  18. onLoad: function (options) {
  19. var that = this;
  20. // 获取地址栏统计类型
  21. const { type } = options;
  22. let word;
  23. if (type === 'yesterday') word = "昨日新增";
  24. else if (type === 'week') word = '本周新增';
  25. else if (type === 'month') word = '本月新增';
  26. else word = '团队统计'
  27. that.setData({ type: options.type, word });
  28. this.getXzqh();
  29. },
  30. /**
  31. * 根据选择的省份进行统计
  32. * @param {Object} object 选择的省份Object
  33. */
  34. getCount(object) {
  35. const { code: province } = object;
  36. wx.request({
  37. url: `${app.globalData.publicUrl}/api/htyd/count/${this.data.type}?r_mobile=${app.globalData.userInfo.mobile}&province=${province}`,
  38. method: 'get',
  39. success: res => {
  40. const { data } = res.data
  41. const keys = Object.keys(data);
  42. const arr = [];
  43. for (const key of keys) {
  44. arr.push({ tc: `${key.includes('套餐') ? key : `${key}-套餐`}`, tzNum: data[key], jpNum: 0 })
  45. }
  46. this.setData({
  47. list: arr
  48. })
  49. }
  50. })
  51. },
  52. /**
  53. * 查询行政区划
  54. * @param {String} pcode 上级code
  55. */
  56. getXzqh(pcode) {
  57. const query = {};
  58. if (pcode) query.pcode = pcode;
  59. wx.request({
  60. url: `${app.globalData.publicUrl}/api/htyd/xzqh`,
  61. method: "get",
  62. success: res => {
  63. this.setData({
  64. provinceList: res.data.data
  65. })
  66. console.log(this.data.provinceList);
  67. }
  68. })
  69. }
  70. })