liyangzheng 2 anni fa
parent
commit
fe3389490d

+ 35 - 0
main.js

@@ -3,9 +3,15 @@ import App from './App'
 import store from './store' // store
 import plugins from './plugins' // plugins
 import './permission' // permission
+import {refreshToken} from "@/api/login";
 // import uView from 'uview-ui'
 import uView from '@/uni_modules/uview-ui'
 import $ from '@/pages/common/fun.js'
+import {	
+	getRefreshToken,	
+	getExpiresTime,
+	setToken
+} from '@/utils/auth'
 // 在main.js中注册全局组件
 import isLodingModel from './components/loading/loading.vue'
 Vue.component('isLodingModel', isLodingModel)
@@ -22,6 +28,35 @@ const app = new Vue({
 	...App
 })
 app.$mount()
+var rsing=0
+rs()
+
+function rs(){
+	const nowTime = new Date().getTime()
+	if (rsing==0 && nowTime > (getExpiresTime()-10*1000)) {
+		rsing=1
+		console.log("===rs call")
+		refreshToken({
+			refreshToken: getRefreshToken()
+		}).then((res) => {
+			console.log(res.data, 'ressss')
+			setToken(res.data)
+			rsing=0
+		}).catch(() => {
+			/*
+			showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => {
+				if (res.confirm) {
+					uni.navigateTo({
+						url: '/pages/login'
+					})
+				}
+			})*/
+		})
+	}
+	 setTimeout(function(){
+		 rs()
+	 },1*1000)
+}
 // #ifdef H5
 Vue.mixin({
     mounted() {

+ 0 - 6
pagesA/fire/check_active/add_check/add_check.vue

@@ -353,7 +353,6 @@
 		},
 		// 在 vue页面,向起始页通过事件传递数据
 		onLoad: function(option) {
-			console.log(option, 'mmmmmmmmm');
 			this.formDataChuangMu.taskType = option.type
 			if (option.id) {
 				this.bianji = true
@@ -366,7 +365,6 @@
 				getCheckActiveTaskXin({
 					id: ids
 				}).then(response => { //获取编辑主动检查的数据
-					console.log(response, 'responseresponse');
 					const res = response.data
 					this.formData.taskName = res.taskInfo.taskName
 					this.formData.taskContent = res.taskInfo.taskContent
@@ -478,7 +476,6 @@
 			checkboxConfirm2() {
 				this.checkboxShow2 = false
 				let arr = []
-				console.log(this.checkedList2, 'this.checkedList2');
 				this.checkedList2.map(v => {
 					v.map(i => {
 						arr.push(i)
@@ -717,14 +714,12 @@
 						getCheckActiveTaskXin({
 							id: this.formDataChuangMu["id"]
 						}).then(response => { //获取编辑主动检查单位的数据                
-							console.log(response, 'ressss');
 							const res = response.data
 							for (let g in this.list2) {
 								// g.map(v => { //进入编辑界面以前勾选的检查项把他放进this.list.orgList中添加一个checkedList
 								this.list2[g].map(i => {
 									// i.orgDOList.map(listK => {
 									if (i.id == this.list2[g].id) {
-										console.log(i, '[i.id][i.id][i.id]', this.list2);
 										this.list2[g].checkedList2 = [i.id]
 
 									}
@@ -759,7 +754,6 @@
 			},
 			cancelNew() { //取消发布--暂存
 				this.showNew = false
-				console.log(this.formDataChuangMu.taskType, 'this.formDataChuangMu.taskType');
 				setTimeout(() => {
 					setTimeout(() => {
 						uni.redirectTo({

+ 0 - 16
pagesA/fire/check_active/check_implement/check_implement.vue

@@ -382,7 +382,6 @@
 				i.name = i.label;
 				i.id = i.value;
 			});
-			console.log(this.choiceDanger, 'this.choiceDanger');
 			this.type = option.type ? option.type : ''
 			that = this;
 			const eventChannel = this.getOpenerEventChannel();
@@ -400,7 +399,6 @@
 				if (that.newtableDatas && that.newtableDatas[0][option.broadId]) { //获取本地缓存的数据
 					that.tableData = that.newtableDatas[0][option.broadId]
 					that.tableData.map(i => i.choiceDanger = that.choiceDanger)
-					console.log(that.tableData, 'that.tableData');
 					that.insTypeData = uni.getStorageSync('insTypeData')
 
 				} else {
@@ -488,7 +486,6 @@
 			//扫码
 			erWeiMa(checkTableDataIds, index) {
 				// #ifdef H5
-				console.log(this.tableData[index], '	this.tableData[index].');
 				this.tableData[index].qrcodeShow = true
 				this.$forceUpdate()
 				this.onDecodeIndex = index
@@ -506,9 +503,7 @@
 							if (that.tableData[index].hisFpdCreateReqVOList.length > 0) {
 								var temp = that.tableData[index].hisFpdCreateReqVOList
 								// console.log(temp);
-								console.log("result.id: ", result.id);
 								temp = temp.filter(i => i.id == result.id)
-								console.log("temp: ", temp);
 								if (temp.length > 0) {
 									this.tableData[this.onDecodeIndex].qrcodeShow = false
 									return that.$modal.alert('该设备已检查')
@@ -517,7 +512,6 @@
 
 							//调接口,会传过来id标识,失败显示错误信息,比如该设备不存在,成功的花弹出扫码成功
 							inspTypeList(JSON.parse(res.result)).then(reponse => {
-								console.log(reponse, 'reponsesssssssssssssss');
 								if (reponse.code == 0) {
 									that.maShow = true
 									that.insTypeData = reponse.data.records
@@ -580,7 +574,6 @@
 
 			},
 			closeImage(item, val, k) { //删除图片
-				console.log(item, 'ddd');
 				if (item.inspType == 'fpd') {
 					this.insTypeData[k].attUrl.splice(val, 1)
 				}else{
@@ -671,7 +664,6 @@
 				let arrs = new Array()
 				this.saveImplement.inspectList.map((i, index) => {
 					if (i.inspType != 'fpd') {
-						console.log('12222');
 						arrs[index] = new Array()
 						i.inspectResultList.map((k, indexs) => {
 							arrs[index][indexs] = new Array(i.inspectResultList.length)
@@ -704,7 +696,6 @@
 				if (!this.show && !this.show3 && !this.show4) { //屏蔽未检查校验2
 					if (!this.show) {
 						// 巡查未完成判断
-						console.log(this.saveImplement, '1111111111111111');
 						checkSubmitRelease(JSON.stringify(this.saveImplement)).then(response => {
 							if (response.data) {
 								uni.showToast({
@@ -730,7 +721,6 @@
 			shuJu() {
 				this.saveImplement.inspectList = this.tableData
 				this.saveImplement.taskId = this.formData.id
-				console.log(this.saveImplement, 'this.saveImplementthis.saveImplement');
 			},
 			// 获取数据
 			getData(pageNo, value = '') {
@@ -758,7 +748,6 @@
 							// ----隐患
 						})
 					}
-					console.log(this.tableData, 'this.tableData');
 				});
 				// this.newInsTypeData.map(i => {
 				// 	i.attUrl = []
@@ -810,7 +799,6 @@
 				if (NorinspectResultList.includes(1)) { //如果互斥的数组存在true  normal!=1的数组
 					if (tableItem.id == this.nnorNormalValue) { //当点击的是value == this.nnorNormalValue是
 						this.tableData[index].inspectResultList.map((i, kindex) => {
-							console.log(i.id, this.nnorNormalValue, 'llllllllo');
 							if (i.id != this.nnorNormalValue) {
 								i.subValue = 0
 								this.show2 = false
@@ -949,7 +937,6 @@
 							this.insTypeData.map(k => {
 								k.attUrl = []
 							})
-							console.log(this.tableData, '111111');
 							this.maShow = false
 
 							// }
@@ -1034,9 +1021,6 @@
 													that.loading = false
 													let imgUrl = JSON.parse(res
 														.data)
-													console.log(val.inspType,
-														'val.inspTyp', val
-														.fpdType);
 													// that.imageList.push(imgUrl.data)
 													if (!val.fpdType && val
 														.inspType != 'fpd') {

+ 0 - 3
pagesA/fire/check_active/check_list/check_list.vue

@@ -213,7 +213,6 @@
 			}
 		},
 		onLoad(options) {
-			console.log(options, 'options');
 			this.history = options.history ? options.history : ''
 			this.current = options.current ? options.current : ''
 			that = this;
@@ -313,7 +312,6 @@
 			},
 			//去完成
 			addClickModify(val) {
-				console.log(val, 'valvalvlavla');
 				uni.navigateTo({
 					url: `/pagesA/fire/check_active/check_implement/check_implement?id=${val}&broadId=${this.broaId}`,
 					success: function(res) {
@@ -334,7 +332,6 @@
 				}).then(response => {
 					// 为数据赋值:通过展开运算符的形式,进行新旧数据的拼接
 					this.tableData = response.data
-					console.log(this.tableData, 'tableData');
 					this.times = this.tableData.taskInfo ? shijianc(this.tableData.taskInfo.publishTime) : ''
 					getempnamebyuserid({
 						userId: this.tableData.taskInfo.receiver

+ 5 - 4
pagesA/fire/fire_station/people_fireStation/people_fireStation.vue

@@ -46,7 +46,11 @@
 				</u-form-item> -->
 				<u-form-item class="antherStyle">
 					<p style="width: 150rpx;">人员类型</p>
+<<<<<<< HEAD
 					<uni-data-select v-model="person.power" :localdata="selectType" @change="change"></uni-data-select>
+=======
+					<uni-data-select v-model="person.worker" :localdata="range" @change="change"></uni-data-select>
+>>>>>>> bdbe9533586d59f8b53dd7c46d65e08d66f11643
 				</u-form-item>
 				<u-form-item>
 					<u-button type="primary" @click="addSure" class="antherBtn">提交</u-button>
@@ -168,7 +172,6 @@
 					fphone: '',
 					fworker: '',
 					fuserNum: '',
-					fpower: '',
 				},
 				editPeopleId: '', //需要修改人员的id
 				nameRules: false, //对name的正则验证
@@ -203,7 +206,6 @@
 						userNum: '',
 						phone: '',
 						worker: '',
-						power: '',
 						// 其他字段
 					};
 					this.membersList.push(newPerson);
@@ -228,9 +230,8 @@
 				if (this.$route.query.addId) {
 					if (!this.userRules && !this.phoneRules && !this.nameRules) {
 						creatFirePeople({
-							duty: this.membersList[0].power,
 							empName: this.membersList[0].name,
-							// empType: this.membersList[0].worker,
+							empType: this.membersList[0].worker,
 							idcardno: this.membersList[0].userNum,
 							microstationid: this.fireStationId - 0,
 							mobile: this.membersList[0].phone,

+ 5 - 2
utils/auth.js

@@ -1,5 +1,6 @@
 const AccessTokenKey = 'ACCESS_TOKEN'
 const RefreshTokenKey = 'REFRESH_TOKEN'
+const EXPIRESTIME = 'EXPIRES_TIME'
 
 // ========== Token 相关 ==========
 
@@ -10,13 +11,15 @@ export function getAccessToken() {
 
 export function getRefreshToken() {
   return uni.getStorageSync(RefreshTokenKey)
-   // return uni.getStorageSync(AccessTokenKey)
 }
-
+export function getExpiresTime() {
+  return uni.getStorageSync(EXPIRESTIME)
+}
 export function setToken(token) {
 	console.log(token,'tokentoken');
   uni.setStorageSync(AccessTokenKey, token.accessToken)
   uni.setStorageSync(RefreshTokenKey, token.refreshToken)
+   uni.setStorageSync(EXPIRESTIME, token.expiresTime)
 }
 
 export function removeToken() {

+ 15 - 27
utils/request.js

@@ -3,7 +3,8 @@ import config from '@/config'
 import {
 	getAccessToken,
 	getRefreshToken,
-	setToken
+	setToken,
+	getExpiresTime
 } from '@/utils/auth'
 import {
 	refreshToken
@@ -17,16 +18,14 @@ import {
 
 let timeout = 10000
 const baseUrl = config.baseUrl + config.baseApi;
-
-
-
-const request = config => {
-
+let isRefresh = false
+const request = async (config) => {
 	// 是否需要设置 token
 	const isToken = (config.headers || {}).isToken === false
 	config.header = config.header || {}
-	if (getAccessToken() && !isToken) {
-		config.header['Authorization'] = 'Bearer ' + getAccessToken()
+	var hastoken=getAccessToken()
+	if ( hastoken!=null && !isToken) {
+		config.header['Authorization'] = 'Bearer ' + hastoken
 	}
 	// 设置租户 TODO 芋艿:强制 1 先
 	config.header['tenant-id'] = '1';
@@ -55,24 +54,13 @@ const request = config => {
 				const code = res.data.code || 200
 				const msg = errorCode[code] || res.data.msg || errorCode['default']
 				if (code === 401) {
-					// 判断是否已经刷新过 token
-					refreshToken({
-							refreshToken: getRefreshToken()
-						})
-						.then((res) => {
-							setToken(res.data)
-							config.header['Authorization'] = 'Bearer ' + res.data.accessToken
-						})
-						.catch(() => {
-							showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => {
-								if (res.confirm) {
-									uni.navigateTo({
-										url: '/pages/login'
-									})
-								}
-							});
-							reject('无效的会话,或者会话已过期,请重新登录。');
-						})
+					showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => {
+						if (res.confirm) {
+							uni.navigateTo({
+								url: '/pages/login'
+							})
+						}
+					});
 				} else if (code === 500) {
 					toast(msg)
 					reject('500')
@@ -99,4 +87,4 @@ const request = config => {
 	})
 }
 
-export default request
+export default request