220 lines
8.5 KiB
JavaScript
220 lines
8.5 KiB
JavaScript
"use strict";
|
|
var __defProp = Object.defineProperty;
|
|
var __defProps = Object.defineProperties;
|
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
var __spreadValues = (a, b) => {
|
|
for (var prop in b || (b = {}))
|
|
if (__hasOwnProp.call(b, prop))
|
|
__defNormalProp(a, prop, b[prop]);
|
|
if (__getOwnPropSymbols)
|
|
for (var prop of __getOwnPropSymbols(b)) {
|
|
if (__propIsEnum.call(b, prop))
|
|
__defNormalProp(a, prop, b[prop]);
|
|
}
|
|
return a;
|
|
};
|
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
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 store_user = require("../../../store/user.js");
|
|
const utils_commUtils = require("../../../utils/commUtils.js");
|
|
const utils_http = require("../../../utils/http.js");
|
|
if (!Array) {
|
|
const _easycom_wd_img2 = common_vendor.resolveComponent("wd-img");
|
|
const _component_w_avatar = common_vendor.resolveComponent("w-avatar");
|
|
const _easycom_wd_icon2 = common_vendor.resolveComponent("wd-icon");
|
|
const _component_layout_default_uni = common_vendor.resolveComponent("layout-default-uni");
|
|
(_easycom_wd_img2 + _component_w_avatar + _easycom_wd_icon2 + _component_layout_default_uni)();
|
|
}
|
|
const _easycom_wd_img = () => "../../../node-modules/wot-design-uni/components/wd-img/wd-img.js";
|
|
const _easycom_wd_icon = () => "../../../node-modules/wot-design-uni/components/wd-icon/wd-icon.js";
|
|
if (!Math) {
|
|
(_easycom_wd_img + _easycom_wd_icon + Tabbar)();
|
|
}
|
|
const Tabbar = () => "../../../components/Tabbar.js";
|
|
const _sfc_main = {
|
|
__name: "index",
|
|
setup(__props) {
|
|
const userStore = store_user.useUserStore();
|
|
const userInfo = userStore.userInfo;
|
|
const stats = common_vendor.ref([
|
|
{ number: 0, label: "粉丝" },
|
|
{ number: 0, label: "关注" },
|
|
{ number: 0, label: "收藏" },
|
|
{ number: 0, label: "获赞" }
|
|
]);
|
|
const services = [
|
|
{ icon: "@/static/my/order.png", label: "我的订单", path: "/modules/pet/order/index" },
|
|
{ icon: "@/static/my/pet.png", label: "我的服务", path: "/modules/pet/service/my-service" },
|
|
{ icon: "@/static/my/wash.png", label: "我的评价", path: "/modules/pet/order/index" },
|
|
{ icon: "@/static/my/service.png", label: "售后服务", path: "/modules/pet/order/index" }
|
|
];
|
|
const pets = common_vendor.ref([]);
|
|
common_vendor.onShow(() => __async(this, null, function* () {
|
|
yield fetchActivities();
|
|
yield fetchPets();
|
|
}));
|
|
const fetchActivities = () => __async(this, null, function* () {
|
|
try {
|
|
const response = yield utils_http.httpGet("/posts/community");
|
|
if (response.code == 200) {
|
|
const index = 0;
|
|
for (const key in response.data) {
|
|
if (response.data[key]) {
|
|
stats.value[index] = { number: response.data[key], label: key };
|
|
}
|
|
}
|
|
} else {
|
|
console.log(response);
|
|
}
|
|
} catch (error) {
|
|
console.log(error);
|
|
}
|
|
});
|
|
const fetchPets = () => __async(this, null, function* () {
|
|
try {
|
|
const response = yield utils_http.httpGet("/petInfo/select", { userId: userStore.userInfo.id });
|
|
pets.value = response.records.map((pet) => __spreadProps(__spreadValues({}, pet), {
|
|
icon: utils_commUtils.baseUrl + pet.profileUrl
|
|
}));
|
|
} catch (error) {
|
|
common_vendor.index.showToast({ title: "网络错误,请重试", icon: "error" });
|
|
}
|
|
});
|
|
const editPet = (pet) => {
|
|
common_vendor.index.navigateTo({
|
|
url: `/modules/pet/pet/pet-add-page?id=${pet.id}&name=${pet.name}&icon=${pet.icon}&breed=${pet.breed}&color=${pet.color}&birthday=${pet.birthday}&gender=${pet.gender}&userId=${pet.userId}`
|
|
});
|
|
};
|
|
const items = [
|
|
{ icon: "@/static/my/send.png", label: "我的发布", to: "/modules/pet/publish/index" },
|
|
{
|
|
icon: "@/static/my/handshake.png",
|
|
label: "帮助中心",
|
|
to: "/modules/pet/others/official-account"
|
|
},
|
|
{
|
|
icon: "@/static/my/feedback.png",
|
|
label: "建议反馈",
|
|
to: "/modules/pet/others/official-account"
|
|
},
|
|
{
|
|
icon: "@/static/my/badge.png",
|
|
label: "宠托师认证",
|
|
to: "/modules/pet/certification/index"
|
|
},
|
|
{ icon: "@/static/my/address.png", label: "我的地址", to: "/modules/pet/address/index" },
|
|
{ icon: "@/static/my/settings.png", label: "设置", to: "/modules/pet/settings/index" },
|
|
{ icon: "@/static/my/address.png", label: "地址", to: "/modules/pet/map/index" }
|
|
];
|
|
const toPath = (path) => {
|
|
common_vendor.index.navigateTo({
|
|
url: path
|
|
});
|
|
};
|
|
return (_ctx, _cache) => {
|
|
return common_vendor.e({
|
|
a: `url(${common_vendor.unref(utils_commUtils.imgUrl)("@/static/my/my-bg.png")})`,
|
|
b: common_vendor.unref(utils_commUtils.imgUrl)("@/static/my/cat-dog.png"),
|
|
c: common_vendor.p({
|
|
width: 100,
|
|
height: 100,
|
|
round: true,
|
|
mode: "aspectFill",
|
|
src: common_vendor.unref(userInfo).avatar == "" ? common_vendor.unref(utils_commUtils.imgUrl)("@/static/my/avatar.jpg") : common_vendor.unref(utils_commUtils.imgUrl)(common_vendor.unref(userInfo).avatar)
|
|
}),
|
|
d: common_vendor.t(common_vendor.unref(userInfo).nickname),
|
|
e: common_vendor.f(stats.value, (item, index, i0) => {
|
|
return {
|
|
a: common_vendor.t(item.number),
|
|
b: common_vendor.t(item.label),
|
|
c: index
|
|
};
|
|
}),
|
|
f: common_vendor.f(services, (service, index, i0) => {
|
|
return common_vendor.e({
|
|
a: service.label == "我的服务"
|
|
}, service.label == "我的服务" ? {
|
|
b: "3567cc5a-2-" + i0 + ",3567cc5a-0",
|
|
c: common_vendor.p({
|
|
width: 42,
|
|
height: 40,
|
|
src: common_vendor.unref(utils_commUtils.imgUrl)(service.icon)
|
|
})
|
|
} : {
|
|
d: "3567cc5a-3-" + i0 + ",3567cc5a-0",
|
|
e: common_vendor.p({
|
|
width: 38,
|
|
height: 40,
|
|
src: common_vendor.unref(utils_commUtils.imgUrl)(service.icon)
|
|
})
|
|
}, {
|
|
f: common_vendor.t(service.label),
|
|
g: common_vendor.o(($event) => toPath(service.path), index),
|
|
h: index
|
|
});
|
|
}),
|
|
g: common_vendor.unref(userInfo).isPetNursery
|
|
}, common_vendor.unref(userInfo).isPetNursery ? {
|
|
h: common_vendor.o(($event) => toPath("/modules/pet/order/take"))
|
|
} : {}, {
|
|
i: common_vendor.f(pets.value, (pet, index, i0) => {
|
|
return {
|
|
a: "3567cc5a-4-" + i0 + ",3567cc5a-0",
|
|
b: common_vendor.p({
|
|
width: 60,
|
|
height: 60,
|
|
round: true,
|
|
src: pet.profileUrl
|
|
}),
|
|
c: common_vendor.t(pet.name),
|
|
d: common_vendor.o(($event) => editPet(pet), index),
|
|
e: index
|
|
};
|
|
}),
|
|
j: common_vendor.p({
|
|
size: 80
|
|
}),
|
|
k: common_vendor.o(($event) => toPath("/modules/pet/pet/pet-add-page")),
|
|
l: common_vendor.f(items, (item, index, i0) => {
|
|
return {
|
|
a: common_vendor.unref(utils_commUtils.imgUrl)(item.icon),
|
|
b: common_vendor.t(item.label),
|
|
c: "3567cc5a-6-" + i0 + ",3567cc5a-0",
|
|
d: common_vendor.o(($event) => toPath(item.to), index),
|
|
e: index
|
|
};
|
|
}),
|
|
m: common_vendor.p({
|
|
name: "arrow-right"
|
|
})
|
|
});
|
|
};
|
|
}
|
|
};
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-3567cc5a"]]);
|
|
wx.createPage(MiniProgramPage);
|