main
parent
cab4ab5e1b
commit
98813a637d
@ -1,43 +1,42 @@
|
||||
<script>
|
||||
export default {
|
||||
onLaunch: function() {
|
||||
console.log('App Launch')
|
||||
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`
|
||||
})
|
||||
}
|
||||
},
|
||||
onShow: function() {
|
||||
console.log('App Show')
|
||||
},
|
||||
onHide: function() {
|
||||
console.log('App Hide')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
/*每个页面公共css */
|
||||
@import "uview-ui/index.scss";
|
||||
|
||||
</style>
|
||||
<script>
|
||||
export default {
|
||||
onLaunch: function() {
|
||||
console.log('App Launch')
|
||||
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`
|
||||
})
|
||||
}
|
||||
},
|
||||
onShow: function() {
|
||||
console.log('App Show')
|
||||
},
|
||||
onHide: function() {
|
||||
console.log('App Hide')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
/*每个页面公共css */
|
||||
@import "uview-ui/index.scss";
|
||||
</style>
|
||||
Loading…
Reference in new issue