Tang преди 3 години
родител
ревизия
e5cde232cb
променени са 4 файла, в които са добавени 186 реда и са изтрити 159 реда
  1. 0 1
      App.vue
  2. 16 3
      pages/index/index.vue
  3. 143 154
      pages/wd/index.vue
  4. 27 1
      store/index.js

+ 0 - 1
App.vue

@@ -10,7 +10,6 @@
 		},
 		methods: {
 	
-		
 		},
 		onShow: function() {
 

+ 16 - 3
pages/index/index.vue

@@ -7,12 +7,12 @@
 		</u-navbar>
 		<u-swiper :list="list" @change="e => current = e.current" :autoplay="false"></u-swiper>
 		<view class="content">
-			<view class="notice">
+			<view class="notice" v-if="infoNums">
 				<image src="/static/icon/msg_icon1.png" class="icon"></image>
 				<view class="text">
-					您有2条新的通知
+					您有{{infoNums}}条新的通知
 				</view>
-				<view class="btn">立即查看</view>
+				<view class="btn" @click="jumpPage">立即查看</view>
 			</view>
 			<view>
 				<!-- 日历-->
@@ -125,6 +125,7 @@ export default {
 	components: {},
 	data() {
 		return {
+			infoNums:0,
 			list:[
 				'https://cdn.uviewui.com/uview/swiper/swiper3.png',
 				'https://cdn.uviewui.com/uview/swiper/swiper2.png',
@@ -180,6 +181,15 @@ export default {
 			this.init()
 			this.isLogin = this.$method.isLogin()
 		}
+		if(this.isLogin){
+			this.$api.getinfoAttached().then(res => {
+				if(res.data.code ===200){
+					this.infoNums = res.data.data.informSum
+					const nums = res.data.data.informSum + res.data.data.orderSum + res.data.data.periodSum + res.data.data.planSum + res.data.data.subscribeSum;
+					this.$store.commit('tabNum', nums);
+				}
+			})
+		}
 	},
 	onShareAppMessage(res) {
 		var self = this;
@@ -189,6 +199,9 @@ export default {
 		};
 	},
 	methods: {
+		jumpPage(){
+			this.$navTo.togo('/pages2/msg/index')
+		},
 		//课程
 		courseList() {
 			var self = this;

+ 143 - 154
pages/wd/index.vue

@@ -1,22 +1,18 @@
 <template>
-<view >
-		<image mode="widthFix" :src="isLogin?'/static/wd_bg_login.jpg':'/static/wd_bg.jpg'" :class="isLogin?'login_full_img':'full_img'"></image>
-		
+	<view>
+		<image mode="widthFix" :src="isLogin ? '/static/wd_bg_login.jpg' : '/static/wd_bg.jpg'" :class="isLogin ? 'login_full_img' : 'full_img'"></image>
+
 		<view style="text-align: center;margin-top: 60rpx;" v-if="!isLogin">
-			<view style="color: #007AFF ;font-size: 36rpx;font-weight: bold;">
-				您还没有登录哦~
-			</view>
-			<view class="loginBtn" @click="jumpLogin">
-				立即登录/注册
-			</view>		
+			<view style="color: #007AFF ;font-size: 36rpx;font-weight: bold;">您还没有登录哦~</view>
+			<view class="loginBtn" @click="jumpLogin">立即登录/注册</view>
 		</view>
-		<view  v-if="isLogin" class="loginBox">
+		<view v-if="isLogin" class="loginBox">
 			<view style="width: 100%;height: 40px;background-color: #F0F1F5;position: fixed;top: 150px;z-index: 100;"></view>
 			<view style="display: flex;height: 160rpx;align-items: center; position: fixed;z-index: 999;top: 110px;" v-if="isLogin">
-				<image  :src="userInfo?$method.splitImgHost(userInfo.avatar, true):''" class="avatar"></image>
+				<image :src="userInfo ? $method.splitImgHost(userInfo.avatar, true) : ''" class="avatar"></image>
 				<view style="margin-left: 20rpx;z-index: 999;">
-					<view style="color: #FFFFFF;font-size: 36rpx;padding: 10rpx;">{{userInfo.realname}}</view>
-					<view style="color: #333333;font-size: 36rpx;padding: 10rpx;">{{userInfo.telphone}}</view>
+					<view style="color: #FFFFFF;font-size: 36rpx;padding: 10rpx;">{{ userInfo.realname }}</view>
+					<view style="color: #333333;font-size: 36rpx;padding: 10rpx;">{{ userInfo.telphone }}</view>
 				</view>
 				<view style="background-color: #F0F1F5;height:80rpx;"></view>
 			</view>
@@ -27,7 +23,9 @@
 						<view>学习计划</view>
 					</view>
 					<view>
-						今天有 <text style="color: #007AFF;margin: 0 5rpx;">{{userNums.planSum}}</text> 个学习任务
+						今天有
+						<text style="color: #007AFF;margin: 0 5rpx;">{{ userNums.planSum }}</text>
+						个学习任务
 					</view>
 				</navigator>
 				<view class="two_menu">
@@ -46,25 +44,29 @@
 						<view>我的学时</view>
 					</view>
 					<view>
-						累计<text style="color: #007AFF;margin: 0 5rpx;">{{userNums.periodSum}}</text> 学时未通过
+						累计
+						<text style="color: #007AFF;margin: 0 5rpx;">{{ userNums.periodSum }}</text>
+						学时未通过
 					</view>
 				</navigator>
-				<navigator url="/pages2/exam/index"  class="menu_box">
+				<navigator url="/pages2/exam/index" class="menu_box">
 					<view style="display: flex;align-items: center;">
 						<image src="/static/icon/my_icon7.png" class="my_icon"></image>
 						<view>我的考试</view>
 					</view>
 					<view>
-						<text style="color: #007AFF;margin: 0 5rpx;">{{userNums.subscribeSum}}</text>考试预约
+						<text style="color: #007AFF;margin: 0 5rpx;">{{ userNums.subscribeSum }}</text>
+						考试预约
 					</view>
 				</navigator>
-				<navigator url="/pages2/order/index"  class="menu_box">
+				<navigator url="/pages2/order/index" class="menu_box">
 					<view style="display: flex;align-items: center;">
 						<image src="/static/icon/my_icon7.png" class="my_icon"></image>
 						<view>我的订单</view>
 					</view>
 					<view>
-						<text style="color: #007AFF;margin: 0 5rpx;">{{userNums.orderSum}}</text>笔待支付
+						<text style="color: #007AFF;margin: 0 5rpx;">{{ userNums.orderSum }}</text>
+						笔待支付
 					</view>
 				</navigator>
 				<navigator url="/pages2/msg/index" class="menu_box">
@@ -73,7 +75,8 @@
 						<view>我的消息</view>
 					</view>
 					<view>
-						<text style="color: #007AFF;margin: 0 5rpx;">{{userNums.informSum}}</text>条未读
+						<text style="color: #007AFF;margin: 0 5rpx;">{{ userNums.informSum }}</text>
+						条未读
 					</view>
 				</navigator>
 				<navigator url="/pages2/wd/info" class="menu_box">
@@ -81,154 +84,140 @@
 						<image src="/static/icon/my_icon9.png" class="my_icon"></image>
 						<view>我的资料</view>
 					</view>
-					
 				</navigator>
-				<view style="color: #999999;text-align: center;font-size: 32rpx;margin-top: 50rpx;" @click="logout">
-					退出
-				</view>
+				<view style="color: #999999;text-align: center;font-size: 32rpx;margin-top: 50rpx;" @click="logout">退出</view>
 			</view>
-			
 		</view>
-		
+
 		<u-navbar :is-back="false" title="我的" :border-bottom="false" background="{ background: '#ffffff',opacity:0.4; }" title-color="#ffffff" back-icon-color="#ffffff">
-			<view class="slot-wrap">
-				<image  src="/static/logo.png" style="width: 178rpx;height: 31rpx;margin-left: 30rpx;"></image>
-			</view>
+			<view class="slot-wrap"><image src="/static/logo.png" style="width: 178rpx;height: 31rpx;margin-left: 30rpx;"></image></view>
 		</u-navbar>
 	</view>
 </template>
 
 <script>
-
-	import {mapGetters} from 'vuex';
-	export default {
-		components: {
-			
-		},
-		data() {
-			return {
-				list:[23,24,25,26,27,28,29],
-				content:'此功能暂未开放',
-				show:false,
-				isLogin:false,
-				userNums:{}
-			}
-		},
-		onLoad() {
-
-		},
-		onShow(){
-			this.isLogin = this.$method.isLogin()
-			this.getNums()
+import { mapGetters } from 'vuex';
+export default {
+	components: {},
+	data() {
+		return {
+			list: [23, 24, 25, 26, 27, 28, 29],
+			content: '此功能暂未开放',
+			show: false,
+			isLogin: false,
+			userNums: {}
+		};
+	},
+	onLoad() {},
+	onShow() {
+		this.isLogin = this.$method.isLogin();
+		this.getNums();
+		// this.$store.dispatch('changeTabsNum')
+	},
+	methods: {
+		getNums() {
+			this.$api.getinfoAttached().then(res => {
+				if (res.data.code === 200) {
+					this.userNums = res.data.data;
+					const nums = res.data.data.informSum + res.data.data.orderSum + res.data.data.periodSum + res.data.data.planSum + res.data.data.subscribeSum;
+					this.$store.commit('tabNum', nums);
+				}
+			});
 		},
-		methods: {
-			getNums(){
-				this.$api.getinfoAttached().then(res => {
-					if(res.data.code ===200){
-						this.userNums = res.data.data
-					}
-				})
-			},
-			logout(){
-				console.log(343)
-				this.$method.isLogout()
-				this.isLogin = this.$method.isLogin()
-				uni.reLaunch({
-					url:'/pages/index/index'
-				})
-			},
-			jumpLogin(){
-				this.$navTo.togo('/pages/login/login');
-				
-			}
-			
+		logout() {
+			console.log(343);
+			this.$method.isLogout();
+			this.isLogin = this.$method.isLogin();
+			uni.reLaunch({
+				url: '/pages/index/index'
+			});
 		},
-		computed: {...mapGetters(['userInfo'])}
-	}
+		jumpLogin() {
+			this.$navTo.togo('/pages/login/login');
+		}
+	},
+	computed: { ...mapGetters(['userInfo']) }
+};
 </script>
 <style>
-	::-webkit-scrollbar{
-		width: 0;
-		height: 0;
-		color: transparent;
-	}
-	page{
-		background-color: #F0F1F5;
-	}
+::-webkit-scrollbar {
+	width: 0;
+	height: 0;
+	color: transparent;
+}
+page {
+	background-color: #f0f1f5;
+}
 </style>
 <style scoped>
-	.avatar{
-		height: 70rpx;
-		width: 70rpx;
-		border-radius: 50%;
-		
-	}
-	.small_menu{
-		width: 45%;
-		height: 104rpx;
-		background: #FFFFFF;
-		border-radius: 24rpx;
-		display: flex;
-		align-items: center;
-		padding-left: 20rpx;
-		margin-top: 30rpx;
-	}
-	.two_menu{
-		display: flex;
-		justify-content:space-between;
-	}
-	.my_icon{
-		width: 56rpx;
-		height: 56rpx;
-		margin-right: 20rpx;
-	}
-	.menu_box{
-		
-		height: 104rpx;
-		background: #FFFFFF;
-		border-radius: 24rpx;
-		margin-top: 30rpx;
-		display: flex;
-		align-items: center;
-		padding: 0 20rpx;
-		justify-content:space-between;
-		color: #666666;
-		font-size: 32rpx;
-	}
-	.loginBox{
-		position: relative;
+.avatar {
+	height: 70rpx;
+	width: 70rpx;
+	border-radius: 50%;
+}
+.small_menu {
+	width: 45%;
+	height: 104rpx;
+	background: #ffffff;
+	border-radius: 24rpx;
+	display: flex;
+	align-items: center;
+	padding-left: 20rpx;
+	margin-top: 30rpx;
+}
+.two_menu {
+	display: flex;
+	justify-content: space-between;
+}
+.my_icon {
+	width: 56rpx;
+	height: 56rpx;
+	margin-right: 20rpx;
+}
+.menu_box {
+	height: 104rpx;
+	background: #ffffff;
+	border-radius: 24rpx;
+	margin-top: 30rpx;
+	display: flex;
+	align-items: center;
+	padding: 0 20rpx;
+	justify-content: space-between;
+	color: #666666;
+	font-size: 32rpx;
+}
+.loginBox {
+	position: relative;
 
-		padding:0 30rpx;
-		
-	}
-	.avatar{
-		width: 80px;
-		height: 80px;
-	}
-	.login_full_img {
-		display: block;
-		width: 100%;
-		height: 150px !important;
-		z-index: 300;
-		top: 0;
-		position: fixed;
-	}
-	.full_img {
-		display: block;
-		width: 100%;
-		z-index: -999;
-		top: 0;
-	}
-	.loginBtn{
-		width: 526rpx;
-		height: 80rpx;
-		background: linear-gradient(90deg, #015EEA, #00C0FA);
-		box-shadow: 0rpx 10rpx 16rpx 4rpx rgba(1, 99, 235, 0.04);
-		border-radius: 40rpx;
-		color: #FFFFFF;
-		line-height: 80rpx;
-		margin: 0 auto;
-		margin-top: 50rpx;
-	}
-	
+	padding: 0 30rpx;
+}
+.avatar {
+	width: 80px;
+	height: 80px;
+}
+.login_full_img {
+	display: block;
+	width: 100%;
+	height: 150px !important;
+	z-index: 300;
+	top: 0;
+	position: fixed;
+}
+.full_img {
+	display: block;
+	width: 100%;
+	z-index: -999;
+	top: 0;
+}
+.loginBtn {
+	width: 526rpx;
+	height: 80rpx;
+	background: linear-gradient(90deg, #015eea, #00c0fa);
+	box-shadow: 0rpx 10rpx 16rpx 4rpx rgba(1, 99, 235, 0.04);
+	border-radius: 40rpx;
+	color: #ffffff;
+	line-height: 80rpx;
+	margin: 0 auto;
+	margin-top: 50rpx;
+}
 </style>

+ 27 - 1
store/index.js

@@ -61,9 +61,22 @@ const store = new Vuex.Store({
 		playSectionId: state => {
 			return state.playSectionId
 		},
-		getCopyData: state => state.copyData
+		getCopyData: state => state.copyData,
 	},
 	mutations: {
+		tabNum(state, nums) {
+			if (nums) {
+				uni.setTabBarBadge({
+					index: 3,
+					text: nums + ''
+				})
+			} else {
+				uni.removeTabBarBadge({
+					index: 3
+				})
+			}
+
+		},
 		updataCopyData(state, objs) {
 			state.copyData = objs
 		},
@@ -82,6 +95,19 @@ const store = new Vuex.Store({
 		setPlaySectionId(state, provider) {
 			state.playSectionId = provider.playSectionId;
 		},
+	},
+	actions: {
+		changeTabsNum({
+			commit
+		}) {
+			api.getinfoAttached().then(res => {
+				if (res.data.code === 200) {
+					const nums = res.data.data.informSum + res.data.data.orderSum + res.data.data
+						.periodSum + res.data.data.planSum + res.data.data.subscribeSum
+					commit('tabNum', nums)
+				}
+			})
+		}
 	}
 })
 async function getUserInfo(state) {