123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- // 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) {
- this.page = 1;
- this.getPhone(e.detail.name);
- },
- 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 => {
- 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() {}
- })
|