11
This commit is contained in:
53
App.vue
53
App.vue
@@ -10,8 +10,7 @@
|
||||
uni.cache.set('NAME', '零点八零');
|
||||
this.userlogin()
|
||||
},
|
||||
onLoad(){
|
||||
},
|
||||
onLoad() {},
|
||||
onShow: function() {
|
||||
this.$store.dispatch("HeightActions"); //获取随时获取页面的高度
|
||||
|
||||
@@ -19,40 +18,32 @@
|
||||
onHide: function() {
|
||||
// console.log('App Hide');
|
||||
},
|
||||
methods:{
|
||||
async userlogin(reslange) {
|
||||
var resdataa = reslange
|
||||
methods: {
|
||||
userlogin() {
|
||||
uni.login({
|
||||
provider: 'weixin',
|
||||
success: async (data) => {
|
||||
try {
|
||||
uni.getUserInfo({
|
||||
provider: 'weixin',
|
||||
success: async (infoRes) => {
|
||||
uni.cache.set('weixincode', data.code);
|
||||
let res = await this.api.userwxlogin({
|
||||
code: uni.cache.get('weixincode'), //临时登录凭证
|
||||
rawData: infoRes.rawData,
|
||||
// signature: infoRes.signature,
|
||||
// iv: infoRes.detail.iv,
|
||||
// encryptedData: infoRes.detail
|
||||
// .encryptedData
|
||||
})
|
||||
if (res.code == 0) {
|
||||
uni.cache.set('token', res.data.token);
|
||||
uni.cache.set('miniAppOpenId', res.data.userInfo
|
||||
.miniAppOpenId)
|
||||
uni.cache.set('userInfo', res.data.userInfo);
|
||||
}
|
||||
},
|
||||
fail: (err) => {}
|
||||
});
|
||||
} catch (e) {}
|
||||
success: (data) => {
|
||||
uni.getUserInfo({
|
||||
provider: 'weixin',
|
||||
success: (infoRes) => {
|
||||
uni.cache.set('weixincode', data.code);
|
||||
let res = this.api.userwxlogin({
|
||||
code: uni.cache.get('weixincode'), //临时登录凭证
|
||||
rawData: infoRes.rawData,
|
||||
})
|
||||
if (res.code == 0) {
|
||||
uni.cache.set('token', res.data.token);
|
||||
uni.cache.set('miniAppOpenId', res.data.userInfo
|
||||
.miniAppOpenId)
|
||||
uni.cache.set('userInfo', res.data.userInfo);
|
||||
}
|
||||
},
|
||||
fail: (err) => {}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user