index.js 2.9 KB

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