
<template>
	<view class="app">
		<view class="cards">
			<view class="item" :style="{background:listcolor[index]}" @tap='goProductList(item)'
				v-for="(item,index) in goodsCategoryList" :key="index">
				<!-- <image src="../../static/sp.png" mode=""></image> -->
				<image :src="item.goodsCatrgoryPicture" mode=""></image>
				<view class="title">
					{{item.goodsCategoryName}}
				</view>
			</view>
			<view class=" item">
			</view>
			<!-- <view class="item" style="background-color: #E1AE3C;">
				<image src="../../static/znsb.png" mode=""></image>
				<view class="title" style="font-size: 42rpx;">
					可穿戴医疗设备
				</view>
			</view>
			<view class="item" style="background: #4C7BC9;">
				<image src="../../static/cp.png" mode=""></image>
				<view class="title" style="font-size: 42rpx;">
					适老化改造
				</view>
			</view> -->
		</view>
	</view>
</template>

<script>
	import {
		goodsCategoryList
	} from '@/api/shopping/shopping.js';
	import baseurl from '@/api/baseurl.js'
	export default {
		data() {
			return {
				pageNum: 1,
				pageSize: 999,
				goodsCategoryList: [],
				listcolor: ['#00C176', '#D43953', '#E1AE3C', '#4C7BC9', '#00C176'],
				// img: '',
			};
		},
		onLoad(options) {
			this.goodsCategory()

		},
		methods: {
			//跳转到商品列表页面
			goProductList(item) {
				console.log(item)
				// if (number == 1) {
				// 	var titlename = '特医食品'
				// 	uni.navigateTo({
				// 		url: `/pages/ProductList/ProductList?title=${titlename}&goodsCategoryId=${this.id}`
				// 	})
				// }
				uni.navigateTo({
					url: `/pages/ProductList/ProductList?title=${item.goodsCategoryName}&goodsCategoryId=${item.id}`
				})

			},
			//获取商城信息
			goodsCategory() {
				goodsCategoryList(this.pageSize, this.pageNum, ).then(res => {
					res.data.forEach(e => {
						e.goodsCatrgoryPicture = baseurl + e.goodsCatrgoryPicture
					})
					this.goodsCategoryList = res.data
				})
			}
		},
	}
</script>

<style lang="scss">
	.app {
		// background-color: #F4F5F7;
		// width: 100%;
		// height: 100vh;
		// position: relative;


	}
</style>
