<template>
	<view>
		<view class="content">
			<view :style="{height:statusBarHeight + 'px'}"></view>
			<view class="navbar">

				<view class="left" @click="click_left()">
					<uni-icons type="arrowleft" color="#fff" size="18"></uni-icons>
				</view>
				<view class="right">
					<view class="input_box">
						<view class="input_icon"></view>
						<view class="input_text">
							<input type="text" v-model="search_text" placeholder="搜索" placeholder-style="color:#fff;" />
						</view>
					</view>
				</view>
				<view class="btn" @click="search()">搜索</view>
			</view>
		</view>
		<!-- 占位符 -->
		<view :style="{height: statusBarHeight + 'px'}"></view>
		<view style="height: 93rpx;"></view>


		<!-- 搜索列表 -->
		<view class="list">
			<view class="item" v-for="(item,index) in list" :key="index" @click="go_record(item.id)">
				<view class="title">{{item.title}}</view>
				<view class="icon">
					<uni-icons type="arrowright"></uni-icons>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				mine_code: "",
				statusBarHeight: 25,

				// 搜索关键词
				search_text: "",

				// 搜索结果列表
				list: [],
			};
		},
		onLoad(option) {
			this.mine_code = option.mine_code
			// 获取手机系统信息
			const info = uni.getSystemInfoSync()
			// 设置状态栏高度
			this.statusBarHeight = info.statusBarHeight

			console.log(this.mine_code)
			// 根据矿编码切换首页接口不同的请求基础路径
			switch (this.mine_code) {
				case 'ningdongyunying':
					this.base_url = "http://ningdongyunying.nxjiewei.com:8011/api"
					break;
				case 'meihuajing':
					this.base_url = "http://meihuajing.nxjiewei.com:8011/api"
					break;
				case 'zaoquan':
					this.base_url = "http://zaoquan.nxjiewei.com:8011/api"
					break;
				default:
					this.base_url = ""
			}
		},
		methods: {
			click_left() {
				uni.navigateBack();
			},
			search() {
				uni.showLoading()

				uni.request({
					url: this.base_url + "/swagger/api/page/v1/getPageList",
					method: "GET",
					data: {
						title: this.search_text,
						departmentId: "",
						pageNumber: 0,
						pageSize: 0
					},
					success: (res) => {
						console.log(res)
						uni.hideLoading()

						this.list = res.data.data
					}
				})
			},

			// 打开二维码页面
			go_record(id) {
				uni.navigateTo({
					url:"../../index/record/record?pageId=" + id + "&mine_code=" + this.mine_code,
				})
			}

		}

	}
</script>

<style lang="scss">
	.content {
		position: fixed;
		top: 0;
		left: 0;

		background-color: #009FE8;
		z-index: 999;
	}

	.navbar {
		width: 750rpx;
		box-sizing: border-box;
		padding-left: 31rpx;
		padding-right: 26rpx;
		padding-top: 14rpx;
		padding-bottom: 14rpx;
		display: flex;
		// justify-content: space-between;

		.left {
			width: 42rpx;
			line-height: 65rpx;
			margin-right: 15rpx;
		}

		.right {
			width: 500rpx;
			height: 65rpx;
			background: rgba(255, 255, 255, 0.2);
			border-radius: 33rpx;

			.input_box {
				display: flex;

				.input_icon {
					margin-left: 43rpx;
					margin-top: 16rpx;
					width: 34rpx;
					height: 34rpx;

					background-image: url(icon/search.png);
					background-size: cover;
					background-repeat: no-repeat;
				}

				.input_text {
					margin-left: 19rpx;

					font-size: 24rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #FFFFFF;
					line-height: 65rpx;

					input {
						font-size: 24rpx;
						height: 65rpx;
						line-height: 65rpx;
					}
				}
			}
		}

		.btn {
			margin-left: 20rpx;
			width: 120rpx;
			text-align: center;
			height: 65rpx;
			line-height: 65rpx;
			background: rgba(255, 255, 255, 0.2);
			border-radius: 33rpx;
			font-size: 24rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #FFFFFF;
		}
	}


	.list {
		box-sizing: border-box;
		padding: 25rpx;

		.item {
			display: flex;
			justify-content: space-between;
			align-items: center;

			box-sizing: border-box;
			padding: 35rpx 0;
			border-bottom: 1rpx solid #F4F4F4;

			.title {
				font-size: 32rpx;
			}

			.icon {}
		}
	}
</style>
