Complete core mini program flows
This commit is contained in:
@@ -12,6 +12,7 @@ Page({
|
||||
care_notes: "",
|
||||
avatar_file_id: "",
|
||||
avatar_url: "",
|
||||
saving: false,
|
||||
},
|
||||
onLoad(options) {
|
||||
if (options.id) {
|
||||
@@ -45,6 +46,7 @@ Page({
|
||||
}
|
||||
},
|
||||
async save() {
|
||||
if (this.data.saving) return;
|
||||
if (!this.data.name.trim()) {
|
||||
wx.showToast({ title: "请输入名字", icon: "none" });
|
||||
return;
|
||||
@@ -61,6 +63,7 @@ Page({
|
||||
care_notes: this.data.care_notes,
|
||||
avatar_file_id: this.data.avatar_file_id || null,
|
||||
};
|
||||
this.setData({ saving: true });
|
||||
try {
|
||||
await secure(
|
||||
"/pets" + (this.data.id ? "/" + this.data.id : ""),
|
||||
@@ -70,6 +73,8 @@ Page({
|
||||
wx.navigateBack();
|
||||
} catch (e) {
|
||||
toast(e);
|
||||
} finally {
|
||||
this.setData({ saving: false });
|
||||
}
|
||||
},
|
||||
async archive() {
|
||||
|
||||
@@ -59,6 +59,6 @@
|
||||
<view class="field-label">照顾备注</view>
|
||||
<textarea value="{{care_notes}}" data-key="care_notes" bindinput="field" />
|
||||
</view>
|
||||
<button class="primary" bindtap="save">保存档案</button>
|
||||
<button class="primary" bindtap="save" disabled="{{saving}}">保存档案</button>
|
||||
<button wx:if="{{id}}" class="archive" bindtap="archive">归档这只宠物</button>
|
||||
</view>
|
||||
|
||||
Reference in New Issue
Block a user