Files
houyi-uniapp/com/share.js
PC-202306242200\Administrator 85b89ccea7 first commit
2026-03-28 23:27:25 +08:00

33 lines
903 B
JavaScript

module.exports = {
onLoad(options) {
if (options && options.invite_code) {
uni.setStorageSync('invite_code', options.invite_code);
}
//设置默认的转发参数
uni.$u.mpShare = {
title: '羿充电', // 默认为小程序名称
path: '', // 默认为当前页面路径
imageUrl: '' // 默认为当前页面的截图
}
},
// #ifdef MP-WEIXIN
onShareAppMessage() {
let user = uni.getStorageSync('user');
let invite_code = user ? user.invite_code : '';
uni.$u.mpShare.path = uni.$u.page() + '?invite_code=' + invite_code; // 默认为当前页面路径
return uni.$u.mpShare
},
// #endif
// #ifdef MP-WEIXIN
onShareTimeline() {
let user = uni.getStorageSync('user');
let invite_code = user ? user.invite_code : '';
uni.$u.mpShare.path = uni.$u.page() + '?invite_code=' + invite_code; // 默认为当前页面路径
return uni.$u.mpShare
}
// #endif
}