feat: add resident miniapp MVP

This commit is contained in:
王鹏
2026-07-07 16:38:13 +08:00
parent bb325151d6
commit 576c54ec9d
52 changed files with 17865 additions and 66 deletions

View File

@@ -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)
}
})

View File

@@ -1 +1,57 @@
<view class="page">邻小帮</view>
<view class="page">
<view class="section">
<view class="section-title">邻小帮</view>
<view class="muted">社区服务 30 分钟到家</view>
</view>
<view class="grid section">
<view class="shortcut" bindtap="go" data-url="/pages/products/index">商品预定</view>
<view class="shortcut" bindtap="go" data-url="/pages/express/create">代取快递</view>
<view class="shortcut" bindtap="goTab" data-url="/pages/group-buy/index">今日团购</view>
<view class="shortcut" bindtap="goTab" data-url="/pages/second-hand/index">二手闲置</view>
<view class="shortcut" bindtap="go" data-url="/pages/notices/index">社区公告</view>
<view class="shortcut" bindtap="go" data-url="/pages/orders/index">我的订单</view>
</view>
<view class="section">
<view class="section-title">公告</view>
<view wx:for="{{notices}}" wx:key="id" class="card" bindtap="go" data-url="/pages/notices/index">
<view>{{item.title}}</view>
<view class="muted">{{item.category}}</view>
</view>
<view wx:if="{{!notices.length}}" class="card muted">暂无公告</view>
</view>
<view class="section">
<view class="section-title">热门商品</view>
<view wx:for="{{products}}" wx:key="id" class="card" bindtap="go" data-url="/pages/products/detail?id={{item.id}}">
<view class="row between">
<view>{{item.name}}</view>
<view class="tag">{{item.status}}</view>
</view>
<view class="muted">{{item.description || '社区商品'}}</view>
</view>
</view>
<view class="section">
<view class="section-title">今日团购</view>
<view wx:for="{{groupBuys}}" wx:key="id" class="card" bindtap="go" data-url="/pages/group-buy/detail?id={{item.id}}">
<view class="row between">
<view>{{item.title}}</view>
<view class="price">¥{{item.priceCent / 100}}</view>
</view>
<view class="muted">已售 {{item.soldCount}} / 库存 {{item.stock}}</view>
</view>
</view>
<view class="section">
<view class="section-title">最新闲置</view>
<view wx:for="{{secondGoods}}" wx:key="id" class="card">
<view class="row between">
<view>{{item.title}}</view>
<view class="price">¥{{item.priceCent / 100}}</view>
</view>
<view class="muted">{{item.category}}</view>
</view>
</view>
</view>

View File

@@ -1,3 +1,3 @@
.page {
min-height: 100vh;
padding-bottom: 40rpx;
}