index.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. import {
  2. ApiModel
  3. } from "../../utils/api";
  4. const _Http = new ApiModel;
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. cooperationList: [], //合作列表
  11. condition: "", //模糊搜索条件
  12. pageNumber: 1, //请求分页
  13. pageTotal: 1, //总页数
  14. },
  15. /**
  16. * 生命周期函数--监听页面加载
  17. */
  18. onLoad: function (options) {},
  19. /* 搜索 */
  20. searchQuery({
  21. detail
  22. }) {
  23. if (this.data.condition == detail) return;
  24. this.setData({
  25. condition: detail,
  26. pageNumber: 1,
  27. pageTotal: 1
  28. })
  29. this.getList();
  30. },
  31. /* 跳转商户 */
  32. jumpForDetails(e) {
  33. const {
  34. index
  35. } = e.currentTarget.dataset;
  36. const data = this.data.cooperationList[index];
  37. wx.navigateTo({
  38. url: '/pages/businessPartner/details?data=' + JSON.stringify(data),
  39. })
  40. },
  41. /**
  42. * 生命周期函数--监听页面初次渲染完成
  43. */
  44. onReady: function () {
  45. },
  46. /**
  47. * 生命周期函数--监听页面显示
  48. */
  49. onShow: function () {
  50. this.setData({
  51. pageNumber: 1,
  52. pageTotal: 1
  53. });
  54. this.getList()
  55. },
  56. /* 下拉触底 */
  57. scrolltolower() {
  58. if (this.data.pageTotal < this.data.pageNumber) return;
  59. this.getList();
  60. },
  61. getList() {
  62. _Http.basic({
  63. "accesstoken": wx.getStorageSync('userData').token,
  64. "classname": "customer.tagents.tagents",
  65. "method": "query_cooperation",
  66. "content": {
  67. "getdatafromdbanyway": true,
  68. "pageNumber": this.data.pageNumber,
  69. "pageSize": 20,
  70. "where": {
  71. "condition": this.data.condition,
  72. "ftype": "",
  73. "fstatus": "合作"
  74. }
  75. }
  76. }).then(res => {
  77. console.log(res)
  78. if (res.msg != '成功') return wx.showToast({
  79. title: res.data,
  80. icon: "none"
  81. });
  82. let cooperationList = res.data;
  83. if (res.pageNumber != 1) {
  84. cooperationList = this.data.cooperationList.concat(cooperationList)
  85. };
  86. this.setData({
  87. cooperationList,
  88. pageTotal: res.pageTotal,
  89. pageNumber: this.data.pageNumber + 1
  90. });
  91. })
  92. },
  93. /**
  94. * 生命周期函数--监听页面隐藏
  95. */
  96. onHide: function () {
  97. },
  98. /**
  99. * 生命周期函数--监听页面卸载
  100. */
  101. onUnload: function () {
  102. },
  103. /**
  104. * 页面相关事件处理函数--监听用户下拉动作
  105. */
  106. onPullDownRefresh: function () {
  107. },
  108. /**
  109. * 页面上拉触底事件的处理函数
  110. */
  111. onReachBottom: function () {
  112. },
  113. /**
  114. * 用户点击右上角分享
  115. */
  116. onShareAppMessage: function () {
  117. }
  118. })