Просмотр исходного кода

【添加】验证失败直接跳转领取校园卡

程志平 4 лет назад
Родитель
Сommit
7ed55023b2
3 измененных файлов с 86 добавлено и 50 удалено
  1. 10 1
      pages.json
  2. 60 49
      pages/index/index.vue
  3. 16 0
      pages/qr_code/qr_code.vue

+ 10 - 1
pages.json

@@ -43,7 +43,16 @@
 			}
 
 		}
-	],
+	    ,{
+            "path" : "pages/qr_code/qr_code",
+            "style" :                                                                                    
+            {
+                "navigationBarTitleText": "",
+                "enablePullDownRefresh": false
+            }
+            
+        }
+    ],
 	"globalStyle": {
 		"navigationBarTextStyle": "black",
 		"navigationBarTitleText": "uni-app",

+ 60 - 49
pages/index/index.vue

@@ -45,7 +45,8 @@
 				app_secret: '58D34C81D82B35179ED896C4362B0FC0', // 获取用户信息
 				my_display: false,
 				userinfo: '',
-				showQR_code: false,
+				// showQR_code: false,
+				validation_failed: false,
 				from: 0
 			}
 		},
@@ -155,54 +156,63 @@
 			 */
 			login_fail_callback() {
 				this.userinfo = {};
-				uni.showModal({
-					title: '提示',
-					content: '授权失败,请先扫码领取校园卡、再激活!',
-					cancelText: '取消',
-					confirmText: '手动截图',
-					success: (res1) => {
-						if (res1.confirm) {
-							uni.showToast({
-								icon: 'none',
-								title: '10秒后自动隐藏二维码,可重新授权调起!',
-								duration: 1000,
-								success: (com) => {
-									this.showQR_code = true
-									setTimeout(() => {
-										this.showQR_code = false
-									}, 10000)
-								}
-							});
-							// 出现二维码,用户扫描二维码添加校园卡、激活
-							// uni.downloadFile({
-							// 	url: 'https://jtishfw.ncjti.edu.cn/jxch-smartmp/HotWaters/image/1.jpg',
-							// 	success: (res2) => {
-							// 		// console.log(res2);
-							// 		if (res2.statusCode == 200) {
-							// 			uni.saveImageToPhotosAlbum({
-							// 				filePath: res2
-							// 					.tempFilePath,
-							// 				success: function() {
-							// 					uni.showToast({
-							// 						title: "保存成功!请用微信扫码添加校园卡!",
-							// 						icon: "none"
-							// 					});
-							// 				},
-							// 				fail: function() {
-							// 					uni.showToast({
-							// 						title: "保存失败,请手动截图保存,再用微信扫二维码!",
-							// 						icon: "none"
-							// 					});
-							// 				}
-							// 			});
-							// 		}
-							// 	}
-							// })
-						} else if (res1.cancel) {
-							// console.log('用户点击取消');
+				setTimeout(() => {
+					this.validation_failed = true
+				}, 2000);
+				if (this.validation_failed) {
+					this.validation_failed = false
+					uni.showModal({
+						title: '提示',
+						content: '授权失败,请先领取校园卡激活!',
+						// cancelText: '取消',
+						confirmText: '领取',
+						success: (res1) => {
+							if (res1.confirm) {
+								uni.navigateTo({
+									url: '../qr_code/qr_code'
+								});
+								// 出现二维码,用户扫描二维码添加校园卡、激活
+								// uni.downloadFile({
+								// 	url: 'https://jtishfw.ncjti.edu.cn/jxch-smartmp/HotWaters/image/1.jpg',
+								// 	success: (res2) => {
+								// 		// console.log(res2);
+								// 		if (res2.statusCode == 200) {
+								// 			uni.saveImageToPhotosAlbum({
+								// 				filePath: res2
+								// 					.tempFilePath,
+								// 				success: function() {
+								// 					uni.showToast({
+								// 						title: "保存成功!请用微信扫码添加校园卡!",
+								// 						icon: "none"
+								// 					});
+								// 				},
+								// 				fail: function() {
+								// 					uni.showToast({
+								// 						title: "保存失败,请手动截图保存,再用微信扫二维码!",
+								// 						icon: "none"
+								// 					});
+								// 				}
+								// 			});
+								// 		}
+								// 	}
+								// })
+							} else if (res1.cancel) {
+								// console.log('用户点击取消');
+								// uni.showToast({
+								// 	icon: 'none',
+								// 	title: '10秒后自动隐藏二维码,可重新授权调起!',
+								// 	duration: 1000,
+								// 	success: (com) => {
+								// 		this.showQR_code = true
+								// 		setTimeout(() => {
+								// 			this.showQR_code = false
+								// 		}, 10000)
+								// 	}
+								// });
+							}
 						}
-					}
-				});
+					});
+				}
 			},
 			/**
 			 * 授权登陆成功回调
@@ -213,7 +223,8 @@
 				const {
 					wxcode = ""
 				} = detail
-
+				
+				this.validation_failed = false
 				// 通过wxcode换取access_token
 				this.get_access_token(wxcode)
 			},

+ 16 - 0
pages/qr_code/qr_code.vue

@@ -0,0 +1,16 @@
+<template>
+	<web-view src="https://msg.weixiao.qq.com/t/700e3125b237694ec06512a4b35ade59" :progress="false"></web-view>
+</template>
+
+<script>
+	export default {
+		data() {
+			return {
+			}
+		}
+	}
+</script>
+
+<style>
+
+</style>