|
@@ -247,12 +247,14 @@
|
|
|
return {
|
|
|
wxLoginData: null,
|
|
|
wxPhoneData: null,
|
|
|
+ iosLoginData: nul,
|
|
|
userNmae: '',
|
|
|
tipxx: '',
|
|
|
showAgreement: false,
|
|
|
html: html,
|
|
|
windowWidth: 0,
|
|
|
- windowHeight: 0
|
|
|
+ windowHeight: 0,
|
|
|
+ isIos: false
|
|
|
}
|
|
|
},
|
|
|
onLoad() {
|
|
@@ -265,6 +267,13 @@
|
|
|
uni.removeStorage({
|
|
|
key: 'wxLoginData'
|
|
|
})
|
|
|
+ uni.removeStorage({
|
|
|
+ key: 'iosLoginData'
|
|
|
+ })
|
|
|
+ // #ifdef APP-PLUS
|
|
|
+ this.isIos = (plus.os.name == "iOS")
|
|
|
+ console.log('isIos:',this.isIos,plus.os.name)
|
|
|
+ // #endif
|
|
|
},
|
|
|
onReady() {
|
|
|
// this.appLoginWx()
|
|
@@ -341,29 +350,44 @@
|
|
|
// 获取app登录权限
|
|
|
getUserinfoApp() {
|
|
|
let that = this
|
|
|
+ console.log('isIos:',this.isIos)
|
|
|
console.log('app enter')
|
|
|
uni.login({
|
|
|
- provider: 'weixin',
|
|
|
+ provider: this.isIos ? 'apple' : 'weixin',
|
|
|
success: (res2) => {
|
|
|
console.log('res2', res2)
|
|
|
uni.getUserInfo({
|
|
|
- provider: 'weixin',
|
|
|
+ provider: this.isIos ? 'apple' : 'weixin',
|
|
|
success: (info) => {
|
|
|
console.log('info',info)
|
|
|
- uni.setStorage({
|
|
|
- key: 'wxLoginData',
|
|
|
- data: {
|
|
|
- nickName: info.userInfo.nickName,
|
|
|
- gender: info.userInfo.gender,
|
|
|
- avatarUrl: info.userInfo.avatarUrl,
|
|
|
- unionId: info.userInfo.unionId,
|
|
|
- openId:info.userInfo.openId
|
|
|
- }
|
|
|
- })
|
|
|
- that.wxLoginData = uni.getStorageSync("wxLoginData")
|
|
|
- console.log(1111111, that.wxLoginData)
|
|
|
- // that.userNmae = JSON.parse(that.wxLoginData.rawData).nickName
|
|
|
- that.getUserInfo()
|
|
|
+ if (this.isIos) {
|
|
|
+ uni.setStorage({
|
|
|
+ key: 'iosLoginData',
|
|
|
+ data: {
|
|
|
+ email: info.appleInfo.email,
|
|
|
+ fullname: info.appleInfo.fullname,
|
|
|
+ user: info.appleInfo.user
|
|
|
+ }
|
|
|
+ })
|
|
|
+ that.iosLoginData = uni.getStorageSync("iosLoginData")
|
|
|
+ console.log(1111111, that.iosLoginData)
|
|
|
+ that.getUserInfoByIOS()
|
|
|
+ } else {
|
|
|
+ uni.setStorage({
|
|
|
+ key: 'wxLoginData',
|
|
|
+ data: {
|
|
|
+ nickName: info.userInfo.nickName,
|
|
|
+ gender: info.userInfo.gender,
|
|
|
+ avatarUrl: info.userInfo.avatarUrl,
|
|
|
+ unionId: info.userInfo.unionId,
|
|
|
+ openId:info.userInfo.openId
|
|
|
+ }
|
|
|
+ })
|
|
|
+ that.wxLoginData = uni.getStorageSync("wxLoginData")
|
|
|
+ console.log(1111111, that.wxLoginData)
|
|
|
+ // that.userNmae = JSON.parse(that.wxLoginData.rawData).nickName
|
|
|
+ that.getUserInfo()
|
|
|
+ }
|
|
|
this.$refs.uTips.show({
|
|
|
title: '获取角色信息成功',
|
|
|
type: 'success',
|
|
@@ -434,6 +458,54 @@
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
+ // #ifdef APP-PLUS
|
|
|
+ // ios发请求获取个人数据
|
|
|
+ getUserInfoByIOS() {
|
|
|
+ NET.request(API.IosLogin, {
|
|
|
+ ...this.iosLoginData
|
|
|
+ }, 'POST').then(res => {
|
|
|
+ console.log('token',res)
|
|
|
+ uni.setStorage({
|
|
|
+ key: 'token',
|
|
|
+ data: res.data.token
|
|
|
+ })
|
|
|
+ console.log('缓存中iosLoginData',this.iosLoginData)
|
|
|
+ uni.setStorage({
|
|
|
+ key: 'userData',
|
|
|
+ data: {
|
|
|
+ headImage: res.data.avatar,
|
|
|
+ userName: res.data.name,
|
|
|
+ userId: res.data.userId,
|
|
|
+ tenantName: res.data.tenantName,
|
|
|
+ isMaster: res.extra.auth.isMaster,
|
|
|
+ registerFlag: res.extra.auth.registerFlag,
|
|
|
+ auditState: res.extra.auth.auditState,
|
|
|
+ roleInfos: res.extra.auth2.roleInfos
|
|
|
+ }
|
|
|
+ })
|
|
|
+ console.log('存个人信息')
|
|
|
+ if (res.extra.auth.registerFlag == 1 && res.extra.auth.auditState == 2) {
|
|
|
+ uni.switchTab({
|
|
|
+ url: '/pages/index/home'
|
|
|
+ })
|
|
|
+ } else if (res.extra.auth.registerFlag == 1 && res.extra.auth.auditState != 2) {
|
|
|
+ uni.navigateTo({
|
|
|
+ url: '/pages/index/registerState'
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ uni.navigateTo({
|
|
|
+ url: '/pages/index/authorize'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }).catch(error => {
|
|
|
+ console.log(error)
|
|
|
+ this.$refs.uTips.show({
|
|
|
+ title: '微信登录授权失败,请再试试',
|
|
|
+ type: 'warning',
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ //#endif
|
|
|
},
|
|
|
}
|
|
|
</script>
|