You've already forked guangan-mp
1.0.0
This commit is contained in:
68
App.vue
Normal file
68
App.vue
Normal file
@ -0,0 +1,68 @@
|
||||
<script>
|
||||
import { TaAjax } from '@/common/ajax';
|
||||
import { TaCache } from '@/common/cache';
|
||||
import { TaToast } from '@/common/toast';
|
||||
export default {
|
||||
onLaunch: function() {
|
||||
console.log('App Launch')
|
||||
uni.login({
|
||||
provider: 'weixin',
|
||||
success(loginRes) {
|
||||
// 换取会话密钥
|
||||
let data = {
|
||||
code: loginRes.code,
|
||||
iv: '',
|
||||
encrypted: ''
|
||||
}
|
||||
TaAjax.post('/plugin-account/api.wxapp/session', data).then((ret) => {
|
||||
console.log('SessionDone: ', ret)
|
||||
TaCache.set('auth.token', ret.data.token)
|
||||
// 获取用户信息
|
||||
uni.getUserInfo({
|
||||
provider: 'weixin',
|
||||
success: (infoRes) => {
|
||||
console.log('UserInfo: ', infoRes)
|
||||
data.iv = infoRes.iv, data.encrypted = infoRes
|
||||
.encryptedData
|
||||
TaAjax.post('/plugin-account/api.wxapp/decode', data)
|
||||
.then((ret) => {
|
||||
console.log('UserDone: ', ret.data)
|
||||
TaCache.set('auth.user', ret.data)
|
||||
}).catch((ret) => {
|
||||
console.log('UserFail: ', ret.data)
|
||||
})
|
||||
}
|
||||
})
|
||||
}).catch((ret) => {
|
||||
console.log('SessionFail: ', ret)
|
||||
reject(ret);
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
onShow: function() {
|
||||
console.log('App Show')
|
||||
},
|
||||
onHide: function() {
|
||||
console.log('App Hide')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
/*每个页面公共css */
|
||||
@import '@/uni_modules/uni-scss/index.scss';
|
||||
|
||||
</style>
|
||||
<style>
|
||||
/*每个页面公共css */
|
||||
@import '/common/free.css';
|
||||
page {
|
||||
background-color: #f8f8f8;
|
||||
box-sizing: border-box;
|
||||
min-height: 100%;
|
||||
}
|
||||
page view {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
</style>
|
Reference in New Issue
Block a user