index.js 2.7 KB

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