feat: 小程序演示版改造 + 服务端安全加固
Build and Publish Commercial Web / build (push) Failing after 25s
Publish Mini Program Dev Version / publish (push) Successful in 1m9s
Build and Publish Server / build (push) Failing after 6m42s

- 许愿树移除付费许愿/商品选择/微信支付调用,全部走免费许愿
- 许愿发布前接入微信 msgSecCheck v2 内容安全检测(access_token 内存缓存)
- 许愿字数限制改为按字符计算(中文按 1 字计)
- 占卜页改名「民俗趣算」并弱化「算命」措辞,占卜/每日运势页加文化声明
- 生产环境 JWT_SECRET 缺失或为默认值/不足 32 位时拒绝启动

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
gouki
2026-10-18 21:25:24 +00:00
co-authored by Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
parent 12fa2b0d19
commit 51d1a1999f
11 changed files with 238 additions and 152 deletions
+17 -100
View File
@@ -54,11 +54,7 @@ Page({
fireflies: [],
showCreateModal: false,
wishContent: '',
wishType: 'free',
maxFreeLength: 20,
maxPaidLength: 100,
products: [],
selectedProduct: null,
},
onLoad() {
@@ -72,7 +68,6 @@ Page({
this.initAmbiance();
this.loadTrees();
this.loadProducts();
},
onUnload() {
@@ -407,7 +402,7 @@ Page({
id: i + 1,
content: texts[i % texts.length],
author: authors[i % authors.length],
type: i % 5 === 0 ? 'paid' : 'free',
type: 'free',
position: i === 0 ? 100 : 0,
isTop: i === 0,
createdAt: new Date(Date.now() - i * 3600 * 1000).toISOString(),
@@ -427,26 +422,6 @@ Page({
this.setData({ detailWish: null });
},
// 加载许愿商品
async loadProducts() {
try {
const res = await request({ url: '/api/wish/products', method: 'GET' });
if (res.code === 0) {
this.setData({ products: res.data.list || [] });
return;
}
} catch (err) {
console.error('加载商品失败:', err);
}
this.setData({
products: [
{ id: 1, name: '普通许愿条', price: 100, duration: 7 },
{ id: 2, name: '精品许愿条', price: 500, duration: 30 },
{ id: 3, name: '至尊许愿条', price: 2000, duration: 90 },
],
});
},
// 打开/关闭许愿弹窗
openCreateModal() {
this.setData({ showCreateModal: true });
@@ -456,8 +431,6 @@ Page({
this.setData({
showCreateModal: false,
wishContent: '',
wishType: 'free',
selectedProduct: null,
});
},
@@ -465,16 +438,6 @@ Page({
this.setData({ wishContent: e.detail.value });
},
selectType(e) {
this.setData({ wishType: e.currentTarget.dataset.type });
},
selectProduct(e) {
const id = e.currentTarget.dataset.id;
const product = this.data.products.find((p) => p.id === id);
this.setData({ selectedProduct: product });
},
// 当前树ID
currentTreeId() {
const { trees, currentTreeIndex } = this.data;
@@ -484,54 +447,32 @@ Page({
// 提交许愿
async submitWish() {
const { wishContent, wishType, selectedProduct, maxFreeLength, maxPaidLength } = this.data;
const { wishContent, maxFreeLength } = this.data;
if (!wishContent.trim()) {
wx.showToast({ title: '请输入许愿内容', icon: 'none' });
return;
}
const maxLength = wishType === 'free' ? maxFreeLength : maxPaidLength;
if (wishContent.length > maxLength) {
wx.showToast({ title: `最多输入${maxLength}个字`, icon: 'none' });
return;
}
if (wishType === 'paid' && !selectedProduct) {
wx.showToast({ title: '请选择许愿商品', icon: 'none' });
if (wishContent.length > maxFreeLength) {
wx.showToast({ title: `最多输入${maxFreeLength}个字`, icon: 'none' });
return;
}
try {
if (wishType === 'paid') {
const orderRes = await request({
url: '/api/pay/create',
method: 'POST',
data: {
type: 'wish',
productId: selectedProduct.id,
content: wishContent,
treeId: this.currentTreeId(),
},
});
if (orderRes.code === 0) {
await this.wxPay(orderRes.data);
}
} else {
const res = await request({
url: '/api/wish/create',
method: 'POST',
data: {
content: wishContent,
type: 'free',
treeId: this.currentTreeId(),
},
});
if (res.code === 0) {
wx.showToast({ title: '许愿成功', icon: 'success' });
this.closeCreateModal();
this.loadTreeWishes(this.data.currentTreeIndex, true);
}
const res = await request({
url: '/api/wish/create',
method: 'POST',
data: {
content: wishContent,
type: 'free',
treeId: this.currentTreeId(),
},
});
if (res.code === 0) {
wx.showToast({ title: '许愿成功', icon: 'success' });
this.closeCreateModal();
this.loadTreeWishes(this.data.currentTreeIndex, true);
}
} catch (err) {
console.error('许愿失败:', err);
@@ -539,30 +480,6 @@ Page({
}
},
// 微信支付
async wxPay(orderData) {
return new Promise((resolve, reject) => {
wx.requestPayment({
timeStamp: orderData.timeStamp,
nonceStr: orderData.nonceStr,
package: orderData.package,
signType: orderData.signType,
paySign: orderData.paySign,
success: () => {
wx.showToast({ title: '支付成功', icon: 'success' });
this.closeCreateModal();
this.loadTreeWishes(this.data.currentTreeIndex, true);
resolve();
},
fail: (err) => {
console.error('支付失败:', err);
wx.showToast({ title: '支付失败', icon: 'none' });
reject(err);
},
});
});
},
// 分享
onShareAppMessage() {
return {