home.vue 10.6 KB
Newer Older
xinzhedeai's avatar
xinzhedeai committed
1 2 3 4 5
<template>
	<view class="wrapper">
		<view class="body-wrapper">
			<view class="logo-wrapper">
				<image class="logoImg" src="/static/image/home/logo.png" alt="" />
xinzhedeai's avatar
xinzhedeai committed
6
				
xinzhedeai's avatar
xinzhedeai committed
7
				<h3>露天炮孔验收仪</h3>
8
				<button @click="gosend">获取电量</button>
xinzhedeai's avatar
xinzhedeai committed
9
			</view>
xinzhedeai's avatar
xinzhedeai committed
10
			<view class="link-info-wrapper" @click="gosend('POWER')">
xinzhedeai's avatar
xinzhedeai committed
11
				<image class="bg" src="../../static/image/paokong/home-title-bg.png" mode=""></image>
xinzhedeai's avatar
xinzhedeai committed
12
				<div class="left">
13
					<image :src="`/static/image/paokong/${connected?'linkY':'linkN'}.png`" mode=""></image>
xinzhedeai's avatar
xinzhedeai committed
14
					<view class="link-status">
15
						蓝牙{{ connected? '已连接': '未连接' }}
xinzhedeai's avatar
xinzhedeai committed
16 17 18
					</view>
				</div>
				<div class="right">
xinzhedeai's avatar
xinzhedeai committed
19 20 21 22 23 24 25 26 27 28 29 30 31 32
					<div class="top">
						<h2>设备电量</h2>
						<p>
							小球 <image src="/static/image/paokong/qiu-dl.png">{{ '22' }} %
							仪器 <image src="/static/image/paokong/shebei-dl.png">{{ '24' }} %
						</p>
					</div>
					<div class="bottom">
						<h2>设备参数</h2>
						<p>设备名称:露天炮孔验收仪</p>
						<p>设备型号:MYSM-OH-01</p>
						<p>设备ID:MYSM-OH-01</p>
					</div>
					
xinzhedeai's avatar
xinzhedeai committed
33 34
				</div>
			</view>
xinzhedeai's avatar
xinzhedeai committed
35
			<p class="list-item" @click="uploadExcel">
xinzhedeai's avatar
xinzhedeai committed
36
				<image src="/static/image/paokong/impexp.png" alt="" />
xinzhedeai's avatar
xinzhedeai committed
37 38
				<span>炮孔设计数据导入</span>
				<!-- <button size="mini" class="funcBtn" type="primary" @click="navTo('import')">导入导出</button> -->
xinzhedeai's avatar
xinzhedeai committed
39
			</p>
xinzhedeai's avatar
xinzhedeai committed
40 41 42 43
			<p class="list-item" @click="navTo('link')">
				<image src="/static/image/paokong/link.png" alt="" />
				<span>连接露天炮孔验收仪</span>
				<!-- <button size="mini" class="funcBtn" type="primary">连接</button> -->
xinzhedeai's avatar
xinzhedeai committed
44
			</p>
xinzhedeai's avatar
xinzhedeai committed
45 46
			<!-- <p class="list-item">
				<image src="/static/image/paokong/measure.png" alt="" />
xinzhedeai's avatar
xinzhedeai committed
47 48
				<span>设备测试</span>
				<button size="mini" class="funcBtn" type="primary" @click="navTo('measureTest')">测量</button>
xinzhedeai's avatar
xinzhedeai committed
49
			</p> -->
xinzhedeai's avatar
xinzhedeai committed
50
			<p class="list-item" @click="navTo('measure')">
xinzhedeai's avatar
xinzhedeai committed
51
				<image src="/static/image/paokong/measure.png" alt="" />
xinzhedeai's avatar
xinzhedeai committed
52
				<span>炮孔测量</span>
xinzhedeai's avatar
xinzhedeai committed
53
				<!-- <button size="mini" class="funcBtn" type="primary" @click="navTo('measure')">测量</button> -->
xinzhedeai's avatar
xinzhedeai committed
54
			</p>
xinzhedeai's avatar
xinzhedeai committed
55 56
			<p class="list-item" @click="exportExcel">
				<image src="/static/image/paokong/impexp.png" alt="" />
xinzhedeai's avatar
xinzhedeai committed
57 58
				<span>炮孔测量数据导出</span>
				<!-- <button size="mini" class="funcBtn" type="primary" @click="navTo('export')">导出</button> -->
xinzhedeai's avatar
xinzhedeai committed
59
			</p>
xinzhedeai's avatar
xinzhedeai committed
60
			<p class="list-item" @click="navTo('operateLog')">
xinzhedeai's avatar
xinzhedeai committed
61 62 63 64 65
				<image src="/static/image/paokong/operatelog.png" alt="" />
				<span>操作日志</span>
				<!-- <button size="mini" class="funcBtn" type="primary" @click="navTo('export')">导出</button> -->
			</p>
			<!-- <p class="list-item">
xinzhedeai's avatar
xinzhedeai committed
66 67 68
				<image src="/static/image/home/5.png" alt="" />
				<span>导入数据预览</span>
				<button size="mini" class="funcBtn" type="primary" @click="navTo('importFileDataPreview')">进入</button>
69 70 71 72 73
			</p>
			<p class="list-item">
				<image src="/static/image/home/5.png" alt="" />
				<span>炮孔测量</span>
				<button size="mini" class="funcBtn" type="primary" @click="navTo('paokongceliang')">进入</button>
xinzhedeai's avatar
xinzhedeai committed
74
			</p> -->
xinzhedeai's avatar
xinzhedeai committed
75 76 77 78 79 80
			<view class="footer">
				<span>
					威海晶合数字矿山技术有限公司
				</span>
			</view>
		</view>
xinzhedeai's avatar
xinzhedeai committed
81

xinzhedeai's avatar
xinzhedeai committed
82 83 84 85
	</view>
</template>

<script>
xinzhedeai's avatar
xinzhedeai committed
86 87 88 89
	import {
		stringToBytes,
		showCustomModal,
		showCustomToast,
xinzhedeai's avatar
xinzhedeai committed
90 91 92 93
		commonStateCodeDeal,
		popup,
		storager,
		pager
xinzhedeai's avatar
xinzhedeai committed
94 95 96 97 98
	} from "../../common/util.js"
	import * as XLSX from '@/common/excel.js'
	import {
		getExportData,
	} from '../../api/home.js'
xinzhedeai's avatar
xinzhedeai committed
99 100
	
	import { BASEURL } from "../../common/config.js";
xinzhedeai's avatar
xinzhedeai committed
101

xinzhedeai's avatar
xinzhedeai committed
102 103 104
	export default {
		data() {
			return {
xinzhedeai's avatar
xinzhedeai committed
105
				deviceInfo: {},
xinzhedeai's avatar
xinzhedeai committed
106 107
			}
		},
108 109 110 111 112 113
		/**
		 * 生命周期函数--监听页面加载
		 */
		onLoad: function(options) {
			uni.hideLoading()
		},
xinzhedeai's avatar
xinzhedeai committed
114 115
		onShow() {
			uni.hideLoading()
116
		},
xinzhedeai's avatar
xinzhedeai committed
117
		mounted() {
xinzhedeai's avatar
xinzhedeai committed
118 119 120
			
			
			
121
			const deviceInfo = uni.getStorageSync('deviceInfo')
xinzhedeai's avatar
xinzhedeai committed
122
			if (deviceInfo) { // 获取蓝牙设备型号id
123 124
				this.deviceInfo = deviceInfo
			}
xinzhedeai's avatar
xinzhedeai committed
125 126
			uni.hideTabBar()
		},
xinzhedeai's avatar
xinzhedeai committed
127

xinzhedeai's avatar
xinzhedeai committed
128
		methods: {
xinzhedeai's avatar
xinzhedeai committed
129 130 131 132 133 134 135 136 137 138 139 140
			uploadExcel(){
				wx.chooseMessageFile({
					count: 1,
					type: 'file',
					extension: ['.xlsx', '.xls'],
					success: function(res) {
						console.log("文件上传", res);
						uni.uploadFile({
							url: BASEURL + '/product/importProduct', //文件上传的接口地址
							filePath: res.tempFiles[0].path,
							name: 'file', //接口需要的参数名
							header: {
xinzhedeai's avatar
xinzhedeai committed
141
								'Authorization': storager.get('token')
xinzhedeai's avatar
xinzhedeai committed
142 143 144
							},
							success(uploadRes) {
								const res = JSON.parse(uploadRes.data)
xinzhedeai's avatar
xinzhedeai committed
145 146 147 148 149 150 151 152 153 154 155
								if(res.code === 401){
									showCustomModal({
										content: res.msg,
										success: function() {
											pager.navTo({ // 登录超时跳转登录页面
												url: "/pages/user/login"
											})
										}
									});
									return
								}
xinzhedeai's avatar
xinzhedeai committed
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
								showCustomToast({
									title: res.msg
								})
								
								console.log(uploadRes, 'uploadRes')
							},
							fail(uploadErr) {
								console.log('上传失败', uploadErr);
								// 处理上传失败后的逻辑
							}
						});
					},
					fail(err) {
						console.log('选择文件失败', err);
						// 处理选择文件失败后的逻辑
					}
				});
			},
xinzhedeai's avatar
xinzhedeai committed
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
			async exportExcel() { // 导出excel
				let res = await getExportData({
				})
				if (res) {
					console.log('export', res)
					const ExcelData = res; //列表数据
					this.loading = false
				
					const fileName='炮孔测量数据导出'
					const header = ['productName', 'artilleryAreaName', 'cannonHoleArrayNum', 'cannonHoleNum', 'expectedDepth',
						'remark'
					];
					const headerName = {
						productName: '工程名称',
						artilleryAreaName: '爆区名称',
						cannonHoleArrayNum: '炮孔排号',
						cannonHoleNum: '炮孔编号',
						expectedDepth: '设计孔深',
						remark: '备注'
					};
					
					showCustomToast({
						title: "导出中,请稍后...",
						duration: 3000,
					})
					XLSX.excel_exprot(ExcelData, header, headerName, fileName)
				}else{
					showCustomToast({
						title: '暂无数据'
					})
				}
			},
			gosend() {
207 208
				var strbuf = new Uint8Array(stringToBytes('POWER'));
				var buffer1 = strbuf.buffer;
xinzhedeai's avatar
xinzhedeai committed
209
				setTimeout(() => {
210 211 212
					uni.writeBLECharacteristicValue({
						deviceId: 'C8:47:80:52:93:A2',
						serviceId: '0000FFE0-0000-1000-8000-00805F9B34FB',
xinzhedeai's avatar
xinzhedeai committed
213
						characteristicId: '0000FFE1-0000-1000-8000-00805F9B34FB',
214 215 216 217 218 219 220
						value: buffer1,
						success: (res) => {
							console.log('writeBLECharacteristicValue-success:res=>', res)
						},
						fail: (res) => {
							console.log('writeBLECharacteristicValue-fail:res=>', res)
							// commonStateCodeDeal(res.errCode || res, 'gosend -> writeBLECharacteristicValue',
xinzhedeai's avatar
xinzhedeai committed
221
							// this)
222 223 224 225
						},
					});
				}, 1000)
			},
xinzhedeai's avatar
xinzhedeai committed
226 227
			navTo(flag) {
				if (flag === 'export') {
xinzhedeai's avatar
xinzhedeai committed
228 229 230 231
					this.exportData2Excel()
					return
				}
				let url = ''
xinzhedeai's avatar
xinzhedeai committed
232
				if (flag === 'login') {
xinzhedeai's avatar
xinzhedeai committed
233 234
					// url = 'test'
					url = '/pages/user/login'
xinzhedeai's avatar
xinzhedeai committed
235
				} else if (flag === 'import') {
xinzhedeai's avatar
xinzhedeai committed
236
					url = '/pages/home/importFile'
xinzhedeai's avatar
xinzhedeai committed
237
				} else if (flag === 'measureTest') {
xinzhedeai's avatar
xinzhedeai committed
238
					url = '/pages/home/blueTest'
xinzhedeai's avatar
xinzhedeai committed
239
				} else if (flag === 'measure') {
xinzhedeai's avatar
xinzhedeai committed
240
					url = '/pages/home/blueMeasure'
xinzhedeai's avatar
xinzhedeai committed
241
				} else if (flag === 'link') {
xinzhedeai's avatar
xinzhedeai committed
242
					url = '/pages/home/blueSearch'
xinzhedeai's avatar
xinzhedeai committed
243
				} else if (flag === 'importFileDataPreview') {
xinzhedeai's avatar
xinzhedeai committed
244
					url = '/pages/home/importFileDataPreview'
xinzhedeai's avatar
xinzhedeai committed
245
				} else if (flag === 'paokongceliang') {
246
					url = '/pages/home/paokongceliang'
xinzhedeai's avatar
xinzhedeai committed
247
				} else if (flag === 'operateLog') {
xinzhedeai's avatar
xinzhedeai committed
248
					url = '/pages/home/operateLog'
xinzhedeai's avatar
xinzhedeai committed
249
				}
xinzhedeai's avatar
xinzhedeai committed
250

xinzhedeai's avatar
xinzhedeai committed
251
				pager.navTo(url)
xinzhedeai's avatar
xinzhedeai committed
252 253 254 255 256
			}
		}
	}
</script>
<style lang="scss">
xinzhedeai's avatar
xinzhedeai committed
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278
	.wrapper {
		width: 100vw;
		height: calc(100vh-55rpx);
		padding-top: 55rpx;
		background: linear-gradient(180deg, #007AFF 0%, #419AFF 16%, #EFF1F4 43%);
		position: relative;

		.footer {
			// position: absolute;
			// bottom: 10rpx;
			width: 100%;
			// padding-top: 200rpx;
			// height: 10rpx;
			// height: 120rpx;
			// line-height: 120rpx;
			text-align: center;

			span {
				font-weight: 400;
				font-size: 27rpx;
				color: #A0A7AE;
			}
xinzhedeai's avatar
xinzhedeai committed
279 280
		}
	}
xinzhedeai's avatar
xinzhedeai committed
281 282 283 284 285 286 287 288 289

	.body-wrapper {
		display: flex;
		justify-content: center;
		flex-direction: column;
		align-items: center;
		gap: 20rpx;
		background-color: linear-gradient(180deg, #007AFF 0%, #419AFF 16%, #EFF1F4 43%);
		padding-top: 50rpx;
xinzhedeai's avatar
xinzhedeai committed
290
	}
xinzhedeai's avatar
xinzhedeai committed
291

xinzhedeai's avatar
xinzhedeai committed
292 293 294 295 296 297 298 299 300 301 302 303 304
	.logo-wrapper {
		position: relative;
		height: 300rpx;
		display: flex;
		justify-content: center;
		flex-direction: column;
		align-items: center;
		gap: 50rpx;
		font-family: Source Han Sans SC;

		.logoImg {
			width: 454rpx;
			height: 98rpx;
xinzhedeai's avatar
xinzhedeai committed
305
		}
xinzhedeai's avatar
xinzhedeai committed
306 307 308 309

		h3 {
			color: #ffffff;
			font-size: 37rpx;
xinzhedeai's avatar
xinzhedeai committed
310 311 312
			font-weight: bold;
		}
	}
xinzhedeai's avatar
xinzhedeai committed
313 314

	.link-info-wrapper {
xinzhedeai's avatar
xinzhedeai committed
315
		position: relative;
xinzhedeai's avatar
xinzhedeai committed
316
		width: 646rpx;
xinzhedeai's avatar
xinzhedeai committed
317 318
		height: 440rpx;
		// background-image: url('/static/image/paokong/home-title-bg.png');
xinzhedeai's avatar
xinzhedeai committed
319
		// background-color: linear-gradient(-90deg, #F6F9FF 31%, #E4EFFF 100%);
xinzhedeai's avatar
xinzhedeai committed
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337
		// background-position: center;
		// background-size: cover;
		// box-shadow: 0rpx 2rpx 24rpx 0rpx rgba(7, 36, 72, 0.11);
		// border-radius: 10rpx;
		// border: 2px solid #FFFFFF;
		// display: flex;
		// align-items: center;
		// gap: 47rpx;
		// padding-left: 49rpx;
		.bg{
			position: absolute;
			bottom: 0;
			left: -40rpx;
			right: 0;
			width: 728rpx;
			height: 464rpx;
			z-index: 0;
		}
xinzhedeai's avatar
xinzhedeai committed
338
		.left {
xinzhedeai's avatar
xinzhedeai committed
339 340 341
			position: absolute;
			left: 60rpx;
			top: 110rpx;
xinzhedeai's avatar
xinzhedeai committed
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360
			image {
				width: 136rpx;
				height: 136rpx;
			}

			.link-status {
				font-family: Source Han Sans SC;
				font-weight: bold;
				font-size: 30rpx;
				color: #007AFF;

				::before {
					content: '';
					width: 12rpx;
					height: 12rpx;
					background: #007AFF;
					border-radius: 50%;
				}
			}
xinzhedeai's avatar
xinzhedeai committed
361
		}
xinzhedeai's avatar
xinzhedeai committed
362 363

		.right {
xinzhedeai's avatar
xinzhedeai committed
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383
			position: absolute;
			right: 10rpx;
			top: 18rpx;
			.top{
				image{
					width: 15rpx;
					height: 30rpx;
				}
				p{
					display: flex;
					justify-content: start;
					align-items: center;
					gap: 10rpx;
					font-size: 30rpx;
					padding-bottom: 20rpx;
					margin-bottom: 20rpx;
					border-bottom: 4rpx solid #CCD1DB;
				}
				
			}
xinzhedeai's avatar
xinzhedeai committed
384 385 386 387 388 389 390 391 392 393 394
			h2 {
				font-size: 34rpx;
				font-weight: bold;
			}

			p {
				font-size: 30rpx;
				// font-weight: bold;
				color: #848484;
				margin-top: 20rpx;
			}
xinzhedeai's avatar
xinzhedeai committed
395 396 397 398
		}
	}


xinzhedeai's avatar
xinzhedeai committed
399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438
	.list-item {
		width: 660rpx;
		height: 140rpx;
		// border-top: 1px solid rgba(187,187,187,1);
		display: flex;
		justify-content: flex-start;
		align-items: center;
		gap: 0px 30px;
		padding: 10px;
		background-color: #ffffff;
		border-radius: 10rpx;

		image {
			width: 102rpx;
			height: 102rpx;
		}

		span {
			display: inline-block;
			width: 420rpx;
			font-family: PingFangSC-regular;
			color: rgba(0, 0, 0, 1);
			font-size: 18px;
			font-weight: bold;
		}

		.funcBtn {
			width: 120rpx;
			height: 62rpx;
			line-height: 62rpx;
			background: #FFFFFF;
			border-radius: 36rpx;
			border: 2rpx solid #007AFF;
			color: #007AFF;
			padding: 0;
			// font-size: 27rp;
			font-family: Source Han Sans SC;
			font-weight: bold;

		}
xinzhedeai's avatar
xinzhedeai committed
439
	}
xinzhedeai's avatar
xinzhedeai committed
440
</style>