|
@@ -20,13 +20,22 @@
|
|
|
</button>
|
|
|
<!-- #endif -->
|
|
|
<!-- #ifdef APP-PLUS -->
|
|
|
- <button class="authorize-login" @click="getUserinfoApp">
|
|
|
+ <button v-if="!isIos" class="authorize-login" @click="getUserinfoApp">
|
|
|
微信一键登录
|
|
|
</button>
|
|
|
+ <button v-if="isIos" class="authorize-login-ios" @click="getUserinfoApp">
|
|
|
+ 苹果账户登录
|
|
|
+ </button>
|
|
|
+ <button v-if="isIos" class="authorize-login-ios" @click="getUserinfoApp">
|
|
|
+ 微信一键登录(苹果)
|
|
|
+ </button>
|
|
|
<!-- #endif -->
|
|
|
- <button class="authorize-login" @click="goIndex">
|
|
|
+ <button v-if="!isIos" class="authorize-login" @click="goIndex">
|
|
|
再逛逛
|
|
|
</button>
|
|
|
+ <button v-if="isIos" class="authorize-login-ios" @click="goIndex">
|
|
|
+ 再逛逛(苹果)
|
|
|
+ </button>
|
|
|
<view @click="showAgreement = true" class="agreement">点击登录视为同意<text class="underline">平台服务协议</text></view>
|
|
|
</view>
|
|
|
{{tipxx}}
|
|
@@ -155,9 +164,17 @@
|
|
|
showAgreement: false,
|
|
|
html: html,
|
|
|
windowWidth: 0,
|
|
|
- windowHeight: 0
|
|
|
+ windowHeight: 0,
|
|
|
+ isIos: false
|
|
|
+
|
|
|
}
|
|
|
},
|
|
|
+ onLoad() {
|
|
|
+ // #ifdef APP-PLUS
|
|
|
+ this.isIos = (plus.os.name == "iOS")
|
|
|
+ console.log('isIos:',this.isIos,plus.os.name)
|
|
|
+ // #endif
|
|
|
+ },
|
|
|
onReady() {
|
|
|
// this.appLoginWx()
|
|
|
uni.getSystemInfo({
|
|
@@ -237,16 +254,32 @@
|
|
|
// 获取app登录权限
|
|
|
getUserinfoApp() {
|
|
|
let that = this
|
|
|
+ // var isIos = (plus.os.name == "iOS")
|
|
|
+ console.log('isIos:',this.isIos)
|
|
|
console.log('app enter')
|
|
|
try {
|
|
|
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)
|
|
|
+ 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()
|
|
|
+ return;
|
|
|
+ }
|
|
|
uni.setStorage({
|
|
|
key: 'wxLoginData',
|
|
|
data: {
|
|
@@ -311,7 +344,7 @@
|
|
|
},
|
|
|
//#endif
|
|
|
|
|
|
- // 发请求获取个人数据 envType:1小程序 0:app
|
|
|
+ // 发请求获取个人数据 envType:1小程序 0:app安卓
|
|
|
getUserInfo(envType) {
|
|
|
console.log('发请求获取个人数据envType',envType)
|
|
|
NET.request(API.WxLogin, {
|
|
@@ -345,6 +378,38 @@
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
+ // 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,
|
|
|
+ }
|
|
|
+ })
|
|
|
+ console.log('存个人信息')
|
|
|
+ uni.switchTab({
|
|
|
+ url: '/pages/index/index'
|
|
|
+ })
|
|
|
+ console.log('switchTab')
|
|
|
+ }).catch(error => {
|
|
|
+ console.log(44444, error)
|
|
|
+ this.$refs.uTips.show({
|
|
|
+ title: '微信登录授权失败,请再试试',
|
|
|
+ type: 'warning',
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
},
|
|
|
}
|
|
|
</script>
|
|
@@ -443,7 +508,19 @@
|
|
|
line-height: 36px;
|
|
|
text-align: center;
|
|
|
}
|
|
|
-
|
|
|
+ .authorize-login-ios {
|
|
|
+ width: 210px;
|
|
|
+ height: 33px;
|
|
|
+ float: left;
|
|
|
+ margin: 10px 5px;
|
|
|
+ background: #FFFFFF;
|
|
|
+ border-radius: 10px;
|
|
|
+ font-size: 15px;
|
|
|
+ font-family: PingFang SC;
|
|
|
+ // color: #56a83a;
|
|
|
+ line-height: 33px;
|
|
|
+ text-align: center;
|
|
|
+ }
|
|
|
.authorize-tip {
|
|
|
width: 220px;
|
|
|
height: 20px;
|