// pages/mine/mine.js const { apiRequest } = require('../../utils/API.js') Page({ /** * 页面的初始数据 */ data: { joinLength: 0, winLength: 0 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { let that = this apiRequest('/user/lotteries').then(data => { that.setData({ joinLength: data.data.end.length + data.data.not_end.length }) }) apiRequest('/user/lotteries/win').then(data => { that.setData({ winLength: data.data.length }) }) } })