You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
149 lines
5.3 KiB
149 lines
5.3 KiB
<script>
|
|
const jwx = require('jweixin-module')
|
|
|
|
export default {
|
|
onLaunch: function() {
|
|
this.$nextTick(() => {
|
|
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 tadk2_lifeData = uni.getStorageSync('tadk2_lifeData')
|
|
if (!tadk2_lifeData.vuex_token) {
|
|
this.$u.api.login({
|
|
code: temp
|
|
}).then(res => {
|
|
this.$u.vuex('vuex_token', res.token)
|
|
this.$u.api.user().then(res => {
|
|
this.$u.vuex('vuex_user', res)
|
|
let url = location.href.split('#')[0]
|
|
let link = "https://vr.langye.net/h5tadk/";
|
|
this.$u.api.share({
|
|
url
|
|
}).then(res => {
|
|
this.$u.vuex('vuex_share', true)
|
|
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: 'https://vr.langye.net/storage/files/170954466365e594d74895e.jpg', // 分享图标
|
|
success: () => {
|
|
console.log(
|
|
'updateAppMessageShareData-success'
|
|
)
|
|
},
|
|
|
|
});
|
|
jwx.updateTimelineShareData({
|
|
title: '阵地有声 理响通安', // 分享标题
|
|
desc: '点击查看',
|
|
link: link, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
|
|
imgUrl: 'https://vr.langye.net/storage/files/170954466365e594d74895e.jpg', // 分享图标
|
|
success: () => {
|
|
console.log(
|
|
'updateTimelineShareData-success'
|
|
)
|
|
}
|
|
});
|
|
})
|
|
// this.$isResolve()
|
|
// console.log("123---to")
|
|
// uni.reLaunch({
|
|
// url: '/pages/index/index',
|
|
// });
|
|
})
|
|
|
|
})
|
|
})
|
|
} else {
|
|
this.$u.api.user().then(res => {
|
|
this.$u.vuex('vuex_user', res)
|
|
let url = location.href.split('#')[0]
|
|
let link = "https://vr.langye.net/h5tadk/";
|
|
this.$u.api.share({
|
|
url
|
|
}).then(res => {
|
|
this.$u.vuex('vuex_share', true)
|
|
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: link, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
|
|
imgUrl: 'https://vr.langye.net/storage/files/170954466365e594d74895e.jpg', // 分享图标
|
|
success: () => {
|
|
console.log(
|
|
'updateAppMessageShareData-success'
|
|
)
|
|
},
|
|
|
|
});
|
|
jwx.updateTimelineShareData({
|
|
title: '阵地有声 理响通安', // 分享标题
|
|
desc: '点击查看',
|
|
link: link, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
|
|
imgUrl: 'https://vr.langye.net/storage/files/170954466365e594d74895e.jpg', // 分享图标
|
|
success: () => {
|
|
console.log(
|
|
'updateTimelineShareData-success'
|
|
)
|
|
}
|
|
});
|
|
})
|
|
// this.$isResolve()
|
|
// console.log("123---to")
|
|
// uni.reLaunch({
|
|
// url: '/pages/index/index',
|
|
// });
|
|
})
|
|
})
|
|
}
|
|
} else {
|
|
|
|
|
|
// let that = this
|
|
// setInterval(function(){
|
|
// console.log("asd-------------")
|
|
// that.$u.vuex('vuex_token', "8849|gyvzzL2oj23cjFEHLkL3R6D3nG1G2LjkXj9j6NfP")
|
|
// that.$u.vuex('vuex_share', true)
|
|
// },10000)
|
|
// this.$u.vuex('vuex_token', "8849|gyvzzL2oj23cjFEHLkL3R6D3nG1G2LjkXj9j6NfP")
|
|
this.$u.api.getAppId().then(res => {
|
|
let redirect = encodeURIComponent(link.replace(/#\//, ""))
|
|
console.log(redirect)
|
|
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() {
|
|
|
|
},
|
|
onHide: function() {
|
|
console.log('App Hide')
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
/*每个页面公共css */
|
|
@import "uview-ui/index.scss";
|
|
</style> |