acdr-ui/dist/dev/mp-weixin/pages/pet/pet-detail-page.js

109 lines
4.0 KiB
JavaScript
Raw Normal View History

2024-09-19 07:20:14 +08:00
"use strict";
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
const common_vendor = require("../../common/vendor.js");
const utils_commUtils = require("../../utils/commUtils.js");
const utils_http = require("../../utils/http.js");
if (!Array) {
const _easycom_wd_icon2 = common_vendor.resolveComponent("wd-icon");
const _component_layout_default_uni = common_vendor.resolveComponent("layout-default-uni");
(_easycom_wd_icon2 + _component_layout_default_uni)();
}
const _easycom_wd_icon = () => "../../node-modules/wot-design-uni/components/wd-icon/wd-icon.js";
if (!Math) {
(TopBar + _easycom_wd_icon + EmptyState)();
}
const EmptyState = () => "../../components/EmptyState.js";
const TopBar = () => "../../components/TopBar.js";
const _sfc_main = {
__name: "pet-detail-page",
setup(__props) {
const tabs = common_vendor.ref(["全部", "心情", "养护", "清洁"]);
const activeTab = common_vendor.ref("全部");
const petInfo = common_vendor.ref({});
const getPetId = (id) => __async(this, null, function* () {
try {
const res = yield utils_http.httpGet("/petInfo/find_by_id/" + id);
if (res.code === 200) {
petInfo.value = res.data;
console.log(petInfo.value);
} else {
utils_commUtils.toast(res.data.message);
}
} catch (e) {
console.log(e);
}
});
const editPet = (id) => {
utils_commUtils.toPath("/pages/pet/pet-add-page?id=" + id);
};
const share = () => {
};
const daysUntilBirthday = (birthDateStr) => {
const birthDate = new Date(birthDateStr);
const today = /* @__PURE__ */ new Date();
const nextBirthday = new Date(today.getFullYear(), birthDate.getMonth(), birthDate.getDate());
if (nextBirthday < today) {
nextBirthday.setFullYear(today.getFullYear() + 1);
}
const oneDay = 24 * 60 * 60 * 1e3;
const daysLeft = Math.ceil((nextBirthday - today) / oneDay);
return daysLeft;
};
common_vendor.onLoad((options) => __async(this, null, function* () {
if (options.id) {
yield getPetId(options.id);
}
}));
return (_ctx, _cache) => {
return {
a: common_vendor.unref(utils_commUtils.imgUrl)("@/static/push/bg.png"),
b: petInfo.value.profileUrl ? common_vendor.unref(utils_commUtils.imgUrl)(petInfo.value.profileUrl) : common_vendor.unref(utils_commUtils.imgUrl)("@/static/icons/cat.png"),
c: common_vendor.t(petInfo.value.name || "cat"),
d: common_vendor.p({
name: "calendar",
size: "20"
}),
e: common_vendor.t(daysUntilBirthday(petInfo.value.age)),
f: common_vendor.o(($event) => editPet(petInfo.value.id)),
g: common_vendor.o(share),
h: common_vendor.f(tabs.value, (tab, k0, i0) => {
return common_vendor.e({
a: common_vendor.t(tab),
b: activeTab.value === tab
}, activeTab.value === tab ? {} : {}, {
c: tab,
d: common_vendor.n(activeTab.value === tab ? "text-_a__a_ffc107_a_ relative border-b-2 border-_a__a_ffc107_a_" : "text-gray-600"),
e: common_vendor.o(($event) => activeTab.value = tab, tab)
});
}),
i: common_vendor.p({
type: "default",
message: "暂无内容"
})
};
};
}
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-3b342191"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=pet-detail-page.js.map