feat: rebuild pet app and backend around core care flows
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
const { secure, toast } = require("../../utils/api");
|
||||
Page({
|
||||
data: { pets: [] },
|
||||
onShow() {
|
||||
this.load();
|
||||
},
|
||||
async load() {
|
||||
try {
|
||||
this.setData({ pets: await secure("/pets") });
|
||||
} catch (e) {
|
||||
toast(e);
|
||||
}
|
||||
},
|
||||
add() {
|
||||
wx.navigateTo({ url: "/pages/pet-edit/pet-edit" });
|
||||
},
|
||||
edit(e) {
|
||||
wx.navigateTo({
|
||||
url: "/pages/pet-edit/pet-edit?id=" + e.currentTarget.dataset.id,
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1 @@
|
||||
{ "usingComponents": { "tab-bar": "/components/tab-bar/index" } }
|
||||
@@ -0,0 +1,43 @@
|
||||
<view class="screen">
|
||||
<view class="eyebrow">MY LITTLE FAMILY</view>
|
||||
<view class="title">我的毛孩子 🐕</view>
|
||||
<view class="family">
|
||||
<view>
|
||||
<text>五只柯基,也能一起遛</text>
|
||||
<strong>每一只都有自己的故事</strong>
|
||||
</view>
|
||||
<image src="/assets/corgi-family-five.png" mode="aspectFit" />
|
||||
</view>
|
||||
<view class="row">
|
||||
<text class="section-title">宠物档案 · {{pets.length}}</text>
|
||||
<text class="add" bindtap="add">+ 添加</text>
|
||||
</view>
|
||||
<view
|
||||
wx:for="{{pets}}"
|
||||
wx:key="id"
|
||||
class="card pet"
|
||||
data-id="{{item.id}}"
|
||||
bindtap="edit"
|
||||
>
|
||||
<view class="pet-avatar">
|
||||
<image
|
||||
wx:if="{{item.avatar_url}}"
|
||||
src="{{item.avatar_url}}"
|
||||
mode="aspectFill"
|
||||
/>
|
||||
<text wx:else>🐕</text>
|
||||
</view>
|
||||
<view class="pet-info">
|
||||
<strong>{{item.name}}</strong>
|
||||
<text>
|
||||
{{item.breed||'小可爱'}} ·
|
||||
{{item.gender==='male'?'男孩':item.gender==='female'?'女孩':'未知'}}
|
||||
</text>
|
||||
<text>体重 {{item.weight_kg||'—'}} kg</text>
|
||||
</view>
|
||||
<text class="arrow">›</text>
|
||||
</view>
|
||||
<view wx:if="{{!pets.length}}" class="empty">给第一只狗狗建个档案吧 🐾</view>
|
||||
<button class="primary add-button" bindtap="add">+ 新建宠物档案</button>
|
||||
</view>
|
||||
<tab-bar current="/pages/pets/pets" />
|
||||
@@ -0,0 +1,75 @@
|
||||
.family {
|
||||
background: #194f42;
|
||||
border-radius: 35rpx;
|
||||
color: white;
|
||||
min-height: 220rpx;
|
||||
padding: 35rpx;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
.family text,
|
||||
.family strong {
|
||||
display: block;
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
}
|
||||
.family text {
|
||||
color: #a4d6b8;
|
||||
font-size: 23rpx;
|
||||
}
|
||||
.family strong {
|
||||
font-size: 32rpx;
|
||||
width: 55%;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
.family image {
|
||||
width: 270rpx;
|
||||
height: 205rpx;
|
||||
position: absolute;
|
||||
right: -5rpx;
|
||||
bottom: 0;
|
||||
}
|
||||
.add {
|
||||
font-weight: 800;
|
||||
color: #368764;
|
||||
}
|
||||
.pet {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 22rpx;
|
||||
}
|
||||
.pet-avatar {
|
||||
width: 125rpx;
|
||||
height: 125rpx;
|
||||
flex: none;
|
||||
border-radius: 28rpx;
|
||||
background: #f1d2a3;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
font-size: 63rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
.pet-avatar image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.pet-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6rpx;
|
||||
flex: 1;
|
||||
}
|
||||
.pet-info strong {
|
||||
font-size: 32rpx;
|
||||
}
|
||||
.pet-info text {
|
||||
font-size: 23rpx;
|
||||
color: #8a9c90;
|
||||
}
|
||||
.arrow {
|
||||
font-size: 42rpx;
|
||||
color: #97a99d;
|
||||
}
|
||||
.add-button {
|
||||
margin-top: 25rpx;
|
||||
}
|
||||
Reference in New Issue
Block a user