competitor.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. const _Http = getApp().globalData.http;
  2. Component({
  3. options: {
  4. addGlobalClass: true
  5. },
  6. lifetimes: {
  7. attached: function () {
  8. getApp().globalData.Language.getLanguagePackage(this)
  9. }
  10. },
  11. data: {
  12. list: [],
  13. "content": {
  14. "nocache": true,
  15. "pageNumber": 1,
  16. "pageTotal": 1,
  17. "total": null,
  18. "where": {
  19. begdate: "",
  20. enddate: "",
  21. }
  22. }
  23. },
  24. methods: {
  25. getList(id, init) {
  26. let content = this.data.content;
  27. content.sa_projectid = id;
  28. content.type = this.data.isAll;
  29. if (init) {
  30. content.pageNumber = 1;
  31. content.total = null;
  32. }
  33. if (!this.data.showList && content.total != null) return;
  34. if (content.pageNumber > content.pageTotal) return;
  35. _Http.basic({
  36. "id": 20230715112004,
  37. content
  38. }).then(res => {
  39. console.log("项目竞争对手", res)
  40. if (res.code != '1') return wx.showToast({
  41. title: res.data,
  42. icon: "none"
  43. })
  44. content.pageNumber = res.pageNumber + 1;
  45. content.pageSize = res.pageSize;
  46. content.pageTotal = res.pageTotal;
  47. content.total = res.total;
  48. this.setData({
  49. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  50. content,
  51. id: id,
  52. });
  53. })
  54. },
  55. upDateList() {
  56. let content = JSON.parse(JSON.stringify(this.data.content));
  57. try {
  58. content.sa_projectid = this.data.id;
  59. content.type = this.data.isAll;
  60. content.pageSize = (content.pageNumber - 1) * content.pageSize;
  61. content.pageNumber = 1;
  62. } catch (error) {
  63. console.log("error", error)
  64. }
  65. _Http.basic({
  66. id: '20230715112004',
  67. content
  68. }).then(res => {
  69. console.log("更新项目竞争对手列表", res);
  70. if (res.code == '1') {
  71. page.setData({
  72. list: res.data,
  73. "content.total": res.total
  74. })
  75. }
  76. })
  77. }
  78. }
  79. })