Browse Source

登录配置文件

zhaoxw 4 years ago
parent
commit
ff769b7c66
2 changed files with 59 additions and 55 deletions
  1. 5 5
      manifest.json
  2. 54 50
      pages/index/login.vue

+ 5 - 5
manifest.json

@@ -1,12 +1,12 @@
 {
     "name" : "千家地用户端",
-    "appid" : "__UNI__C3D39A2",
+    "appid" : "__UNI__UNIECFC1F2",
     "description" : "千家地用户端",
     "versionName" : "1.0.0",
     "versionCode" : "100",
     "transformPx" : false,
     "app-plus" : {
-        "nvueCompiler":"uni-app",
+        "nvueCompiler" : "uni-app",
         "usingComponents" : true,
         "compilerVersion" : 3,
         /* 5+App特有相关 */
@@ -53,15 +53,15 @@
                 "ad" : {},
                 "oauth" : {
                     "weixin" : {
-                        "appid" : "wxc6ab95e70160a2ee",
-                        "appsecret" : "a1eee335af123ba2f7621e6687ddb33b",
+                        "appid" : "wxb99caa72401e1d3f",
+                        "appsecret" : "dbf7d351aecf53d7d8217e8264e61570",
                         "UniversalLinks" : ""
                     }
                 },
                 "payment" : {
                     "weixin" : {
                         "__platform__" : [ "android" ],
-                        "appid" : "wxc6ab95e70160a2ee",
+                        "appid" : "wxb99caa72401e1d3f",
                         "UniversalLinks" : ""
                     }
                 }

+ 54 - 50
pages/index/login.vue

@@ -21,7 +21,7 @@
 			<!-- #endif -->
 			<!-- #ifdef APP-PLUS -->
 			<button class="authorize-login" @click="getUserinfoApp">
-				登录3
+				登录9
 			</button>
 			<!-- #endif -->
 			<view @click="showAgreement = true" class="agreement">点击登录视为同意<text class="underline">平台服务协议</text></view>
@@ -230,55 +230,59 @@
 			getUserinfoApp() {
 				let that = this
 				console.log('app enter')
-				uni.login({
-					provider: 'weixin',
-					success: (res2) => {
-						console.log('res2', res2)
-						uni.getUserInfo({
-							provider: '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
-										// code: res2.code,
-										// encryptedData: info.encryptedData,
-										// iv: info.iv,
-										// rawData: info.rawData,
-										// signature: info.signature,
-									}
-								})
-								that.wxLoginData = uni.getStorageSync("wxLoginData")
-								console.log(1111111, that.wxLoginData)
-								// that.userNmae = JSON.parse(that.wxLoginData.rawData).nickName
-								that.getUserInfo(0)
-								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',
-						})
-					}
-				})
+				try {
+					uni.login({
+						provider: 'weixin',
+						success: (res2) => {
+							console.log('res2', res2)
+							uni.getUserInfo({
+								provider: '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
+											// code: res2.code,
+											// encryptedData: info.encryptedData,
+											// iv: info.iv,
+											// rawData: info.rawData,
+											// signature: info.signature,
+										}
+									})
+									that.wxLoginData = uni.getStorageSync("wxLoginData")
+									console.log(1111111, that.wxLoginData)
+									// that.userNmae = JSON.parse(that.wxLoginData.rawData).nickName
+									that.getUserInfo(0)
+									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',
+							})
+						}
+					})
+				} catch(e) {
+					console.log('是否调登录',e.message)
+				}
 				// uni.getProvider({
 				// 	service: 'oauth',
 				// 	success: (res) => {