chore:链接可以复制
This commit is contained in:
@@ -55,17 +55,17 @@
|
||||
:style="mainBtnBgStyle()" @tap="onShareClick" open-type="share">
|
||||
<text>{{ value.buttonText || '立即分享' }}</text>
|
||||
</view>
|
||||
<view class="rc-btn rc-btn-copy" :style="secondaryBtnStyle" @tap="copyLink">
|
||||
<view class="rc-btn rc-btn-copy" :style="secondaryBtnStyle" @tap="copyLink" :disabled="secondaryBtnStyle">
|
||||
<text>{{ value.placeholderCopyText || '复制链接' }}</text>
|
||||
</view>
|
||||
<view v-if="isFeatureOn(value.allowRegenerate)" class="rc-btn rc-btn-regenerate"
|
||||
:style="secondaryBtnStyle()" @tap="regenerate">
|
||||
:style="secondaryBtnStyle" @tap="regenerate">
|
||||
<text>{{ value.placeholderRegenerateText || '换一个新码' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- showLink:是否显示分享链接文字 -->
|
||||
<view v-if="isFeatureOn(value.showLink)" class="rc-link-row">
|
||||
<text class="rc-link-text" @tap="copyLink">{{ shareLink }}</text>
|
||||
<text class="rc-link-text" @tap="copyLink">{{ shareLink || formatShareLink }}</text>
|
||||
</view>
|
||||
<!-- showQR:是否显示二维码 -->
|
||||
<view v-if="isFeatureOn(value.showQR)" class="rc-qr-row">
|
||||
@@ -91,12 +91,12 @@
|
||||
<text>{{ value.buttonText || '立即分享' }}</text>
|
||||
</button>
|
||||
<view v-if="isFeatureOn(value.allowRegenerate)" class="rc-btn rc-btn-regenerate"
|
||||
:style="secondaryBtnStyle()" @tap="regenerate">
|
||||
:style="secondaryBtnStyle" @tap="regenerate">
|
||||
<text>{{ value.placeholderRegenerateText || '换一个新码' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="isFeatureOn(value.showLink)" class="rc-link-row">
|
||||
<text class="rc-link-text rc-link-minimal" @tap="copyLink">{{ shareLink }}</text>
|
||||
<text class="rc-link-text rc-link-minimal" @tap="copyLink">{{ shareLink || formatShareLink }}</text>
|
||||
</view>
|
||||
<view v-if="isFeatureOn(value.showQR)" class="rc-qr-row rc-qr-minimal">
|
||||
<image :src="qrcodeRenderUrl" mode="aspectFit" class="rc-qr-img rc-qr-minimal-img" />
|
||||
@@ -123,16 +123,16 @@
|
||||
:style="mainBtnBgStyle()" @tap="onShareClick" open-type="share">
|
||||
<text>{{ value.buttonText || '立即分享' }}</text>
|
||||
</button>
|
||||
<view class="rc-btn rc-btn-copy" :style="secondaryBtnStyle" @tap="copyLink">
|
||||
<view class="rc-btn rc-btn-copy" :style="secondaryBtnStyle" @tap="copyLink" :disabled="loadingCode">
|
||||
<text>{{ value.placeholderCopyText || '复制链接' }}</text>
|
||||
</view>
|
||||
<view v-if="isFeatureOn(value.allowRegenerate)" class="rc-btn rc-btn-regenerate"
|
||||
:style="secondaryBtnStyle()" @tap="regenerate">
|
||||
:style="secondaryBtnStyle" @tap="regenerate">
|
||||
<text>{{ value.placeholderRegenerateText || '换一个新码' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="isFeatureOn(value.showLink)" class="rc-link-row rc-link-card">
|
||||
<text class="rc-link-text" @tap="copyLink">{{ shareLink }}</text>
|
||||
<text class="rc-link-text" @tap="copyLink">{{ shareLink || formatShareLink }}</text>
|
||||
</view>
|
||||
<view v-if="isFeatureOn(value.showQR)" class="rc-qr-row rc-qr-card">
|
||||
<view class="rc-qr-wrap-card" :style="{ borderColor: value.accentColor || '#FFD700' }">
|
||||
@@ -408,10 +408,17 @@ export default {
|
||||
qrcodeRenderUrl() {
|
||||
// 优先用后端占位接口返回的真实 qrcode_url;没返回就 fallback 用公共 api 合成 share_link 的二维码
|
||||
if (this.qrcodeUrl && String(this.qrcodeUrl).trim()) return this.qrcodeUrl;
|
||||
const url = encodeURIComponent(this.shareLink || '');
|
||||
if (!url) return '';
|
||||
const realUrl = this.formatShareLink;
|
||||
if (!realUrl) return '';
|
||||
const url = encodeURIComponent(realUrl);
|
||||
return 'https://api.qrserver.com/v1/create-qr-code/?size=300x300&margin=0&data=' + url;
|
||||
}
|
||||
},
|
||||
formatShareLink() {
|
||||
// 固定自定义分享链接模板(customShareLink)
|
||||
const customShareLink = "http://192.168.8.118/hwappx/common/pages_tool/form/formdata?id=13&uniacid=1&recommend_code={code}";
|
||||
// 把模板里 {code} 替换成当前用户唯一邀请码
|
||||
return customShareLink.replace(/\{code\}/g, this.code || '');
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
/* 登录态切换:guest → login → 自动调 getMyCode;logout → 清空状态
|
||||
@@ -852,12 +859,14 @@ export default {
|
||||
|
||||
/** 复制「分享链接」(后端给的 share_link 原样复制) */
|
||||
copyLink() {
|
||||
if (!this.shareLink) {
|
||||
uni.showToast && uni.showToast({ title: '分享链接还未生成,请稍候', icon: 'none' });
|
||||
// 后端没有shareLink时,自动使用前端固定模板链接
|
||||
const targetUrl = this.shareLink || this.formatShareLink;
|
||||
if (!targetUrl) {
|
||||
uni.showToast({ title: '分享链接还未生成,请稍候', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
rcCopyToClipboard(this, this.shareLink, (ok, err) => {
|
||||
uni.showToast && uni.showToast({
|
||||
rcCopyToClipboard(this, targetUrl, (ok, err) => {
|
||||
uni.showToast({
|
||||
title: ok ? '推广链接已复制' : (err || '复制失败'),
|
||||
icon: ok ? 'success' : 'none'
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user