feat: add resident miniapp MVP
This commit is contained in:
@@ -1 +1,49 @@
|
||||
Page({})
|
||||
const { getHomeData } = require('../../api/homeApi')
|
||||
const { yuan } = require('../../utils/request')
|
||||
|
||||
Page({
|
||||
data: {
|
||||
loading: false,
|
||||
banners: [],
|
||||
notices: [],
|
||||
products: [],
|
||||
groupBuys: [],
|
||||
secondGoods: []
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.load()
|
||||
},
|
||||
|
||||
onPullDownRefresh() {
|
||||
this.load().finally(() => wx.stopPullDownRefresh())
|
||||
},
|
||||
|
||||
load() {
|
||||
this.setData({ loading: true })
|
||||
return getHomeData()
|
||||
.then((data) => {
|
||||
this.setData({
|
||||
banners: data.banners || [],
|
||||
notices: (data.notices || []).slice(0, 3),
|
||||
products: (data.products || []).slice(0, 6),
|
||||
groupBuys: (data.groupBuys || []).slice(0, 3),
|
||||
secondGoods: (data.secondGoods || []).slice(0, 3)
|
||||
})
|
||||
})
|
||||
.catch((error) => wx.showToast({ title: error.message, icon: 'none' }))
|
||||
.finally(() => this.setData({ loading: false }))
|
||||
},
|
||||
|
||||
go(event) {
|
||||
wx.navigateTo({ url: event.currentTarget.dataset.url })
|
||||
},
|
||||
|
||||
goTab(event) {
|
||||
wx.switchTab({ url: event.currentTarget.dataset.url })
|
||||
},
|
||||
|
||||
yuan(cent) {
|
||||
return yuan(cent)
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user