|
@@ -28,10 +28,17 @@
|
|
|
|
|
|
<!-- #ifdef APP-PLUS -->
|
|
|
<button
|
|
|
+ v-if="!isIos"
|
|
|
class="authorize-login"
|
|
|
- @click="getUserinfoApp">
|
|
|
+ @click="getUserinfoApp()">
|
|
|
微信一键登录
|
|
|
</button>
|
|
|
+ <button v-if="isIos" class="authorize-login-ios" @click="getUserinfoApp('ioslogin')">
|
|
|
+ <image class="login-icon" src="../../static/images/login-apple.png"></image>苹果账户登录
|
|
|
+ </button>
|
|
|
+ <button v-if="isIos" class="authorize-login-ios" @click="getUserinfoApp()">
|
|
|
+ <image class="login-icon2" src="../../static/images/login-weixin.png"></image>微信一键登录
|
|
|
+ </button>
|
|
|
<!-- #endif -->
|
|
|
<view @click="showAgreement = true" class="agreement">点击登录视为同意<text class="underline">商家入驻协议</text></view>
|
|
|
</view>
|
|
@@ -271,7 +278,8 @@
|
|
|
key: 'iosLoginData'
|
|
|
})
|
|
|
// #ifdef APP-PLUS
|
|
|
- this.isIos = (plus.os.name == "iOS")
|
|
|
+ this.isIos = (plus.os.name == "iOS") && plus.os.version >= 13
|
|
|
+ // this.isIos = true
|
|
|
console.log('isIos:',this.isIos,plus.os.name)
|
|
|
// #endif
|
|
|
},
|
|
@@ -348,68 +356,72 @@
|
|
|
|
|
|
// #ifdef APP-PLUS
|
|
|
// 获取app登录权限
|
|
|
- getUserinfoApp() {
|
|
|
+ getUserinfoApp(iosFlag) {
|
|
|
let that = this
|
|
|
- console.log('isIos:',this.isIos)
|
|
|
+ console.log('isIos:',this.isIos,iosFlag)
|
|
|
console.log('app enter')
|
|
|
- uni.login({
|
|
|
- provider: this.isIos ? 'apple' : 'weixin',
|
|
|
- success: (res2) => {
|
|
|
- console.log('res2', res2)
|
|
|
- uni.getUserInfo({
|
|
|
- provider: this.isIos ? 'apple' : 'weixin',
|
|
|
- success: (info) => {
|
|
|
- console.log('info',info)
|
|
|
- if (this.isIos) {
|
|
|
- uni.setStorage({
|
|
|
- key: 'iosLoginData',
|
|
|
- data: {
|
|
|
- email: info.userInfo.email,
|
|
|
- fullname: info.userInfo.fullName.familyName || '匿名用户',
|
|
|
- user: info.userInfo.openId
|
|
|
- }
|
|
|
+ try {
|
|
|
+ uni.login({
|
|
|
+ provider: (this.isIos && iosFlag) ? 'apple' : 'weixin',
|
|
|
+ success: (res2) => {
|
|
|
+ console.log('res2', res2)
|
|
|
+ uni.getUserInfo({
|
|
|
+ provider: (this.isIos && iosFlag) ? 'apple' : 'weixin',
|
|
|
+ success: (info) => {
|
|
|
+ console.log('info',info)
|
|
|
+ if (this.isIos && iosFlag) {
|
|
|
+ uni.setStorage({
|
|
|
+ key: 'iosLoginData',
|
|
|
+ data: {
|
|
|
+ email: info.userInfo.email,
|
|
|
+ fullname: info.userInfo.fullName.familyName || '匿名用户',
|
|
|
+ user: info.userInfo.openId
|
|
|
+ }
|
|
|
+ })
|
|
|
+ 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',
|
|
|
})
|
|
|
- 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
|
|
|
- }
|
|
|
+ },
|
|
|
+ fail: (error) => {
|
|
|
+ console.log(2222, error)
|
|
|
+ that.$refs.uTips.show({
|
|
|
+ title: '微信登录授权失败,请再试试',
|
|
|
+ type: 'warning',
|
|
|
})
|
|
|
- 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',
|
|
|
- })
|
|
|
- },
|
|
|
- fail: (error) => {
|
|
|
- console.log(2222, error)
|
|
|
- that.$refs.uTips.show({
|
|
|
- title: '微信登录授权失败,请再试试',
|
|
|
- type: 'warning',
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- fail: (error) => {
|
|
|
- console.log(33333, error)
|
|
|
- that.$refs.uTips.show({
|
|
|
- title: '微信登录授权失败',
|
|
|
- type: 'warning',
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ fail: (error) => {
|
|
|
+ console.log(33333, error)
|
|
|
+ that.$refs.uTips.show({
|
|
|
+ title: '微信登录授权失败',
|
|
|
+ type: 'warning',
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } catch(e) {
|
|
|
+ console.log('是否调登录',e.message)
|
|
|
+ }
|
|
|
console.log('app end')
|
|
|
},
|
|
|
//#endif
|
|
@@ -604,6 +616,33 @@
|
|
|
line-height: 36px;
|
|
|
text-align: center;
|
|
|
}
|
|
|
+ .authorize-login-ios {
|
|
|
+ width: 210px;
|
|
|
+ height: 33px;
|
|
|
+ float: left;
|
|
|
+ margin: 10px 5px;
|
|
|
+ background: #FFFFFF;
|
|
|
+ border-radius: 4px;
|
|
|
+ font-size: 14px;
|
|
|
+ font-family: PingFang SC;
|
|
|
+ // color: #56a83a;
|
|
|
+ line-height: 33px;
|
|
|
+ text-align: center;
|
|
|
+ }
|
|
|
+ .login-icon {
|
|
|
+ width: 13px;
|
|
|
+ height: 15px;
|
|
|
+ position: absolute;
|
|
|
+ left: 13px;
|
|
|
+ top: 25%;
|
|
|
+ }
|
|
|
+ .login-icon2 {
|
|
|
+ width: 13px;
|
|
|
+ height: 11px;
|
|
|
+ position: absolute;
|
|
|
+ left: 13px;
|
|
|
+ top: 30%;
|
|
|
+ }
|
|
|
.authorize-tip {
|
|
|
width: 220px;
|
|
|
height: 20px;
|