后端:公告√

注意数据库新建notice表
This commit is contained in:
2025-09-16 20:03:17 +08:00
parent 158b3e65b6
commit 562ec4abf9
26 changed files with 1468 additions and 35 deletions

View File

@@ -1,5 +1,6 @@
"use strict";
const common_vendor = require("../../common/vendor.js");
const common_http = require("../../common/http.js");
const common_assets = require("../../common/assets.js");
const _sfc_main = {
data() {
@@ -8,12 +9,9 @@ const _sfc_main = {
monthProfit: "0.00",
stockQty: "0.00",
activeTab: "home",
notices: [
{ text: "选材精工:不锈钢、合金钢,耐腐蚀更耐用", tag: "品质" },
{ text: "表面工艺:电镀锌/镀镍/发黑处理,性能均衡", tag: "工艺" },
{ text: "库存齐全:螺丝、螺母、垫圈、膨胀螺栓等现货", tag: "库存" },
{ text: "企业采购支持:批量优惠,次日发货", tag: "服务" }
],
notices: [],
loadingNotices: false,
noticeError: "",
features: [
{ key: "customer", title: "客户", img: "/static/icons/customer.png", emoji: "👥" },
{ key: "sale", title: "销售", img: "/static/icons/sale.png", emoji: "💰" },
@@ -27,7 +25,25 @@ const _sfc_main = {
]
};
},
onLoad() {
this.fetchNotices();
},
methods: {
async fetchNotices() {
this.loadingNotices = true;
this.noticeError = "";
try {
const list = await common_http.get("/api/notices");
this.notices = Array.isArray(list) ? list.map((n) => ({
text: n.content || n.title || "",
tag: n.tag || ""
})) : [];
} catch (e) {
this.noticeError = e && e.message || "公告加载失败";
} finally {
this.loadingNotices = false;
}
},
onFeatureTap(item) {
common_vendor.index.showToast({ title: item.title + "(开发中)", icon: "none" });
},
@@ -37,7 +53,7 @@ const _sfc_main = {
onNoticeTap(n) {
common_vendor.index.showModal({
title: "公告",
content: n.text,
content: n && (n.text || n.title || n.content) || "",
showCancel: false
});
},
@@ -50,12 +66,16 @@ const _sfc_main = {
}
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return {
return common_vendor.e({
a: common_assets._imports_0,
b: common_vendor.t($data.todayAmount),
c: common_vendor.t($data.monthProfit),
d: common_vendor.t($data.stockQty),
e: common_vendor.f($data.notices, (n, idx, i0) => {
e: $data.loadingNotices
}, $data.loadingNotices ? {} : $data.noticeError ? {
g: common_vendor.t($data.noticeError)
} : !$data.notices.length ? {} : {
i: common_vendor.f($data.notices, (n, idx, i0) => {
return common_vendor.e({
a: common_vendor.t(n.text),
b: n.tag
@@ -65,9 +85,12 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
d: common_vendor.o(($event) => $options.onNoticeTap(n), idx),
e: idx
});
}),
f: common_vendor.o((...args) => $options.onNoticeList && $options.onNoticeList(...args)),
g: common_vendor.f($data.features, (item, k0, i0) => {
})
}, {
f: $data.noticeError,
h: !$data.notices.length,
j: common_vendor.o((...args) => $options.onNoticeList && $options.onNoticeList(...args)),
k: common_vendor.f($data.features, (item, k0, i0) => {
return common_vendor.e({
a: item.img
}, item.img ? {
@@ -82,14 +105,14 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
h: common_vendor.o(($event) => $options.onFeatureTap(item), item.key)
});
}),
h: $data.activeTab === "home" ? 1 : "",
i: common_vendor.o(($event) => $data.activeTab = "home"),
j: common_vendor.o((...args) => $options.onCreateOrder && $options.onCreateOrder(...args)),
k: $data.activeTab === "detail" ? 1 : "",
l: common_vendor.o(($event) => $data.activeTab = "detail"),
m: $data.activeTab === "me" ? 1 : "",
n: common_vendor.o(($event) => $data.activeTab = "me")
};
l: $data.activeTab === "home" ? 1 : "",
m: common_vendor.o(($event) => $data.activeTab = "home"),
n: common_vendor.o((...args) => $options.onCreateOrder && $options.onCreateOrder(...args)),
o: $data.activeTab === "detail" ? 1 : "",
p: common_vendor.o(($event) => $data.activeTab = "detail"),
q: $data.activeTab === "me" ? 1 : "",
r: common_vendor.o(($event) => $data.activeTab = "me")
});
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
wx.createPage(MiniProgramPage);