|
|
|
|
@ -2,72 +2,71 @@
|
|
|
|
|
const jwx = require('jweixin-module')
|
|
|
|
|
export default {
|
|
|
|
|
onLaunch: function() {
|
|
|
|
|
// let link = window.location.href;
|
|
|
|
|
// if (/code=/.test(link) || link.indexOf("code") > -1) {
|
|
|
|
|
// let temp = decodeURIComponent((new RegExp('[?|&]' + 'code' + '=' + '([^&;]+?)(&|#|;|$)').exec(link) ||
|
|
|
|
|
// [, ''])[1].replace(/\+/g, '%20')) || null
|
|
|
|
|
// let lifeData = uni.getStorageSync('lifeData')
|
|
|
|
|
// if (!lifeData.vuex_token || !lifeData.vuex_userId) {
|
|
|
|
|
// this.$u.api.login({
|
|
|
|
|
// code: temp
|
|
|
|
|
// }).then(res => {
|
|
|
|
|
// uni.setStorageSync('lifeData', {
|
|
|
|
|
// vuex_token: res.token,
|
|
|
|
|
// vuex_userId: res.user_id
|
|
|
|
|
// })
|
|
|
|
|
// this.$u.vuex('vuex_token', res.token)
|
|
|
|
|
// this.$u.vuex('vuex_userId', res.user_id)
|
|
|
|
|
// })
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// this.$u.api.getAppId().then(res => {
|
|
|
|
|
// let redirect = encodeURIComponent(link.replace(/#\//, ""))
|
|
|
|
|
// window.location.href =
|
|
|
|
|
// `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${res.appid}&redirect_uri=${redirect}&response_type=code&scope=snsapi_base#wechat_redirect`
|
|
|
|
|
// })
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
let url = location.href.split('#')[0]
|
|
|
|
|
this.$u.api.share({
|
|
|
|
|
url
|
|
|
|
|
}).then(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: '我是党史记录人-红色少年行 未成年人研学', // 分享标题
|
|
|
|
|
desc: '我是党史记录人-红色少年行 未成年人研学',
|
|
|
|
|
link: url, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
|
|
|
|
|
imgUrl: 'http://h5.ali251.langye.net/res/share-img.jpeg', // 分享图标
|
|
|
|
|
});
|
|
|
|
|
jwx.updateTimelineShareData({
|
|
|
|
|
title: '我是党史记录人-红色少年行 未成年人研学', // 分享标题
|
|
|
|
|
desc: '我是党史记录人-红色少年行 未成年人研学',
|
|
|
|
|
link: url, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
|
|
|
|
|
imgUrl: 'http://h5.ali251.langye.net/res/share-img.jpeg', // 分享图标
|
|
|
|
|
});
|
|
|
|
|
jwx.onMenuShareAppMessage({
|
|
|
|
|
title: '我是党史记录人-红色少年行 未成年人研学', // 分享标题
|
|
|
|
|
desc: '我是党史记录人-红色少年行 未成年人研学',
|
|
|
|
|
link: url, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
|
|
|
|
|
imgUrl: 'http://h5.ali251.langye.net/res/share-img.jpeg', // 分享图标
|
|
|
|
|
});
|
|
|
|
|
jwx.onMenuShareTimeline({
|
|
|
|
|
title: '我是党史记录人-红色少年行 未成年人研学', // 分享标题
|
|
|
|
|
desc: '我是党史记录人-红色少年行 未成年人研学',
|
|
|
|
|
link: url, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
|
|
|
|
|
imgUrl: 'http://h5.ali251.langye.net/res/share-img.jpeg', // 分享图标
|
|
|
|
|
});
|
|
|
|
|
let link = window.location.href;
|
|
|
|
|
if (/code=/.test(link) || link.indexOf("code") > -1) {
|
|
|
|
|
let temp = decodeURIComponent((new RegExp('[?|&]' + 'code' + '=' + '([^&;]+?)(&|#|;|$)').exec(link) ||
|
|
|
|
|
[, ''])[1].replace(/\+/g, '%20')) || null
|
|
|
|
|
let lifeData = uni.getStorageSync('lifeData')
|
|
|
|
|
if (!lifeData.vuex_token || !lifeData.vuex_userId) {
|
|
|
|
|
this.$u.api.login({
|
|
|
|
|
code: temp
|
|
|
|
|
}).then(res => {
|
|
|
|
|
this.$u.api.user().then(res => {
|
|
|
|
|
this.$u.vuex('vuex_user', res)
|
|
|
|
|
})
|
|
|
|
|
this.$u.vuex('vuex_token', res.token)
|
|
|
|
|
|
|
|
|
|
let url = location.href.split('#')[0]
|
|
|
|
|
this.$u.api.share({
|
|
|
|
|
url
|
|
|
|
|
}).then(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: '我是党史记录人-红色少年行 未成年人研学', // 分享标题
|
|
|
|
|
desc: '我是党史记录人-红色少年行 未成年人研学',
|
|
|
|
|
link: url, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
|
|
|
|
|
imgUrl: 'http://h5.ali251.langye.net/res/share-img.jpeg', // 分享图标
|
|
|
|
|
});
|
|
|
|
|
jwx.updateTimelineShareData({
|
|
|
|
|
title: '我是党史记录人-红色少年行 未成年人研学', // 分享标题
|
|
|
|
|
desc: '我是党史记录人-红色少年行 未成年人研学',
|
|
|
|
|
link: url, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
|
|
|
|
|
imgUrl: 'http://h5.ali251.langye.net/res/share-img.jpeg', // 分享图标
|
|
|
|
|
});
|
|
|
|
|
jwx.onMenuShareAppMessage({
|
|
|
|
|
title: '我是党史记录人-红色少年行 未成年人研学', // 分享标题
|
|
|
|
|
desc: '我是党史记录人-红色少年行 未成年人研学',
|
|
|
|
|
link: url, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
|
|
|
|
|
imgUrl: 'http://h5.ali251.langye.net/res/share-img.jpeg', // 分享图标
|
|
|
|
|
});
|
|
|
|
|
jwx.onMenuShareTimeline({
|
|
|
|
|
title: '我是党史记录人-红色少年行 未成年人研学', // 分享标题
|
|
|
|
|
desc: '我是党史记录人-红色少年行 未成年人研学',
|
|
|
|
|
link: url, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
|
|
|
|
|
imgUrl: 'http://h5.ali251.langye.net/res/share-img.jpeg', // 分享图标
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
this.$u.api.getAppId().then(res => {
|
|
|
|
|
let redirect = encodeURIComponent(link.replace(/#\//, ""))
|
|
|
|
|
window.location.href =
|
|
|
|
|
`https://open.weixin.qq.com/connect/oauth2/authorize?appid=${res.appid}&redirect_uri=${redirect}&response_type=code&scope=snsapi_base#wechat_redirect`
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
onShow: function() {
|
|
|
|
|
console.log('App Show')
|
|
|
|
|
|