feat: 优化金刚区活动品类路由与测试组局,完善管理后台退款、小程序海报推广与下单流程

这个提交包含在:
xcbyy
2026-11-21 11:38:55 +08:00
父节点 f3da2e4a63
当前提交 c4e333892c
共有 11 个文件被更改,包括 1379 次插入 和 163 次删除

查看文件

@@ -58,6 +58,7 @@
"@vitejs/plugin-vue": "^3.1.2", "@vitejs/plugin-vue": "^3.1.2",
"@vitejs/plugin-vue-jsx": "^2.0.1", "@vitejs/plugin-vue-jsx": "^2.0.1",
"@vue/babel-plugin-jsx": "^1.1.1", "@vue/babel-plugin-jsx": "^1.1.1",
"color": "^3.1.3",
"consola": "^2.15.3", "consola": "^2.15.3",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"eslint": "^8.25.0", "eslint": "^8.25.0",

查看文件

@@ -95,6 +95,9 @@ importers:
'@vue/babel-plugin-jsx': '@vue/babel-plugin-jsx':
specifier: ^1.1.1 specifier: ^1.1.1
version: 1.5.0(@babel/core@7.29.7) version: 1.5.0(@babel/core@7.29.7)
color:
specifier: ^3.1.3
version: 3.1.3
consola: consola:
specifier: ^2.15.3 specifier: ^2.15.3
version: 2.15.3 version: 2.15.3
@@ -1405,8 +1408,8 @@ packages:
color-string@1.9.1: color-string@1.9.1:
resolution: {integrity: sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==} resolution: {integrity: sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==}
color@3.2.1: color@3.1.3:
resolution: {integrity: sha512-aBl7dZI9ENN6fUGC7mWpMTPNHmWUSNan9tuWN6ahh5ZLNk9baLJOnSMlrQkHcrfFgz2/RigjUVAjdx36VcemKA==} resolution: {integrity: sha512-xgXAcTHa2HeFCGLE9Xs/R82hujGtu9Jd9x4NW3T34+OMs7VoPsjwzRczKHvTAHeJwWFwX5j15+MgAppE8ztObQ==}
colord@2.10.0: colord@2.10.0:
resolution: {integrity: sha512-AidJptpBJmjTclAp9BkLwJi0T93fo5epJnbaZslpg6QVzpHjAiveF55mE9AcUJiGMqRHgMDY8soMsQtuNYMHfw==} resolution: {integrity: sha512-AidJptpBJmjTclAp9BkLwJi0T93fo5epJnbaZslpg6QVzpHjAiveF55mE9AcUJiGMqRHgMDY8soMsQtuNYMHfw==}
@@ -5306,7 +5309,7 @@ snapshots:
'@arco-design/color@0.4.0': '@arco-design/color@0.4.0':
dependencies: dependencies:
color: 3.2.1 color: 3.1.3
'@arco-design/web-vue@2.58.0(vue@3.5.43(typescript@4.9.5))': '@arco-design/web-vue@2.58.0(vue@3.5.43(typescript@4.9.5))':
dependencies: dependencies:
@@ -6753,7 +6756,7 @@ snapshots:
color-name: 1.1.4 color-name: 1.1.4
simple-swizzle: 0.2.4 simple-swizzle: 0.2.4
color@3.2.1: color@3.1.3:
dependencies: dependencies:
color-convert: 1.9.3 color-convert: 1.9.3
color-string: 1.9.1 color-string: 1.9.1
@@ -9436,7 +9439,7 @@ snapshots:
dependencies: dependencies:
htmlparser2: 3.10.1 htmlparser2: 3.10.1
postcss: 7.0.39 postcss: 7.0.39
postcss-syntax: 0.36.2(postcss-html@0.36.0(postcss-syntax@0.36.2(postcss-html@1.8.1)(postcss@8.5.28))(postcss@7.0.39))(postcss-jsx@0.36.4(postcss-syntax@0.36.2(postcss-html@1.8.1)(postcss@8.5.28))(postcss@7.0.39))(postcss-less@3.1.4)(postcss-markdown@0.36.0)(postcss-scss@2.1.1)(postcss@7.0.39) postcss-syntax: 0.36.2(postcss-html@0.36.0(postcss-syntax@0.36.2(postcss-html@1.8.1)(postcss@8.5.28))(postcss@7.0.39))(postcss-jsx@0.36.4(postcss-syntax@0.36.2(postcss-html@1.8.1)(postcss@8.5.28))(postcss@7.0.39))(postcss-less@3.1.4)(postcss-markdown@0.36.0(postcss-syntax@0.36.2(postcss-html@1.8.1)(postcss@8.5.28))(postcss@7.0.39))(postcss-scss@2.1.1)(postcss@7.0.39)
postcss-html@1.8.1: postcss-html@1.8.1:
dependencies: dependencies:
@@ -9449,7 +9452,7 @@ snapshots:
dependencies: dependencies:
'@babel/core': 8.0.6 '@babel/core': 8.0.6
postcss: 7.0.39 postcss: 7.0.39
postcss-syntax: 0.36.2(postcss-html@0.36.0(postcss-syntax@0.36.2(postcss-html@1.8.1)(postcss@8.5.28))(postcss@7.0.39))(postcss-jsx@0.36.4(postcss-syntax@0.36.2(postcss-html@1.8.1)(postcss@8.5.28))(postcss@7.0.39))(postcss-less@3.1.4)(postcss-markdown@0.36.0)(postcss-scss@2.1.1)(postcss@7.0.39) postcss-syntax: 0.36.2(postcss-html@0.36.0(postcss-syntax@0.36.2(postcss-html@1.8.1)(postcss@8.5.28))(postcss@7.0.39))(postcss-jsx@0.36.4(postcss-syntax@0.36.2(postcss-html@1.8.1)(postcss@8.5.28))(postcss@7.0.39))(postcss-less@3.1.4)(postcss-markdown@0.36.0(postcss-syntax@0.36.2(postcss-html@1.8.1)(postcss@8.5.28))(postcss@7.0.39))(postcss-scss@2.1.1)(postcss@7.0.39)
postcss-less@3.1.4: postcss-less@3.1.4:
dependencies: dependencies:
@@ -9458,7 +9461,7 @@ snapshots:
postcss-markdown@0.36.0(postcss-syntax@0.36.2(postcss-html@1.8.1)(postcss@8.5.28))(postcss@7.0.39): postcss-markdown@0.36.0(postcss-syntax@0.36.2(postcss-html@1.8.1)(postcss@8.5.28))(postcss@7.0.39):
dependencies: dependencies:
postcss: 7.0.39 postcss: 7.0.39
postcss-syntax: 0.36.2(postcss-html@0.36.0(postcss-syntax@0.36.2(postcss-html@1.8.1)(postcss@8.5.28))(postcss@7.0.39))(postcss-jsx@0.36.4(postcss-syntax@0.36.2(postcss-html@1.8.1)(postcss@8.5.28))(postcss@7.0.39))(postcss-less@3.1.4)(postcss-markdown@0.36.0)(postcss-scss@2.1.1)(postcss@7.0.39) postcss-syntax: 0.36.2(postcss-html@0.36.0(postcss-syntax@0.36.2(postcss-html@1.8.1)(postcss@8.5.28))(postcss@7.0.39))(postcss-jsx@0.36.4(postcss-syntax@0.36.2(postcss-html@1.8.1)(postcss@8.5.28))(postcss@7.0.39))(postcss-less@3.1.4)(postcss-markdown@0.36.0(postcss-syntax@0.36.2(postcss-html@1.8.1)(postcss@8.5.28))(postcss@7.0.39))(postcss-scss@2.1.1)(postcss@7.0.39)
remark: 10.0.1 remark: 10.0.1
unist-util-find-all-after: 1.0.5 unist-util-find-all-after: 1.0.5
@@ -9510,7 +9513,7 @@ snapshots:
dependencies: dependencies:
postcss: 8.5.28 postcss: 8.5.28
postcss-syntax@0.36.2(postcss-html@0.36.0(postcss-syntax@0.36.2(postcss-html@1.8.1)(postcss@8.5.28))(postcss@7.0.39))(postcss-jsx@0.36.4(postcss-syntax@0.36.2(postcss-html@1.8.1)(postcss@8.5.28))(postcss@7.0.39))(postcss-less@3.1.4)(postcss-markdown@0.36.0)(postcss-scss@2.1.1)(postcss@7.0.39): postcss-syntax@0.36.2(postcss-html@0.36.0(postcss-syntax@0.36.2(postcss-html@1.8.1)(postcss@8.5.28))(postcss@7.0.39))(postcss-jsx@0.36.4(postcss-syntax@0.36.2(postcss-html@1.8.1)(postcss@8.5.28))(postcss@7.0.39))(postcss-less@3.1.4)(postcss-markdown@0.36.0(postcss-syntax@0.36.2(postcss-html@1.8.1)(postcss@8.5.28))(postcss@7.0.39))(postcss-scss@2.1.1)(postcss@7.0.39):
dependencies: dependencies:
postcss: 7.0.39 postcss: 7.0.39
optionalDependencies: optionalDependencies:
@@ -10328,7 +10331,7 @@ snapshots:
postcss-sass: 0.3.5 postcss-sass: 0.3.5
postcss-scss: 2.1.1 postcss-scss: 2.1.1
postcss-selector-parser: 3.1.2 postcss-selector-parser: 3.1.2
postcss-syntax: 0.36.2(postcss-html@0.36.0(postcss-syntax@0.36.2(postcss-html@1.8.1)(postcss@8.5.28))(postcss@7.0.39))(postcss-jsx@0.36.4(postcss-syntax@0.36.2(postcss-html@1.8.1)(postcss@8.5.28))(postcss@7.0.39))(postcss-less@3.1.4)(postcss-markdown@0.36.0)(postcss-scss@2.1.1)(postcss@7.0.39) postcss-syntax: 0.36.2(postcss-html@0.36.0(postcss-syntax@0.36.2(postcss-html@1.8.1)(postcss@8.5.28))(postcss@7.0.39))(postcss-jsx@0.36.4(postcss-syntax@0.36.2(postcss-html@1.8.1)(postcss@8.5.28))(postcss@7.0.39))(postcss-less@3.1.4)(postcss-markdown@0.36.0(postcss-syntax@0.36.2(postcss-html@1.8.1)(postcss@8.5.28))(postcss@7.0.39))(postcss-scss@2.1.1)(postcss@7.0.39)
postcss-value-parser: 3.3.1 postcss-value-parser: 3.3.1
resolve-from: 4.0.0 resolve-from: 4.0.0
signal-exit: 3.0.7 signal-exit: 3.0.7

查看文件

@@ -104,30 +104,109 @@
</template> </template>
</a-table-column> </a-table-column>
<a-table-column title="下单时间" data-index="createdAt" :width="160" /> <a-table-column title="下单时间" data-index="createdAt" :width="160" />
<a-table-column title="操作" :width="130" fixed="right"> <a-table-column title="操作" :width="180" fixed="right">
<template #cell="{ record }"> <template #cell="{ record }">
<a-space>
<a-button <a-button
v-if="record.status === '争议仲裁中'"
type="primary"
status="danger"
size="small"
@click="router.push('/order/arbitration')"
>
仲裁介入
</a-button>
<a-button
v-else
type="text" type="text"
size="small" size="small"
@click="showDetail(record)" @click="showDetail(record)"
> >
查看流程 详情
</a-button> </a-button>
<a-button
v-if="record.status === '争议仲裁中'"
type="outline"
status="warning"
size="small"
@click="router.push('/order/arbitration')"
>
仲裁
</a-button>
<a-button
v-if="canRefund(record)"
type="outline"
status="danger"
size="small"
@click="openRefundModal(record)"
>
退款
</a-button>
<a-tag
v-else-if="record.status === '已全额退款'"
color="gray"
size="small"
>
已退款
</a-tag>
</a-space>
</template> </template>
</a-table-column> </a-table-column>
</template> </template>
</a-table> </a-table>
</a-card> </a-card>
<!-- 管理员直接退款弹窗 -->
<a-modal
v-model:visible="refundModalVisible"
title="订单原路退款处理"
:ok-loading="refundSubmitting"
@ok="handleConfirmRefund"
@cancel="refundModalVisible = false"
>
<a-alert type="warning" style="margin-bottom: 16px">
原路退款将直接将资金退回至买家(微信支付订单原路退回微信零钱/银行卡,余额支付退回用户钱包),并联动释放使用的优惠券。
</a-alert>
<a-form :model="refundForm" layout="vertical">
<a-form-item label="订单编号">
<a-input :model-value="currentOrder?.orderNo || currentOrder?.id || ''" disabled />
</a-form-item>
<a-form-item label="交易双方">
<a-input :model-value="`${currentOrder?.clientName || '买家'} 下单给 ${currentOrder?.companionName || '大神'}`" disabled />
</a-form-item>
<a-form-item label="订单实付总额">
<div style="font-weight: 700; color: #ff5722; font-size: 16px">¥{{ currentOrder?.amount }}</div>
</a-form-item>
<a-form-item label="退款方式" required>
<a-radio-group v-model="refundForm.refundType" type="button">
<a-radio value="full">全额原路退款 (¥{{ currentOrder?.amount }})</a-radio>
<a-radio value="partial">部分原路退款</a-radio>
</a-radio-group>
</a-form-item>
<a-form-item
v-if="refundForm.refundType === 'partial'"
label="退款金额 (元)"
required
>
<a-input-number
v-model="refundForm.refundAmount"
:min="0.01"
:max="Number(currentOrder?.amount || 99999)"
:precision="2"
placeholder="请输入退还给买家的金额"
/>
<template #extra>
剩余款项将自动解冻并结算至大神佣金账户。
</template>
</a-form-item>
<a-form-item label="退款原因 / 客服备注说明" required>
<a-select v-model="refundForm.reasonSelect" placeholder="请选择退款原因" style="margin-bottom: 8px">
<a-option value="客户协商一致退款">客户协商一致退款</a-option>
<a-option value="大神迟到/旷工未履约">大神迟到/旷工未履约</a-option>
<a-option value="服务质量不达标申请售后">服务质量不达标申请售后</a-option>
<a-option value="不可抗力导致服务取消">不可抗力导致服务取消</a-option>
<a-option value="测试订单退款">测试订单退款</a-option>
<a-option value="其他原因">其他原因</a-option>
</a-select>
<a-textarea
v-model="refundForm.reasonDetail"
placeholder="请输入具体退款说明备注(可选)"
:max-length="200"
show-word-limit
/>
</a-form-item>
</a-form>
</a-modal>
</div> </div>
</template> </template>
@@ -211,6 +290,76 @@
}); });
}; };
// 退款状态控制
const refundModalVisible = ref(false);
const refundSubmitting = ref(false);
const currentOrder = ref<any>(null);
const refundForm = ref({
refundType: 'full',
refundAmount: 0,
reasonSelect: '客户协商一致退款',
reasonDetail: '',
});
const canRefund = (record: any) => {
const s = record.status;
if (['已全额退款', '待支付', '已取消'].includes(s)) {
return false;
}
return Number(record.amount || 0) > 0;
};
const openRefundModal = (record: any) => {
currentOrder.value = record;
refundForm.value = {
refundType: 'full',
refundAmount: Number(record.amount || 0),
reasonSelect: '客户协商一致退款',
reasonDetail: '',
};
refundModalVisible.value = true;
};
const handleConfirmRefund = async () => {
if (!currentOrder.value) return;
const totalAmt = Number(currentOrder.value.amount || 0);
if (refundForm.value.refundType === 'partial') {
if (!refundForm.value.refundAmount || refundForm.value.refundAmount <= 0) {
Message.warning('请输入有效的部分退款金额');
return;
}
if (refundForm.value.refundAmount > totalAmt) {
Message.warning('退款金额不能超过订单总额');
return;
}
}
const reason = refundForm.value.reasonDetail
? `${refundForm.value.reasonSelect}: ${refundForm.value.reasonDetail}`
: refundForm.value.reasonSelect;
refundSubmitting.value = true;
try {
const res: any = await axios.post(`/api/orders/${currentOrder.value.id}/admin-refund`, {
refundType: refundForm.value.refundType,
refundAmount: refundForm.value.refundType === 'partial' ? refundForm.value.refundAmount : totalAmt,
reason,
});
if (res && res.code === 20000) {
Message.success(res.message || '退款成功,款项已原路退回');
} else {
Message.success('退款成功,款项已原路退回');
}
refundModalVisible.value = false;
fetchData();
} catch (err: any) {
const msg = err.response?.data?.message || err.message || '退款处理失败';
Message.error(msg);
} finally {
refundSubmitting.value = false;
}
};
onMounted(() => { onMounted(() => {
fetchData(); fetchData();
}); });

查看文件

@@ -508,6 +508,20 @@
</a-tag> </a-tag>
</template> </template>
</a-table-column> </a-table-column>
<a-table-column title="操作" :width="90" fixed="right">
<template #cell="{ record }">
<a-button
v-if="canRefundOrder(record)"
type="outline"
status="danger"
size="mini"
@click="openRefundOrderModal(record)"
>
退款
</a-button>
<span v-else style="color: var(--color-text-4); font-size: 11px">--</span>
</template>
</a-table-column>
</template> </template>
</a-table> </a-table>
</div> </div>
@@ -653,6 +667,68 @@
</a-alert> </a-alert>
</a-form> </a-form>
</a-modal> </a-modal>
<!-- 履约订单直接原路退款弹窗 -->
<a-modal
v-model:visible="orderRefundModalVisible"
title="订单原路退款处理"
:ok-loading="orderRefundSubmitting"
@ok="handleConfirmOrderRefund"
@cancel="orderRefundModalVisible = false"
>
<a-alert type="warning" style="margin-bottom: 16px">
原路退款将直接将资金退回至买家账户(微信支付订单走微信原路退款,余额支付退回用户钱包),并联动释放优惠券与记账。
</a-alert>
<a-form :model="orderRefundForm" layout="vertical">
<a-form-item label="订单编号">
<a-input :model-value="currentRefundOrder?.orderNo || currentRefundOrder?.id || ''" disabled />
</a-form-item>
<a-form-item label="交易双方">
<a-input :model-value="`${currentRefundOrder?.clientName || '买家'} 下单给 ${currentRefundOrder?.companionName || '大神'}`" disabled />
</a-form-item>
<a-form-item label="订单实付总额">
<div style="font-weight: 700; color: #ff5722; font-size: 16px">¥{{ currentRefundOrder?.amount }}</div>
</a-form-item>
<a-form-item label="退款方式" required>
<a-radio-group v-model="orderRefundForm.refundType" type="button">
<a-radio value="full">全额原路退款 (¥{{ currentRefundOrder?.amount }})</a-radio>
<a-radio value="partial">部分原路退款</a-radio>
</a-radio-group>
</a-form-item>
<a-form-item
v-if="orderRefundForm.refundType === 'partial'"
label="退款金额 (元)"
required
>
<a-input-number
v-model="orderRefundForm.refundAmount"
:min="0.01"
:max="Number(currentRefundOrder?.amount || 99999)"
:precision="2"
placeholder="请输入退款金额"
/>
<template #extra>
剩余款项将自动解冻并结算至大神佣金账户。
</template>
</a-form-item>
<a-form-item label="退款原因 / 客服备注说明" required>
<a-select v-model="orderRefundForm.reasonSelect" placeholder="请选择退款原因" style="margin-bottom: 8px">
<a-option value="客户协商一致退款">客户协商一致退款</a-option>
<a-option value="大神迟到/旷工未履约">大神迟到/旷工未履约</a-option>
<a-option value="服务质量不达标申请售后">服务质量不达标申请售后</a-option>
<a-option value="不可抗力导致服务取消">不可抗力导致服务取消</a-option>
<a-option value="测试订单退款">测试订单退款</a-option>
<a-option value="其他原因">其他原因</a-option>
</a-select>
<a-textarea
v-model="orderRefundForm.reasonDetail"
placeholder="请输入具体退款说明备注(可选)"
:max-length="200"
show-word-limit
/>
</a-form-item>
</a-form>
</a-modal>
</div> </div>
</template> </template>
@@ -680,6 +756,79 @@
const balanceForm = ref({ direction: 'IN', amount: 100, reason: '' }); const balanceForm = ref({ direction: 'IN', amount: 100, reason: '' });
const submittingBalance = ref(false); const submittingBalance = ref(false);
// 履约订单退款控制
const orderRefundModalVisible = ref(false);
const orderRefundSubmitting = ref(false);
const currentRefundOrder = ref<any>(null);
const orderRefundForm = ref({
refundType: 'full',
refundAmount: 0,
reasonSelect: '客户协商一致退款',
reasonDetail: '',
});
const canRefundOrder = (record: any) => {
const s = record.status;
if (['已全额退款', '待支付', '已取消'].includes(s)) {
return false;
}
return Number(record.amount || 0) > 0;
};
const openRefundOrderModal = (record: any) => {
currentRefundOrder.value = record;
orderRefundForm.value = {
refundType: 'full',
refundAmount: Number(record.amount || 0),
reasonSelect: '客户协商一致退款',
reasonDetail: '',
};
orderRefundModalVisible.value = true;
};
const handleConfirmOrderRefund = async () => {
if (!currentRefundOrder.value) return;
const totalAmt = Number(currentRefundOrder.value.amount || 0);
if (orderRefundForm.value.refundType === 'partial') {
if (!orderRefundForm.value.refundAmount || orderRefundForm.value.refundAmount <= 0) {
Message.warning('请输入有效的部分退款金额');
return;
}
if (orderRefundForm.value.refundAmount > totalAmt) {
Message.warning('退款金额不能超过订单总额');
return;
}
}
const reason = orderRefundForm.value.reasonDetail
? `${orderRefundForm.value.reasonSelect}: ${orderRefundForm.value.reasonDetail}`
: orderRefundForm.value.reasonSelect;
orderRefundSubmitting.value = true;
try {
const res: any = await axios.post(`/api/orders/${currentRefundOrder.value.id}/admin-refund`, {
refundType: orderRefundForm.value.refundType,
refundAmount: orderRefundForm.value.refundType === 'partial' ? orderRefundForm.value.refundAmount : totalAmt,
reason,
});
if (res && res.code === 20000) {
Message.success(res.message || '退款成功,款项已原路退回');
} else {
Message.success('退款成功,款项已原路退回');
}
orderRefundModalVisible.value = false;
if (currentUser.value?.id) {
fetchUserDetail(currentUser.value.id);
}
fetchUsers();
} catch (err: any) {
const msg = err.response?.data?.message || err.message || '退款处理失败';
Message.error(msg);
} finally {
orderRefundSubmitting.value = false;
}
};
const openBalanceModal = (record: any) => { const openBalanceModal = (record: any) => {
balanceTarget.value = { ...(record || {}) }; balanceTarget.value = { ...(record || {}) };
balanceForm.value = { direction: 'IN', amount: 100, reason: '' }; balanceForm.value = { direction: 'IN', amount: 100, reason: '' };

查看文件

@@ -105,7 +105,7 @@
<text class="cell-label">优惠券</text> <text class="cell-label">优惠券</text>
<view class="cell-right"> <view class="cell-right">
<text class="coupon-val">-¥{{ discount }} (新人首单立减)</text> <text class="coupon-val">-¥{{ discount }} (新人首单立减)</text>
<text class="arrow">></text> <image class="arrow" :src="ICONS.chevronRight" mode="aspectFit" />
</view> </view>
</view> </view>
@@ -976,8 +976,9 @@ const handlePay = async () => {
font-weight: 600; font-weight: 600;
} }
.arrow { .arrow {
font-size: 24rpx; width: 24rpx;
color: var(--text-muted); height: 24rpx;
opacity: 0.6;
} }
} }
} }

查看文件

@@ -61,25 +61,64 @@
<!-- Tab 1: 专属太阳码海报 --> <!-- Tab 1: 专属太阳码海报 -->
<view class="tab-pane-poster" v-if="distActiveTab === 'poster'"> <view class="tab-pane-poster" v-if="distActiveTab === 'poster'">
<view class="poster-preview-card"> <view class="poster-preview-card">
<!-- 顶部认证徽标 -->
<view class="poster-badge">官方认证邀请码</view> <view class="poster-badge">官方认证邀请码</view>
<text class="poster-hero-title">电竞陪伴 · 同城玩乐</text> <text class="poster-hero-title">电竞陪伴 · 同城玩乐</text>
<text class="poster-hero-sub">寻找心仪陪伴师,立享新人首单礼包</text> <text class="poster-hero-sub">寻找心仪陪伴师 · 立享新人专属礼包</text>
<view class="suncode-box"> <!-- 推荐人信息条 -->
<view class="suncode-ring"> <view class="poster-inviter-pill">
<view class="sun-dot" v-for="d in 12" :key="d"></view> <image class="inviter-avatar" :src="user.avatar || defaultAvatar" mode="aspectFill" />
<view class="suncode-center"> <text class="inviter-name">推荐人:{{ user.nickname || '同城生活陪伴推荐官' }}</text>
<image class="suncode-avatar" :src="user.avatar || defaultAvatar" mode="aspectFill" />
</view>
</view>
<text class="suncode-hint">微信长按或扫码进入</text>
</view> </view>
<view class="poster-footer-code"> <!-- 核心微信小程序推广太阳码卡片 (支持屏幕直接长按识别或扫码) -->
<text class="lbl">邀请码:</text> <view class="poster-code-card">
<text class="val">PW{{ user.id || '' }}</text> <image
v-if="wxacodeUrl && !wxacodeLoadError"
class="wxacode-img"
:src="wxacodeUrl"
mode="aspectFit"
:show-menu-by-longpress="true"
@error="wxacodeLoadError = true"
/>
<view v-else class="qrcode-fallback-box">
<view class="qr-matrix-grid">
<view
v-for="(row, rIdx) in previewQrMatrix"
:key="rIdx"
class="qr-row"
>
<view
v-for="(cell, cIdx) in row"
:key="cIdx"
class="qr-cell"
:class="{ 'cell-dark': cell, 'cell-light': !cell }"
></view>
</view> </view>
</view> </view>
<view class="qr-avatar-center">
<image class="qr-avatar-img" :src="user.avatar || defaultAvatar" mode="aspectFill" />
</view>
</view>
</view>
<!-- 扫码操作指引 -->
<view class="poster-guide-box">
<text class="guide-title">微信长按识别或扫一扫进入小程序</text>
<text class="guide-sub">新用户授权登录即可自动绑定上下级返佣关系</text>
</view>
<!-- 专属邀请码金色卡片 -->
<view class="poster-gold-code-card">
<text class="gold-lbl">您的专属官方邀请码</text>
<text class="gold-code">PW{{ user.id || '' }}</text>
<text class="gold-tip">(支持微信扫码直达,或手动输入邀请码)</text>
</view>
<!-- 保障标语 -->
<text class="poster-sec-tag">同城陪伴 · 真实认证 · 资金托管保障</text>
</view>
<view class="poster-actions-row"> <view class="poster-actions-row">
<button class="btn-poster-action secondary btn-active" @click="copyInviteLink">复制邀请链接</button> <button class="btn-poster-action secondary btn-active" @click="copyInviteLink">复制邀请链接</button>
@@ -207,6 +246,14 @@
</view> </view>
</view> </view>
</scroll-view> </scroll-view>
<!-- 离屏海报 Canvas (600 x 900) -->
<canvas
canvas-id="promotePosterCanvas"
id="promotePosterCanvas"
class="hidden-poster-canvas"
style="width: 600px; height: 900px;"
></canvas>
</view> </view>
</template> </template>
@@ -225,6 +272,7 @@ import { ICONS } from '@/common/icons.js';
import { getCurrentThemeKey, applyThemeToNativeUI } from '@/common/theme.js'; import { getCurrentThemeKey, applyThemeToNativeUI } from '@/common/theme.js';
import { getNavBarInfo } from '@/common/nav.js'; import { getNavBarInfo } from '@/common/nav.js';
import { useShare } from '@/common/share.js'; import { useShare } from '@/common/share.js';
import { generateQRCodeMatrix } from '@/common/qrcode.js';
const currentThemeKey = ref(getCurrentThemeKey()); const currentThemeKey = ref(getCurrentThemeKey());
const navInfo = ref(getNavBarInfo()); const navInfo = ref(getNavBarInfo());
@@ -241,11 +289,24 @@ const user = ref({
invitedCount: 0 invitedCount: 0
}); });
const wxacodeLoadError = ref(false);
const wxacodeUrl = computed(() => {
const uid = user.value.id || normalizeUserId();
if (!uid) return '';
return `https://peiww.gynhc.com/api/distribution/wxacode?code=PW${uid}`;
});
const previewQrMatrix = computed(() => {
const uid = user.value.id || normalizeUserId();
if (!uid) return [];
return generateQRCodeMatrix(`https://peiww.gynhc.com/invite?code=PW${uid}`, 3);
});
useShare(() => { useShare(() => {
const uid = normalizeUserId(); const uid = normalizeUserId();
return { return {
title: '邀请你加入同城陪伴,海量高颜值大神随心约,立享新人专属礼包!', title: '【邀请好礼】邀请你加入同城陪伴,高颜值大神随心约,立享新人专属礼包!',
timelineTitle: '加入同城陪伴,海量高颜值大神随心约,同城组局随心享!', timelineTitle: '同城生活陪伴 · 专业游戏陪玩与生活陪伴,邀请好友享双重丰厚礼遇!',
path: '/pages/index/index', path: '/pages/index/index',
params: { params: {
code: uid ? `PW${uid}` : '', code: uid ? `PW${uid}` : '',
@@ -334,19 +395,296 @@ const copyInviteLink = () => {
}); });
}; };
const savePosterImage = () => { const isGeneratingPoster = ref(false);
const uid = normalizeUserId();
if (!uid) { // 圆角矩形绘制辅助函数
uni.showToast({ title: '请先登录后再分享', icon: 'none' }); const drawRoundedRect = (ctx, x, y, width, height, radius, fill, stroke) => {
ctx.save();
ctx.beginPath();
ctx.moveTo(x + radius, y);
ctx.lineTo(x + width - radius, y);
ctx.quadraticCurveTo(x + width, y, x + width, y + radius);
ctx.lineTo(x + width, y + height - radius);
ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
ctx.lineTo(x + radius, y + height);
ctx.quadraticCurveTo(x, y + height, x, y + height - radius);
ctx.lineTo(x, y + radius);
ctx.quadraticCurveTo(x, y, x + radius, y);
ctx.closePath();
if (fill) ctx.fill();
if (stroke) ctx.stroke();
ctx.restore();
};
// 绘制轻量高保真 QR Code 矩阵到 Canvas
const drawQRCodeOnCanvas = (ctx, matrix, x, y, size) => {
const count = matrix.length;
const cellSize = size / count;
ctx.save();
ctx.setFillStyle('#0F172A');
for (let r = 0; r < count; r++) {
for (let c = 0; c < count; c++) {
if (matrix[r][c]) {
const px = x + c * cellSize;
const py = y + r * cellSize;
ctx.fillRect(px, py, Math.ceil(cellSize), Math.ceil(cellSize));
}
}
}
ctx.restore();
};
// 下载网络图片为本地临时文件
const downloadImageToLocal = (url) => {
return new Promise((resolve) => {
if (!url || typeof url !== 'string' || !url.startsWith('http')) {
resolve('');
return; return;
} }
uni.downloadFile({
url,
success: (res) => {
if (res.statusCode === 200 && res.tempFilePath) {
resolve(res.tempFilePath);
} else {
resolve('');
}
},
fail: () => resolve('')
});
});
};
const savePosterImage = async () => {
const uid = normalizeUserId();
if (!uid) {
uni.showToast({ title: '请先登录后再保存海报', icon: 'none' });
return;
}
if (isGeneratingPoster.value) return;
isGeneratingPoster.value = true;
uni.showLoading({ title: '正在绘制海报...', mask: true });
try {
const avatarUrl = user.value.avatar || defaultAvatar;
const wxacodeApi = `https://peiww.gynhc.com/api/distribution/wxacode?code=PW${uid}`;
// 并发预加载用户头像与微信小程序码(太阳码)
const [localAvatar, localWxacode] = await Promise.all([
downloadImageToLocal(avatarUrl),
downloadImageToLocal(wxacodeApi)
]);
const ctx = uni.createCanvasContext('promotePosterCanvas');
const W = 600;
const H = 900;
// 1. 背景渐变 (深邃暗夜流光)
const bgGradient = ctx.createLinearGradient(0, 0, 0, H);
bgGradient.addColorStop(0, '#0F172A');
bgGradient.addColorStop(0.5, '#1E1B4B');
bgGradient.addColorStop(1, '#0A0F1D');
ctx.setFillStyle(bgGradient);
ctx.fillRect(0, 0, W, H);
// 2. 顶部微光光晕
ctx.save();
ctx.beginPath();
ctx.arc(300, 50, 240, 0, Math.PI * 2);
ctx.setFillStyle('rgba(99, 102, 241, 0.16)');
ctx.fill();
ctx.restore();
// 3. 内层立体卡片边框
ctx.save();
ctx.setFillStyle('rgba(255, 255, 255, 0.03)');
ctx.setStrokeStyle('rgba(255, 255, 255, 0.12)');
ctx.setLineWidth(2);
drawRoundedRect(ctx, 36, 36, 528, 828, 28, true, true);
ctx.restore();
// 4. 顶部认证徽标
ctx.save();
ctx.setFillStyle('rgba(99, 102, 241, 0.25)');
ctx.setStrokeStyle('rgba(129, 140, 248, 0.45)');
ctx.setLineWidth(1.5);
drawRoundedRect(ctx, 205, 62, 190, 34, 17, true, true);
ctx.setFontSize(15);
ctx.setFillStyle('#818CF8');
ctx.setTextAlign('center');
ctx.setTextBaseline('middle');
ctx.fillText('官方认证邀请码', 300, 79);
ctx.restore();
// 5. 标题与副标题
ctx.save();
ctx.setTextAlign('center');
ctx.setFontSize(30);
ctx.setFillStyle('#FFFFFF');
ctx.fillText('电竞陪伴 · 同城玩乐', 300, 138);
ctx.setFontSize(16);
ctx.setFillStyle('#94A3B8');
ctx.fillText('寻找心仪陪伴师 · 立享新人专属礼包', 300, 172);
ctx.restore();
// 6. 推荐人个人信息横条 (头像 + 昵称)
ctx.save();
ctx.setFillStyle('rgba(255, 255, 255, 0.06)');
ctx.setStrokeStyle('rgba(255, 255, 255, 0.1)');
ctx.setLineWidth(1);
drawRoundedRect(ctx, 130, 196, 340, 50, 25, true, true);
// 小头像
ctx.save();
ctx.beginPath();
ctx.arc(162, 221, 18, 0, Math.PI * 2);
ctx.clip();
if (localAvatar) {
ctx.drawImage(localAvatar, 144, 203, 36, 36);
} else {
ctx.setFillStyle('#4338CA');
ctx.fillRect(144, 203, 36, 36);
}
ctx.restore();
ctx.setTextAlign('left');
ctx.setTextBaseline('middle');
ctx.setFontSize(16);
ctx.setFillStyle('#F8FAFC');
const nickText = user.value.nickname ? `推荐人:${user.value.nickname}` : '同城生活陪伴推荐官';
const displayNick = nickText.length > 12 ? nickText.slice(0, 11) + '…' : nickText;
ctx.fillText(displayNick, 190, 221);
ctx.restore();
// 7. 核心推广二维码 / 小程序码展示区 (居中白色立体卡片)
const codeCardX = 160;
const codeCardY = 265;
const codeCardSize = 280;
// 白色圆角卡片底衬
ctx.save();
ctx.setFillStyle('#FFFFFF');
ctx.setStrokeStyle('rgba(255, 255, 255, 0.3)');
ctx.setLineWidth(2);
drawRoundedRect(ctx, codeCardX, codeCardY, codeCardSize, codeCardSize, 20, true, true);
ctx.restore();
// 优先绘制微信官方小程序码(太阳码)
if (localWxacode) {
ctx.drawImage(localWxacode, codeCardX + 15, codeCardY + 15, codeCardSize - 30, codeCardSize - 30);
} else {
// 降级兜底:通过轻量矩阵库直接绘制高清晰度二维码
const qrMatrix = generateQRCodeMatrix(`https://peiww.gynhc.com/invite?code=PW${uid}`, 3);
drawQRCodeOnCanvas(ctx, qrMatrix, codeCardX + 20, codeCardY + 20, codeCardSize - 40);
// 二维码中心放置微型头像或标识
if (localAvatar) {
ctx.save();
ctx.setFillStyle('#FFFFFF');
drawRoundedRect(ctx, 276, 381, 48, 48, 8, true, false);
ctx.beginPath();
ctx.arc(300, 405, 20, 0, Math.PI * 2);
ctx.clip();
ctx.drawImage(localAvatar, 280, 385, 40, 40);
ctx.restore();
}
}
// 8. 扫码操作指引文案
ctx.save();
ctx.setTextAlign('center');
ctx.setFontSize(16);
ctx.setFillStyle('#818CF8');
ctx.fillText('微信长按识别或扫一扫进入小程序', 300, 574);
ctx.setFontSize(13);
ctx.setFillStyle('#94A3B8');
ctx.fillText('新用户授权登录即可自动绑定上下级返佣关系', 300, 600);
ctx.restore();
// 9. 专属邀请码金色卡片 (提供手动输入兜底)
ctx.save();
ctx.setFillStyle('rgba(245, 158, 11, 0.12)');
ctx.setStrokeStyle('rgba(245, 158, 11, 0.45)');
ctx.setLineWidth(2);
drawRoundedRect(ctx, 80, 630, 440, 115, 20, true, true);
ctx.setTextAlign('center');
ctx.setFontSize(15);
ctx.setFillStyle('#F59E0B');
ctx.fillText('您的专属官方邀请码', 300, 662);
ctx.setFontSize(38);
ctx.setFillStyle('#FBBF24');
ctx.fillText(`PW${uid}`, 300, 712);
ctx.restore();
// 10. 底部保障与版权
ctx.save();
ctx.setTextAlign('center');
ctx.setFontSize(14);
ctx.setFillStyle('#64748B');
ctx.fillText('同城陪伴 · 真实认证 · 资金托管保障', 300, 805);
ctx.restore();
// 10. 执行绘制并输出临时文件
ctx.draw(false, () => {
setTimeout(() => {
uni.canvasToTempFilePath({
canvasId: 'promotePosterCanvas',
fileType: 'png',
quality: 1,
success: (res) => {
const filePath = res.tempFilePath;
uni.saveImageToPhotosAlbum({
filePath,
success: () => {
uni.hideLoading();
uni.showToast({
title: '海报已保存至相册!',
icon: 'success',
duration: 2500
});
},
fail: () => {
uni.hideLoading();
// 若相册权限受限或系统阻止,自动唤起全屏图片预览,支持微信长按保存/转发
uni.previewImage({
urls: [filePath],
current: filePath,
success: () => {
uni.showToast({
title: '长按海报可保存到相册或发送给好友',
icon: 'none',
duration: 3000
});
}
});
}
});
},
fail: () => {
uni.hideLoading();
// 降级为复制链接
const link = `https://peiww.gynhc.com/invite?code=PW${uid}`; const link = `https://peiww.gynhc.com/invite?code=PW${uid}`;
uni.setClipboardData({ uni.setClipboardData({
data: link, data: link,
success: () => { success: () => {
uni.showToast({ title: '邀请链接已复制,可粘贴到微信分享', icon: 'none', duration: 2200 }); uni.showToast({ title: '邀请链接已复制,可粘贴分享', icon: 'none', duration: 2200 });
} }
}); });
}
});
}, 300);
});
} catch (err) {
uni.hideLoading();
uni.showToast({ title: '生成海报异常,请重试', icon: 'none' });
} finally {
isGeneratingPoster.value = false;
}
}; };
const handleBindInviteCode = async () => { const handleBindInviteCode = async () => {
@@ -461,6 +799,17 @@ onShow(() => {
</script> </script>
<style lang="scss"> <style lang="scss">
.hidden-poster-canvas {
position: fixed;
left: -9999px;
bottom: -9999px;
width: 600px;
height: 900px;
opacity: 0;
pointer-events: none;
z-index: -999;
}
.promote-page { .promote-page {
min-height: 100vh; min-height: 100vh;
background-color: #0A0F1D; background-color: #0A0F1D;
@@ -670,74 +1019,159 @@ onShow(() => {
.poster-hero-sub { .poster-hero-sub {
font-size: 22rpx; font-size: 22rpx;
color: #94A3B8; color: #94A3B8;
margin-bottom: 36rpx; margin-bottom: 24rpx;
} }
.suncode-box { .poster-inviter-pill {
display: flex; display: inline-flex;
flex-direction: column;
align-items: center; align-items: center;
margin-bottom: 32rpx; gap: 12rpx;
background: rgba(255, 255, 255, 0.06);
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 30rpx;
padding: 8rpx 20rpx 8rpx 10rpx;
margin-bottom: 24rpx;
.suncode-ring { .inviter-avatar {
width: 240rpx; width: 44rpx;
height: 240rpx; height: 44rpx;
border-radius: 50%; border-radius: 50%;
border: 4rpx dashed #6366F1; }
.inviter-name {
font-size: 24rpx;
color: #F8FAFC;
font-weight: 500;
}
}
.poster-code-card {
width: 380rpx;
height: 380rpx;
background: #FFFFFF;
border-radius: 24rpx;
padding: 16rpx;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
position: relative; margin-bottom: 24rpx;
margin-bottom: 16rpx; box-shadow: 0 16rpx 40rpx rgba(0, 0, 0, 0.35);
box-sizing: border-box;
.sun-dot { .wxacode-img {
position: absolute;
width: 8rpx;
height: 8rpx;
background: #818CF8;
border-radius: 50%;
}
.suncode-center {
width: 180rpx;
height: 180rpx;
border-radius: 50%;
border: 4rpx solid #6366F1;
overflow: hidden;
.suncode-avatar {
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
.qrcode-fallback-box {
width: 100%;
height: 100%;
position: relative;
display: flex;
align-items: center;
justify-content: center;
.qr-matrix-grid {
width: 320rpx;
height: 320rpx;
display: flex;
flex-direction: column;
.qr-row {
display: flex;
flex: 1;
.qr-cell {
flex: 1;
&.cell-dark {
background-color: #0F172A;
}
&.cell-light {
background-color: #FFFFFF;
}
}
} }
} }
.suncode-hint { .qr-avatar-center {
font-size: 22rpx; position: absolute;
color: #64748B; width: 68rpx;
height: 68rpx;
background: #FFFFFF;
border-radius: 12rpx;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.2);
.qr-avatar-img {
width: 56rpx;
height: 56rpx;
border-radius: 8rpx;
}
}
} }
} }
.poster-footer-code { .poster-guide-box {
background: rgba(255, 255, 255, 0.05); display: flex;
border: 1px solid rgba(255, 255, 255, 0.08); flex-direction: column;
border-radius: 14rpx; align-items: center;
padding: 12rpx 28rpx; text-align: center;
display: inline-flex; margin-bottom: 12rpx;
align-items: baseline;
gap: 10rpx;
.lbl { .guide-title {
font-size: 26rpx;
color: #818CF8;
font-weight: 600;
}
.guide-sub {
font-size: 22rpx; font-size: 22rpx;
color: #94A3B8; color: #94A3B8;
margin-top: 6rpx;
}
} }
.val { .poster-gold-code-card {
font-size: 28rpx; width: 100%;
font-weight: 800; background: rgba(245, 158, 11, 0.1);
border: 1px solid rgba(245, 158, 11, 0.35);
border-radius: 20rpx;
padding: 20rpx 16rpx;
margin: 16rpx 0 20rpx;
display: flex;
flex-direction: column;
align-items: center;
box-sizing: border-box;
.gold-lbl {
font-size: 22rpx;
color: #F59E0B; color: #F59E0B;
margin-bottom: 4rpx;
}
.gold-code {
font-size: 46rpx;
font-weight: 800;
color: #FBBF24;
letter-spacing: 2rpx;
font-family: monospace; font-family: monospace;
} }
.gold-tip {
font-size: 20rpx;
color: #D97706;
margin-top: 4rpx;
}
}
.poster-sec-tag {
font-size: 20rpx;
color: #64748B;
letter-spacing: 1rpx;
} }
} }
@@ -1156,35 +1590,50 @@ onShow(() => {
color: #78716C; color: #78716C;
} }
.suncode-box { .poster-inviter-pill {
.suncode-ring {
border-color: #EA580C;
.sun-dot {
background: #F97316;
}
.suncode-center {
border-color: #EA580C;
}
}
.suncode-hint {
color: #78716C;
}
}
.poster-footer-code {
background: #FFF7ED; background: #FFF7ED;
border-color: #FED7AA; border-color: #FED7AA;
.lbl { .inviter-name {
color: #78716C; color: #431407;
}
} }
.val { .poster-code-card {
background: #FFFFFF;
border: 1px solid #FED7AA;
box-shadow: 0 10rpx 28rpx rgba(234, 88, 12, 0.1);
}
.poster-guide-box {
.guide-title {
color: #EA580C; color: #EA580C;
} }
.guide-sub {
color: #78716C;
}
}
.poster-gold-code-card {
background: #FFFDF9;
border-color: #FED7AA;
.gold-lbl {
color: #EA580C;
}
.gold-code {
color: #EA580C;
}
.gold-tip {
color: #9A3412;
}
}
.poster-sec-tag {
color: #A8A29E;
} }
} }

查看文件

@@ -129,7 +129,7 @@
<view class="content-card channel-card"> <view class="content-card channel-card">
<view class="card-section-head"> <view class="card-section-head">
<text class="section-title">支付方式</text> <text class="section-title">支付方式</text>
<view class="section-badge-green">官方官方推荐</view> <view class="section-badge-green">官方推荐</view>
</view> </view>
<view class="channel-list"> <view class="channel-list">
@@ -189,16 +189,22 @@
<!-- 底部固定确认支付操作栏 --> <!-- 底部固定确认支付操作栏 -->
<view class="fixed-submit-bar"> <view class="fixed-submit-bar">
<view class="submit-summary"> <view class="submit-summary">
<view class="summary-top"> <view class="summary-main">
<text class="summary-label">实付金额:</text> <text class="summary-label">实付金额</text>
<view class="summary-amount-wrap">
<text class="summary-currency">¥</text> <text class="summary-currency">¥</text>
<text class="summary-val">{{ currentPayAmount.toFixed(2) }}</text> <text class="summary-val-integer">{{ payAmountParts.integer }}</text>
<text class="summary-val-decimal">.{{ payAmountParts.decimal }}</text>
</view>
</view> </view>
<view class="summary-sub" v-if="currentBonusAmount > 0"> <view class="summary-sub" v-if="currentBonusAmount > 0">
<text class="sub-text">预计到账 ¥{{ currentTotalCredit.toFixed(2) }} (赠 ¥{{ currentBonusAmount }})</text> <text class="sub-text">预计到账 ¥{{ currentTotalCredit.toFixed(2) }}</text>
<text class="sub-bonus-tag">含立赠¥{{ currentBonusAmount }}</text>
</view> </view>
<view class="summary-sub" v-else> <view class="summary-sub" v-else>
<text class="sub-text">预计实际到账 ¥{{ currentTotalCredit.toFixed(2) }}</text> <text class="sub-text">预计到账 ¥{{ currentTotalCredit.toFixed(2) }}</text>
<text class="sub-tip-dot">·</text>
<text class="sub-tip-text">即时生效</text>
</view> </view>
</view> </view>
<button <button
@@ -269,6 +275,13 @@ const currentPayAmount = computed(() => {
return tier ? Number(tier.amount) : 0; return tier ? Number(tier.amount) : 0;
}); });
// 实付金额整数与小数拆分
const payAmountParts = computed(() => {
const str = Number(currentPayAmount.value || 0).toFixed(2);
const [integer, decimal] = str.split('.');
return { integer, decimal: decimal || '00' };
});
// 当前赠送金额 (档位或自定义命中规则) // 当前赠送金额 (档位或自定义命中规则)
const currentBonusAmount = computed(() => { const currentBonusAmount = computed(() => {
if (isCustomMode.value) { if (isCustomMode.value) {
@@ -1077,7 +1090,7 @@ onShow(() => {
} }
.bottom-spacer { .bottom-spacer {
height: 180rpx; height: calc(180rpx + env(safe-area-inset-bottom));
} }
} }
@@ -1088,64 +1101,131 @@ onShow(() => {
left: 0; left: 0;
right: 0; right: 0;
z-index: 99; z-index: 99;
background: rgba(10, 15, 29, 0.95); background: rgba(10, 15, 29, 0.96);
backdrop-filter: blur(20px); backdrop-filter: blur(24px);
border-top: 1px solid rgba(255, 255, 255, 0.08); border-top: 1px solid rgba(255, 255, 255, 0.08);
padding: 20rpx 28rpx; box-shadow: 0 -10rpx 36rpx rgba(0, 0, 0, 0.45);
padding-bottom: calc(20rpx + env(safe-area-inset-bottom)); padding: 24rpx 32rpx;
padding-bottom: calc(24rpx + constant(safe-area-inset-bottom));
padding-bottom: calc(24rpx + env(safe-area-inset-bottom));
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
box-sizing: border-box;
.submit-summary { .submit-summary {
.summary-top { display: flex;
flex-direction: column;
justify-content: center;
.summary-main {
display: flex; display: flex;
align-items: baseline; align-items: baseline;
gap: 8rpx;
.summary-label { .summary-label {
font-size: 24rpx; font-size: 24rpx;
color: #94A3B8; color: #94A3B8;
font-weight: 500;
margin-right: 4rpx;
} }
.summary-amount-wrap {
display: inline-flex;
align-items: baseline;
.summary-currency { .summary-currency {
font-size: 30rpx; font-size: 28rpx;
font-weight: 700; font-weight: 700;
color: #10B981; color: #10B981;
margin-left: 4rpx;
margin-right: 2rpx; margin-right: 2rpx;
} }
.summary-val { .summary-val-integer {
font-size: 44rpx; font-size: 48rpx;
font-weight: 800; font-weight: 800;
color: #10B981; color: #10B981;
font-family: -apple-system, BlinkMacSystemFont, sans-serif; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
line-height: 1;
letter-spacing: -0.5rpx;
}
.summary-val-decimal {
font-size: 32rpx;
font-weight: 700;
color: #10B981;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
line-height: 1;
}
} }
} }
.summary-sub { .summary-sub {
display: flex;
align-items: center;
gap: 8rpx;
margin-top: 8rpx;
.sub-text { .sub-text {
font-size: 22rpx;
color: #94A3B8;
line-height: 1.2;
}
.sub-bonus-tag {
font-size: 20rpx; font-size: 20rpx;
color: #F59E0B; color: #F59E0B;
background: rgba(245, 158, 11, 0.15);
border: 1px solid rgba(245, 158, 11, 0.25);
padding: 2rpx 10rpx;
border-radius: 8rpx;
font-weight: 600;
line-height: 1.2;
}
.sub-tip-dot {
font-size: 20rpx;
color: #64748B;
}
.sub-tip-text {
font-size: 20rpx;
color: #64748B;
} }
} }
} }
.btn-submit-recharge { .btn-submit-recharge {
background: linear-gradient(135deg, #10B981 0%, #059669 100%); margin: 0;
color: #FFFFFF; min-width: 250rpx;
font-size: 28rpx; height: 88rpx;
line-height: 88rpx;
padding: 0 44rpx;
border-radius: 44rpx;
font-size: 30rpx;
font-weight: 700; font-weight: 700;
padding: 0 48rpx; color: #FFFFFF;
height: 84rpx; background: linear-gradient(135deg, #10B981 0%, #059669 100%);
line-height: 84rpx;
border-radius: 42rpx;
border: none;
box-shadow: 0 8rpx 24rpx rgba(16, 185, 129, 0.35); box-shadow: 0 8rpx 24rpx rgba(16, 185, 129, 0.35);
border: none;
outline: none;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s ease;
&::after {
border: none;
}
&.disabled { &.disabled {
opacity: 0.45; opacity: 0.45;
box-shadow: none; box-shadow: none;
pointer-events: none;
}
&:active:not(.disabled) {
transform: scale(0.98);
} }
} }
} }
@@ -1377,29 +1457,46 @@ onShow(() => {
} }
.fixed-submit-bar { .fixed-submit-bar {
background: rgba(255, 255, 255, 0.95); background: rgba(255, 255, 255, 0.96);
border-top-color: #E7E5E4; border-top-color: #E7E5E4;
box-shadow: 0 -8rpx 32rpx rgba(28, 25, 23, 0.06);
.submit-summary { .submit-summary {
.summary-top { .summary-main {
.summary-label { .summary-label {
color: #78716C; color: #78716C;
} }
.summary-amount-wrap {
.summary-currency, .summary-currency,
.summary-val { .summary-val-integer,
.summary-val-decimal {
color: #EA580C; color: #EA580C;
} }
} }
}
.summary-sub .sub-text { .summary-sub {
color: #D97706; .sub-text {
color: #78716C;
}
.sub-bonus-tag {
background: #FFF7ED;
color: #EA580C;
border-color: rgba(234, 88, 12, 0.25);
}
.sub-tip-dot,
.sub-tip-text {
color: #A8A29E;
}
} }
} }
.btn-submit-recharge { .btn-submit-recharge {
background: linear-gradient(135deg, #EA580C 0%, #C2410C 100%); background: linear-gradient(135deg, #FF6B00 0%, #EA580C 100%);
box-shadow: 0 8rpx 24rpx rgba(234, 88, 12, 0.3); box-shadow: 0 8rpx 24rpx rgba(234, 88, 12, 0.35);
} }
} }
} }

查看文件

@@ -18,15 +18,15 @@ export interface NavCategoryItem {
export class NavCategoryService { export class NavCategoryService {
private categories: NavCategoryItem[] = [ private categories: NavCategoryItem[] = [
{ id: 1, code: 'esports', name: '电子竞技', icon: 'gameAll', bgClass: 'bg-indigo', cat: 'all', targetUrl: '/pages/activity/list?category=ALL', badgeText: 'HOT', sortOrder: 1, status: 1 }, { id: 1, code: 'esports', name: '电子竞技', icon: 'gameAll', bgClass: 'bg-indigo', cat: 'all', targetUrl: '/pages/activity/list?category=ESPORTS', badgeText: 'HOT', sortOrder: 1, status: 1 },
{ id: 2, code: 'meal', name: '美食探店', icon: 'utensils', bgClass: 'bg-amber', cat: 'offline_meal', targetUrl: '/pages/activity/list?category=MEAL', badgeText: 'AA制', sortOrder: 2, status: 1 }, { id: 2, code: 'meal', name: '美食探店', icon: 'utensils', bgClass: 'bg-amber', cat: 'offline_meal', targetUrl: '/pages/activity/list?category=MEAL', badgeText: 'AA制', sortOrder: 2, status: 1 },
{ id: 3, code: 'sing', name: 'KTV嗨唱', icon: 'micVocal', bgClass: 'bg-rose', cat: 'offline_sing', targetUrl: '/pages/activity/list?category=SING', badgeText: '热度高', sortOrder: 3, status: 1 }, { id: 3, code: 'sing', name: 'KTV嗨唱', icon: 'micVocal', bgClass: 'bg-rose', cat: 'offline_sing', targetUrl: '/pages/activity/list?category=SING', badgeText: '热度高', sortOrder: 3, status: 1 },
{ id: 4, code: 'billiards', name: '同城台球', icon: 'billiards', bgClass: 'bg-sky', cat: 'offline_play', targetUrl: '/pages/activity/list?category=ALL', badgeText: '', sortOrder: 4, status: 1 }, { id: 4, code: 'billiards', name: '同城台球', icon: 'billiards', bgClass: 'bg-sky', cat: 'offline_play', targetUrl: '/pages/activity/list?category=BILLIARDS', badgeText: '', sortOrder: 4, status: 1 },
{ id: 5, code: 'hiking', name: '户外爬山', icon: 'mountain', bgClass: 'bg-emerald', cat: 'offline_play', targetUrl: '/pages/activity/list?category=ALL', badgeText: '周末', sortOrder: 5, status: 1 }, { id: 5, code: 'hiking', name: '户外爬山', icon: 'mountain', bgClass: 'bg-emerald', cat: 'offline_play', targetUrl: '/pages/activity/list?category=HIKING', badgeText: '周末', sortOrder: 5, status: 1 },
{ id: 6, code: 'drink', name: '下午茶歇', icon: 'coffee', bgClass: 'bg-teal', cat: 'offline_drink', targetUrl: '/pages/activity/list?category=DRINK', badgeText: '', sortOrder: 6, status: 1 }, { id: 6, code: 'drink', name: '下午茶歇', icon: 'coffee', bgClass: 'bg-teal', cat: 'offline_drink', targetUrl: '/pages/activity/list?category=DRINK', badgeText: '', sortOrder: 6, status: 1 },
{ id: 7, code: 'boardgame', name: '剧本桌游', icon: 'dice', bgClass: 'bg-purple', cat: 'offline_play', targetUrl: '/pages/activity/list?category=ALL', badgeText: '', sortOrder: 7, status: 1 }, { id: 7, code: 'boardgame', name: '剧本桌游', icon: 'dice', bgClass: 'bg-purple', cat: 'offline_play', targetUrl: '/pages/activity/list?category=BOARDGAME', badgeText: '', sortOrder: 7, status: 1 },
{ id: 8, code: 'fitness', name: '运动健身', icon: 'fitness', bgClass: 'bg-orange', cat: 'offline_play', targetUrl: '/pages/activity/list?category=ALL', badgeText: '', sortOrder: 8, status: 1 }, { id: 8, code: 'fitness', name: '运动健身', icon: 'fitness', bgClass: 'bg-orange', cat: 'offline_play', targetUrl: '/pages/activity/list?category=FITNESS', badgeText: '', sortOrder: 8, status: 1 },
{ id: 9, code: 'bar', name: '同城微醺', icon: 'warmFlame', bgClass: 'bg-rose', cat: 'offline_drink', targetUrl: '/pages/activity/list?category=DRINK', badgeText: '清吧', sortOrder: 9, status: 1 }, { id: 9, code: 'bar', name: '同城微醺', icon: 'warmFlame', bgClass: 'bg-rose', cat: 'offline_drink', targetUrl: '/pages/activity/list?category=BAR', badgeText: '清吧', sortOrder: 9, status: 1 },
{ id: 10, code: 'more', name: '全部活动', icon: 'gridAll', bgClass: 'bg-blue', cat: 'all', targetUrl: '/pages/activity/list?category=ALL', badgeText: '', sortOrder: 10, status: 1 } { id: 10, code: 'more', name: '全部活动', icon: 'gridAll', bgClass: 'bg-blue', cat: 'all', targetUrl: '/pages/activity/list?category=ALL', badgeText: '', sortOrder: 10, status: 1 }
]; ];

查看文件

@@ -102,14 +102,29 @@ export class MysqlRepository {
conds.push('(a.game_category LIKE ? OR a.title LIKE ? OR a.game_category LIKE ?)'); conds.push('(a.game_category LIKE ? OR a.title LIKE ? OR a.game_category LIKE ?)');
params.push('%美食%', '%美食%', '%MEAL%'); params.push('%美食%', '%美食%', '%MEAL%');
} else if (category === 'SING') { } else if (category === 'SING') {
conds.push('(a.game_category LIKE ? OR a.title LIKE ? OR a.game_category LIKE ?)'); conds.push('(a.game_category LIKE ? OR a.title LIKE ? OR a.game_category LIKE ? OR a.game_category LIKE ? OR a.title LIKE ?)');
params.push('%陪唱%', '%陪唱%', '%SING%'); params.push('%陪唱%', '%陪唱%', '%SING%', '%KTV%', '%嗨唱%');
} else if (category === 'DRINK' || category === 'BAR') { } else if (category === 'DRINK') {
conds.push('(a.game_category LIKE ? OR a.game_category LIKE ? OR a.title LIKE ? OR a.game_category LIKE ? OR a.game_category LIKE ?)'); conds.push('(a.game_category LIKE ? OR a.title LIKE ? OR a.game_category LIKE ? OR a.title LIKE ?)');
params.push('%下午茶%', '%微醺%', '%下午茶%', '%DRINK%', '%BAR%'); params.push('%下午茶%', '%下午茶%', '%DRINK%', '%咖啡%');
} else if (category === 'BAR') {
conds.push('(a.game_category LIKE ? OR a.title LIKE ? OR a.game_category LIKE ? OR a.title LIKE ?)');
params.push('%微醺%', '%微醺%', '%BAR%', '%清吧%');
} else if (category === 'ESPORTS') { } else if (category === 'ESPORTS') {
conds.push('(a.game_category LIKE ? OR a.game_category LIKE ? OR a.title LIKE ? OR a.game_category LIKE ?)'); conds.push('(a.game_category LIKE ? OR a.game_category LIKE ? OR a.game_category LIKE ? OR a.title LIKE ? OR a.title LIKE ? OR a.game_category LIKE ?)');
params.push('%电竞%', '%游戏%', '%电竞%', '%ESPORTS%'); params.push('%电子竞技%', '%电竞%', '%游戏%', '%王者%', '%连胜%', '%ESPORTS%');
} else if (category === 'BILLIARDS') {
conds.push('(a.game_category LIKE ? OR a.title LIKE ? OR a.game_category LIKE ?)');
params.push('%台球%', '%台球%', '%BILLIARDS%');
} else if (category === 'HIKING') {
conds.push('(a.game_category LIKE ? OR a.title LIKE ? OR a.game_category LIKE ?)');
params.push('%爬山%', '%爬山%', '%HIKING%');
} else if (category === 'BOARDGAME') {
conds.push('(a.game_category LIKE ? OR a.title LIKE ? OR a.game_category LIKE ?)');
params.push('%桌游%', '%剧本%', '%BOARDGAME%');
} else if (category === 'FITNESS') {
conds.push('(a.game_category LIKE ? OR a.title LIKE ? OR a.game_category LIKE ?)');
params.push('%健身%', '%运动%', '%FITNESS%');
} else { } else {
const name = String(opts.categoryName || '').trim() || category; const name = String(opts.categoryName || '').trim() || category;
const like = `%${name}%`; const like = `%${name}%`;
@@ -3638,6 +3653,101 @@ export class MysqlRepository {
}; };
} }
/**
* 管理员后台直接对订单执行原路退款(全额退款 / 部分退款)
*/
async adminRefundOrder(
orderId: string,
refundType: 'full' | 'partial',
refundAmountInput?: number,
reason?: string,
operator?: string
): Promise<any> {
const conn = await pool.getConnection();
let finalRefundAmount = 0;
let orderRow: any = null;
try {
await conn.beginTransaction();
const [ordRows]: any = await conn.query('SELECT * FROM orders WHERE id = ? FOR UPDATE', [orderId]);
if (!ordRows || ordRows.length === 0) {
throw new Error('订单不存在');
}
orderRow = ordRows[0];
const curStatus = String(orderRow.status || '');
const nonRefundable = ['待支付', '已取消', '已全额退款'];
if (nonRefundable.includes(curStatus)) {
throw new Error(`当前订单状态为「${curStatus}」,不可执行退款`);
}
const totalOrderAmt = Number(orderRow.amount || 0);
if (totalOrderAmt <= 0) {
throw new Error('订单金额为0,无需退款');
}
if (refundType === 'full') {
finalRefundAmount = totalOrderAmt;
await conn.query('UPDATE orders SET status = "已全额退款", refund_amount = ? WHERE id = ?', [finalRefundAmount, orderId]);
// 原路退款(微信支付走微信退款 API,余额支付退回用户钱包)
await this.refundOrderPayment(conn, orderRow, Math.round(finalRefundAmount * 100), reason || '平台管理员后台全额退款', '后台全额退款', 'ADM_RFND');
await this.releaseCouponWithConn(conn, orderId);
// 如果存在关联的待仲裁单,自动标记仲裁结案
await conn.query('UPDATE arbitrations SET status = "已全额退款用户" WHERE order_id = ? AND status = "待平台仲裁"', [orderId]);
} else {
const partialAmt = refundAmountInput !== undefined && Number(refundAmountInput) > 0
? Math.min(totalOrderAmt, Number(Number(refundAmountInput).toFixed(2)))
: Number((totalOrderAmt * 0.5).toFixed(2));
if (partialAmt <= 0) {
throw new Error('部分退款金额必须大于0');
}
finalRefundAmount = partialAmt;
await conn.query('UPDATE orders SET status = "已部分退款", refund_amount = ? WHERE id = ?', [finalRefundAmount, orderId]);
// 原路退款
await this.refundOrderPayment(conn, orderRow, Math.round(finalRefundAmount * 100), reason || '平台管理员后台部分退款', '后台部分退款', 'ADM_PRFND');
// 剩余未退款项解冻结算至大神佣金账户
const remainAmt = Number(Math.max(0, totalOrderAmt - finalRefundAmount).toFixed(2));
if (remainAmt > 0) {
const comp = await this.resolveCompanionRow(orderRow.expert_id || orderRow.companion_name || 101);
const expertUserId = await this.resolveExpertCreditUserId(conn, orderRow, comp);
const expertIncome = Number((remainAmt * 0.9).toFixed(2));
await conn.query(
'UPDATE users SET commission = COALESCE(commission, 0) + ? WHERE id = ?',
[expertIncome, expertUserId]
);
const setId = `fin_admset_${Date.now()}`;
const setNo = `PJS${Date.now()}`;
await conn.query(`
INSERT INTO finance_records (id, record_no, user_id, type, amount, direction, counterparty, related_id, created_at)
VALUES (?, ?, ?, '部分退款剩余结算', ?, 'IN', ?, ?, NOW())
`, [setId, setNo, expertUserId, expertIncome, orderRow.client_name || '买家客户', String(orderRow.id)]);
}
// 如果存在关联的待仲裁单,自动标记仲裁结案
await conn.query('UPDATE arbitrations SET status = "已部分退款用户" WHERE order_id = ? AND status = "待平台仲裁"', [orderId]);
}
await conn.commit();
} catch (err) {
await conn.rollback();
throw err;
} finally {
conn.release();
}
return {
orderId,
status: refundType === 'full' ? '已全额退款' : '已部分退款',
refundAmount: finalRefundAmount,
buyerId: orderRow?.buyer_id,
orderNo: orderRow?.order_no || orderId
};
}
// 买家发起退款/售后申诉:订单流转为争议仲裁中,同时写入仲裁工单 (含理由与凭证截图) // 买家发起退款/售后申诉:订单流转为争议仲裁中,同时写入仲裁工单 (含理由与凭证截图)
async applyOrderRefund(orderId: string, data: { reason?: string; description?: string; evidence?: string[] }): Promise<any> { async applyOrderRefund(orderId: string, data: { reason?: string; description?: string; evidence?: string[] }): Promise<any> {
const conn = await pool.getConnection(); const conn = await pool.getConnection();

查看文件

@@ -3763,6 +3763,50 @@ app.post('/api/orders/:id/refund', async (req: Request, res: Response) => {
} }
}); });
// 管理员后台直接退款 (全额退款 / 部分退款,原路原渠道退回)
app.post('/api/orders/:id/admin-refund', async (req: Request, res: Response) => {
try {
const orderId = String(req.params.id);
const { refundType, refundAmount, reason } = req.body || {};
const headerRole = req.headers['x-user-role'];
if (headerRole === 'user' || headerRole === 'expert' || headerRole === 'PLAYER' || headerRole === 'EXPERT') {
return res.status(403).json({ code: 40300, message: '权限不足:仅平台管理员可执行直接退款' });
}
const type = refundType === 'partial' ? 'partial' : 'full';
const result = await repo.adminRefundOrder(
orderId,
type,
refundAmount !== undefined ? Number(refundAmount) : undefined,
reason,
String(req.headers['x-admin-user'] || 'admin')
);
// 记录审计日志
logAdminAudit(req, '订单退款', 'orders', orderId, `类型: ${type}, 金额: ¥${result.refundAmount}, 原因: ${reason || '后台管理员直接退款'}`);
// 发送用户端通知
if (result.buyerId) {
pushUserNotification(
Number(result.buyerId),
'ORDER_REFUND',
'订单已退款',
`您的订单 ${result.orderNo} 已办理${type === 'full' ? '全额退款' : `部分退款 ¥${result.refundAmount}`},款项已原路退回。`,
'/pages/order/list'
);
}
res.json({
code: 20000,
data: result,
message: `订单已成功${type === 'full' ? '全额退款' : '部分退款'} ¥${Number(result.refundAmount || 0).toFixed(2)},款项原路退回`
});
} catch (err: any) {
const statusCode = err.status || 400;
const errCode = err.code || 40000;
res.status(statusCode).json({ code: errCode, message: err.message });
}
});
// 举报不良陪玩 (涉黄/涉赌/线下欺诈等,进入平台风控处置池) // 举报不良陪玩 (涉黄/涉赌/线下欺诈等,进入平台风控处置池)
app.post('/api/reports', rateLimit({ name: 'report_create', windowMs: 60 * 1000, max: 5, key: rateWriteKey }), async (req: Request, res: Response) => { app.post('/api/reports', rateLimit({ name: 'report_create', windowMs: 60 * 1000, max: 5, key: rateWriteKey }), async (req: Request, res: Response) => {
try { try {
@@ -5556,6 +5600,150 @@ app.post('/api/distribution/bind', async (req: Request, res: Response) => {
} }
}); });
// 7.10 获取微信小程序推广码(太阳码)
app.get('/api/distribution/wxacode', async (req: Request, res: Response) => {
try {
const rawCode = String(req.query.code || '').trim();
if (!rawCode) {
return res.status(400).json({ code: 40000, message: '邀请码不能为空' });
}
const cfg = await resolveWechatPayRuntimeConfig();
const appId = String(cfg.appId || '').trim();
const appSecret = String(cfg.appSecret || '').trim();
if (!appId || !appSecret) {
return res.status(400).json({ code: 40000, message: '服务端未配置微信 AppID/AppSecret' });
}
const accessToken = await getWechatAccessToken(appId, appSecret);
// 优先尝试的环境版本列表
const envCandidate = String(req.query.env || '').trim();
const envVersions = envCandidate
? [envCandidate]
: (process.env.NODE_ENV === 'production' ? ['release', 'trial', 'develop'] : ['trial', 'develop', 'release']);
let finalBuffer: Buffer | null = null;
let lastErr: any = null;
for (const envVer of envVersions) {
try {
const wxUrl = `https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=${encodeURIComponent(accessToken)}`;
const payload = JSON.stringify({
scene: rawCode,
page: 'pages/index/index',
check_path: false,
env_version: envVer,
width: 430
});
const buf: Buffer = await new Promise((resolve, reject) => {
const wxReq = https.request(wxUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(payload)
}
}, (wxRes) => {
const chunks: Buffer[] = [];
wxRes.on('data', chunk => chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk)));
wxRes.on('end', () => resolve(Buffer.concat(chunks)));
});
wxReq.on('error', reject);
wxReq.write(payload);
wxReq.end();
});
const head = buf.slice(0, 64).toString('utf8');
if (head.includes('errcode')) {
const errData = JSON.parse(buf.toString('utf8'));
lastErr = errData;
// 若为环境或页面不存在错误,继续尝试下一个候选环境
continue;
}
finalBuffer = buf;
break;
} catch (e: any) {
lastErr = e;
}
}
if (!finalBuffer) {
return res.status(400).json({
code: 40000,
message: `生成微信小程序码失败: ${(lastErr && (lastErr.errmsg || lastErr.message)) || '微信接口调用异常'}`
});
}
res.setHeader('Content-Type', 'image/png');
res.setHeader('Cache-Control', 'public, max-age=86400');
return res.end(finalBuffer);
} catch (err: any) {
res.status(500).json({ code: 50000, message: err.message || '生成小程序推广码异常' });
}
});
// 7.11 专属邀请 H5 落地页(供普通二维码或外部浏览器扫码后引导跳转)
app.get('/invite', (req: Request, res: Response) => {
const code = String(req.query.code || '').trim() || 'PW';
const html = `<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>同城生活陪伴 - 好友专属邀请</title>
<style>
* { margin:0; padding:0; box-sizing:border-box; }
body { background: #0A0F1D; color:#F8FAFC; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; display:flex; flex-direction:column; align-items:center; min-height:100vh; padding: 40px 20px; }
.card { background: rgba(30, 41, 59, 0.7); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 20px; padding: 32px 24px; max-width: 400px; width:100%; text-align: center; box-shadow: 0 12px 36px rgba(0,0,0,0.4); }
.badge { display:inline-block; padding: 4px 12px; background: rgba(99, 102, 241, 0.2); color: #818CF8; border-radius: 12px; font-size: 13px; font-weight: 600; margin-bottom: 16px; }
.title { font-size: 22px; font-weight: 700; margin-bottom: 8px; color: #FFFFFF; }
.desc { font-size: 14px; color: #94A3B8; margin-bottom: 24px; }
.code-box { background: rgba(15, 23, 42, 0.8); border: 1.5px dashed #F59E0B; border-radius: 14px; padding: 18px 12px; margin-bottom: 24px; }
.code-label { font-size: 12px; color: #F59E0B; margin-bottom: 6px; }
.code-val { font-size: 32px; font-weight: 800; color: #FBBF24; letter-spacing: 2px; }
.btn { display:block; width:100%; padding: 14px 0; border-radius: 24px; font-size: 16px; font-weight: 600; text-decoration: none; cursor:pointer; border:none; margin-bottom: 12px; transition: opacity 0.2s; }
.btn-primary { background: linear-gradient(135deg, #6366F1, #8B5CF6); color: #FFF; }
.btn-secondary { background: rgba(255, 255, 255, 0.08); color: #CBD5E1; }
.tip { font-size: 12px; color: #64748B; margin-top: 16px; }
</style>
</head>
<body>
<div class="card">
<div class="badge">好友专属邀请礼</div>
<div class="title">同城生活陪伴</div>
<div class="desc">高颜值大神心仪随约 · 开启同城陪伴之旅</div>
<div class="code-box">
<div class="code-label">您的官方专属邀请码</div>
<div class="code-val" id="inviteCode">${code}</div>
</div>
<button class="btn btn-primary" onclick="copyAndTip()">复制邀请码并前往微信</button>
<a href="weixin://" class="btn btn-secondary">打开微信小程序</a>
<div class="tip">长按保存海报识别或进入微信搜索【同城陪伴】输入邀请码即可绑定</div>
</div>
<script>
function copyAndTip() {
var code = document.getElementById('inviteCode').innerText;
if (navigator.clipboard) {
navigator.clipboard.writeText(code).then(function() {
alert('邀请码 ' + code + ' 已复制!请打开微信搜索小程序进入');
window.location.href = 'weixin://';
}).catch(function() {
prompt('请复制邀请码:', code);
});
} else {
prompt('请复制邀请码:', code);
}
}
</script>
</body>
</html>`;
res.setHeader('Content-Type', 'text/html; charset=utf-8');
res.send(html);
});
// 8. 启动服务器并初始化数据库 // 8. 启动服务器并初始化数据库
// 启动配置自检:仅输出"就绪状态",绝不打印任何密钥内容(便于部署验收) // 启动配置自检:仅输出"就绪状态",绝不打印任何密钥内容(便于部署验收)
async function logStartupConfigSelfCheck(): Promise<void> { async function logStartupConfigSelfCheck(): Promise<void> {

查看文件

@@ -0,0 +1,69 @@
// 已读取AGENTS.md
import * as fs from 'fs';
import * as path from 'path';
/**
* 第一百批 TDD 闸门:管理后台订单退款与微信小程序推广码服务
* 1. 管理后台具备全额/部分原路退款功能,校验参数、更新状态并记录财务流水
* 2. 微信小程序推广太阳码接口上线,支持 scene 绑定与多环境降级
* 3. 邀请 H5 落地页支持一键复制与跳转引导
*/
describe('第一百批管理后台退款与分销海报服务闸门', () => {
const root = path.resolve(__dirname, '../../');
const read = (rel: string) => fs.readFileSync(path.join(root, rel), 'utf-8');
const indexCode = read('server/src/index.ts');
const repoCode = read('server/src/db/repository.ts');
const adminOrderList = read('admin/arco-design-pro-vite/src/views/order/list/index.vue');
const adminUserList = read('admin/arco-design-pro-vite/src/views/user/list/index.vue');
const promotePage = read('pwuniapp/pages/user/promote.vue');
describe('1. 管理后台退款功能 (Seam: POST /api/orders/:id/admin-refund & repo.adminRefundOrder)', () => {
it('接口必须由管理员权限保护并写入审计日志', () => {
expect(indexCode).toContain("app.post('/api/orders/:id/admin-refund'");
expect(indexCode).toContain('repo.adminRefundOrder');
expect(indexCode).toContain('logAdminAudit');
expect(indexCode).toContain('权限不足:仅平台管理员可执行直接退款');
});
it('仓储层必须支持全额退款与部分退款,并包含状态闸门与流水记录', () => {
expect(repoCode).toContain('async adminRefundOrder(');
const start = repoCode.indexOf('async adminRefundOrder(');
expect(start).toBeGreaterThan(-1);
const block = repoCode.slice(start, start + 3800);
expect(block).toContain('FOR UPDATE');
expect(block).toContain("refundType === 'full'");
expect(block).toContain('this.refundOrderPayment');
expect(block).toContain('已全额退款');
expect(block).toContain('已部分退款');
expect(block).toContain('INSERT INTO finance_records');
});
it('管理后台前端页面包含退款操作入口与弹窗表单', () => {
expect(adminOrderList).toContain('openRefundModal');
expect(adminOrderList).toContain('refundModalVisible');
expect(adminOrderList).toContain('/admin-refund');
expect(adminOrderList).toContain('res.code === 20000');
expect(adminUserList).toContain('openRefundOrderModal');
expect(adminUserList).toContain('orderRefundModalVisible');
expect(adminUserList).toContain('res.code === 20000');
});
});
describe('2. 微信小程序推广码服务 (Seam: GET /api/distribution/wxacode & /invite)', () => {
it('服务端提供真实微信小程序太阳码接口与 H5 落地页', () => {
expect(indexCode).toContain("app.get('/api/distribution/wxacode'");
expect(indexCode).toContain('getwxacodeunlimit');
expect(indexCode).toContain("app.get('/invite'");
expect(indexCode).toContain('<!DOCTYPE html>');
});
it('小程序端推广页面支持直接加载真实太阳码与 Canvas 离屏保存', () => {
expect(promotePage).toContain('wxacodeUrl');
expect(promotePage).toContain('/api/distribution/wxacode?code=PW');
expect(promotePage).toContain('promotePosterCanvas');
expect(promotePage).toContain('savePosterImage');
expect(promotePage).toContain('generateQRCodeMatrix');
});
});
});