index.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. import {
  2. ApiModel
  3. } from "../../utils/api";
  4. const _Http = new ApiModel();
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. active: 0, //tabs选中下标
  11. pageNumber: 1, //请求页号
  12. productList: [], //产品列表
  13. },
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */
  17. onLoad: function (options) {
  18. },
  19. /* tabs 切换事件 */
  20. tabsChange(e) {
  21. const {
  22. index
  23. } = e.detail;
  24. this.setData({
  25. active: e.detail.index
  26. })
  27. this.gettingData(index)
  28. },
  29. /* 获取数据 */
  30. gettingData(index, value) {
  31. let where = {
  32. "condition": "",
  33. "fisonsale": ""
  34. };
  35. //请求类型
  36. if (index == 1) {
  37. where.fisonsale = 1;
  38. } else if (index == 2) {
  39. where.fisonsale = 0;
  40. }
  41. //模糊搜索
  42. if (value) {
  43. where.condition = value
  44. };
  45. /* 发送请求 */
  46. _Http.basic({
  47. "accesstoken": wx.getStorageSync('userData').token,
  48. "classname": "customer.products.products",
  49. "method": "query_productsList",
  50. "content": {
  51. "getdatafromdbanyway": true,
  52. "pageNumber": this.data.pageNumber,
  53. "pageSize": 20,
  54. "where": where
  55. }
  56. }).then(res => {
  57. console.log(res)
  58. if (res.msg != '成功') return;
  59. this.setData({
  60. productList: res.data
  61. })
  62. //增加页码
  63. if (res.pageTotal > res.pageNumber) {
  64. this.setData({
  65. pageNumber: res.pageNumber + 1
  66. })
  67. }
  68. })
  69. },
  70. /* 产品信息修改 */
  71. changeProductMessage(e) {
  72. const {
  73. index
  74. } = e.currentTarget.dataset;
  75. console.log(index)
  76. },
  77. /**
  78. * 生命周期函数--监听页面初次渲染完成
  79. */
  80. onReady: function () {
  81. },
  82. /**
  83. * 生命周期函数--监听页面显示
  84. */
  85. onShow: function () {
  86. this.gettingData(this.data.active)
  87. },
  88. /**
  89. * 生命周期函数--监听页面隐藏
  90. */
  91. onHide: function () {
  92. },
  93. /**
  94. * 生命周期函数--监听页面卸载
  95. */
  96. onUnload: function () {
  97. },
  98. /**
  99. * 页面相关事件处理函数--监听用户下拉动作
  100. */
  101. onPullDownRefresh: function () {
  102. },
  103. /**
  104. * 页面上拉触底事件的处理函数
  105. */
  106. onReachBottom: function () {
  107. },
  108. /**
  109. * 用户点击右上角分享
  110. */
  111. onShareAppMessage: function () {
  112. }
  113. })