chore:可以复制链接自动更新
This commit is contained in:
@@ -65,7 +65,7 @@
|
|||||||
</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 || formatShareLink }}</text>
|
<text class="rc-link-text" @tap="copyLink">{{ 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">
|
||||||
@@ -96,7 +96,7 @@
|
|||||||
</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 || formatShareLink }}</text>
|
<text class="rc-link-text rc-link-minimal" @tap="copyLink">{{ 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" />
|
||||||
@@ -132,7 +132,7 @@
|
|||||||
</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 || formatShareLink }}</text>
|
<text class="rc-link-text" @tap="copyLink">{{ 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' }">
|
||||||
@@ -414,10 +414,14 @@ export default {
|
|||||||
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() {
|
formatShareLink() {
|
||||||
// 固定自定义分享链接模板(customShareLink)
|
// 读取后台装修配置的链接前缀模板
|
||||||
const customShareLink = "http://192.168.8.118/hwappx/common/pages_tool/form/formdata?id=13&uniacid=1&recommend_code={code}";
|
const baseTemplate = this.nc.customShareLink || '';
|
||||||
// 把模板里 {code} 替换成当前用户唯一邀请码
|
// 后台未配置时兜底默认地址
|
||||||
return customShareLink.replace(/\{code\}/g, this.code || '');
|
const defaultBase = "http://192.168.8.118/hwappx/common/pages_tool/form/formdata?id=13&uniacid=1&recommend_code=";
|
||||||
|
// 取最终基础链接
|
||||||
|
const linkPrefix = baseTemplate ? baseTemplate : defaultBase;
|
||||||
|
// 直接拼接推荐码,不需要{code}占位
|
||||||
|
return linkPrefix + (this.code || '');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@@ -802,46 +806,43 @@ export default {
|
|||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
},
|
},
|
||||||
|
|
||||||
/* ======================== 分享 / 复制 ======================== */
|
onShareClick() {
|
||||||
|
const vm = this;
|
||||||
/** 点击主按钮「立即分享」:小程序(原生 open-type 已处理);H5/APP 走 navigator.share */
|
const v = this.nc;
|
||||||
onShareClick() {
|
const shareUrl = this.formatShareLink; // 改用后台拼接链接
|
||||||
const vm = this;
|
// #ifdef H5
|
||||||
const v = this.nc;
|
try {
|
||||||
// #ifdef H5
|
if (navigator && navigator.share && typeof navigator.share && shareUrl) {
|
||||||
try {
|
navigator.share({
|
||||||
if (navigator && navigator.share && typeof navigator.share === 'function' && this.shareLink) {
|
title: v.shareTitle || v.title || '邀您入驻低空经济产业平台',
|
||||||
navigator.share({
|
text: v.shareDesc || '',
|
||||||
title: v.shareTitle || v.title || '邀您入驻低空经济产业平台',
|
url: shareUrl
|
||||||
text: v.shareDesc || '',
|
}).catch(() => vm.copyLink());
|
||||||
url: this.shareLink
|
|
||||||
}).catch(() => vm.copyLink());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} catch (e) {}
|
|
||||||
this.copyLink();
|
|
||||||
return;
|
return;
|
||||||
// #endif
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
this.copyLink();
|
||||||
|
return;
|
||||||
|
// #endif
|
||||||
|
|
||||||
// #ifdef APP-PLUS
|
// #ifdef APP-PLUS
|
||||||
try {
|
try {
|
||||||
if (plus && plus.share && this.shareLink) {
|
if (plus && plus.share && shareUrl) {
|
||||||
plus.share.sendWithSystem({
|
plus.share.sendWithSystem({
|
||||||
title: v.shareTitle || v.title || '邀您入驻低空经济产业平台',
|
title: v.shareTitle || v.title || '邀您入驻低空经济产业平台',
|
||||||
content: v.shareDesc || '',
|
content: v.shareDesc || '',
|
||||||
href: this.shareLink
|
href: shareUrl
|
||||||
}, function () {}, function () { vm.copyLink(); });
|
}, function () {}, function () { vm.copyLink(); });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
this.copyLink();
|
this.copyLink();
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP-WEIXIN
|
||||||
// 小程序:主按钮 open-type=share 原生处理,这里兜底复制链接
|
this.copyLink();
|
||||||
if (this.shareLink) this.copyLink();
|
// #endif
|
||||||
// #endif
|
},
|
||||||
},
|
|
||||||
|
|
||||||
/** 复制「推荐码」本身(点击推荐码盒子时) */
|
/** 复制「推荐码」本身(点击推荐码盒子时) */
|
||||||
copyRecommendCode() {
|
copyRecommendCode() {
|
||||||
@@ -857,12 +858,12 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
/** 复制「分享链接」(后端给的 share_link 原样复制) */
|
|
||||||
copyLink() {
|
copyLink() {
|
||||||
// 后端没有shareLink时,自动使用前端固定模板链接
|
// 直接读取后台配置拼接后的完整链接
|
||||||
const targetUrl = this.shareLink || this.formatShareLink;
|
const targetUrl = this.formatShareLink;
|
||||||
if (!targetUrl) {
|
if (!targetUrl) {
|
||||||
uni.showToast({ title: '分享链接还未生成,请稍候', icon: 'none' });
|
uni.showToast({ title: '推荐码加载完成后再复制', icon: 'none' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rcCopyToClipboard(this, targetUrl, (ok, err) => {
|
rcCopyToClipboard(this, targetUrl, (ok, err) => {
|
||||||
@@ -879,22 +880,14 @@ export default {
|
|||||||
* - 绝对 URL / H5 URL:提取 recommend_code 参数,拼成小程序标准落地页(/pages_tool/form/formdata?recommend_code=xxx)
|
* - 绝对 URL / H5 URL:提取 recommend_code 参数,拼成小程序标准落地页(/pages_tool/form/formdata?recommend_code=xxx)
|
||||||
*/
|
*/
|
||||||
extractMiniProgramPath() {
|
extractMiniProgramPath() {
|
||||||
try {
|
// 直接生成落地页路径,不需要解析后端废弃shareLink
|
||||||
const u = this.shareLink || '';
|
if (!this.code) return '/pages_tool/form/formdata';
|
||||||
if (!u) return '/pages_tool/form/formdata';
|
return `/pages_tool/form/formdata?recommend_code=${encodeURIComponent(this.code)}`;
|
||||||
if (u.startsWith('/')) return u;
|
|
||||||
// 绝对 URL:解析 recommend_code query
|
|
||||||
const m = u.match(/[?&](recommend_code|invite)=([^&]+)/i);
|
|
||||||
if (m && m[2]) return '/pages_tool/form/formdata?recommend_code=' + decodeURIComponent(m[2]);
|
|
||||||
return '/pages_tool/form/formdata';
|
|
||||||
} catch (e) {
|
|
||||||
return '/pages_tool/form/formdata';
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/* ======================== 工具 / 持久化 ======================== */
|
|
||||||
|
|
||||||
/** 把 code + share_link 持久化到 Vuex + storage,供 util.js 现场 banner 跳转自动拼 recommend_code */
|
|
||||||
_persistRecommendInfo() {
|
_persistRecommendInfo() {
|
||||||
try {
|
try {
|
||||||
const sInfo = (this.$store && this.$store.state && this.$store.state.memberInfo) || {};
|
const sInfo = (this.$store && this.$store.state && this.$store.state.memberInfo) || {};
|
||||||
|
|||||||
Reference in New Issue
Block a user