kindSecondList.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. var app = getApp();
  2. var host = app.globalData.servsers;
  3. Page({
  4. data: {
  5. contentList: [],
  6. forid:null,
  7. page:0, // 表示从第一页开始
  8. limit:10, // 每页10条数据
  9. requestState:true, // 表示可以请求
  10. loginStatic: false //登陆状态,默认为false
  11. },
  12. onLoad: function (options) {
  13. var that = this;
  14. // var classify_name = options.classify_name;
  15. // var flag = options.flag;
  16. // var shareFlag = options.shareFlag;
  17. // if (shareFlag != '' && shareFlag != null && shareFlag != undefined){
  18. // that.setData({
  19. // shareFlag: shareFlag
  20. // })
  21. // }
  22. console.log("id:" + options.id);
  23. console.log("classify_name:" + options.classify_name);
  24. console.log("shareFlag:" + options.shareFlag);
  25. console.log("classify_des: "+options.classify_des);
  26. if (options.id){
  27. that.getId(that, options.id)
  28. } else {
  29. that.getGoodsList(that)
  30. }
  31. if(options.id == '2298' || options.id == '3000'){//内部员工和VIP禁止分享
  32. //禁止分享
  33. wx.hideShareMenu();
  34. }
  35. // that.setData({
  36. // id: options.id
  37. // })
  38. // wx.request({
  39. // url: host+"classifyapi/findAllforviewSce",
  40. // data: {
  41. // id: options.id
  42. // },
  43. // method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
  44. // header: {
  45. // 'Accept': 'application/json'
  46. // },
  47. // success: function (res) {
  48. // that.setData({
  49. // contentList: res.data.rows
  50. // });
  51. // console.log(res.data.rows);
  52. // if (res.data.rows != ''){
  53. // var forid = res.data.rows[0].id;
  54. // var forname = res.data.rows[0].classify_name;
  55. // var classifydes = res.data.rows[0].classify_des;
  56. // }
  57. // if (res == null || res.data == null) {
  58. // console.error('网络请求失败');
  59. // return;
  60. // }
  61. // }
  62. // });
  63. // wx.setNavigationBarTitle({
  64. // title: options.classify_name
  65. // })
  66. // this.setData({
  67. // classify_name: options.classify_name,
  68. // classify_des: options.classify_des,
  69. // flag: flag
  70. // })
  71. },
  72. onShow(){
  73. let that = this;
  74. if (wx.getStorageSync('channelIdObj').channelId) {
  75. that.setData({
  76. loginStatic: true,
  77. })
  78. }
  79. },
  80. //滚动到底部触发事件
  81. /**
  82. * 页面上拉触底事件的处理函数
  83. */
  84. onReachBottom: function () {
  85. let that = this;
  86. if (that.data.requestState) {
  87. that.setData({
  88. page: that.data.page + 1
  89. })
  90. that.getGoodsList(that)
  91. }
  92. },
  93. getId(that,id){
  94. wx.request({
  95. url: host + "classifyapi/findAllforviewSce",
  96. method:'get',
  97. data:{
  98. id:id
  99. },
  100. success(res){
  101. if(res.data.rows.length > 0){
  102. that.setData({
  103. forid: res.data.rows[0].id
  104. })
  105. }
  106. that.getGoodsList(that)
  107. }
  108. })
  109. },
  110. getGoodsList(that){
  111. let data = {
  112. offset: that.data.page,
  113. limit: that.data.limit,
  114. channelId: wx.getStorageSync('channelIdObj').channelId ? wx.getStorageSync('channelIdObj').channelId : ""
  115. }
  116. if (that.data.forid) {
  117. data.commodity_levelTwo = that.data.forid
  118. }
  119. // if (that.data.channelIdObj.channelAccountId) {
  120. // data.commodity_levelTwo = that.data.forid
  121. // }
  122. wx.request({
  123. url: host + "commodityapi/commoditviewfoeeverybody",
  124. data: data,
  125. method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
  126. header: {
  127. 'Accept': 'application/json'
  128. },
  129. success: function (res) {
  130. let contentList = that.data.contentList;
  131. contentList.push(...res.data.rows)
  132. that.setData({
  133. contentList: contentList,
  134. requestState: res.data.rows.length ==that.data.limit
  135. });
  136. if (res == null || res.data == null) {
  137. console.error('网络请求失败');
  138. return;
  139. }
  140. }
  141. });
  142. },
  143. toGoodsDetail(e) { // 进入商品详情页
  144. let that = this, id = e.currentTarget.dataset.id;
  145. wx.navigateTo({
  146. url: '/pages/buy/buy?com_id=' + id,
  147. })
  148. },
  149. })