// pages/homePageInfo/index.js const $$ = require('../../utils/util'); // 热门资讯 与 视频 function getVideoAndMessageApi(param) { return $$.request({ url: 'paHotNews/listShow', type: 'get', submitData: param || {}, service: 'sys', noToken: true }); } Page({ /** * 页面的初始数据 */ data: { searchValue: '', type: '', // 'newMsg':最新资讯 'hotVideo':'热门视频' data: [], }, // 跳转资讯链接 goSeeMessage(e) { let url = e.currentTarget.dataset.url; wx.navigateTo({ url: '../webview/index?showUrl=' + url }); }, // 获取最新资讯 和 热门视频 async getVideoAndMessage({ appid, type }) { $$.showLoading(); const res = await getVideoAndMessageApi({ appid }); if (res.type) { let hotVideoList = res.data.hotVideoList || []; let hotNewsList = res.data.hotNewsList || []; this.setData({ data: type === 'newMsg' ? hotNewsList : hotVideoList, type }); } $$.hideLoading(); }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { let appid = wx.getAccountInfoSync().miniProgram.appId; this.getVideoAndMessage({ appid, type: options.type }); wx.setNavigationBarTitle({ title: options.type === 'newMsg' ? '最新资讯' : '热门视频', }); }, });