index.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. import {
  2. getGroupList,
  3. getPositionList
  4. } from '../../services/index.js'
  5. import {
  6. formatTime
  7. } from '../../utils/util.js'
  8. import {
  9. showToast
  10. } from '../../utils/tips.js'
  11. import {
  12. updataStorageData
  13. } from '../../utils/storage.js'
  14. import {
  15. imgServerUrl
  16. } from '../../config/config.js'
  17. const app = getApp();
  18. Page({
  19. data: {
  20. hasShare: true,
  21. imgServerUrl: imgServerUrl,
  22. cityCode: '',
  23. pageNo: 1, //当前分页
  24. isScroll: true, //是否可以滚动
  25. clearTimer: false,
  26. djsEnd: false,
  27. myFormat: ['天', ':', ':', ' '],
  28. list: [],
  29. showNoMore: "没有更多信息...", //显示已无更多
  30. },
  31. onLoad: function(options) {
  32. },
  33. onReady: function() {
  34. },
  35. onShow: function() {
  36. this.start();
  37. },
  38. start() {
  39. let cityName = wx.getStorageSync('city') || '无锡'
  40. let cityCode = wx.getStorageSync('cityCode') || '320200';
  41. console.log(cityName)
  42. console.log(cityCode)
  43. this.setData({
  44. cityName: cityName,
  45. cityCode: cityCode,
  46. pageNo: 1, //当前分页
  47. isScroll: true, //是否可以滚动
  48. list: []
  49. })
  50. this.fetchList()
  51. },
  52. //下拉刷新
  53. onPullDownRefresh: function() {
  54. this.setData({
  55. pageNo: 1, //当前分页
  56. isScroll: true, //是否可以滚动
  57. list: [],
  58. })
  59. this.start();
  60. wx.stopPullDownRefresh();
  61. },
  62. onReachBottom: function() {
  63. var pageNo = this.data.pageNo + 1;
  64. this.setData({
  65. pageNo
  66. })
  67. this.fetchList()
  68. },
  69. doArrow(e) {
  70. const index = e.currentTarget.dataset.index;
  71. const list = this.data.list;
  72. this.setData({
  73. [`list[${index}].up`]: !list[index].up
  74. })
  75. },
  76. //获取拼团列表数据
  77. fetchList() {
  78. if (!this.data.isScroll) {
  79. return false
  80. }
  81. let paramsObj = {
  82. cityCode: this.data.cityCode,
  83. pageNo: this.data.pageNo,
  84. }
  85. getGroupList(paramsObj).then(data => {
  86. var pageNo = data.data.pageNo;
  87. let setData = {};
  88. // 是否可以滚动加载数据
  89. if (data.data.isLast) {
  90. setData.isScroll = false
  91. }
  92. if (data.data.groupPosition.length != 0) {
  93. setData.list = this.data.list.concat(data.data.groupPosition)
  94. setData.currentTime = data.data.currentTime;
  95. setData.pageNo = pageNo;
  96. } else {
  97. setData.list = this.data.list;
  98. }
  99. this.setData({
  100. ...setData
  101. })
  102. })
  103. },
  104. //去详情页
  105. toDetail(e) {
  106. const {
  107. id,
  108. cate
  109. } = e.currentTarget.dataset
  110. wx.navigateTo({
  111. url: '../detail/index?hpPositionId=' + id + "&cate=" + cate,
  112. })
  113. },
  114. //去申请列表
  115. toApplyList() {
  116. wx.navigateTo({
  117. url: '../apply-list/index?type=pt'
  118. })
  119. },
  120. //倒计时结束回调
  121. myLinsterner() {
  122. // this.fetchPt()
  123. this.setData({
  124. djsEnd: true
  125. })
  126. },
  127. onShareAppMessage: function() {
  128. return {
  129. title: '快来开心工作看看吧',
  130. path: '/pages/index/index',
  131. imageUrl: ''
  132. }
  133. },
  134. onError(err) {
  135. app.aldstat.sendEvent('报错', {
  136. 'err': err
  137. });
  138. },
  139. })