index.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. this.setData({
  46. showIndex: -1
  47. })
  48. wx.navigateTo({
  49. url: '/pages/businessPartner/details?data=' + JSON.stringify(data),
  50. })
  51. },
  52. /**
  53. * 生命周期函数--监听页面初次渲染完成
  54. */
  55. onReady: function () {
  56. },
  57. /**
  58. * 生命周期函数--监听页面显示
  59. */
  60. onShow: function () {
  61. this.setData({
  62. pageNumber: 1,
  63. pageTotal: 1
  64. });
  65. this.getList()
  66. },
  67. /* 下拉触底 */
  68. scrolltolower() {
  69. if (!this.data.scrolltolowerThrottle) return;
  70. this.setData({
  71. scrolltolowerThrottle: false
  72. })
  73. if (this.data.pageTotal > this.data.pageNumber) this.getList();
  74. },
  75. getList() {
  76. _Http.basic({
  77. "accesstoken": wx.getStorageSync('userData').token,
  78. "classname": "customer.tagents.tagents",
  79. "method": "query_cooperation",
  80. "content": {
  81. "getdatafromdbanyway": true,
  82. "pageNumber": this.data.pageNumber,
  83. "pageSize": 20,
  84. "where": {
  85. "condition": this.data.condition,
  86. "ftype": "",
  87. "fstatus": "合作"
  88. }
  89. }
  90. }).then(res => {
  91. console.log(res)
  92. if (res.msg != '成功') return wx.showToast({
  93. title: res.data,
  94. icon: "none"
  95. });
  96. let cooperationList = [];
  97. if (res.pageNumber == 1) {
  98. cooperationList = res.data
  99. } else {
  100. cooperationList = this.data.requestList.concat(res.data)
  101. };
  102. this.setData({
  103. cooperationList,
  104. pageTotal: res.pageTotal,
  105. pageNumber: this.data.pageNumber + 1,
  106. scrolltolowerThrottle: true
  107. });
  108. })
  109. },
  110. /**
  111. * 生命周期函数--监听页面隐藏
  112. */
  113. onHide: function () {
  114. },
  115. /**
  116. * 生命周期函数--监听页面卸载
  117. */
  118. onUnload: function () {
  119. },
  120. /**
  121. * 页面相关事件处理函数--监听用户下拉动作
  122. */
  123. onPullDownRefresh: function () {
  124. },
  125. /**
  126. * 页面上拉触底事件的处理函数
  127. */
  128. onReachBottom: function () {
  129. },
  130. /**
  131. * 用户点击右上角分享
  132. */
  133. onShareAppMessage: function () {
  134. }
  135. })