zhengkaixin 3 år sedan
förälder
incheckning
52c7bf91e2

+ 10 - 0
apis/common.js

@@ -11,6 +11,15 @@ export function getBannerInfo(formData) {
 		
 	})
 }
+export function readMessageNum() {
+	return request({
+		url: '/mobile/messageApi/readMessageNum',
+		//data: formData,
+		method: 'post',
+		
+	})
+}
+
 export function getScreenList(formData) {
 	return request({
 		url: '/mobile/recruitmentApi/getScreenList',
@@ -19,6 +28,7 @@ export function getScreenList(formData) {
 		
 	})
 }
+
 //字典表
 export function getData(id) {
 	return request({

+ 14 - 3
components/TabbarHr.vue

@@ -11,6 +11,7 @@
 		name:"tabbarHr",
 		props:{
 			current: {
+				setIntervalId:"",
 				require: false,
 				default: 0,
 			},
@@ -32,6 +33,7 @@
 									iconPath: "chat",
 									selectedIconPath: "chat",
 										text: '消息',
+											count:0,
 										customIcon: false,
 										pagePath2:"/pages/hr/newsIndex/newsIndex",
 									},
@@ -47,7 +49,7 @@
 			
 		},methods:{
 			beforeSwitch(index){
-				
+				clearInterval(this.setIntervalId)
 				if(index==this.current){
 					return false
 				}
@@ -56,9 +58,18 @@
 					url: url
 				})
 				return true;
-			}
-			 
+			},
+			 getNum(){
+				 
+			 				 this.list[1].count=this.carhelp.get("tabbar_show_num")
+			 				
+			 }
 		},mounted(){
+			
+			this.getNum()
+			this.setIntervalId=setTimeout(()=>{
+				this.getNum()
+			},1000*2)
 				
 		},destroyed(){
 			

+ 15 - 4
components/TabbarJob.vue

@@ -11,6 +11,7 @@
 		name:"tabbarJob",
 		props:{
 			current: {
+				setIntervalId:'',
 				require: false,
 				default: 0,
 			},
@@ -19,6 +20,7 @@
 			return {
 				activeColor:"#5098FF",
 				 myCurrent:this.current,
+				 num:0,
 				list: [{
 										iconPath: "home",
 										selectedIconPath: "home",
@@ -39,6 +41,7 @@
 										selectedIconPath: "chat",
 										text: '消息',
 										customIcon: false,
+										count:0,
 										pagePath2:"/pages/job/newsIndex/newsIndex",
 									},
 									{
@@ -53,6 +56,7 @@
 			
 		},methods:{
 			beforeSwitch(index){
+				clearInterval(this.setIntervalId)
 				
 				if(index==this.current){
 					return false
@@ -62,12 +66,19 @@
 					url: url
 				})
 				return true;
-			}
-			 
-		},mounted(){
+			},
+			 getNum(){
+				 this.list[2].count=this.carhelp.get("tabbar_show_num")
 				
-		},destroyed(){
+			 }
+		},mounted(){
+			this.getNum()
+			this.setIntervalId= setInterval(()=>{
+				this.getNum()
+			},1000*2)
+		
 			
+		},destroyed(){
 		}
 		
 	}

+ 6 - 3
pages/hr/index/index.js

@@ -115,6 +115,8 @@ export default {
 					this.popupList=list.map((item)=>{
 						return item.name;
 					})
+					this.getBanner()
+					this.getList();
 				}).catch(error => {
 						uni.showToast({
 							
@@ -133,9 +135,10 @@ export default {
 			}
 			
 		},onReady(){ 
-			this.getBanner()
-			this.getList();
-			this.getScreenList();
+			
+			this.getScreenList();
+			
+		
 			this.isReady=true;
 		},onShow(){
 			if(this.isReady){

+ 17 - 2
pages/hr/newsIndex/index.js

@@ -61,13 +61,28 @@ import * as API from '@/apis/common.js'
 							})
 					})
 				 },
-				
+				getInfo(){
+								 
+								API.readMessageNum().then((response) => {
+									var a =response.data;
+									
+									this.carhelp.set("tabbar_show_num",a);
+									
+								}).catch(error => {
+										uni.showToast({
+											
+											title:error
+										})
+								})
+				},
 			},onReady(){ 
+					this.getInfo();
 				this.getList();
 				this.isReady=true;
 			},onShow(){
 				if(this.isReady){
-					
+						this.getInfo();
+						this.getList();
 				}	
 			},
 		}

+ 4 - 1
pages/hr/newsIndex/newsEntry/index.js

@@ -57,7 +57,10 @@ export default {
 			 	})
 			 	API.messageDetail(this.id).then((res)=>{
 			 		  this.info=res.data;
-					  this.companyId=this.info.company.id
+					  if(this.info.company){
+						  this.companyId=this.info.company.id
+						  
+					  }
 			 		 uni.hideLoading()		
 			 	 }).catch(error => {
 			 			uni.showToast({

+ 1 - 1
pages/hr/newsIndex/newsEntry/newsEntry.vue

@@ -1,6 +1,6 @@
 <template>
 	<view>
-		<CompanyInfo ref="refCompanyInfo" v-show="showcompany" :vshow="showcompany"   :companyId="companyId" :companyInfo="info.company"   @back="showcompany=false" ></CompanyInfo>
+		<CompanyInfo ref="refCompanyInfo" v-show="showcompany" :vshow="showcompany"   :companyId="companyId" :companyInfo="info.company"  v-if="info.company"  @back="showcompany=false" ></CompanyInfo>
 		
 		<view v-show="!showcompany">
 			<u-navbar title="详情"   >

+ 18 - 3
pages/job/newsIndex/index.js

@@ -57,13 +57,28 @@ export default {
 						})
 				})
 			 },
-			
-		},onReady(){ 
+			getInfo(){
+							 
+							API.readMessageNum().then((response) => {
+								var a =response.data;
+								
+								this.carhelp.set("tabbar_show_num",a);
+								
+							}).catch(error => {
+									uni.showToast({
+										
+										title:error
+									})
+							})
+			},
+		},onReady(){ 
+			this.getInfo();
 			this.getList();
 			this.isReady=true;
 		},onShow(){
 			if(this.isReady){
-				
+				this.getInfo();
+					this.getList();
 			}	
 		},
 	}

+ 2 - 0
utils/request.js

@@ -1,5 +1,6 @@
 import  carhelp from '@/utils/mixin.js'
 import requestSon from './requestSon.js';
+import requestNum from './requestNum.js';
 
 
 const request = (options) => {
@@ -66,6 +67,7 @@ const request = (options) => {
 				options.token=token
 				
 				var isson= requestSon(options)
+				requestNum(options);
 				resolve(isson);
 				 
 			} else  if(res.data.code == 415||(res.data.code == 200&&!res.data.data)||res.data.code == 400){

+ 59 - 0
utils/requestNum.js

@@ -0,0 +1,59 @@
+import  carhelp from '@/utils/mixin.js'
+
+//记录请求次数和响应次数
+let reqCount = 0,
+	resCount = 0;
+var baseUrl=process.car.BASE_URL;
+const request = (options) => {
+	var token=carhelp.getToken();
+	
+	reqCount++;
+	 
+	return new Promise((resolve, reject) => {
+		//如果特殊链接需要传入token
+		if(options&&options.token){
+			token=options.token;
+		}
+		uni.request({
+			method: 'post',
+			url: baseUrl + '/mobile/messageApi/readMessageNum',
+			//data: options.data?options.data:{},
+			
+			header: {
+				'Content-Type': 'application/x-www-form-urlencoded',
+				'X-Requested-With': 'XMLHttpRequest',
+				'Authorization':token
+			}
+		}).then((response) => {
+			//for(var t = Date.now(); Date.now() - t <= 2000;);
+			
+			resCount++
+			//防止连续请求多个接口时loading闪现
+			let [error, res] = response;
+			
+			
+			if (res.data.code != 200) {
+				reject(res.data.message)
+			} else {
+				if(!res.data.result){
+					uni.showToast({
+						title: res.data.message,
+						position:'bottom'
+					})
+					reject(res.data.message);
+				}else{
+					
+					carhelp.set("tabbar_show_num",res.data.data);
+					resolve(res.data);
+				}
+			
+			}
+		}).catch(error => {
+			resCount++
+		
+			let [err, res] = error;
+			reject(err)
+		})
+	});
+}
+export default request