chore:微信小程序可以分享给好友表单
This commit is contained in:
@@ -1011,7 +1011,16 @@ onShareClick() {
|
|||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP-WEIXIN
|
||||||
// open-type="share" 会自动触发 onShareAppMessage 弹出微信原生分享面板,无需手动复制链接
|
// open-type="share" 会自动触发 onShareAppMessage 弹出微信原生分享面板
|
||||||
|
// 存储分享数据供页面级 onShareAppMessage 读取(组件级钩子会被页面级覆盖)
|
||||||
|
try {
|
||||||
|
var shareData = {
|
||||||
|
title: v.shareTitle || v.title || '邀您入驻低空经济产业平台',
|
||||||
|
path: this.extractMiniProgramPath(),
|
||||||
|
imageUrl: v.shareImageUrl || ''
|
||||||
|
};
|
||||||
|
uni.setStorageSync('_recommendShareData', JSON.stringify(shareData));
|
||||||
|
} catch(e) {}
|
||||||
return;
|
return;
|
||||||
// #endif
|
// #endif
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="body-wrap">
|
<view class="body-wrap">
|
||||||
<view class="form-wrap">
|
<view class="form-wrap">
|
||||||
<view class="input-wrap" v-show="loginMode == 'mobile'">
|
<view class="input-wrap" v-show="loginMode == 'mobile'">
|
||||||
<view class="content">
|
<view class="content">
|
||||||
<!-- <view class="area-code">+86</view> -->
|
<!-- <view class="area-code">+86</view> -->
|
||||||
@@ -324,16 +324,16 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mobileAuthLogin(e) {
|
mobileAuthLogin(e) {
|
||||||
if (e.detail.errMsg == 'getPhoneNumber:ok') {
|
if (e.detail.errMsg == 'getPhoneNumber:ok') {
|
||||||
var data = {
|
var data = {
|
||||||
iv: e.detail.iv,
|
iv: e.detail.iv,
|
||||||
encryptedData: e.detail.encryptedData
|
encryptedData: e.detail.encryptedData
|
||||||
};
|
};
|
||||||
if (Object.keys(this.authInfo).length) {
|
if (Object.keys(this.authInfo).length) {
|
||||||
Object.assign(data, this.authInfo);
|
Object.assign(data, this.authInfo);
|
||||||
if (this.authInfo.nickName) data.nickname = this.authInfo.nickName;
|
if (this.authInfo.nickName) data.nickname = this.authInfo.nickName;
|
||||||
if (this.authInfo.avatarUrl) data.headimg = this.authInfo.avatarUrl;
|
if (this.authInfo.avatarUrl) data.headimg = this.authInfo.avatarUrl;
|
||||||
}
|
}
|
||||||
if (uni.getStorageSync('source_member')) data.source_member = uni.getStorageSync('source_member');
|
if (uni.getStorageSync('source_member')) data.source_member = uni.getStorageSync('source_member');
|
||||||
|
|
||||||
if (this.isSub) return;
|
if (this.isSub) return;
|
||||||
|
|||||||
@@ -113,6 +113,32 @@ export default {
|
|||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
this.$util.hideHomeButton();
|
this.$util.hideHomeButton();
|
||||||
|
},
|
||||||
|
// 覆写 mixin 的分享钩子:优先使用推荐码组件存储的分享数据
|
||||||
|
onShareAppMessage() {
|
||||||
|
try {
|
||||||
|
var shareDataStr = uni.getStorageSync('_recommendShareData');
|
||||||
|
if (shareDataStr) {
|
||||||
|
uni.removeStorageSync('_recommendShareData');
|
||||||
|
return JSON.parse(shareDataStr);
|
||||||
|
}
|
||||||
|
} catch(e) {}
|
||||||
|
return this.mpShareData?.appMessage;
|
||||||
|
},
|
||||||
|
onShareTimeline() {
|
||||||
|
try {
|
||||||
|
var shareDataStr = uni.getStorageSync('_recommendShareData');
|
||||||
|
if (shareDataStr) {
|
||||||
|
uni.removeStorageSync('_recommendShareData');
|
||||||
|
var d = JSON.parse(shareDataStr);
|
||||||
|
var query = '';
|
||||||
|
if (d.path && d.path.indexOf('?') >= 0) {
|
||||||
|
query = d.path.split('?')[1];
|
||||||
|
}
|
||||||
|
return { title: d.title, query: query, imageUrl: d.imageUrl || '' };
|
||||||
|
}
|
||||||
|
} catch(e) {}
|
||||||
|
return this.mpShareData?.timeLine;
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user