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