xusd
7 days ago 998218675eb243d43912c203174a6b72b299c0f8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// 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' ? '最新资讯' : '热门视频',
        });
    },
});