174 lines
6.0 KiB
JavaScript
174 lines
6.0 KiB
JavaScript
|
"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_http = require("../../utils/http.js");
|
||
|
const utils_commUtils = require("../../utils/commUtils.js");
|
||
|
if (!Array) {
|
||
|
const _easycom_wd_icon2 = common_vendor.resolveComponent("wd-icon");
|
||
|
const _easycom_wd_img2 = common_vendor.resolveComponent("wd-img");
|
||
|
const _component_layout_default_uni = common_vendor.resolveComponent("layout-default-uni");
|
||
|
(_easycom_wd_icon2 + _easycom_wd_img2 + _component_layout_default_uni)();
|
||
|
}
|
||
|
const _easycom_wd_icon = () => "../../node-modules/wot-design-uni/components/wd-icon/wd-icon.js";
|
||
|
const _easycom_wd_img = () => "../../node-modules/wot-design-uni/components/wd-img/wd-img.js";
|
||
|
if (!Math) {
|
||
|
(_easycom_wd_icon + _easycom_wd_img + UserPost + Tabbar)();
|
||
|
}
|
||
|
const UserPost = () => "./components/UserPost.js";
|
||
|
const Tabbar = () => "../../components/Tabbar.js";
|
||
|
const _sfc_main = {
|
||
|
__name: "index",
|
||
|
setup(__props) {
|
||
|
const tabs = common_vendor.ref(["推荐", "关注"]);
|
||
|
const activeTab = common_vendor.ref(0);
|
||
|
const focusUser = common_vendor.ref([]);
|
||
|
const postsList = common_vendor.ref(null);
|
||
|
common_vendor.ref({
|
||
|
name: "王小样",
|
||
|
avatar: "/static/my/pet-auatar.jpg",
|
||
|
location: "不拉多尔-泡芙"
|
||
|
});
|
||
|
common_vendor.ref({
|
||
|
time: "1分钟前",
|
||
|
images: [
|
||
|
"/static/my/pet-auatar.jpg",
|
||
|
"/static/my/pet-auatar-2.jpg",
|
||
|
"/static/my/pet-auatar.jpg",
|
||
|
"/static/my/pet-auatar-2.jpg",
|
||
|
"/static/my/pet-auatar.jpg"
|
||
|
],
|
||
|
content: "狗狗是人类的最好的朋友,它们忠诚可靠,守护着他们的主人不离不弃。甚至,比生命更为重要。",
|
||
|
likes: 289,
|
||
|
comments: 36,
|
||
|
shares: 14
|
||
|
});
|
||
|
const focus = () => __async(this, null, function* () {
|
||
|
try {
|
||
|
const res = yield utils_http.httpGet("/posts/followed-users");
|
||
|
if (res.code == 200) {
|
||
|
focusUser.value = res.data;
|
||
|
} else {
|
||
|
utils_commUtils.toast(res.message || "数据获取失败");
|
||
|
}
|
||
|
} catch (error) {
|
||
|
utils_commUtils.toast(error.data.message || "获取关注博主数据失败");
|
||
|
}
|
||
|
});
|
||
|
const getPosts = () => __async(this, null, function* () {
|
||
|
try {
|
||
|
const res = yield utils_http.httpGet("/posts/list");
|
||
|
if (res.code == 200) {
|
||
|
postsList.value = res.data;
|
||
|
} else {
|
||
|
utils_commUtils.toast(res.message || "数据获取失败");
|
||
|
}
|
||
|
} catch (error) {
|
||
|
utils_commUtils.toast(error.data.message || "获取关注博主数据失败");
|
||
|
}
|
||
|
});
|
||
|
const selectTab = (index) => {
|
||
|
activeTab.value = index;
|
||
|
console.log(index);
|
||
|
};
|
||
|
const actions = () => {
|
||
|
console.log("actions");
|
||
|
};
|
||
|
const camera = () => {
|
||
|
console.log("camera");
|
||
|
};
|
||
|
const pushTo = () => {
|
||
|
common_vendor.index.navigateTo({
|
||
|
url: "/pages/push/share"
|
||
|
});
|
||
|
};
|
||
|
const toPath = (path) => {
|
||
|
common_vendor.index.navigateTo({
|
||
|
url: path
|
||
|
});
|
||
|
};
|
||
|
common_vendor.onLoad(() => __async(this, null, function* () {
|
||
|
yield focus();
|
||
|
yield getPosts();
|
||
|
}));
|
||
|
return (_ctx, _cache) => {
|
||
|
return common_vendor.e({
|
||
|
a: common_vendor.unref(utils_commUtils.imgUrl)("@/static/space/bg.png"),
|
||
|
b: common_vendor.unref(utils_commUtils.imgUrl)("@/static/space/ai-space-button.png"),
|
||
|
c: common_vendor.p({
|
||
|
name: "arrow-right"
|
||
|
}),
|
||
|
d: common_vendor.o(($event) => toPath("/pages/ai/ai-interactive-space")),
|
||
|
e: common_vendor.o(actions),
|
||
|
f: common_vendor.unref(utils_commUtils.imgUrl)("@/static/space/doctor.png"),
|
||
|
g: common_vendor.o(actions),
|
||
|
h: common_vendor.unref(utils_commUtils.imgUrl)("@/static/space/talent.png"),
|
||
|
i: common_vendor.unref(utils_commUtils.imgUrl)("@/static/space/calendar-number.png"),
|
||
|
j: common_vendor.unref(utils_commUtils.imgUrl)("@/static/space/calendar.png"),
|
||
|
k: common_vendor.f(tabs.value, (tab, index, i0) => {
|
||
|
return common_vendor.e({
|
||
|
a: common_vendor.t(tab),
|
||
|
b: activeTab.value === index
|
||
|
}, activeTab.value === index ? {} : {}, {
|
||
|
c: index,
|
||
|
d: common_vendor.n({
|
||
|
active: activeTab.value === index
|
||
|
}),
|
||
|
e: common_vendor.o(($event) => selectTab(index), index)
|
||
|
});
|
||
|
}),
|
||
|
l: common_vendor.o(camera),
|
||
|
m: common_vendor.p({
|
||
|
name: "camera"
|
||
|
}),
|
||
|
n: common_vendor.o(pushTo),
|
||
|
o: focusUser.value.length > 0
|
||
|
}, focusUser.value.length > 0 ? {
|
||
|
p: common_vendor.f(focusUser.value, (user, index, i0) => {
|
||
|
return {
|
||
|
a: "31e6e34e-3-" + i0 + ",31e6e34e-0",
|
||
|
b: common_vendor.p({
|
||
|
round: true,
|
||
|
src: common_vendor.unref(utils_commUtils.imgUrl)(user.avatar)
|
||
|
}),
|
||
|
c: common_vendor.t(user.name),
|
||
|
d: index
|
||
|
};
|
||
|
})
|
||
|
} : {}, {
|
||
|
q: postsList.value
|
||
|
}, postsList.value ? {
|
||
|
r: common_vendor.f(postsList.value[activeTab.value == 0 ? "posts" : "followedPosts"], (post, k0, i0) => {
|
||
|
return {
|
||
|
a: "31e6e34e-4-" + i0 + ",31e6e34e-0",
|
||
|
b: common_vendor.p({
|
||
|
post
|
||
|
})
|
||
|
};
|
||
|
})
|
||
|
} : {});
|
||
|
};
|
||
|
}
|
||
|
};
|
||
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-31e6e34e"]]);
|
||
|
wx.createPage(MiniProgramPage);
|
||
|
//# sourceMappingURL=index.js.map
|