index.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. console.log(options)
  20. },
  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. /* 编辑 */
  34. jumpForChange(e) {
  35. const {
  36. index
  37. } = e.currentTarget.dataset;
  38. const data = this.data.cooperationList[index];
  39. wx.navigateTo({
  40. url: '/pages/businessPartner/details?data=' + JSON.stringify(data),
  41. })
  42. },
  43. /* 跳转商户 */
  44. jumpForDetails(e) {
  45. const {
  46. index
  47. } = e.currentTarget.dataset;
  48. wx.navigateTo({
  49. url: '/pages/storeMessage/storehomepage?id=' + this.data.cooperationList[index].tcooperationagentsid
  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.pageTotal < this.data.pageNumber) return;
  70. this.getList();
  71. },
  72. /* 获取列表 */
  73. getList() {
  74. _Http.basic({
  75. "accesstoken": wx.getStorageSync('userData').token,
  76. "classname": "customer.tagents.tagents",
  77. "method": "query_cooperation",
  78. "content": {
  79. "getdatafromdbanyway": true,
  80. "pageNumber": this.data.pageNumber,
  81. "pageSize": 20,
  82. "where": {
  83. "condition": this.data.condition,
  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. for (let i = 0; i < res.data.length; i++) {
  94. let mySaleprodclass = '';
  95. for (let k = 0; k < res.data[i].saleprodclass.length; k++) {
  96. if (k <= 2) {
  97. (k == 0) ? mySaleprodclass += res.data[i].saleprodclass[k]: mySaleprodclass += ',' + res.data[i].saleprodclass[k];
  98. } else {
  99. mySaleprodclass += '...'
  100. break;
  101. }
  102. }
  103. res.data[i].mySaleprodclass = mySaleprodclass;
  104. }
  105. let cooperationList = res.data;
  106. if (res.pageNumber != 1) {
  107. cooperationList = this.data.cooperationList.concat(cooperationList)
  108. };
  109. this.setData({
  110. cooperationList,
  111. pageTotal: res.pageTotal,
  112. pageNumber: this.data.pageNumber + 1
  113. });
  114. })
  115. },
  116. /**
  117. * 生命周期函数--监听页面隐藏
  118. */
  119. onHide: function () {
  120. },
  121. /**
  122. * 生命周期函数--监听页面卸载
  123. */
  124. onUnload: function () {
  125. },
  126. /**
  127. * 页面相关事件处理函数--监听用户下拉动作
  128. */
  129. onPullDownRefresh: function () {
  130. },
  131. /**
  132. * 页面上拉触底事件的处理函数
  133. */
  134. onReachBottom: function () {
  135. },
  136. /**
  137. * 用户点击右上角分享
  138. */
  139. onShareAppMessage: function () {
  140. }
  141. })