diff --git a/admin/arco-design-pro-vite/package.json b/admin/arco-design-pro-vite/package.json index 82ca247..3fa4130 100644 --- a/admin/arco-design-pro-vite/package.json +++ b/admin/arco-design-pro-vite/package.json @@ -58,6 +58,7 @@ "@vitejs/plugin-vue": "^3.1.2", "@vitejs/plugin-vue-jsx": "^2.0.1", "@vue/babel-plugin-jsx": "^1.1.1", + "color": "^3.1.3", "consola": "^2.15.3", "cross-env": "^7.0.3", "eslint": "^8.25.0", diff --git a/admin/arco-design-pro-vite/pnpm-lock.yaml b/admin/arco-design-pro-vite/pnpm-lock.yaml index ae34e40..27bae83 100644 --- a/admin/arco-design-pro-vite/pnpm-lock.yaml +++ b/admin/arco-design-pro-vite/pnpm-lock.yaml @@ -95,6 +95,9 @@ importers: '@vue/babel-plugin-jsx': specifier: ^1.1.1 version: 1.5.0(@babel/core@7.29.7) + color: + specifier: ^3.1.3 + version: 3.1.3 consola: specifier: ^2.15.3 version: 2.15.3 @@ -1405,8 +1408,8 @@ packages: color-string@1.9.1: resolution: {integrity: sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==} - color@3.2.1: - resolution: {integrity: sha512-aBl7dZI9ENN6fUGC7mWpMTPNHmWUSNan9tuWN6ahh5ZLNk9baLJOnSMlrQkHcrfFgz2/RigjUVAjdx36VcemKA==} + color@3.1.3: + resolution: {integrity: sha512-xgXAcTHa2HeFCGLE9Xs/R82hujGtu9Jd9x4NW3T34+OMs7VoPsjwzRczKHvTAHeJwWFwX5j15+MgAppE8ztObQ==} colord@2.10.0: resolution: {integrity: sha512-AidJptpBJmjTclAp9BkLwJi0T93fo5epJnbaZslpg6QVzpHjAiveF55mE9AcUJiGMqRHgMDY8soMsQtuNYMHfw==} @@ -5306,7 +5309,7 @@ snapshots: '@arco-design/color@0.4.0': dependencies: - color: 3.2.1 + color: 3.1.3 '@arco-design/web-vue@2.58.0(vue@3.5.43(typescript@4.9.5))': dependencies: @@ -6753,7 +6756,7 @@ snapshots: color-name: 1.1.4 simple-swizzle: 0.2.4 - color@3.2.1: + color@3.1.3: dependencies: color-convert: 1.9.3 color-string: 1.9.1 @@ -9436,7 +9439,7 @@ snapshots: dependencies: htmlparser2: 3.10.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-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: dependencies: @@ -9449,7 +9452,7 @@ snapshots: dependencies: '@babel/core': 8.0.6 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: 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): dependencies: 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 unist-util-find-all-after: 1.0.5 @@ -9510,7 +9513,7 @@ snapshots: dependencies: 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: postcss: 7.0.39 optionalDependencies: @@ -10328,7 +10331,7 @@ snapshots: postcss-sass: 0.3.5 postcss-scss: 2.1.1 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 resolve-from: 4.0.0 signal-exit: 3.0.7 diff --git a/admin/arco-design-pro-vite/src/views/order/list/index.vue b/admin/arco-design-pro-vite/src/views/order/list/index.vue index 5dbb166..050325a 100644 --- a/admin/arco-design-pro-vite/src/views/order/list/index.vue +++ b/admin/arco-design-pro-vite/src/views/order/list/index.vue @@ -104,30 +104,109 @@ - + - - 仲裁介入 - - - 查看流程 - + + + 详情 + + + 仲裁 + + + 退款 + + + 已退款 + + + + + + + 原路退款将直接将资金退回至买家(微信支付订单原路退回微信零钱/银行卡,余额支付退回用户钱包),并联动释放使用的优惠券。 + + + + + + + + + + ¥{{ currentOrder?.amount }} + + + + 全额原路退款 (¥{{ currentOrder?.amount }}) + 部分原路退款 + + + + + + 剩余款项将自动解冻并结算至大神佣金账户。 + + + + + 客户协商一致退款 + 大神迟到/旷工未履约 + 服务质量不达标申请售后 + 不可抗力导致服务取消 + 测试订单退款 + 其他原因 + + + + + @@ -211,6 +290,76 @@ }); }; + // 退款状态控制 + const refundModalVisible = ref(false); + const refundSubmitting = ref(false); + const currentOrder = ref(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(() => { fetchData(); }); diff --git a/admin/arco-design-pro-vite/src/views/user/list/index.vue b/admin/arco-design-pro-vite/src/views/user/list/index.vue index a23863d..398a844 100644 --- a/admin/arco-design-pro-vite/src/views/user/list/index.vue +++ b/admin/arco-design-pro-vite/src/views/user/list/index.vue @@ -508,6 +508,20 @@ + + + + 退款 + + -- + + @@ -653,6 +667,68 @@ + + + + + 原路退款将直接将资金退回至买家账户(微信支付订单走微信原路退款,余额支付退回用户钱包),并联动释放优惠券与记账。 + + + + + + + + + + ¥{{ currentRefundOrder?.amount }} + + + + 全额原路退款 (¥{{ currentRefundOrder?.amount }}) + 部分原路退款 + + + + + + 剩余款项将自动解冻并结算至大神佣金账户。 + + + + + 客户协商一致退款 + 大神迟到/旷工未履约 + 服务质量不达标申请售后 + 不可抗力导致服务取消 + 测试订单退款 + 其他原因 + + + + + @@ -680,6 +756,79 @@ const balanceForm = ref({ direction: 'IN', amount: 100, reason: '' }); const submittingBalance = ref(false); + // 履约订单退款控制 + const orderRefundModalVisible = ref(false); + const orderRefundSubmitting = ref(false); + const currentRefundOrder = ref(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) => { balanceTarget.value = { ...(record || {}) }; balanceForm.value = { direction: 'IN', amount: 100, reason: '' }; diff --git a/pwuniapp/pages/order/create.vue b/pwuniapp/pages/order/create.vue index 5e62fc4..aef0bb4 100644 --- a/pwuniapp/pages/order/create.vue +++ b/pwuniapp/pages/order/create.vue @@ -105,7 +105,7 @@ 优惠券 -¥{{ discount }} (新人首单立减) - > + @@ -976,8 +976,9 @@ const handlePay = async () => { font-weight: 600; } .arrow { - font-size: 24rpx; - color: var(--text-muted); + width: 24rpx; + height: 24rpx; + opacity: 0.6; } } } diff --git a/pwuniapp/pages/user/promote.vue b/pwuniapp/pages/user/promote.vue index fc4dc74..31f8bd4 100644 --- a/pwuniapp/pages/user/promote.vue +++ b/pwuniapp/pages/user/promote.vue @@ -61,24 +61,63 @@ + 官方认证邀请码 电竞陪伴 · 同城玩乐 - 寻找心仪陪伴师,立享新人首单礼包 + 寻找心仪陪伴师 · 立享新人专属礼包 - - - - - + + + + 推荐人:{{ user.nickname || '同城生活陪伴推荐官' }} + + + + + + + + + + + + + - 微信长按或扫码进入 - - 邀请码: - PW{{ user.id || '' }} + + + 微信长按识别或扫一扫进入小程序 + 新用户授权登录即可自动绑定上下级返佣关系 + + + + 您的专属官方邀请码 + PW{{ user.id || '' }} + (支持微信扫码直达,或手动输入邀请码) + + + + 同城陪伴 · 真实认证 · 资金托管保障 @@ -207,6 +246,14 @@ + + + @@ -225,6 +272,7 @@ import { ICONS } from '@/common/icons.js'; import { getCurrentThemeKey, applyThemeToNativeUI } from '@/common/theme.js'; import { getNavBarInfo } from '@/common/nav.js'; import { useShare } from '@/common/share.js'; +import { generateQRCodeMatrix } from '@/common/qrcode.js'; const currentThemeKey = ref(getCurrentThemeKey()); const navInfo = ref(getNavBarInfo()); @@ -241,11 +289,24 @@ const user = ref({ 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(() => { const uid = normalizeUserId(); return { - title: '邀请你加入同城陪伴,海量高颜值大神随心约,立享新人专属礼包!', - timelineTitle: '加入同城陪伴,海量高颜值大神随心约,同城组局随心享!', + title: '【邀请好礼】邀请你加入同城陪伴,高颜值大神随心约,立享新人专属礼包!', + timelineTitle: '同城生活陪伴 · 专业游戏陪玩与生活陪伴,邀请好友享双重丰厚礼遇!', path: '/pages/index/index', params: { code: uid ? `PW${uid}` : '', @@ -334,19 +395,296 @@ const copyInviteLink = () => { }); }; -const savePosterImage = () => { +const isGeneratingPoster = ref(false); + +// 圆角矩形绘制辅助函数 +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; + } + 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' }); + uni.showToast({ title: '请先登录后再保存海报', icon: 'none' }); return; } - const link = `https://peiww.gynhc.com/invite?code=PW${uid}`; - uni.setClipboardData({ - data: link, - success: () => { - uni.showToast({ title: '邀请链接已复制,可粘贴到微信分享', icon: 'none', duration: 2200 }); + + 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}`; + uni.setClipboardData({ + data: link, + success: () => { + uni.showToast({ title: '邀请链接已复制,可粘贴分享', icon: 'none', duration: 2200 }); + } + }); + } + }); + }, 300); + }); + } catch (err) { + uni.hideLoading(); + uni.showToast({ title: '生成海报异常,请重试', icon: 'none' }); + } finally { + isGeneratingPoster.value = false; + } }; const handleBindInviteCode = async () => { @@ -461,6 +799,17 @@ onShow(() => { + + + + 好友专属邀请礼 + 同城生活陪伴 + 高颜值大神心仪随约 · 开启同城陪伴之旅 + + 您的官方专属邀请码 + ${code} + + 复制邀请码并前往微信 + 打开微信小程序 + 长按保存海报识别或进入微信搜索【同城陪伴】输入邀请码即可绑定 + + + +