patternMenu.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. // newsShop/pages/patternMenu/patternMenu.js
  2. let app = getApp();
  3. let host = app.globalData.servsers; // 请求的url
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. host:host,
  10. isSelect: "1", //默认全部
  11. dataStateArray: [
  12. {
  13. state: '1',
  14. label: "营销礼赠",
  15. },
  16. {
  17. state: '2',
  18. label: "商务送礼",
  19. },
  20. {
  21. state: '3',
  22. label: "员工/福利",
  23. }
  24. ],
  25. filterArray: [
  26. // { name: '1', value: '0~499元' },
  27. // { name: '2', value: '500~999元' },
  28. // { name: '3', value: '1000~1999元' },
  29. // { name: '4', value: '2000元以上' },
  30. ],
  31. requestState:true, //检测请求状态是否结束了
  32. filterStatic: false,
  33. isNew: true,
  34. isMin: true,
  35. goodsList:[],
  36. page:1, //默认是第一页
  37. limit:20, //一页20条数据
  38. maxPrice:null,//最大价格
  39. minPrice:null,//最低价格
  40. priceSort: null, //价格排序,默认降序
  41. timeSort: null, //价时间排序,默认降序
  42. },
  43. /**
  44. * 生命周期函数--监听页面加载
  45. */
  46. onLoad: function (options) {
  47. this.getGiftNavTab(this)
  48. },
  49. /**
  50. * 生命周期函数--监听页面初次渲染完成
  51. */
  52. onReady: function () {
  53. },
  54. /**
  55. * 生命周期函数--监听页面显示
  56. */
  57. onShow: function () {
  58. },
  59. /**
  60. * 生命周期函数--监听页面隐藏
  61. */
  62. onHide: function () {
  63. },
  64. /**
  65. * 生命周期函数--监听页面卸载
  66. */
  67. onUnload: function () {
  68. },
  69. /**
  70. * 页面相关事件处理函数--监听用户下拉动作
  71. */
  72. onPullDownRefresh: function () {
  73. },
  74. /**
  75. * 页面上拉触底事件的处理函数
  76. */
  77. onReachBottom: function () {
  78. },
  79. /**
  80. * 用户点击右上角分享
  81. */
  82. onShareAppMessage: function () {
  83. },
  84. tab(e){
  85. let that = this;
  86. that.setData({
  87. isSelect: e.currentTarget.dataset.id,
  88. goodsList:[],
  89. page:1,
  90. })
  91. that.getGiftList(that)
  92. },
  93. timeSortTap(){ // 时间筛选
  94. let that = this;
  95. that.setData({
  96. timeSort: that.data.timeSort === null ? 'asc' : that.data.timeSort === 'asc' ? 'desc' : 'asc',
  97. goodsList: [],
  98. page: 1,
  99. })
  100. that.getGiftList(that)
  101. },
  102. priceSortTap() { // 价格筛选
  103. let that = this;
  104. that.setData({
  105. priceSort: that.data.priceSort === null ? 'asc' : that.data.priceSort === 'asc' ? 'desc' : 'asc',
  106. goodsList: [],
  107. page: 1,
  108. })
  109. that.getGiftList(that)
  110. },
  111. getGiftNavTab(that){
  112. wx.request({
  113. url: host + '/classifyapi/classifyTwoAll',
  114. method: 'get',
  115. data: {
  116. classifyHigher:'3060'
  117. },
  118. success(res){
  119. console.log(res,"res")
  120. that.setData({
  121. dataStateArray:res.data.rows,
  122. isSelect:res.data.rows[0].id
  123. })
  124. that.getGiftList(that)
  125. }
  126. })
  127. },
  128. getGiftList(that){
  129. let data = {
  130. channelId: 5, // 渠道id,现在为5,一件选礼为5
  131. classId: that.data.isSelect,
  132. limit: that.data.limit, // 一页20条数据
  133. offset: that.data.page, //当前页数
  134. }
  135. if (that.data.priceSort) {
  136. data.priceSort = that.data.priceSort
  137. }
  138. if (that.data.timeSort) {
  139. data.timeSort = that.data.timeSort
  140. }
  141. if (that.data.maxPrice){
  142. data.maxPrice = that.data.maxPrice
  143. }
  144. if (that.data.minPrice) {
  145. data.minPrice = that.data.minPrice
  146. }
  147. wx.request({
  148. url: host +'/commodityapi/queryCommodityByClass',
  149. method:'get',
  150. data:data,
  151. success(res){
  152. let dataArray = that.data.goodsList;
  153. res.data.rows.forEach(el=>{
  154. el.logo = el.commodity_logo.split(",")
  155. })
  156. dataArray.push(...res.data.rows)
  157. that.setData({
  158. goodsList: dataArray
  159. })
  160. }
  161. })
  162. }
  163. })