wangguoyu 4 месяцев назад
Родитель
Сommit
4ac2935ce4
4 измененных файлов с 93 добавлено и 35 удалено
  1. 6 0
      App.vue
  2. 11 0
      api/login.js
  3. 53 23
      pages/login/index.vue
  4. 23 12
      pages/study/index.vue

+ 6 - 0
App.vue

@@ -11,13 +11,19 @@
 		// creat by wgy 0619  生命周期 钩子  
 		onLaunch: function() {
 			//console.log('App Launch')
+			
 		},
 		onShow: function() {
+
 			// #ifdef APP-PLUS
+					
 			if (cacheManager.get('auth')) {	
 				uni.redirectTo({
 					url: `/pages/study/index`
 				})
+			}else if(!(cacheManager.get('wxLogin').bind)){
+					console.log('asdfadsfadsfasd')
+				// 微信登录且未绑定 
 			} else {
 				cacheManager.clearAll()
 				uni.redirectTo({

+ 11 - 0
api/login.js

@@ -54,4 +54,15 @@ export function telBind(data = {}) {
     data,
     timeout: 20000
   })
+}
+export function firstTelBind(data = {}) {
+  return request({
+    'url': '/common/app/bind/code',
+    headers: {
+      isToken: false
+    },
+    method: 'post',
+    data,
+    timeout: 20000
+  })
 }

+ 53 - 23
pages/login/index.vue

@@ -31,12 +31,14 @@
 		<agree-content-dialog ref="agreeContentDialogRef"></agree-content-dialog>
 		<agree-dialog ref="agreeDialogRef" @confirm-btn="confirmBtn"></agree-dialog>
 		<agree-dialog ref="agreeYkDialog" @confirm-btn="ykConfirmBtn"></agree-dialog>
+		<tel-dialog ref="telDialogRef" @telClose="telClose" @bindBtn="bindBtn" v-if="telDialogFlag"></tel-dialog>
 	</view>
 </template>
 
 <script setup>
 	import {
 		ref,
+		nextTick,
 		reactive
 	} from "vue"
 	import {
@@ -52,6 +54,8 @@
 		toast,
 		getUserIdentity
 	} from "@/utils/common";
+	import telDialog from './telDialog.vue'
+	import cacheManager from "@/utils/cacheManager.js";
 	import {
 		error
 	} from "uview-plus";
@@ -65,6 +69,8 @@
 	const agreeContentDialogRef = ref(null);
 	const agreeDialogRef = ref(null);
 	const agreeYkDialog = ref(null);
+	const telDialogRef = ref(null);
+	let telDialogFlag = ref(false);
 
 	onLoad((options) => {})
 
@@ -84,7 +90,22 @@
 		indexData.isAgreed = true;
 		getYzmBtn();
 	}
-	
+	const telClose = () => {
+		telDialogFlag.value = false;
+	}
+	const bindBtn = (res) => {
+		telDialogFlag.value = false;
+		if (res.cardId == 0) {
+			uni.redirectTo({
+				url: `/pages/selectGradesTerms/index`
+			})
+		} else {
+			uni.redirectTo({
+				url: `/pages/study/index`
+			})
+		}
+	}
+
 	const ykConfirmBtn = () => {
 		uni.navigateTo({
 			url: `/pages/selectGradesTerms/index`
@@ -137,26 +158,23 @@
 		}
 	}
 
-	const wxLoginClick = () => {
-		
-		//获取服务商信息判断手机端是否安装了app
-		// uni.getProvider({
-		// 	service: 'oauth',// oauth  代表授权登录
-		// 	success: function (res) {
-		// 	  // 登录
-		// 	  uni.login({
-		// 		  // 表示授权方式  如果不设置则弹出登录列表选择界面
-		// 		  provider: 'weixin',
-		// 		 	"onlyAuthorize": true, // 微信登录仅请求授权认证
-		// 		  success: function (loginRes) {
-		// 			  		console.log('loginRes',loginRes); 
-				 
-		// 		  }
-		// 	  });
-		//    }
-		// });
-		
-		
+	const wxLoginClick = () => {
+		//获取服务商信息判断手机端是否安装了app
+		// uni.getProvider({
+		// 	service: 'oauth',// oauth  代表授权登录
+		// 	success: function (res) {
+		// 	  // 登录
+		// 	  uni.login({
+		// 		  // 表示授权方式  如果不设置则弹出登录列表选择界面
+		// 		  provider: 'weixin',
+		// 		 	"onlyAuthorize": true, // 微信登录仅请求授权认证
+		// 		  success: function (loginRes) {
+		// 			  		console.log('loginRes',loginRes); 
+
+		// 		  }
+		// 	  });
+		//    }
+		// });
 		uni.login({
 			"provider": "weixin",
 			"onlyAuthorize": true, // 微信登录仅请求授权认证
@@ -170,8 +188,20 @@
 					"apple": false,
 					"code": code
 				}
-				wxLogin(req).then(res => {
+				wxLogin(req).then(res => {
 					console.log(res);
+					if (!res.data.bind) {
+						console.log('未绑定');
+						cacheManager.set('wxLogin', { 
+							bind: res.data.bing
+						})
+						telDialogFlag.value = true;
+						nextTick(() => {
+							telDialogRef.value.getOpenId(res.data.openId);
+						})
+					} else {
+
+					}
 				}).catch((error) => {
 					console.log(error);
 				})
@@ -183,4 +213,4 @@
 			}
 		})
 	}
-</script> 
+</script>

+ 23 - 12
pages/study/index.vue

@@ -81,7 +81,7 @@
 			// 已登录
 			// 选择年级进入调用此接口
 			//options.flag == 'selectGrades'
-			if (!selectZhang.value.eggFlag) {
+			if (!selectZhang.value.firstLogin) {
 				nextTick(() => {
 					eggDialogRef.value.eggShow();
 				})
@@ -175,6 +175,7 @@
 	}
 
 	function onRight(event) {
+		console.log('');
 		const authCode = getUserIdentity();
 		if (authCode !== 'VIP') {
 			return false
@@ -187,16 +188,26 @@
 		}
 		userZhangNextInfo(req).then(res => {
 			cacheManager.set('zhangInfo', res.data)
-			infoData.jieList = res.data.jieList
-			infoData.haveFlag = res.data.haveFlag
-			infoData.nianji = res.data.nianji
-			infoData.number = res.data.number
-			infoData.numberStr = res.data.numberStr
-			infoData.cardId = res.data.cardId
-			infoData.zhangId = res.data.zhangId
-			infoData.zhangName = res.data.zhangName
-			recordZhangJie()
-			getNewData()
+			nextTick(() => {
+				// uni.redirectTo({
+				// 	url: `/pages/study/index`
+				// })
+				uni.navigateTo({
+				  url:  `/pages/study/index`
+				});
+			})
+
+			// cacheManager.set('zhangInfo', res.data)
+			// infoData.jieList = res.data.jieList
+			// infoData.haveFlag = res.data.haveFlag
+			// infoData.nianji = res.data.nianji
+			// infoData.number = res.data.number
+			// infoData.numberStr = res.data.numberStr
+			// infoData.cardId = res.data.cardId
+			// infoData.zhangId = res.data.zhangId
+			// infoData.zhangName = res.data.zhangName
+			// recordZhangJie()
+			// getNewData()
 		})
 	}
 
@@ -303,7 +314,7 @@
 	function eggBtn() {
 		console.log('点击:开启提分之旅');
 		cacheManager.updateObject('auth', {
-			eggFlag: true
+			firstLogin: true
 		})
 	}
 </script>