<template>
	<view class="fourcontent flex-between">
		<view class="fourcontent_item flex-start" v-for="(item,index) in menu" :key="index"
			@click="viewHistorycategoryss(item,index)"
			:class="!item.isChild && viewHistoryindex == index ? 'fourcontent_itemactev':''">
			<text>{{item.name}}</text>
	
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {};
		},
		props: {
			menu: {
				type: Array,
				default () {
					return []
				}
			},
			title: {
				type: String,
				default: '每日特价'
			},
			viewHistoryindex: {
				type: String,
				default: ''
			},
		},
		methods: {
			viewHistorycategoryss(item, index) {
				console.log(item, index)
				 uni.$emit('viewHistory', {
					item:item,
					index:index
				});
			},
			clickdistrict(item) {
				switch (item.jumpType) {
					case 'absolute':
						uni.pro.navigateTo('webview/webview', {
							url: item.absUrl
						});
						break;
					case 'relative':
						uni.pro.navigateTo(item.absUrl, item);
						break;
					case 'scan':
						if (!uni.utils.pluschooseImage()) {
							return false
						}
						// #ifdef H5
						if (this.wxSdk) {
							wx.scanQRCode({
								needResult: 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
								scanType: ['qrCode', 'barCode'], // 可以指定扫二维码还是一维码，默认二者都有
								success: res => {
									// 当needResult 为 1 时，扫码返回的结果
									console.log(res.resultStr, res)
								}
							});
						} else {
							uni.showModal({
								title: '注意',
								content: '微信sdk初始化失败，请重新加载',
								success: res => {
									window.location.reload();
								}
							});
						}
						// #endif
						// #ifdef APP || MP-WEIXIN
						uni.scanCode({
							success: res => {
								console.log(res.result, res)
							}
						});
						// #endif
						break;
				}
			}
		}
	};
</script>

<style scoped lang="scss">
	.fourcontent {
		padding: 32rpx 28rpx 32rpx 28rpx;
		overflow-x: auto;
		flex-wrap: nowrap;

		.fourcontent_item {
			flex-wrap: nowrap;
			margin-left: 22rpx;
			padding: 4rpx 14rpx;
			background: #FFFFFF;
			border-radius: 8rpx 8rpx 8rpx 8rpx;

			text {
				width: max-content;
			}
		}

		.fourcontent_itemactev {
			background: #fee06a;
		}

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