index.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. let app = getApp();
  2. const getReq = require('./../../config.js').getReq;
  3. Page({
  4. data: {
  5. tabs: [],
  6. prop_special:[],
  7. surplus_special:[],
  8. special_datas: {},
  9. summery: [],
  10. isScroll:false,
  11. isSendProp:false
  12. },
  13. onShow: function() {
  14. if (app.globalData.backLogin) {
  15. app.globalData.backLogin = false;
  16. wx.reLaunch({
  17. url: "/pages/index/index"
  18. });
  19. }
  20. },
  21. onLoad: function () {
  22. // this.req_tabs();
  23. this.getDatas(0)
  24. },
  25. req_tabs(){
  26. let self = this
  27. getReq({
  28. act: 'index',
  29. op: 'tabs'
  30. }, function (res) {
  31. if (res.code == 200) {
  32. self.getDatas(res.datas.tabs[0].special_id);
  33. // console.log(res.datas.tabs[0].special_id);
  34. // self.getDatas(1364);
  35. self.setData({
  36. tabs: res.datas.tabs
  37. });
  38. }
  39. })
  40. },
  41. onMyEvent: function (e) {
  42. this.setData({
  43. prop_special:[],
  44. surplus_special:[],
  45. special_datas: {},
  46. summery: []
  47. });
  48. this.getDatas(e.detail.item.special_id)
  49. },
  50. getDatas(special_id) {
  51. wx.showLoading({
  52. title: '加载中'
  53. });
  54. let self = this;
  55. getReq({
  56. act: 'special',
  57. op: 'index',
  58. special_id,
  59. page: 10,
  60. curpage: 1
  61. }, function (res) {
  62. if (res.code == 200) {
  63. let prop_special = res.datas.special_list;
  64. let sent_down_special = prop_special.splice(0, 8);
  65. self.setData({
  66. surplus_special: prop_special,
  67. prop_special: sent_down_special,
  68. special_datas: res.datas,
  69. summery: res.datas.summary
  70. });
  71. }
  72. setTimeout(function () {
  73. wx.hideLoading()
  74. }, 1000)
  75. })
  76. },
  77. onPageScroll(e){
  78. clearTimeout(this.showTop);
  79. this.showTop = setTimeout(()=>{
  80. let scrollTop = e.scrollTop;
  81. if (scrollTop >= 300) {
  82. this.setData({
  83. isScroll: true
  84. })
  85. }
  86. else {
  87. this.setData({
  88. isScroll: false
  89. })
  90. }
  91. },100);
  92. },
  93. backTop(){
  94. wx.pageScrollTo({
  95. scrollTop: 0,
  96. duration: 300
  97. })
  98. },
  99. onShareAppMessage: function () {
  100. return {
  101. title:"熊猫美妆小程序",
  102. path:"/pages/index/index"
  103. }
  104. },
  105. onReachBottom: function(){
  106. if (this.data.isSendProp){
  107. return;
  108. }
  109. let surplus_special_num = this.data.surplus_special.length;
  110. if (surplus_special_num > 0){
  111. // wx.showLoading({
  112. // title: '加载中'
  113. // });
  114. this.setData({
  115. isSendProp:true
  116. });
  117. this.data.isSendProp = true;
  118. let prop_special = this.data.surplus_special;
  119. let sent_down_special = prop_special.splice(0, 8);
  120. this.setData({
  121. surplus_special: prop_special,
  122. prop_special: this.data.prop_special.concat(sent_down_special)
  123. })
  124. this.setData({
  125. isSendProp: false
  126. });
  127. // wx.hideLoading();
  128. }
  129. }
  130. })