<template>
	<view class="wanl-list" style="background-color: #F2F3F4;min-height: calc(100vh);">
		<!-- 导航条 -->
		<view class="cu-custom" :style="{height: $wanlshop.wanlsys().height + 'px' }">
			<view class="cu-bar bg-bgcolor fixed" :style="{ height: $wanlshop.wanlsys().height + 'px', paddingTop: $wanlshop.wanlsys().top + 'px'}">
				<!-- 1.1.9 升级 其他页面进入 -->
				<view v-if="pagesNum > 1" class="action" @tap="$wanlshop.back(1)"><text class="wlIcon-fanhui1"></text></view>
				<!-- 直接进入 -->
				<view v-else class="action" @tap="$wanlshop.on('/pages/index')"><text class="wlIcon-zhuye"></text></view>
				
				<view style="margin:0 24rpx;width: 100%;">
					<u-search placeholder="搜索商品" bgColor="#F2F3F4" v-model="keyword" 
					@search="searchHandle"
					height="60rpx" :showAction="false"></u-search>
				</view>
				<!-- <view class="action" @tap="editListstyle()">
					<text class="wlIcon-listing-jf" v-if="liststyle == 'col-2-20'"></text>
					<text class="wlIcon-liebiao" v-else></text>
				</view> -->
			</view>
		</view>
		<view class="imgContent">
			<image src="../../static/images/img/bg2.png" mode="aspectFill"></image>
		</view>
		<u-tabs :list="catagoryData" keyName="name" lineColor="#EB6100"
		 :activeStyle="{'font-weight': 'bold','font-size': '36rpx','color': '#222222'}"
		 @click="clickHandle"></u-tabs>
		<!-- 主体 -->
		<block v-if="goodsData.length > 0">
			<wanl-product :dataList="goodsData"/>
		</block>
		<view v-else style="text-align: center;margin-top: 30rpx;">
			暂无数据
		</view>
		
		
		
		<view class="edgeInsetBottom"></view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			keyword:'',
			catagoryData:[],
			// WanlScroll: 0, //记录页面滚动
			// scrollStype: false, //滚动状态
			liststyle: 'col-2-20', //列表样式
			goodsData: [], //商品列表数据
			goodsType: 'goods',
		};
	},
	async onLoad(option) {
		
		await uni.request({
			url: '/wanlshop/common/init',
			success: res => {
				this.catagoryData = res.data.modulesData.categoryModules;
				if(this.catagoryData.length>0){
					this.category = this.catagoryData[0].id
				}
				this.loadData();
			}
		});
		
		
	},
	// 监听返回
	onUnload() {
		
	},
	methods: {
		clickHandle(val){
			console.log(val)
		},
		//异步加载商品列表
		async loadData() {
			
			console.log(this.category,"liudan")
			uni.request({
				url: '/wanlshop/product/activelists',
				method: 'GET',
				data: {
					type:3, //今日特价
					
				},
				success: res => {
					this.goodsData = res.data;
					
					
				}
			})
		},
		
		search() {
			this.$wanlshop.to(`/pages/page/search?type=${this.goodsType}`,'fade-in',100);
		},
		// editListstyle() {
		// 	this.liststyle = this.liststyle == 'col-1-10'?'col-2-20':'col-1-10';
		// }
	}
};
</script>

<style scoped lang="scss">
	.cu-custom .search-form{
		border: 3rpx solid #fe6600;
		background-color: #fff;
	}
	.cu-tag:not([class*="bg"]):not([class*="line"]){
		background-color: #f7f7f7;
	}
	.imgContent{
		image{
			height: 360rpx;
			width: 100%;
		}
	}
</style>
