index.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. pageNumber: 1, //请求分页
  14. pageTotal: 1, //总页数
  15. },
  16. /**
  17. * 生命周期函数--监听页面加载
  18. */
  19. onLoad: function (options) {},
  20. /* 搜索 */
  21. searchQuery({
  22. detail
  23. }) {
  24. if (this.data.condition == detail) return;
  25. this.setData({
  26. condition: detail,
  27. pageNumber: 1,
  28. pageTotal: 1
  29. })
  30. this.getList();
  31. },
  32. /* 点击item */
  33. showBtnIndex(e) {
  34. const {
  35. index
  36. } = e.currentTarget.dataset;
  37. this.setData({
  38. showIndex: index
  39. })
  40. },
  41. /* 跳转商户 */
  42. jumpForDetails() {
  43. const data = this.data.cooperationList[this.data.showIndex];
  44. this.setData({
  45. showIndex: -1
  46. })
  47. wx.navigateTo({
  48. url: '/pages/businessPartner/details?data=' + JSON.stringify(data),
  49. })
  50. },
  51. /**
  52. * 生命周期函数--监听页面初次渲染完成
  53. */
  54. onReady: function () {
  55. },
  56. /**
  57. * 生命周期函数--监听页面显示
  58. */
  59. onShow: function () {
  60. this.setData({
  61. pageNumber: 1,
  62. pageTotal: 1
  63. });
  64. this.getList()
  65. },
  66. /* 下拉触底 */
  67. scrolltolower() {
  68. if (this.data.pageTotal < this.data.pageNumber) return;
  69. 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. let cooperationList = res.data;
  93. if (res.pageNumber != 1) {
  94. cooperationList = this.data.cooperationList.concat(cooperationList)
  95. };
  96. this.setData({
  97. cooperationList,
  98. pageTotal: res.pageTotal,
  99. pageNumber: this.data.pageNumber + 1
  100. });
  101. })
  102. },
  103. /**
  104. * 生命周期函数--监听页面隐藏
  105. */
  106. onHide: function () {
  107. },
  108. /**
  109. * 生命周期函数--监听页面卸载
  110. */
  111. onUnload: function () {
  112. },
  113. /**
  114. * 页面相关事件处理函数--监听用户下拉动作
  115. */
  116. onPullDownRefresh: function () {
  117. },
  118. /**
  119. * 页面上拉触底事件的处理函数
  120. */
  121. onReachBottom: function () {
  122. },
  123. /**
  124. * 用户点击右上角分享
  125. */
  126. onShareAppMessage: function () {
  127. }
  128. })