// pages/media/index.js import api from "../../api/index"; const { globalData: { systemInfo } } = getApp(); Page({ /** * 页面的初始数据 */ data: { actMeet: '', top: { height: 0, width: systemInfo.windowWidth }, phone: { width: (systemInfo.windowWidth - 20) / 3, height: 0 }, tabs: [], images: [] }, page: 1, size: 10, total: 0, changeMeet(e) { console.log(e.detail) }, imageLoad(e) { const { width, height } = e.detail; const image = e.currentTarget.dataset.image || 'top'; const p = {}; p[image] = { ...this.data[image] } p[image].height = height / width * p[image].width this.setData(p); }, showImage(e) { wx.previewMedia({ sources: this.data.images.map(v => { return { url: v.photo } }), current: e.currentTarget.dataset.index }) }, // 获取图片直播 getPhone(id) { const { page, size } = this; api.getLivePhone({ page, size, id }).then(res => { console.log(res) this.page += 1; this.total = res.total; this.setData({ images: res.records || [] }) }) }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { api.getStroke().then(strokeList => { const item = strokeList[0] || {} this.setData({ actMeet: item.id, tabs: strokeList }) this.getPhone(item.id); }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { if( this.total <= this.data.images.length) return this.getPhone(this.data.actMeet); }, /** * 用户点击右上角分享 */ onShareAppMessage() { }, onShareTimeline() {} })