wangguoyu 2 viikkoa sitten
vanhempi
commit
a416a01fa4
4 muutettua tiedostoa jossa 247 lisäystä ja 145 poistoa
  1. 11 0
      api/login.js
  2. 38 0
      components/dialog/tipDialog.vue
  3. 132 102
      pages/login/index.vue
  4. 66 43
      pages/study/index.vue

+ 11 - 0
api/login.js

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

+ 38 - 0
components/dialog/tipDialog.vue

@@ -0,0 +1,38 @@
+<template>
+	<uni-popup ref="tipPopup" :animation="false" :is-mask-click="false"
+	 mask-background-color="rgba(0, 0, 0, 0.4)">
+	 <view class="phone-tip-dialog">
+			<view class="common-body-box">
+				<view class="tip-title">{{title}}</view>
+				<view class="tip-content" :class="dialogContentClass">{{content}}</view>
+			</view>
+	 </view>
+	</uni-popup>
+</template>
+
+<script setup>
+	import { ref } from 'vue';
+	const props = defineProps({
+		title: {
+		  type: String,
+		  default: ''
+		},
+	  content: {
+	    type: String,
+		require: true,
+	    default: ''
+	  },
+	});
+	const tipPopup = ref(null); // 索引
+	const $emit = defineEmits(['confirm-btn'])
+	// 打开弹窗
+	function handleShow() {
+		tipPopup.value.open();
+	}
+	defineExpose({
+			handleShow
+		})
+</script>
+
+<style>
+</style>

+ 132 - 102
pages/login/index.vue

@@ -35,6 +35,8 @@
 		<agree-dialog ref="agreeYkDialog" @confirm-btn="ykConfirmBtn"></agree-dialog>
 		<agree-dialog ref="agreeWxDialog" @confirm-btn="wxConfirmBtn"></agree-dialog>
 		<tel-dialog ref="telDialogRef" @telClose="telClose" @bindBtn="bindBtn" v-if="telDialogFlag"></tel-dialog>
+		<tip-dialog ref="tipDialogRef" :title="tipTitle" :content="tipContent"></tip-dialog>
+
 	</view>
 </template>
 
@@ -52,6 +54,7 @@
 	import agreeDialog from './agreeDialog.vue'
 	import {
 		wxLogin,
+		getVersion
 	} from "@/api/login.js"
 	import {
 		toast,
@@ -64,8 +67,11 @@
 		onShow,
 		onUnload,
 	} from '@dcloudio/uni-app';
-	import {useIsCanBack} from "@/store/isCanBack.js"
-
+	import {
+		useIsCanBack
+	} from "@/store/isCanBack.js"
+	import tipDialog from '@/components/dialog/tipDialog.vue';
+	import config from '../../config.js'
 	import {
 		error
 	} from "uview-plus";
@@ -85,31 +91,50 @@
 	let telDialogFlag = ref(false);
 	let showAppleLogin = ref(false);
 	let wxFlag = ref(true);
-	
+
+	const version = config.appInfo.version;
+	const tipDialogRef = ref(null);
+	const tipTitle = '升级提醒';
+	const tipContent = '您的APP不是最新版本,部分功能不能使用,请升级至最新版本!';
+
+
+
 	const store = useIsCanBack();
 	onUnload(() => {
 		console.log('unload')
 		store.setIsCanBack(false)
 	})
-	
+
 	onShow(() => {
 		setTimeout(() => {
 			console.log('onShow')
 			store.setIsCanBack(true)
-		},500)
+		}, 500)
 	})
 
 	onLoad((options) => {
 		showAppleLogin.value = isIOS13OrAbove();
-		if(plus.runtime.isApplicationExist({ pname: 'com.tencent.mm', action: 'weixin://' })) {
-				console.log('111',"已安装微信");
-					wxFlag.value = true
-		}else{
+		getLoginInit()
+		if (plus.runtime.isApplicationExist({
+				pname: 'com.tencent.mm',
+				action: 'weixin://'
+			})) {
+			console.log('111', "已安装微信");
+			wxFlag.value = true
+		} else {
 			wxFlag.value = false
 		}
-		console.log('showAppleLogin.value',showAppleLogin.value);
+		console.log('showAppleLogin.value', showAppleLogin.value);
+
 	})
 
+	function getLoginInit() {
+		getVersion({}).then(res => {
+			if (version != res.data.version) {
+				tipDialogRef.value.handleShow();
+			}
+		})
+	}
 	const getYzmBtn = () => {
 		if (indexData.telStatus === 'tel-btn-normal') {
 			if (indexData.isAgreed === true) {
@@ -157,7 +182,7 @@
 		})
 	}
 
-	const wxConfirmBtn= () => {
+	const wxConfirmBtn = () => {
 		wxLoginFun();
 	}
 
@@ -222,42 +247,43 @@
 					"code": loginRes.appleInfo.user
 				}
 				console.log(req);
-			console.log(req);
-			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 {
-					uni.showLoading({
-						title: '登录中'
-					});
-					setTimeout(() => {
-						cacheManager.set('auth', res.data.loginVo)
-						if (res.data.loginVo.subjectId ==0 &&res.data.loginVo.levelId == 0) {
+				console.log(req);
+				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 {
+						uni.showLoading({
+							title: '登录中'
+						});
+						setTimeout(() => {
+							cacheManager.set('auth', res.data.loginVo)
+							if (res.data.loginVo.subjectId == 0 && res.data.loginVo
+								.levelId == 0) {
 
-							uni.redirectTo({
-								url: `/pages/selectGradesTerms/index`
-							})
-							uni.hideLoading();
-						} else {
+								uni.redirectTo({
+									url: `/pages/selectGradesTerms/index`
+								})
+								uni.hideLoading();
+							} else {
 
-							uni.redirectTo({
-								url: `/pages/study/index`
-							})
-							uni.hideLoading();
-						}
-					}, 1000)
-				}
-			}).catch((error) => {
-				console.log(error);
-			})
+								uni.redirectTo({
+									url: `/pages/study/index`
+								})
+								uni.hideLoading();
+							}
+						}, 1000)
+					}
+				}).catch((error) => {
+					console.log(error);
+				})
 			},
 			fail: function(err) {
 				console.log('err.code', err.code);
@@ -277,7 +303,7 @@
 		}
 	}
 
-	const wxLoginFun= () => {
+	const wxLoginFun = () => {
 		//获取服务商信息判断手机端是否安装了app
 		// uni.getProvider({
 		// 	service: 'oauth',// oauth  代表授权登录
@@ -295,64 +321,68 @@
 		//    }
 		// });
 
-		if(plus.runtime.isApplicationExist({ pname: 'com.tencent.mm', action: 'weixin://' })) {
-			console.log('111',"已安装微信");
-		uni.login({
-			"provider": "weixin",
-			"onlyAuthorize": true, // 微信登录仅请求授权认证
-			success: function(event) {
-				console.log(event);
-				const {
-					code
-				} = event
-				//客户端成功获取授权临时票据(code),向业务服务器发起登录请求。
-				let req = {
-					"apple": false,
-					"code": code
-				}
-				console.log(req);
-				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 {
-						uni.showLoading({
-							title: '登录中'
-						});
-						setTimeout(() => {
-							cacheManager.set('auth', res.data.loginVo)
-							if (res.data.loginVo.subjectId ==0 &&res.data.loginVo.levelId == 0) {
+		if (plus.runtime.isApplicationExist({
+				pname: 'com.tencent.mm',
+				action: 'weixin://'
+			})) {
+			console.log('111', "已安装微信");
+			uni.login({
+				"provider": "weixin",
+				"onlyAuthorize": true, // 微信登录仅请求授权认证
+				success: function(event) {
+					console.log(event);
+					const {
+						code
+					} = event
+					//客户端成功获取授权临时票据(code),向业务服务器发起登录请求。
+					let req = {
+						"apple": false,
+						"code": code
+					}
+					console.log(req);
+					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 {
+							uni.showLoading({
+								title: '登录中'
+							});
+							setTimeout(() => {
+								cacheManager.set('auth', res.data.loginVo)
+								if (res.data.loginVo.subjectId == 0 && res.data.loginVo
+									.levelId == 0) {
 
-								uni.redirectTo({
-									url: `/pages/selectGradesTerms/index`
-								})
-								uni.hideLoading();
-							} else {
+									uni.redirectTo({
+										url: `/pages/selectGradesTerms/index`
+									})
+									uni.hideLoading();
+								} else {
 
-								uni.redirectTo({
-									url: `/pages/study/index`
-								})
-								uni.hideLoading();
-							}
-						}, 1000)
-					}
-				}).catch((error) => {
-					console.log(error);
-				})
-			},
-			fail: function(err) {
-				console.log(err);
-				// 登录授权失败
-				// err.code是错误码
-			}
-		})
+									uni.redirectTo({
+										url: `/pages/study/index`
+									})
+									uni.hideLoading();
+								}
+							}, 1000)
+						}
+					}).catch((error) => {
+						console.log(error);
+					})
+				},
+				fail: function(err) {
+					console.log(err);
+					// 登录授权失败
+					// err.code是错误码
+				}
+			})
 		} else {
 			toast("请重启应用重试")
 			return false

+ 66 - 43
pages/study/index.vue

@@ -21,12 +21,14 @@
 		<egg-dialog ref="eggDialogRef" @eggBtn="eggBtn"></egg-dialog>
 		<catalogue ref="catalogueRef" :list=zhangList @change-zhang="handleChangeZhang"
 			@listSelectJieClick="listSelectJieClick"></catalogue>
-		<CustomTabBar :levelId="levelId" :currentTabNumber="0" :subjectId="subjectId" :typeId="typeId" :tipFlag="tipFlag">
+		<CustomTabBar :levelId="levelId" :currentTabNumber="0" :subjectId="subjectId" :typeId="typeId"
+			:tipFlag="tipFlag">
 		</CustomTabBar>
 		<tip-small-dialog ref="goPayDialogRef" @confirm-btn="goPayPage" :content="tipContent"></tip-small-dialog>
 		<tip-big-dialog ref="youkeDialogRef" @confirm-btn="ykConfirm" :imgShow="true"></tip-big-dialog>
 		<dao-tip-dialog ref="daoTipDialogRef" v-if="showDaoTip" :productTip="productTipImg"
 			@dao-tip-close="daoTipClose"></dao-tip-dialog>
+		<tip-dialog ref="tipDialogRef" :title="tipTitle" :content="tipContentVersion"></tip-dialog>
 	</view>
 </template>
 <script setup>
@@ -39,6 +41,9 @@
 		getCommonZhangInfo
 	} from "@/api/learnPlan.js"
 	import {
+		getVersion
+	} from "@/api/login.js"
+	import {
 		reactive,
 		ref,
 		nextTick,
@@ -63,6 +68,8 @@
 		useTabBarHistory
 	} from '@/utils/emitEvents.js';
 	import eggDialog from './eggDialog.vue'
+	import tipDialog from '@/components/dialog/tipDialog.vue';
+	import config from '../../config.js'
 	import {
 		toast,
 		getUserIdentity
@@ -81,8 +88,8 @@
 	const youkeImage = ref(null);
 	const currentProduct = ref(null);
 	const localAuth = ref(null);
-	const levelId = ref(null);//游客使用
-	const subjectId = ref(null);//游客使用
+	const levelId = ref(null); //游客使用
+	const subjectId = ref(null); //游客使用
 	const typeId = ref(null);
 	const zhangList = ref(null);
 	const gradeTerm = ref(null);
@@ -104,8 +111,16 @@
 	const showDaoTip = ref(true);
 	const productTipImg = ref('');
 
+
+	const version = config.appInfo.version;
+	const tipDialogRef = ref(null);
+	const tipTitle = '升级提醒';
+	const tipContentVersion = '您的APP不是最新版本,部分功能不能使用,请升级至最新版本!';
+
+
 	onLoad((options) => {
 		init(options);
+		getLoginInit()
 	})
 
 	function listSelectJieClick(item, data, index) {
@@ -120,16 +135,24 @@
 		listClick(data, item, index);
 	}
 
+	function getLoginInit() {
+		getVersion({}).then(res => {
+			if (version != res.data.version) {
+				tipDialogRef.value.handleShow();
+			}
+		})
+	}
+
 	function getProjectImg() {
-		if (currentProduct.value == 1 && typeId.value==2) {
+		if (currentProduct.value == 1 && typeId.value == 2) {
 			// 数学
 			productTipImg.value = 'static/images/study/shuxue/shuxue-tip.gif';
 			getBj('shuxue')
-		} else if (currentProduct.value == 2 && typeId.value==2) {
+		} else if (currentProduct.value == 2 && typeId.value == 2) {
 			// 英语
 			productTipImg.value = 'static/images/study/yingyu/yingyu-tip.gif'
 			getBj('yingyu');
-		}else if (currentProduct.value == 1 && typeId.value==1) {
+		} else if (currentProduct.value == 1 && typeId.value == 1) {
 			// 计算特训
 			productTipImg.value = 'static/images/study/jstx/jstx-tip.gif'
 			getBj('shuxueNew');
@@ -158,17 +181,17 @@
 	function daoTipClose() {
 		if (cacheManager.get('auth')) {
 			// 非游客 记缓存
-			if (currentProduct.value == 1 && typeId.value==2) {
+			if (currentProduct.value == 1 && typeId.value == 2) {
 				// 数学
 				cacheManager.updateObject('dao-tip', {
 					shuxue: 'has'
 				})
-			} else if (currentProduct.value == 2 && typeId.value==2) {
+			} else if (currentProduct.value == 2 && typeId.value == 2) {
 				// 英语
 				cacheManager.updateObject('dao-tip', {
 					yingyu: 'has'
 				})
-			}else if (currentProduct.value == 1 && typeId.value==1) {
+			} else if (currentProduct.value == 1 && typeId.value == 1) {
 				// 英语
 				cacheManager.updateObject('dao-tip', {
 					shuxueNew: 'has'
@@ -333,8 +356,8 @@
 		})
 	}
 
-	function goLookShipin(data, index) {
-	
+	function goLookShipin(data, index) {
+
 		if (!cacheManager.get('auth')) {
 			console.log('zhangList.value[0].jieList', zhangList.value[0].jieList);
 			console.log('zhangList.value[0].jieList.index', zhangList.value[0].jieList[index]);
@@ -346,39 +369,39 @@
 				tipFlag: tipFlag.value,
 				jieList: zhangList.value[0].jieList[index],
 				jieName: zhangList.value[0].jieList[index].jieName
-			}
-			
-			if(youkeData.typeId ==1){
-				if(!data.videoId){
-					toast("videoId 丢失!");
-					return false
-				}
-				uni.redirectTo({
-					url: '/pages/study/lookShipinNew?youkePageData=' + JSON.stringify(youkeData)
-				})
-			}else{
-				if(!data.videoId){
-					toast("videoId 丢失!");
-					return false
-				}
-				uni.redirectTo({
-					url: '/pages/study/lookShipin?youkePageData=' + JSON.stringify(youkeData)
-				})
+			}
+
+			if (youkeData.typeId == 1) {
+				if (!data.videoId) {
+					toast("videoId 丢失!");
+					return false
+				}
+				uni.redirectTo({
+					url: '/pages/study/lookShipinNew?youkePageData=' + JSON.stringify(youkeData)
+				})
+			} else {
+				if (!data.videoId) {
+					toast("videoId 丢失!");
+					return false
+				}
+				uni.redirectTo({
+					url: '/pages/study/lookShipin?youkePageData=' + JSON.stringify(youkeData)
+				})
 			}
 		} else {
-			if (typeId.value == 1) {
-				// 1新 2旧
-				if(!data.videoId){
-					toast("videoId 丢失!");
-					return false
+			if (typeId.value == 1) {
+				// 1新 2旧
+				if (!data.videoId) {
+					toast("videoId 丢失!");
+					return false
 				}
 				uni.redirectTo({
 					url: '/pages/study/lookShipinNew?jieId=' + data.jieId
 				})
-			} else {
-				if(!data.videoId){
-					toast("videoId 丢失!");
-					return false
+			} else {
+				if (!data.videoId) {
+					toast("videoId 丢失!");
+					return false
 				}
 				uni.redirectTo({
 					url: '/pages/study/lookShipin?jieId=' + data.jieId
@@ -396,7 +419,7 @@
 	function listClick(data, data2, index) {
 		console.log('data', data); // 节内容
 		console.log('data2', data2); //章内容
-		if (!cacheManager.get('auth') && data.firstFlag!=1) {
+		if (!cacheManager.get('auth') && data.firstFlag != 1) {
 			youkeDialogRef.value.handleShow();
 			return;
 		}
@@ -425,10 +448,10 @@
 		// 	cacheManager.updateObject('auth', {
 		// 		currentZhang: 0
 		// 	})
-		// }
-		uni.navigateTo({
-		  url: `/pages/selectGradesTerms/index?tipFlag=${tipFlag.value}&from=daoPage&productId=${levelId.value}&xuekeId=${subjectId.value}`
-		})
+		// }
+		uni.navigateTo({
+			url: `/pages/selectGradesTerms/index?tipFlag=${tipFlag.value}&from=daoPage&productId=${levelId.value}&xuekeId=${subjectId.value}`
+		})
 
 	}
 	// 游客弹窗---确定