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
+1 -1
View File
@@ -1,4 +1,4 @@
{
"navigationBarTitleText": "占卜",
"navigationBarTitleText": "民俗趣算",
"enablePullDownRefresh": false
}
+9 -3
View File
@@ -1,4 +1,10 @@
<view class="container">
<!-- 文化声明 -->
<view class="culture-card">
<view class="culture-title">民俗趣算 · 传统文化</view>
<view class="culture-text">梅花易数与称骨歌诀源自古代典籍与民间传统文化,属于传统民俗知识与趣味体验,仅供学习参考与娱乐,不构成任何决策建议,请理性看待,切勿迷信。</view>
</view>
<!-- 梅花易数 -->
<view class="card">
<view class="section-title">梅花易数</view>
@@ -48,9 +54,9 @@
</view>
</view>
<!-- 称骨算命 -->
<!-- 称骨测算 -->
<view class="card mt-2">
<view class="section-title">称骨算命</view>
<view class="section-title">称骨测算</view>
<view class="form-item">
<text class="form-label">出生年份(干支)</text>
<picker mode="selector" range="{{yearGanzhiList}}" value="{{boneYearIndex}}" bindchange="onBoneYearChange">
@@ -75,7 +81,7 @@
<view class="picker-input">{{hourList[boneHourIndex]}}</view>
</picker>
</view>
<view class="btn-primary" bindtap="calcBone">算命</view>
<view class="btn-primary" bindtap="calcBone">测算</view>
</view>
<!-- 称骨结果 -->
+21
View File
@@ -50,3 +50,24 @@
.trigram-name {
font-size: 28rpx;
}
/* 文化声明 */
.culture-card {
background: linear-gradient(135deg, #C41E3A 0%, #8B1A2B 100%);
border-radius: 24rpx;
padding: 28rpx 24rpx;
margin-bottom: 16rpx;
}
.culture-title {
color: #FFFFFF;
font-size: 32rpx;
font-weight: 700;
margin-bottom: 12rpx;
}
.culture-text {
color: rgba(255, 255, 255, 0.92);
font-size: 24rpx;
line-height: 1.7;
}
+6
View File
@@ -1,4 +1,10 @@
<view class="container">
<!-- 文化声明 -->
<view class="culture-card">
<view class="culture-title">每日运势 · 传统文化参考</view>
<view class="culture-text">本页内容基于传统干支历法与五行文化的趣味化呈现,仅供休闲娱乐与传统文化学习参考,不构成任何人生决策建议,请理性看待,切勿迷信。</view>
</view>
<!-- 无八字提示 -->
<view class="card text-center" wx:if="{{!hasBazi}}">
<text class="text-lg text-muted">请先排八字以查看每日运势</text>
+21
View File
@@ -45,3 +45,24 @@
.suggestion-item {
padding: 12rpx 0;
}
/* 文化声明 */
.culture-card {
background: linear-gradient(135deg, #C41E3A 0%, #8B1A2B 100%);
border-radius: 24rpx;
padding: 28rpx 24rpx;
margin-bottom: 16rpx;
}
.culture-title {
color: #FFFFFF;
font-size: 32rpx;
font-weight: 700;
margin-bottom: 12rpx;
}
.culture-text {
color: rgba(255, 255, 255, 0.92);
font-size: 24rpx;
line-height: 1.7;
}
+1 -1
View File
@@ -59,7 +59,7 @@
<text class="menu-arrow">›</text>
</view>
<view class="menu-item" bindtap="navigateTo" data-url="/pages/divination/divination">
<text class="menu-label">占卜</text>
<text class="menu-label">民俗趣算</text>
<text class="menu-arrow">›</text>
</view>
<view class="menu-item" bindtap="navigateTo" data-url="/pages/solar-terms/solar-terms">
+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 {
+3 -45
View File
@@ -122,64 +122,22 @@
</view>
<view class="modal-body">
<!-- 许愿类型选择 -->
<view class="type-selector">
<view
class="type-item {{wishType === 'free' ? 'active' : ''}}"
bindtap="selectType"
data-type="free"
>
<text class="type-name">免费许愿</text>
<text class="type-desc">20字以内</text>
</view>
<view
class="type-item {{wishType === 'paid' ? 'active' : ''}}"
bindtap="selectType"
data-type="paid"
>
<text class="type-name">付费许愿</text>
<text class="type-desc">更多特权</text>
</view>
</view>
<!-- 许愿内容输入 -->
<textarea
class="wish-input"
placeholder="请输入你的愿望..."
maxlength="{{wishType === 'free' ? maxFreeLength : maxPaidLength}}"
maxlength="{{maxFreeLength}}"
bindinput="onInputContent"
value="{{wishContent}}"
></textarea>
<view class="input-count">
{{wishContent.length}}/{{wishType === 'free' ? maxFreeLength : maxPaidLength}}
</view>
<!-- 付费商品选择 -->
<view class="product-section" wx:if="{{wishType === 'paid'}}">
<view class="product-title">选择许愿商品</view>
<view class="product-list">
<view
wx:for="{{products}}"
wx:key="id"
class="product-item {{selectedProduct && selectedProduct.id === item.id ? 'active' : ''}}"
bindtap="selectProduct"
data-id="{{item.id}}"
>
<view class="product-info">
<text class="product-name">{{item.name}}</text>
<text class="product-desc">展示{{item.duration}}天</text>
</view>
<view class="product-price">¥{{item.price / 100}}</view>
</view>
</view>
{{wishContent.length}}/{{maxFreeLength}}
</view>
</view>
<view class="modal-footer">
<button class="btn-outline" bindtap="closeCreateModal">取消</button>
<button class="btn-primary" bindtap="submitWish">
{{wishType === 'paid' ? '支付并许愿' : '提交许愿'}}
</button>
<button class="btn-primary" bindtap="submitWish">提交许愿</button>
</view>
</view>
</view>