flower-mp/pages/store/index.js
2025-12-08 16:03:03 +08:00

106 lines
1.9 KiB
JavaScript

const { api } = require("../../utils/api")
// pages/store/index.js
Page({
/**
* 页面的初始数据
*/
data: {
points:0,
list:[],
inviteCode:""
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
const inviteCode = wx.getStorageSync('inviteCode')
this.setData({
inviteCode: inviteCode
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
this.fetchList()
},
fetchList(){
api('/personal/personal', 'GET').then(res => {
if (res.code === 200) {
const tmps = res.data
this.setData({
points: tmps.pointsCount
})
api('/claim/list','POST',{current:0,pageSize:10,name:'',keyword:''},'json').then(res => {
if (res.code === 200){
const tmps = res.data.list.map(e => {
e.status = e.points < this.data.points ? 0:1
return e
})
this.setData({list:tmps})
}
})
}
})
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
return {
title: '发现一个宝藏养花神器',
imageUrl: "https://res.catter.cn/pub/2025/12/08/20251208112039694.png",
path: '/pages/index/index?inviteCode=' + this.data.inviteCode
};
},
onShareTimeline() {
return {
title: '发现一个宝藏养花神器',
imageUrl: "https://res.catter.cn/pub/2025/12/08/20251208112039694.png",
path: '/pages/index/index?inviteCode=' + this.data.inviteCode
};
}
})