问星数据小程序

index.js 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. // pages/hotProduct/index.js
  2. var app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. liveList:[],
  9. scrollHeight: 0,
  10. hasAuno: false,//是否限制条数
  11. page: 1,
  12. pages: 1,
  13. },
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */
  17. onLoad: function (options) {
  18. var that = this;
  19. wx.getSystemInfo({
  20. success: function (res) {
  21. that.setData({
  22. scrollHeight: res.windowHeight - 10
  23. });
  24. }
  25. });
  26. this.getList();
  27. },
  28. getList:function() {
  29. wx.showLoading({
  30. title: '加载中',
  31. })
  32. var that = this;
  33. app.func.req('/api/kwaiShowToday/livingIndex','get',{
  34. 'pagesize': 20,
  35. 'just_goods': 1,
  36. 'page': that.data.page
  37. },
  38. function(res) {
  39. that.setData({
  40. hasAuno: res.auno==4403||res.errno==4003
  41. })
  42. wx.hideLoading({
  43. title: '加载中',
  44. })
  45. if(res && res.errno == 0){
  46. //成功
  47. var data = res.rst;
  48. data.data.forEach((item) => {
  49. item.minute = that.formatDuring(item.minute)
  50. })
  51. that.setData({
  52. pages: data.pageInfo.pages,
  53. liveList: that.data.liveList.concat(data.data)
  54. })
  55. }
  56. },function(err){
  57. console.log(err)
  58. })
  59. },
  60. bindDownLoad() {
  61. if(!this.data.hasAuno) {
  62. if(this.data.page<this.data.pages) {
  63. this.setData({
  64. page: ++this.data.page
  65. })
  66. this.getList();
  67. }
  68. }
  69. },
  70. toLive(e){//直播展板
  71. if(e.currentTarget.dataset.id) {
  72. wx.navigateTo({
  73. url: '/pages/liveBoard/index?live_stream_id='+e.currentTarget.dataset.id+'&user_id='+e.currentTarget.dataset.userid,
  74. })
  75. }
  76. },
  77. // 将毫秒转换成几天
  78. formatDuring(mss) {
  79. // 分钟*60*1000=毫秒
  80. mss = mss*60*1000;
  81. var days = parseInt(mss / (1000 * 60 * 60 * 24))+'天';
  82. var hours = parseInt((mss % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))+'小时';
  83. var minutes = parseInt((mss % (1000 * 60 * 60)) / (1000 * 60))+'分钟';
  84. return (parseInt(days)>0?days:'') + (parseInt(hours)>0?hours:'') + (parseInt(minutes)>0?minutes:'');
  85. },
  86. /**
  87. * 生命周期函数--监听页面初次渲染完成
  88. */
  89. onReady: function () {
  90. },
  91. /**
  92. * 生命周期函数--监听页面显示
  93. */
  94. onShow: function () {
  95. },
  96. /**
  97. * 生命周期函数--监听页面隐藏
  98. */
  99. onHide: function () {
  100. },
  101. /**
  102. * 生命周期函数--监听页面卸载
  103. */
  104. onUnload: function () {
  105. },
  106. /**
  107. * 页面相关事件处理函数--监听用户下拉动作
  108. */
  109. onPullDownRefresh: function () {
  110. },
  111. /**
  112. * 页面上拉触底事件的处理函数
  113. */
  114. onReachBottom: function () {
  115. },
  116. /**
  117. * 用户点击右上角分享
  118. */
  119. onShareAppMessage: function () {
  120. }
  121. })