feat: rebuild pet app and backend around core care flows
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
const { secure, toast } = require("../../utils/api");
|
||||
Page({
|
||||
data: {
|
||||
pets: [],
|
||||
selected: [],
|
||||
title: "",
|
||||
description: "",
|
||||
place_name: "",
|
||||
latitude: 0,
|
||||
longitude: 0,
|
||||
date: "",
|
||||
time: "",
|
||||
max_people: 8,
|
||||
},
|
||||
onLoad() {
|
||||
this.load();
|
||||
},
|
||||
async load() {
|
||||
try {
|
||||
this.setData({ pets: await secure("/pets") });
|
||||
} catch (e) {
|
||||
toast(e);
|
||||
}
|
||||
},
|
||||
field(e) {
|
||||
this.setData({ [e.currentTarget.dataset.key]: e.detail.value });
|
||||
},
|
||||
pick(e) {
|
||||
this.setData({ selected: e.detail.selected });
|
||||
},
|
||||
date(e) {
|
||||
this.setData({ date: e.detail.value });
|
||||
},
|
||||
time(e) {
|
||||
this.setData({ time: e.detail.value });
|
||||
},
|
||||
async location() {
|
||||
try {
|
||||
const r = await wx.chooseLocation();
|
||||
this.setData({
|
||||
place_name: r.name || r.address,
|
||||
latitude: r.latitude,
|
||||
longitude: r.longitude,
|
||||
});
|
||||
} catch (e) {
|
||||
toast(e);
|
||||
}
|
||||
},
|
||||
async save() {
|
||||
const d = this.data;
|
||||
if (
|
||||
!d.title.trim() ||
|
||||
!d.place_name ||
|
||||
!d.date ||
|
||||
!d.time ||
|
||||
!d.selected.length
|
||||
) {
|
||||
wx.showToast({ title: "请填完时间地点并选择狗狗", icon: "none" });
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await secure("/meetups", "POST", {
|
||||
title: d.title,
|
||||
description: d.description,
|
||||
place_name: d.place_name,
|
||||
latitude: d.latitude,
|
||||
longitude: d.longitude,
|
||||
starts_at: new Date(d.date + "T" + d.time + ":00+08:00").toISOString(),
|
||||
max_people: Number(d.max_people),
|
||||
pet_ids: d.selected,
|
||||
});
|
||||
wx.navigateBack();
|
||||
} catch (e) {
|
||||
toast(e);
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1 @@
|
||||
{ "usingComponents": { "pet-picker": "/components/pet-picker/index" } }
|
||||
@@ -0,0 +1,53 @@
|
||||
<view class="screen">
|
||||
<view class="eyebrow">HOST A WALK</view>
|
||||
<view class="title">发起约遛 🌿</view>
|
||||
<view class="field">
|
||||
<view class="field-label">活动名称</view>
|
||||
<input
|
||||
placeholder="周末一起逛公园"
|
||||
value="{{title}}"
|
||||
data-key="title"
|
||||
bindinput="field"
|
||||
/>
|
||||
</view>
|
||||
<view class="field">
|
||||
<view class="field-label">时间</view>
|
||||
<view class="row">
|
||||
<picker mode="date" bindchange="date">
|
||||
<view class="picker">{{date||'选择日期'}}</view>
|
||||
</picker>
|
||||
<picker mode="time" bindchange="time">
|
||||
<view class="picker">{{time||'选择时间'}}</view>
|
||||
</picker>
|
||||
</view>
|
||||
</view>
|
||||
<view class="field">
|
||||
<view class="field-label">集合地点</view>
|
||||
<view class="picker" bindtap="location">
|
||||
📍 {{place_name||'选择地图位置'}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="field">
|
||||
<view class="field-label">人数上限</view>
|
||||
<input
|
||||
type="number"
|
||||
value="{{max_people}}"
|
||||
data-key="max_people"
|
||||
bindinput="field"
|
||||
/>
|
||||
</view>
|
||||
<view class="field">
|
||||
<view class="field-label">介绍一下</view>
|
||||
<textarea
|
||||
placeholder="聊聊这次约遛安排"
|
||||
value="{{description}}"
|
||||
data-key="description"
|
||||
bindinput="field"
|
||||
/>
|
||||
</view>
|
||||
<view class="field">
|
||||
<view class="field-label">带哪些狗狗?可以多选</view>
|
||||
<pet-picker pets="{{pets}}" selected="{{selected}}" bind:change="pick" />
|
||||
</view>
|
||||
<button class="primary" bindtap="save">发布约遛 →</button>
|
||||
</view>
|
||||
@@ -0,0 +1,13 @@
|
||||
.picker {
|
||||
background: white;
|
||||
border-radius: 20rpx;
|
||||
padding: 23rpx;
|
||||
min-width: 260rpx;
|
||||
}
|
||||
.field .row {
|
||||
gap: 15rpx;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
.field textarea {
|
||||
padding: 20rpx;
|
||||
}
|
||||
Reference in New Issue
Block a user