diff --git a/components-diy/diy-recommend-code.vue b/components-diy/diy-recommend-code.vue
index 4101b11..b6b8142 100644
--- a/components-diy/diy-recommend-code.vue
+++ b/components-diy/diy-recommend-code.vue
@@ -65,7 +65,7 @@
- {{ shareLink || formatShareLink }}
+ {{ formatShareLink}}
@@ -96,7 +96,7 @@
- {{ shareLink || formatShareLink }}
+ {{ formatShareLink }}
@@ -132,7 +132,7 @@
- {{ shareLink || formatShareLink }}
+ {{ formatShareLink }}
@@ -414,10 +414,14 @@ export default {
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 || '');
+ // 读取后台装修配置的链接前缀模板
+ const baseTemplate = this.nc.customShareLink || '';
+ // 后台未配置时兜底默认地址
+ 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: {
@@ -802,46 +806,43 @@ export default {
} catch (e) {}
},
- /* ======================== 分享 / 复制 ======================== */
-
- /** 点击主按钮「立即分享」:小程序(原生 open-type 已处理);H5/APP 走 navigator.share */
- onShareClick() {
- const vm = this;
- const v = this.nc;
- // #ifdef H5
- try {
- if (navigator && navigator.share && typeof navigator.share === 'function' && this.shareLink) {
- navigator.share({
- title: v.shareTitle || v.title || '邀您入驻低空经济产业平台',
- text: v.shareDesc || '',
- url: this.shareLink
- }).catch(() => vm.copyLink());
- return;
- }
- } catch (e) {}
- this.copyLink();
+onShareClick() {
+ const vm = this;
+ const v = this.nc;
+ const shareUrl = this.formatShareLink; // 改用后台拼接链接
+ // #ifdef H5
+ try {
+ if (navigator && navigator.share && typeof navigator.share && shareUrl) {
+ navigator.share({
+ title: v.shareTitle || v.title || '邀您入驻低空经济产业平台',
+ text: v.shareDesc || '',
+ url: shareUrl
+ }).catch(() => vm.copyLink());
return;
- // #endif
+ }
+ } catch (e) {}
+ this.copyLink();
+ return;
+ // #endif
- // #ifdef APP-PLUS
- try {
- if (plus && plus.share && this.shareLink) {
- plus.share.sendWithSystem({
- title: v.shareTitle || v.title || '邀您入驻低空经济产业平台',
- content: v.shareDesc || '',
- href: this.shareLink
- }, function () {}, function () { vm.copyLink(); });
- return;
- }
- } catch (e) {}
- this.copyLink();
- // #endif
+ // #ifdef APP-PLUS
+ try {
+ if (plus && plus.share && shareUrl) {
+ plus.share.sendWithSystem({
+ title: v.shareTitle || v.title || '邀您入驻低空经济产业平台',
+ content: v.shareDesc || '',
+ href: shareUrl
+ }, function () {}, function () { vm.copyLink(); });
+ return;
+ }
+ } catch (e) {}
+ this.copyLink();
+ // #endif
- // #ifdef MP-WEIXIN
- // 小程序:主按钮 open-type=share 原生处理,这里兜底复制链接
- if (this.shareLink) this.copyLink();
- // #endif
- },
+ // #ifdef MP-WEIXIN
+ this.copyLink();
+ // #endif
+},
/** 复制「推荐码」本身(点击推荐码盒子时) */
copyRecommendCode() {
@@ -857,12 +858,12 @@ export default {
});
},
- /** 复制「分享链接」(后端给的 share_link 原样复制) */
+
copyLink() {
- // 后端没有shareLink时,自动使用前端固定模板链接
- const targetUrl = this.shareLink || this.formatShareLink;
+ // 直接读取后台配置拼接后的完整链接
+ const targetUrl = this.formatShareLink;
if (!targetUrl) {
- uni.showToast({ title: '分享链接还未生成,请稍候', icon: 'none' });
+ uni.showToast({ title: '推荐码加载完成后再复制', icon: 'none' });
return;
}
rcCopyToClipboard(this, targetUrl, (ok, err) => {
@@ -879,22 +880,14 @@ export default {
* - 绝对 URL / H5 URL:提取 recommend_code 参数,拼成小程序标准落地页(/pages_tool/form/formdata?recommend_code=xxx)
*/
extractMiniProgramPath() {
- try {
- const u = this.shareLink || '';
- if (!u) return '/pages_tool/form/formdata';
- 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';
- }
+ // 直接生成落地页路径,不需要解析后端废弃shareLink
+ if (!this.code) return '/pages_tool/form/formdata';
+ return `/pages_tool/form/formdata?recommend_code=${encodeURIComponent(this.code)}`;
},
- /* ======================== 工具 / 持久化 ======================== */
+
- /** 把 code + share_link 持久化到 Vuex + storage,供 util.js 现场 banner 跳转自动拼 recommend_code */
+
_persistRecommendInfo() {
try {
const sInfo = (this.$store && this.$store.state && this.$store.state.memberInfo) || {};