index.js 3.2 KB

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