// miniprogram/pages/home/index.js const app = getApp(); Page({ /** * 页面的初始数据 */ data: { newList: [] }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { let url = app.base.url + '/t.json?time=' + (new Date()); // if(wx.getSystemInfoSync().platform === "devtools") url = app.base.url + '/t_dev.json?time=' + (new Date()) wx.showLoading() const fs = wx.getFileSystemManager(); wx.downloadFile({ url, success: r => { fs.readFile({ filePath: r.tempFilePath, encoding: 'utf8', position: 0, success(res) { let D = res.data; if(/xml/g.test(D)) { D = '{}' } let data = res.data ? JSON.parse(D) : {}; app.globalData.origin = data; wx.hideLoading() }, fail(res) { wx.hideLoading() } }) }, fail() { wx.hideLoading() } }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, toDetail: function (e) { let data = e.currentTarget.dataset || {}; wx.navigateTo({ url: '/pages/detail/detail?title=' + data.title + "&key=" + data.key + "&type=" + data.type, }) }, toMarvellous: function (e) { wx.navigateTo({ url: '/pages/marvellous/index?title=' + e.currentTarget.dataset.title + "&type=" + e.currentTarget.dataset.type, }) } })