index.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. import recordSource from '../../utils/recordSource';
  2. import bonusUp from '../../utils/bonusUp';
  3. const getReq = require('../../config.js').getReq;
  4. const getTypeSn = require('../../utils/util.js').getTypeSn;
  5. let app = getApp();
  6. Page({
  7. data: {
  8. tabs: [],
  9. prop_special: [],
  10. surplus_special: [],
  11. special_datas: {},
  12. summery: [],
  13. isScroll: false,
  14. isSendProp: false,
  15. firstLoad: true,
  16. fromSource: '',
  17. tipsFlag: false,
  18. tipsDatas: null,
  19. daliy_bonus: ''
  20. },
  21. onShow: function ()
  22. {
  23. this.closeTips()
  24. if (!this.data.firstLoad) {
  25. app.setFromSource(this.data.fromSource)
  26. }
  27. // if (app.globalData.userInfo) {
  28. // setTimeout(() => {
  29. // bonusUp((tipsFlag, tipsDatas) => {
  30. // this.setData({
  31. // tipsFlag,
  32. // tipsDatas
  33. // })
  34. // })
  35. // }, 0);
  36. // }
  37. },
  38. onLoad: function (options) {
  39. console.log('onLoad options:',options)
  40. if (options && options.relay_id) {
  41. app.globalData.relay_id = options.relay_id
  42. console.log('options.relay_id:', options.relay_id)
  43. }
  44. this.getDatas()
  45. },
  46. freeBonus() {
  47. if (this.data.daliy_bonus) {
  48. let type_sn = getTypeSn(this.data.daliy_bonus)
  49. if (type_sn) {
  50. app.navigateto(`/pages/shareBonus/shareBonus?type_sn=${type_sn}`)
  51. return
  52. }
  53. }
  54. },
  55. getDatas(special_id) {
  56. let fromSource = recordSource(app, 'act=index&op=index&special_id=0&page=10&curpage=1&client_type=mini')
  57. wx.showLoading({
  58. title: '加载中'
  59. });
  60. let self = this;
  61. console.log('fromSource =' + fromSource)
  62. getReq(app,{
  63. act: 'index',
  64. op: 'mini_index',
  65. page: 10,
  66. curpage: 1,
  67. from: fromSource
  68. }, function (res) {
  69. wx.stopPullDownRefresh()
  70. if (res.code == 200) {
  71. let prop_special = res.datas.special_list;
  72. let sent_down_special = prop_special.splice(0, 8);
  73. self.setData({
  74. surplus_special: prop_special,
  75. prop_special: sent_down_special,
  76. special_datas: res.datas,
  77. summery: res.datas.summary,
  78. firstLoad: false,
  79. fromSource: app.globalData.fromSource
  80. });
  81. }
  82. setTimeout(function () {
  83. wx.hideLoading()
  84. }, 1000)
  85. })
  86. },
  87. req_tabs() {
  88. let self = this
  89. getReq(app,{
  90. act: 'index',
  91. op: 'tabs'
  92. }, function (res) {
  93. if (res.code == 200) {
  94. self.getDatas(res.datas.tabs[0].special_id);
  95. self.setData({
  96. tabs: res.datas.tabs,
  97. daliy_bonus: res.datas.daliy_bonus
  98. });
  99. }
  100. })
  101. },
  102. onMyEvent: function (e) {
  103. this.setData({
  104. prop_special: [],
  105. surplus_special: [],
  106. special_datas: {},
  107. summery: []
  108. });
  109. this.getDatas(e.detail.item.special_id)
  110. },
  111. closeTips() {
  112. this.setData({
  113. tipsFlag: false,
  114. tipsDatas: null
  115. })
  116. },
  117. onPageScroll(e) {
  118. clearTimeout(this.showTop);
  119. this.showTop = setTimeout(() => {
  120. let scrollTop = e.scrollTop;
  121. if (scrollTop >= 300) {
  122. this.setData({
  123. isScroll: true
  124. })
  125. }
  126. else {
  127. this.setData({
  128. isScroll: false
  129. })
  130. }
  131. }, 100);
  132. },
  133. backTop() {
  134. wx.pageScrollTo({
  135. scrollTop: 0,
  136. duration: 300
  137. })
  138. },
  139. onShareAppMessage: function () {
  140. return app.cardShareInfo();
  141. },
  142. onReachBottom: function () {
  143. if (this.data.isSendProp) {
  144. return;
  145. }
  146. let surplus_special_num = this.data.surplus_special.length;
  147. if (surplus_special_num > 0) {
  148. wx.showLoading({
  149. title: '加载中'
  150. });
  151. this.setData({
  152. isSendProp: true
  153. });
  154. this.data.isSendProp = true;
  155. let prop_special = this.data.surplus_special;
  156. let sent_down_special = prop_special.splice(0, 8);
  157. this.setData({
  158. surplus_special: prop_special,
  159. prop_special: this.data.prop_special.concat(sent_down_special)
  160. })
  161. this.setData({
  162. isSendProp: false
  163. });
  164. setTimeout(function () {
  165. wx.hideLoading()
  166. }, 1500)
  167. }
  168. else {
  169. return;
  170. }
  171. },
  172. onPullDownRefresh(){
  173. this.getDatas()
  174. }
  175. })