fix: ignore cancelled pet photo selection
ci-cd / verify (push) Successful in 6s
ci-cd / deploy (push) Skipped

This commit is contained in:
2026-10-05 20:13:10 +08:00
parent 9d7cf720a5
commit fbc1eda561
2 changed files with 87 additions and 2 deletions
+11 -2
View File
@@ -41,9 +41,18 @@ Page({
this.setData({ gender: e.detail.value });
},
async choose() {
let selection;
try {
const r = await wx.chooseMedia({ count: 1, mediaType: ["image"] });
const file = await upload(r.tempFiles[0].tempFilePath);
selection = await wx.chooseMedia({ count: 1, mediaType: ["image"] });
} catch (e) {
if (/^chooseMedia:fail cancel\b/i.test((e && e.errMsg) || "")) return;
toast(e);
return;
}
const photo = selection && selection.tempFiles && selection.tempFiles[0];
if (!photo || !photo.tempFilePath) return;
try {
const file = await upload(photo.tempFilePath);
this.setData({ avatar_file_id: file.id, avatar_url: file.url });
} catch (e) {
toast(e);