feat: rebuild pet app and backend around core care flows
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
const { request } = require("../../utils/api");
|
||||
Page({
|
||||
data: {
|
||||
latitude: 31.23,
|
||||
longitude: 121.47,
|
||||
markers: [],
|
||||
status: "加载中",
|
||||
updated: "",
|
||||
},
|
||||
onLoad(options) {
|
||||
this.token = options.token;
|
||||
this.load();
|
||||
this.timer = setInterval(() => this.load(), 15000);
|
||||
},
|
||||
onUnload() {
|
||||
clearInterval(this.timer);
|
||||
},
|
||||
async load() {
|
||||
try {
|
||||
const p = await request("/share/walk/" + this.token);
|
||||
this.setData({
|
||||
latitude: p.latitude,
|
||||
longitude: p.longitude,
|
||||
markers: [
|
||||
{
|
||||
id: 1,
|
||||
latitude: p.latitude,
|
||||
longitude: p.longitude,
|
||||
title: "目前在这里",
|
||||
},
|
||||
],
|
||||
status: p.status === "paused" ? "暂时停下休息" : "正在遛狗",
|
||||
updated: new Date(p.recorded_at).toLocaleTimeString(),
|
||||
});
|
||||
} catch (e) {
|
||||
this.setData({ status: "分享已结束或尚无位置" });
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1 @@
|
||||
{}
|
||||
@@ -0,0 +1,15 @@
|
||||
<view class="screen">
|
||||
<view class="eyebrow">肉垫计划 · 位置分享</view>
|
||||
<view class="title">找到小短腿的脚印 🐾</view>
|
||||
<map
|
||||
latitude="{{latitude}}"
|
||||
longitude="{{longitude}}"
|
||||
scale="16"
|
||||
markers="{{markers}}"
|
||||
style="width: 100%; height: 70vh; border-radius: 32rpx"
|
||||
/>
|
||||
<view class="card">
|
||||
<view>{{status}}</view>
|
||||
<view class="muted">上次更新 {{updated}}</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1,6 @@
|
||||
page {
|
||||
background: #f6f9f6;
|
||||
}
|
||||
.card {
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
Reference in New Issue
Block a user