import { View, Image, Text } from "@tarojs/components";
import "./index.less";
import Taro from "@tarojs/taro";

const CategoryList = (props) => {
  const { categoryList } = props; //分类列表引用
  const handleCategoryClick = (jpath, type_jpath) => {
    if (type_jpath == 2) {
      return;
    }
    Taro.navigateTo({
      url: jpath,
    });
  };
  return (
    <View className="category-wrap">
      <View className="category-list">
        {categoryList.map((item) => (
          <View
            onClick={() => handleCategoryClick(item.jpath, item.type_jpath)}
            key={item.id}
            className="category-item"
          >
            <Image className="category-icon" src={item.img} mode="aspectFit" />
            <Text className="category-name">{item.name}</Text>
          </View>
        ))}
      </View>
    </View>
  );
};

export default CategoryList;
