master
lion 1 month ago
parent 4107588164
commit d497c2ff49

@ -6,6 +6,8 @@ const HOSTARR = {
// 'production': 'https://leyitest.ali251.langye.net', // 'production': 'https://leyitest.ali251.langye.net',
}; // 审核状态 }; // 审核状态
const jwx = require('jweixin-module')
const HOST = HOSTARR[process.env const HOST = HOSTARR[process.env
.NODE_ENV]; //"https://tiantianxinye.365care.langye.net/";//HOSTARR[process.env.NODE_ENV];// .NODE_ENV]; //"https://tiantianxinye.365care.langye.net/";//HOSTARR[process.env.NODE_ENV];//
@ -109,7 +111,8 @@ const wxH5AuthLogin = (cb) => {
// 可以根据需要添加其他字段,如 WeChatOpenID 等 // 可以根据需要添加其他字段,如 WeChatOpenID 等
} }
uni.setStorageSync(user_info_key, userInfo) uni.setStorageSync(user_info_key, userInfo)
cb(userInfo) cb(userInfo)
shareIndex()
} else { } else {
console.error('登录失败: token为空') console.error('登录失败: token为空')
uni.showToast({ title: '登录失败,请重试', icon: 'none' }) uni.showToast({ title: '登录失败,请重试', icon: 'none' })
@ -134,7 +137,60 @@ const wxH5AuthLogin = (cb) => {
window.location.href = authUrl window.location.href = authUrl
} }
} }
// 分享
const shareIndex = (cb) => {
console.log("开始分享配置",location.href.split('#')[0])
let link = HOST+"/h5/";
request({
api: `/api/mobile/user/wx-jssdk`,
method: 'GET',
data:{
url:location.href.split('#')[0]
},
utilSuccess: (res) => {
jwx.config({
debug: false, // 开启调试模式,调用的所有 api 的返回值会在客户端 alert 出来,若要查看传入的参数,可以在 pc 端打开,参数信息会通过 log 打出,仅在 pc 端时才会打印。
appId: res.appId,
jsApiList: res.jsApiList,
nonceStr: res.nonceStr,
signature: res.signature,
timestamp: res.timestamp,
})
jwx.ready(() => {
jwx.updateAppMessageShareData({
title: '中共苏州独立支部旧址', // 分享标题
link: link, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
desc: '点击查看',
imgUrl: HOST+'/h5/share.jpg', // 分享图标
success: () => {
console.log(
'updateAppMessageShareData-success'
)
},
});
jwx.updateTimelineShareData({
title: '中共苏州独立支部旧址', // 分享标题
desc: '点击查看',
link: link, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
imgUrl: HOST+'/h5/share.jpg', // 分享图标
success: () => {
console.log(
'updateTimelineShareData-success'
)
}
});
})
},
utilFail: (err) => {
console.error('分享配置失败:', err)
// uni.showToast({ title: '分享配置失败', icon: 'none' })
}
})
}
const getUserProfile = (cb) => { const getUserProfile = (cb) => {
cb = cb || function() {} cb = cb || function() {}

Loading…
Cancel
Save