index.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. let _Http = getApp().globalData.http,
  2. content = {
  3. pageNumber: 1,
  4. pageTotal: 1,
  5. pageSize: 10,
  6. "where": {
  7. "condition": "",
  8. "status": ""
  9. }
  10. },
  11. currency = require("../../../../../utils/currency"),
  12. CNY = value => currency(value, {
  13. symbol: "",
  14. precision: 2
  15. }).format(),
  16. obj = {};
  17. import {
  18. formatTime
  19. } from "../../../../../utils/getTime"
  20. Component({
  21. lifetimes: {
  22. attached: function () {
  23. this.getList(true)
  24. let date = formatTime().split(" ")[0].split("/");
  25. obj = {
  26. year: date[0],
  27. month: date[1],
  28. day: date[2],
  29. quarter: Math.ceil(date[1] / 3)
  30. };
  31. console.log(obj)
  32. },
  33. },
  34. data: {
  35. list: []
  36. },
  37. methods: {
  38. getList(init = false) {
  39. if (init) {
  40. content.pageNumber = 1;
  41. content.pageTotal = 1;
  42. }
  43. if (content.pageNumber > content.pageTotal) return;
  44. _Http.basic({
  45. "id": 20231103100503,
  46. "version": 1,
  47. content
  48. }).then(res => {
  49. console.log("获取经销商排名", res)
  50. if (res.msg != '成功') return;
  51. let list = res.data.map(v => {
  52. //l基本 h挑战 a实际 pl基础目标实际完成率 ph挑战目标实际完成率
  53. let ar = [{
  54. fulfill: CNY(v.m1a + v.m2a + v.m3a),
  55. target: CNY(v.m3l + v.m3l + v.m3l),
  56. }, {
  57. fulfill: CNY(v.m4a + v.m5a + v.m6a),
  58. target: CNY(v.m4l + v.m5l + v.m6l),
  59. }, {
  60. fulfill: CNY(v.m7a + v.m8a + v.m9a),
  61. target: CNY(v.m7l + v.m8l + v.m9l),
  62. }, {
  63. fulfill: CNY(v.m10a + v.m11a + v.m12a),
  64. target: CNY(v.m10l + v.m11l + v.m12l),
  65. }];
  66. v.quarter = ar[obj.quarter - 1];
  67. console.log(obj.month)
  68. console.log(CNY(v[`m${obj.month}a`]))
  69. v.thisMonth = {
  70. fulfill: CNY(v[`m${obj.month}a`]),
  71. target: CNY(v[`m${obj.month}l`])
  72. }
  73. v.sumamount_currentmonth = CNY(v.sumamount_currentmonth)
  74. v.sumamount_year = CNY(v.sumamount_year)
  75. return v
  76. })
  77. this.setData({
  78. list: res.pageNumber == 1 ? list : this.data.list.concat(list)
  79. });
  80. content.pageNumber = res.pageNumber + 1;
  81. content.pageTotal = res.pageTotal;
  82. })
  83. }
  84. }
  85. })