<template>
	<view>
		<view>
			<view style="padding: 4%" v-if="list.length>0">
				<u-swiper :list="list" keyName="img" @click="clickInfo"></u-swiper>
			</view>
			<view class="listbox flex-row">
				<view class="boxitem" @click="tolist(1)">
					<text class="iconfont icon-xuzhixianxiao"></text>
					<text>参观须知</text>
				</view>
				<view class="boxitem" @click="tolist(2)">
					<text class="iconfont icon-bus-alt"></text>
					<text>公共交通</text>
				</view>
				<view class="boxitem" @click="tolist(3)">
					<text class="iconfont icon-tousujianyi"></text>
					<text>投诉建议</text>
				</view>
				<view class="boxitem" @click="tolist(4)">
					<text class="iconfont icon-changjianwenti"></text>
					<text>常见问题</text>
				</view>
				<view class="boxitem" @click="tolist(5)">
					<text class="iconfont icon-lianxiwomen"></text>
					<text>联系我们</text>
				</view>
			</view>
		</view>
		<view class="box-footer"
			style="position: fixed;bottom: -60rpx;left: 0;text-align: center;width: 100%;z-index: -1;">
			<image src="../../static/img/footer_logo.png" class="footer-img"></image>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: []
			}
		},
		onLoad() {
			var that = this;
			wx.getLocation({
				success(res) {
					that.latitude = res.latitude;
					that.longitude = res.longitude;
					that.loadActivity()
				}
			})
		},
		methods: {
			tolist(type) {
				if (type == 5) {
					uni.navigateTo({
						url: "contact"
					})
				} else if (type == 3) {
					uni.navigateTo({
						url: "feedback"
					})
				} else
					uni.navigateTo({
						url: "list?type=" + type
					})
			},
			loadActivity() {
				var that = this;
				this.util.request({
					api: '/api/mobile/activity/index',
					data: {
						latitude: that.latitude,
						longitude: that.longitude,
						time_type: 2
					},
					utilSuccess: function(res) {
						for (var m of res.data) {
							m.img = m.cover_upload.url;
						}
						that.list = res.data;
					},
					utilFail: function(res) {

					}
				})
			},
			clickInfo(e) {
				var obj = this.list[e];
				uni.navigateTo({
					url: "../activity/info?id=" + obj.id + "&latitude=" + obj.latitude + "&longitude=" + obj
						.longitude
				})
			}
		}
	}
</script>

<style>
	page {
		background: #f7f6f4;
	}

	.iconfont {
		font-size: 48rpx;
		color: #dec096;
		margin-bottom: 15rpx;
	}

	.footer-img {
		width: 421rpx;
		height: 364rpx;
	}

	.listbox {
		flex-wrap: wrap;
		padding: 2%;
	}

	.boxitem {
		background: url("@/static/img/nav_bg.png") no-repeat;
		background-size: 100% 100%;
		width: 50%;
		width: 46%;
		height: 100px;
		margin-bottom: 20rpx;
		margin-bottom: 20rpx;
		margin-right: 2%;
		margin-left: 2%;
		font-size: 32rpx;
		font-family: PingFang SC;
		font-weight: 400;
		color: #351C1B;
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: column;
	}
</style>
