index.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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. jumpForChange(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. jumpForDetails(e) {
  43. const {
  44. index
  45. } = e.currentTarget.dataset;
  46. wx.navigateTo({
  47. url: '/pages/storeMessage/storehomepage?id=' + this.data.cooperationList[index].tcooperationagentsid
  48. })
  49. },
  50. /**
  51. * 生命周期函数--监听页面初次渲染完成
  52. */
  53. onReady: function () {
  54. },
  55. /**
  56. * 生命周期函数--监听页面显示
  57. */
  58. onShow: function () {
  59. this.setData({
  60. pageNumber: 1,
  61. pageTotal: 1
  62. });
  63. this.getList()
  64. },
  65. /* 下拉触底 */
  66. scrolltolower() {
  67. if (this.data.pageTotal < this.data.pageNumber) return;
  68. this.getList();
  69. },
  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. "fstatus": "合作"
  83. }
  84. }
  85. }).then(res => {
  86. console.log("合作列表", res)
  87. if (res.msg != '成功') return wx.showToast({
  88. title: res.data,
  89. icon: "none"
  90. });
  91. for (let i = 0; i < res.data.length; i++) {
  92. let mySaleprodclass = '';
  93. for (let k = 0; k < res.data[i].saleprodclass.length; k++) {
  94. if (k <= 2) {
  95. (k == 0) ? mySaleprodclass += res.data[i].saleprodclass[k]: mySaleprodclass += ',' + res.data[i].saleprodclass[k];
  96. } else {
  97. mySaleprodclass += '...'
  98. break;
  99. }
  100. }
  101. res.data[i].mySaleprodclass = mySaleprodclass;
  102. }
  103. let cooperationList = res.data;
  104. if (res.pageNumber != 1) {
  105. cooperationList = this.data.cooperationList.concat(cooperationList)
  106. };
  107. this.setData({
  108. cooperationList,
  109. pageTotal: res.pageTotal,
  110. pageNumber: this.data.pageNumber + 1
  111. });
  112. })
  113. },
  114. /**
  115. * 生命周期函数--监听页面隐藏
  116. */
  117. onHide: function () {
  118. },
  119. /**
  120. * 生命周期函数--监听页面卸载
  121. */
  122. onUnload: function () {
  123. },
  124. /**
  125. * 页面相关事件处理函数--监听用户下拉动作
  126. */
  127. onPullDownRefresh: function () {
  128. },
  129. /**
  130. * 页面上拉触底事件的处理函数
  131. */
  132. onReachBottom: function () {
  133. },
  134. /**
  135. * 用户点击右上角分享
  136. */
  137. onShareAppMessage: function () {
  138. }
  139. })