瀏覽代碼

Merge branch 'master' of http://git.jihengcc.cn/liubaiyan/qjd-shell-uniapp

able99 4 年之前
父節點
當前提交
78f86bd5ff
共有 4 個文件被更改,包括 100 次插入60 次删除
  1. 2 1
      manifest.json
  2. 98 59
      pages/index/index.vue
  3. 二進制
      static/images/login-apple.png
  4. 二進制
      static/images/login-weixin.png

+ 2 - 1
manifest.json

@@ -65,7 +65,8 @@
                         "appid" : "wx53db61c69b2e1ed1",
                         "appsecret" : "944e2b205734646479c0b76be6cdbd90",
                         "UniversalLinks" : "https://www.qianjiadi.com/merchant/"
-                    }
+                    },
+                    "apple" : {}
                 }
             },
             "splashscreen" : {

+ 98 - 59
pages/index/index.vue

@@ -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;

二進制
static/images/login-apple.png


二進制
static/images/login-weixin.png