<template>
	<view class="page">
		<navBar :title="name" :back="true" color="black" background="white" />

		<view class="con" v-if="list.length!=0">
			<view class="item" v-for="(item,index) in list" @click="goDetail(item)">
				<view class="topBox">
					<image :src="picBase+item.cover" mode=""></image>
				</view>
				<view class="bottom">
					<view class="txt">
						{{item.name}}
					</view>
				</view>
			</view>
		</view>
		<view class="con" v-else style="justify-content: center;">
			<u-empty mode="data" text="暂无数据" width="160" height="160" :icon="picUrl+'/static/other/empty.png'">
			</u-empty>
		</view>


		<u-loadmore v-if="list.length!=0" style="" loadmoreText="已经到底啦" color="#CCCCCC" lineColor="#CCCCCC" line />

		<u-loading-page :loading="loading" image="/static/index/logo.png" loading-text="页面加载中..."></u-loading-page>
	</view>
</template>

<script>
	import {
		getMallReq,
	} from '@/api/test/index.js'
	export default {
		components: {

		},
		data() {
			return {
				picUrl: this.$picUrl,
				picBase: this.$picBase,
				list: [],
				name: '',

				brand: 0,
				type: 0,
				typeNameId: 0,
				pid: -1,

				loading: true
			}
		},
		async onLoad(o) {
			console.log('typeNameId ', o.typeNameId, 'pId ', o.pid);
			this.pid = o.pid
			this.name = o.name
			this.typeNameId = o.typeNameId
			this.brand = o.brand
			this.type = o.type
		},
		async onShow() {
			let res = await getMallReq({
				typeNameId: this.typeNameId,
				pid: this.pid
				// brand: this.brand,
				// type: this.type,
			})
			if (res.code == 0) {
				this.list = res.data
				this.loading = false
				console.log('获取商城列表数据返回值-子分类: ', res);
			} else {
				this.loading = false
				uni.showToast({
					title: res.message,
					icon: 'none'
				})
			}
		},
		methods: {
			goDetail(item) {
				getApp().mallItem = item
				uni.navigateTo({
					url: '/pages/mall/detail/index'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import "./index.scss";
</style>