Browse Source

校园打卡定位逻辑修改

xiaoxin 2 years ago
parent
commit
d9c80afdd0

+ 50 - 19
pagesClockIn/home/home.vue

@@ -208,7 +208,7 @@ export default {
 				uni.setStorageSync('userInfo', this.userInfo)
 				if (this.userInfo.roles) {
 					let temList = []
-					this.userInfo.roles.forEach(ele => {
+					this.userInfo.roles.forEach((ele) => {
 						temList.push(ele.id)
 					})
 					let flag = temList.includes('2' || 2)
@@ -237,12 +237,51 @@ export default {
 		},
 		// 获取当前定位位置信息
 		getLocationData() {
+			uni.getSetting({
+				success: (res) => {
+					if (!res.authSetting['scope.userLocation']) {
+						uni.authorize({
+							scope: 'scope.userLocation',
+							success: (res) => {
+								// 授权成功
+								this.getAddress()
+							},
+							fail: () => {
+								uni.showModal({
+									content: '获取定位权限失败将会影响使用部分功能,是否去设置打开?',
+									confirmText: '确认',
+									cancelText: '取消',
+									success: (res) => {
+										if (res.confirm) {
+											uni.openSetting({
+												success: (res) => {
+													console.log(res)
+													this.getLocationData()
+												}
+											})
+										} else {
+											uni.showToast({
+												title: '获取定位权限失败',
+												icon: 'none'
+											})
+										}
+									}
+								})
+							}
+						})
+					} else {
+						this.getAddress()
+					}
+				}
+			})
+		},
+		getAddress() {
 			uni.showLoading({
 				title: '定位中,请稍后',
 				mask: true
 			})
 			qqmapsdk.reverseGeocoder({
-				success: res => {
+				success: (res) => {
 					// console.log(res);
 					if (res.status == 0) {
 						// 获取详细地址信息 经纬度
@@ -258,22 +297,14 @@ export default {
 						})
 					}
 				},
-				fail: error => {
-					uni.showModal({
-						title: '提示',
-						content: '请先开启定位权限,否则将无法使用定位功能',
-						cancelText: '不授权',
-						confirmText: '授权',
-						success: function(res) {
-							if (res.confirm) {
-								uni.openSetting({
-									success(res) {}
-								})
-							} else if (res.cancel) {
-								uni.redirectTo({
-									url: '/pagesClockIn/index/index'
-								})
-							}
+				fail: (error) => {
+					uni.getLocation({
+						type: 'gcj02',
+						success: (res) => {
+							this.myLat = res.latitude
+							this.myLng = res.longitude
+							this.address = '未知地址'
+							this.getRulesList()
 						}
 					})
 				}
@@ -315,7 +346,7 @@ export default {
 				else {
 					if (this.contrastObj.locations.length) {
 						let temList = []
-						temList = this.contrastObj.locations.map(ele => {
+						temList = this.contrastObj.locations.map((ele) => {
 							this.centerLat = ele.lat
 							this.centerLng = ele.lng
 							this.radius = ele.radius

+ 7 - 7
pagesRepairs/evaluate/evaluate.vue

@@ -47,13 +47,13 @@ export default {
 				})
 				return
 			}
-			if (!this.textareaValue) {
-				uni.showToast({
-					title: '请输入服务评价',
-					icon: 'none'
-				})
-				return
-			}
+			// if (!this.textareaValue) {
+			// 	uni.showToast({
+			// 		title: '请输入服务评价',
+			// 		icon: 'none'
+			// 	})
+			// 	return
+			// }
 
 			const res = await this.$myRequest_repairs({
 				url: '/repairEvaluate/insertRepairEvaluate',

+ 5 - 4
pagesRepairs/home/home.vue

@@ -173,7 +173,7 @@ export default {
 				},
 				extra: {
 					bar: {
-						width: 15,
+						width: 10,
 						activeBgColor: '#000000',
 						activeBgOpacity: 0.08,
 						linearType: 'custom',
@@ -265,7 +265,8 @@ export default {
 				data: {
 					currentPage: this.currentPage,
 					pageCount: this.pageCount,
-					schoolId: this.schoolId
+					schoolId: this.schoolId,
+					userId: this.btns.includes('表格编辑') ? '' : this.userId
 				}
 			})
 			// console.log(res)
@@ -614,7 +615,7 @@ export default {
 		margin: 0 auto 100rpx;
 		padding: 0 30rpx;
 		width: 690rpx;
-		height: 745rpx;
+		height: 945rpx;
 		border-radius: 10rpx;
 		box-shadow: 0px 0px 4rpx rgba(0, 0, 0, 0.25);
 
@@ -638,7 +639,7 @@ export default {
 			right: 30rpx;
 			bottom: 0;
 			width: 630rpx;
-			height: 650rpx;
+			height: 850rpx;
 		}
 	}
 

+ 4 - 1
pagesRepairs/index/index.vue

@@ -50,9 +50,11 @@ export default {
 		hasUserInfo() {
 			const repairsUserInfo = uni.getStorageSync('repairsUserInfo')
 			const openId = uni.getStorageSync('openId')
+			const college = uni.getStorageSync('college')
 			// console.log(repairsUserInfo)
 			// console.log(openId)
-			if (repairsUserInfo && openId) {
+			// console.log(college)
+			if (repairsUserInfo && openId && college) {
 				uni.setStorageSync('currentIndexRepairs', 0)
 				uni.reLaunch({
 					url: '/pagesRepairs/box/box'
@@ -84,6 +86,7 @@ export default {
 			// console.log(res)
 			if (res.code === '200') {
 				uni.setStorageSync('repairsUserInfo', res.data)
+				uni.setStorageSync('college', res.data.college)
 				uni.setStorageSync('currentIndexRepairs', 0)
 				this.getOpenId()
 			}

+ 280 - 26
pagesRepairs/management/management.vue

@@ -106,6 +106,12 @@
 					<view class="box_type" v-if="item.maintenanceTimeout">维修超时</view>
 				</view>
 
+				<!-- 部门 -->
+				<view class="item_box" v-if="item.userClass">
+					<view class="box_key">部门:</view>
+					<view class="box_value">{{ item.userClass }}</view>
+				</view>
+
 				<!-- 报修电话 -->
 				<view class="item_box">
 					<view class="box_key">报修电话:</view>
@@ -157,7 +163,7 @@
 				</view>
 
 				<!-- 维修师傅 -->
-				<view class="item_time" v-if="item.state !== '待接单' && item.state !== '待确认' && item.maintenancerName">
+				<view class="item_time" v-if="item.maintenancerName">
 					<view class="time_msg">
 						维修师傅:
 						<text>{{ item.maintenancerName }}</text>
@@ -165,7 +171,7 @@
 				</view>
 
 				<!-- 师傅电话 -->
-				<view class="item_box" v-if="item.state !== '待接单' && item.state !== '待确认' && item.maintenancerPhone">
+				<view class="item_box" v-if="item.maintenancerPhone">
 					<view class="box_key">师傅电话:</view>
 					<view class="box_value phone" @click.stop="handleCallPhone(item.maintenancerPhone)">
 						{{ item.maintenancerPhone }}
@@ -218,17 +224,34 @@
 			<!-- 关闭按钮弹窗 -->
 			<uni-popup ref="popup_close" :is-mask-click="false">
 				<view class="popup_close">
-					<view
-						:class="[{ active: activeIndex === index }, { radius: index === 0 }]"
-						class="close_box"
-						v-for="(ele, index) in closeList"
-						:key="ele.id"
-						@click="handleChangeItem(index)"
-					>
-						{{ ele.name }}
+					<view class="close_reason">
+						关单原因:
+						<picker @change="bindPickerChange" :value="activeIndex" :range="closeList" range-key="name">
+							<view class="picker_input">
+								{{ closeList[activeIndex].name }}
+								<img src="../../static/images/repairsImg/bottom.png" />
+							</view>
+						</picker>
+					</view>
+
+					<view class="close_note">备注(二选一):</view>
+
+					<view class="close_voice">
+						<view class="voice_box" v-if="!recordingPath" @click="handleRecording">
+							<img src="../../static/images/repairsImg/voice.png" />
+						</view>
+						<view v-if="!recordingPath" @click="handleRecording">点击录音</view>
+						<view class="item_recording" v-if="recordingPath" @click="handlePlayRecordingPop">
+							<img :src="recordingImg" />
+							{{ recordingTime }}″
+						</view>
+						<view class="recording_icon" v-if="recordingPath" @click="handleDeleteRecording">×</view>
 					</view>
+
+					<textarea class="close_input" placeholder-style="color:#CCCCCC" placeholder="请输入备注" v-model="closeNote"></textarea>
+
 					<view class="close_btn">
-						<view class="btn_box cancel" @click="$refs.popup_close.close()">取消</view>
+						<view class="btn_box cancel" @click="handleCloseCancel">取消</view>
 						<view class="btn_box confirm" @click="handleCloseConfirm">确定</view>
 					</view>
 				</view>
@@ -277,6 +300,13 @@
 					</view>
 				</view>
 			</uni-popup>
+
+			<!-- 录音弹窗区域 -->
+			<uni-popup :safe-area="true" background-color="#fff" ref="popup_recording">
+				<view class="popup_recording">
+					<recording @getTempFilePath="getTempFilePath" />
+				</view>
+			</uni-popup>
 		</view>
 
 		<!-- 没有数据时展示的图片 -->
@@ -288,8 +318,12 @@
 </template>
 
 <script>
+import recording from '../components/recording.vue'
 const innerAudioContext = uni.createInnerAudioContext()
 export default {
+	components: {
+		recording
+	},
 	data() {
 		return {
 			scrollY: true,
@@ -338,7 +372,19 @@ export default {
 			// 订单状态参数
 			state: 1,
 			// 订单id
-			orderId: ''
+			orderId: '',
+			// 关闭订单备注
+			closeNote: '',
+			// 录音文件路径
+			recordingPath: '',
+			// 录音时长
+			recordingTime: 0,
+			// 录音图片地址
+			recordingImg: '../../static/images/repairsImg/recording.jpg',
+			// 播放状态
+			playStatus: false,
+			// 定时器标识
+			timer: null
 		}
 	},
 	mounted() {
@@ -501,8 +547,31 @@ export default {
 				})
 			}
 		},
+		// 关闭弹窗取消按钮回调
+		handleCloseCancel() {
+			this.recordingPath = ''
+			this.recordingTime = 0
+			this.closeNote = ''
+			this.$refs.popup_close.close()
+		},
 		// 关闭弹窗确定按钮回调
 		handleCloseConfirm() {
+			if (this.closeNote && this.recordingPath) {
+				uni.showToast({
+					title: '录音和备注二选一,不能同时选择',
+					icon: 'none',
+					mask: true
+				})
+				return
+			}
+			if (!this.closeNote && !this.recordingPath) {
+				uni.showToast({
+					title: '请录音或者输入备注,二选一',
+					icon: 'none',
+					mask: true
+				})
+				return
+			}
 			uni.showModal({
 				title: '提示',
 				content: '确定关闭订单吗?',
@@ -513,7 +582,9 @@ export default {
 							data: {
 								recordId: this.orderId,
 								userId: this.userId,
-								reason: this.closeList[this.activeIndex].name
+								reason: this.closeList[this.activeIndex].name,
+								remark: this.recordingPath ? this.recordingPath : this.closeNote,
+								voiceLength: this.recordingPath ? this.recordingTime : ''
 							}
 						})
 						// console.log(res)
@@ -582,8 +653,8 @@ export default {
 			this.$refs.popup_close.open('center')
 		},
 		// 关闭按钮弹窗选中按钮时回调
-		handleChangeItem(val) {
-			this.activeIndex = val
+		bindPickerChange(e) {
+			this.activeIndex = e.detail.value
 		},
 		// 报价按钮回调
 		handleOffer(item) {
@@ -709,6 +780,110 @@ export default {
 			uni.navigateTo({
 				url: `/pagesRepairs/repairDetails/repairDetails?id=${item.id}`
 			})
+		},
+		// 点击录音按钮回调
+		handleRecording() {
+			uni.getSetting({
+				success: (res) => {
+					if (!res.authSetting['scope.record']) {
+						uni.authorize({
+							scope: 'scope.record',
+							success(res) {
+								// 授权成功
+								uni.showToast({
+									title: '授权成功',
+									icon: 'none'
+								})
+							},
+							fail() {
+								uni.showModal({
+									content: '检测到您没打开麦克风权限,是否去设置打开?',
+									confirmText: '确认',
+									cancelText: '取消',
+									success: (res) => {
+										if (res.confirm) {
+											uni.openSetting({
+												success: (res) => {}
+											})
+										} else {
+											uni.showToast({
+												title: '获取麦克风权限失败',
+												icon: 'none'
+											})
+										}
+									}
+								})
+							}
+						})
+					} else {
+						this.$refs.popup_recording.open('bottom')
+					}
+				},
+				fail() {
+					uni.showToast({
+						title: '获取麦克风权限失败',
+						icon: 'none'
+					})
+				}
+			})
+		},
+		// 自定义事件回调,获取录音文件路径
+		getTempFilePath(path, time) {
+			this.recordingPath = path
+			this.recordingTime = time
+			this.$refs.popup_recording.close()
+		},
+		// 点击录音播放回调
+		handlePlayRecordingPop() {
+			innerAudioContext.src = this.recordingPath
+			if (!this.playStatus) {
+				this.playStatus = true
+				innerAudioContext.play()
+
+				this.timer = setInterval(() => {
+					if (this.recordingImg == '../../static/images/repairsImg/recording.jpg') {
+						this.recordingImg = '../../static/images/repairsImg/recording2.jpg'
+					} else if (this.recordingImg == '../../static/images/repairsImg/recording2.jpg') {
+						this.recordingImg = '../../static/images/repairsImg/recording3.jpg'
+					} else if (this.recordingImg == '../../static/images/repairsImg/recording3.jpg') {
+						this.recordingImg = '../../static/images/repairsImg/recording.jpg'
+					}
+				}, 300)
+
+				//播放结束
+				innerAudioContext.onEnded(() => {
+					clearInterval(this.timer)
+					this.timer = null
+					this.recordingImg = '../../static/images/repairsImg/recording.jpg'
+					this.playStatus = false
+				})
+			} else {
+				clearInterval(this.timer)
+				this.recordingImg = '../../static/images/repairsImg/recording.jpg'
+				this.playStatus = false
+				innerAudioContext.stop()
+			}
+		},
+		// 删除录音回调
+		handleDeleteRecording() {
+			if (this.playStatus) {
+				uni.showToast({
+					title: '播放中不能删除',
+					icon: 'none',
+					mask: true
+				})
+			} else {
+				uni.showModal({
+					title: '提示',
+					content: '确定删除录音吗?',
+					success: (res) => {
+						if (res.confirm) {
+							this.recordingPath = ''
+							this.recordingTime = 0
+						}
+					}
+				})
+			}
 		}
 	}
 }
@@ -880,6 +1055,7 @@ export default {
 				.box_key {
 					width: 160rpx;
 					color: #808080;
+					text-align-last: justify;
 				}
 
 				.box_value {
@@ -946,6 +1122,7 @@ export default {
 				display: flex;
 				align-items: center;
 				padding: 0 30rpx;
+				margin: 10rpx 0;
 				height: 120rpx;
 				color: #808080;
 
@@ -1010,21 +1187,92 @@ export default {
 			border-radius: 19rpx;
 			background-color: #fff;
 
-			.close_box {
-				height: 100rpx;
-				line-height: 100rpx;
-				text-align: center;
-				font-size: 32rpx;
-				border: 1rpx solid #e6e6e6;
+			.close_reason {
+				padding-top: 50rpx;
+				margin-left: 80rpx;
+				display: flex;
+				align-items: center;
+
+				.picker_input {
+					display: flex;
+					justify-content: space-between;
+					align-items: center;
+					padding: 10rpx 20rpx;
+					width: 300rpx;
+					border-radius: 14rpx;
+					border: 1rpx solid #e6e6e6;
+
+					img {
+						width: 40rpx;
+						height: 40rpx;
+					}
+				}
 			}
 
-			.radius {
-				border-radius: 19rpx 19rpx 0 0;
+			.close_note {
+				margin: 20rpx 0 20rpx 80rpx;
 			}
 
-			.active {
-				color: #fff;
-				background-color: #6fb6b8;
+			.close_voice {
+				display: flex;
+				align-items: center;
+				margin-top: 30rpx;
+				margin-left: 80rpx;
+				width: 500rpx;
+				height: 94rpx;
+				font-size: 32rpx;
+				color: #cccccc;
+				border-radius: 10rpx;
+				border: 1rpx solid #cccccc;
+
+				.voice_box {
+					display: flex;
+					justify-content: center;
+					align-items: center;
+					margin: 0 38rpx 0 33rpx;
+					width: 101rpx;
+					height: 47rpx;
+					border-radius: 33rpx;
+					box-shadow: 0px 0px 4rpx rgba(0, 0, 0, 0.25);
+
+					img {
+						width: 33rpx;
+						height: 33rpx;
+					}
+				}
+
+				.item_recording {
+					margin-left: 35rpx;
+					display: flex;
+					align-items: center;
+					width: 230rpx;
+					height: 65rpx;
+					color: #000;
+					border-radius: 100rpx;
+					border: 1rpx solid #cccccc;
+
+					img {
+						margin: 0 12rpx;
+						width: 40rpx;
+						height: 40rpx;
+					}
+				}
+
+				.recording_icon {
+					margin-left: auto;
+					margin-right: 35rpx;
+					font-size: 40rpx;
+				}
+			}
+
+			.close_input {
+				box-sizing: border-box;
+				margin: 35rpx 40rpx 35rpx 80rpx;
+				padding: 20rpx;
+				width: 520rpx;
+				height: 312rpx;
+				border-radius: 14rpx;
+				border: 1rpx solid #e6e6e6;
 			}
 
 			.close_btn {
@@ -1161,6 +1409,12 @@ export default {
 				}
 			}
 		}
+
+		.popup_recording {
+			width: 100%;
+			height: 460rpx;
+			background-color: #fff;
+		}
 	}
 
 	.no_data {

+ 7 - 1
pagesRepairs/myRepairs/myRepairs.vue

@@ -38,6 +38,12 @@
 					<view class="box_value">{{ item.userName }}</view>
 				</view>
 
+				<!-- 部门 -->
+				<view class="item_box" v-if="item.userClass">
+					<view class="box_key">部门:</view>
+					<view class="box_value">{{ item.userClass }}</view>
+				</view>
+
 				<!-- 报修电话 -->
 				<view class="item_box">
 					<view class="box_key">报修电话:</view>
@@ -646,7 +652,7 @@ export default {
 				font-size: 28rpx;
 
 				.box_key {
-					width: 145rpx;
+					// width: 145rpx;
 					color: #808080;
 				}
 

+ 1 - 1
pagesRepairs/repairs/repairs.vue

@@ -393,7 +393,7 @@ export default {
 		},
 		// 全局自定义事件
 		addRepairsArea(e) {
-			console.log(e)
+			// console.log(e)
 			this.repairsArea = e.data
 			this.schoolId = e.schoolId
 			this.buildId = e.buildId

+ 28 - 16
pagesRepairs/transferOrder/transferOrder.vue

@@ -33,7 +33,7 @@
 		<view class="title">备注</view>
 
 		<view class="textarea">
-			<textarea placeholder-style="color:#CCCCCC" placeholder="请输入转单说明" :disabled="type === '1'" v-model="info.remark"></textarea>
+			<textarea placeholder-style="color:#CCCCCC" :placeholder="type === '1' ? '无备注' : '请输入转单说明'" :disabled="type === '1'" v-model="info.remark"></textarea>
 		</view>
 
 		<view class="btn2" v-if="type === '1'">
@@ -106,28 +106,40 @@ export default {
 		handleRefuse() {
 			uni.showModal({
 				title: '提示',
-				content: '确定拒绝该审核吗?',
+				placeholderText: '请输入拒绝原因',
+				editable: true,
 				success: async (res) => {
 					if (res.confirm) {
-						const res = await this.$myRequest_repairs({
-							url: '/repairRecord/transfer',
-							method: 'post',
-							data: {
-								id: this.info.id,
-								approverStatu: 0
-							}
-						})
-						// console.log(res)
-						if (res.code === '200') {
+						if (!res.content) {
 							uni.showToast({
-								title: '已拒绝该审核',
+								title: '拒绝原因为必填,请重新输入',
 								icon: 'none'
 							})
 							setTimeout(() => {
-								uni.reLaunch({
-									url: '/pagesRepairs/box/box'
-								})
+								this.handleRefuse()
 							}, 1500)
+						} else {
+							const result = await this.$myRequest_repairs({
+								url: '/repairRecord/transfer',
+								method: 'post',
+								data: {
+									id: this.info.id,
+									approverStatu: 0,
+									refuseRemark: res.content
+								}
+							})
+							// console.log(res)
+							if (result.code === '200') {
+								uni.showToast({
+									title: '已拒绝该审核',
+									icon: 'none'
+								})
+								setTimeout(() => {
+									uni.reLaunch({
+										url: '/pagesRepairs/box/box'
+									})
+								}, 1500)
+							}
 						}
 					}
 				}

+ 5 - 2
pagesRepairs/util/api.js

@@ -1,5 +1,8 @@
-const BASE_URL = "https://chtech.ncjti.edu.cn/campusMaintenance/repair-api/repair/api"
-// const BASE_URL = "http://192.168.161.220:8080/repair/api"
+// 正式服务器
+// const BASE_URL = "https://chtech.ncjti.edu.cn/campusMaintenance/repair-api/repair/api"
+
+// 测试服务器
+const BASE_URL = "https://chtech.ncjti.edu.cn/testingServer/repairTest/repair/api"
 export const myRequest_repairs = (options) => {
 	uni.showLoading({
 		title: "加载中",