index.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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. if (options && options.channel) {
  45. app.globalData.channel_num = options.channel
  46. console.log('options.channel:', options.channel)
  47. }
  48. this.getDatas(1039)
  49. },
  50. freeBonus() {
  51. if (this.data.daliy_bonus) {
  52. let type_sn = getTypeSn(this.data.daliy_bonus)
  53. if (type_sn) {
  54. app.navigateto(`/pages/shareBonus/shareBonus?type_sn=${type_sn}`)
  55. return
  56. }
  57. }
  58. },
  59. getDatas(special_id) {
  60. let fromSource = recordSource(app, 'act=index&op=index&special_id=0&page=10&curpage=1&client_type=mini')
  61. // wx.showLoading({
  62. // title: '加载中'
  63. // });
  64. let self = this;
  65. console.log('fromSource =' + fromSource)
  66. // getReq(app,{
  67. // act: 'index',
  68. // op: 'mini_index',
  69. // page: 10,
  70. // curpage: 1,
  71. // from: fromSource
  72. // },
  73. getReq(app,{
  74. act: 'special',
  75. op: 'index',
  76. special_id:special_id
  77. },
  78. function (res) {
  79. wx.stopPullDownRefresh()
  80. if (res.code == 200) {
  81. console.log(res)
  82. let prop_special = res.datas.special_list;
  83. let sent_down_special = prop_special.splice(0, 8);
  84. self.setData({
  85. surplus_special: prop_special,
  86. prop_special: sent_down_special,
  87. special_datas: res.datas,
  88. summery: res.datas.summary,
  89. firstLoad: false,
  90. fromSource: app.globalData.fromSource
  91. });
  92. }
  93. setTimeout(function () {
  94. wx.hideLoading()
  95. }, 1000)
  96. })
  97. },
  98. req_tabs() {
  99. let self = this
  100. getReq(app,{
  101. act: 'index',
  102. op: 'tabs'
  103. }, function (res) {
  104. if (res.code == 200) {
  105. self.getDatas(res.datas.tabs[0].special_id);
  106. self.setData({
  107. tabs: res.datas.tabs,
  108. daliy_bonus: res.datas.daliy_bonus
  109. });
  110. }
  111. })
  112. },
  113. onMyEvent: function (e) {
  114. this.setData({
  115. prop_special: [],
  116. surplus_special: [],
  117. special_datas: {},
  118. summery: []
  119. });
  120. this.getDatas(e.detail.item.special_id)
  121. },
  122. closeTips() {
  123. this.setData({
  124. tipsFlag: false,
  125. tipsDatas: null
  126. })
  127. },
  128. onPageScroll(e) {
  129. clearTimeout(this.showTop);
  130. this.showTop = setTimeout(() => {
  131. let scrollTop = e.scrollTop;
  132. if (scrollTop >= 300) {
  133. this.setData({
  134. isScroll: true
  135. })
  136. }
  137. else {
  138. this.setData({
  139. isScroll: false
  140. })
  141. }
  142. }, 100);
  143. },
  144. backTop() {
  145. wx.pageScrollTo({
  146. scrollTop: 0,
  147. duration: 300
  148. })
  149. },
  150. onShareAppMessage: function () {
  151. return app.cardShareInfo();
  152. },
  153. onReachBottom: function () {
  154. if (this.data.isSendProp) {
  155. return;
  156. }
  157. let surplus_special_num = this.data.surplus_special.length;
  158. if (surplus_special_num > 0) {
  159. wx.showLoading({
  160. title: '加载中'
  161. });
  162. this.setData({
  163. isSendProp: true
  164. });
  165. this.data.isSendProp = true;
  166. let prop_special = this.data.surplus_special;
  167. let sent_down_special = prop_special.splice(0, 8);
  168. this.setData({
  169. surplus_special: prop_special,
  170. prop_special: this.data.prop_special.concat(sent_down_special)
  171. })
  172. this.setData({
  173. isSendProp: false
  174. });
  175. setTimeout(function () {
  176. wx.hideLoading()
  177. }, 1500)
  178. }
  179. else {
  180. return;
  181. }
  182. },
  183. onPullDownRefresh(){
  184. this.getDatas()
  185. }
  186. })