<template>
	<view class="towcontent flex-between" v-if="district">
		<view v-for="(item,index) in district" :key="index" @click="clickdistrict(item,index)">
			<view class="towcontent_item flex-colum" v-if="item.isShowMall == 1">
				<image :src="item.coverImg" mode="aspectFill"></image>
				<text>{{item.name}}</text>
			</view>
		</view>

	</view>
</template>

<script setup>
	import {
		ref,
		defineProps
	} from 'vue';
	import {
		productStore
	} from '@/stores/user.js';
	const props = defineProps({
		district: Array
	});
	const clickdistrict = async (item) => {
		switch (item.jumpType) {
			case 'absolute':
				uni.pro.navigateTo('webview/webview', {
					url: item.absUrl
				});
				break;
			case 'scan_applet':
				uni.navigateToMiniProgram(JSON.parse(item.value))
				break;
			case 'relative':
				uni.pro.navigateTo(item.absUrl);
				break;
			case 'scan':
				// #ifndef H5
				if (!uni.utils.pluschooseImage()) {
					return false
				}
				// #endif
				const store = productStore();
				await store.scanCodeactions()
				break;
		}
	}
	const getQueryString = (url, name) => { //解码
		var reg = new RegExp('(^|&|/?)' + name + '=([^&|/?]*)(&|/?|$)', 'i')
		var r = url.substr(1).match(reg)
		if (r != null) {
			return r[2]
		}
		return null;
	}
</script>

<style scoped lang="scss">
	.towcontent {
		position: relative;
		margin-top: -32rpx;
		padding: 32rpx 40rpx;
		width: 100%;
		background: #F9F9F9;
		border-radius: 48rpx 48rpx 0rpx 0rpx;
		overflow-x: auto;
		flex-wrap: nowrap;
		box-sizing: border-box;

		.towcontent_item {
			width: 25%;
			margin-left: 34rpx;

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

			text {
				margin-top: 16rpx;
				font-family: Source Han Sans CN, Source Han Sans CN;
				font-weight: 400;
				font-size: 28rpx;
				color: #333333;
				white-space: nowrap;
			}
		}

		// .towcontent_item:nth-child(1) {
		// 	margin-left: 0rpx;
		// }
	}
</style>