123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- // pages/hotProduct/index.js
- var app = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- liveList:[],
- scrollHeight: 0,
- hasAuno: false,//是否限制条数
- page: 1,
- pages: 1,
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- var that = this;
- wx.getSystemInfo({
- success: function (res) {
- that.setData({
- scrollHeight: res.windowHeight - 10
- });
- }
- });
- this.getList();
- },
- getList:function() {
- wx.showLoading({
- title: '加载中',
- })
- var that = this;
- app.func.req('/api/kwaiShowToday/livingIndex','get',{
- 'pagesize': 20,
- 'just_goods': 1,
- 'page': that.data.page
- },
- function(res) {
- that.setData({
- hasAuno: res.auno==4403||res.errno==4003
- })
- wx.hideLoading({
- title: '加载中',
- })
- if(res && res.errno == 0){
- //成功
- var data = res.rst;
- data.data.forEach((item) => {
- item.minute = that.formatDuring(item.minute)
- })
- that.setData({
- pages: data.pageInfo.pages,
- liveList: that.data.liveList.concat(data.data)
- })
- }
- },function(err){
- console.log(err)
- })
- },
- bindDownLoad() {
- if(!this.data.hasAuno) {
- if(this.data.page<this.data.pages) {
- this.setData({
- page: ++this.data.page
- })
- this.getList();
- }
- }
- },
- toLive(e){//直播展板
- if(e.currentTarget.dataset.id) {
- wx.navigateTo({
- url: '/pages/liveBoard/index?live_stream_id='+e.currentTarget.dataset.id+'&user_id='+e.currentTarget.dataset.userid,
- })
- }
- },
- // 将毫秒转换成几天
- formatDuring(mss) {
- // 分钟*60*1000=毫秒
- mss = mss*60*1000;
- var days = parseInt(mss / (1000 * 60 * 60 * 24))+'天';
- var hours = parseInt((mss % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))+'小时';
- var minutes = parseInt((mss % (1000 * 60 * 60)) / (1000 * 60))+'分钟';
- return (parseInt(days)>0?days:'') + (parseInt(hours)>0?hours:'') + (parseInt(minutes)>0?minutes:'');
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|