index.js 3.4 KB

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