uniapp微信小程序商品分类

<template>
	<view class="content">
		<!-- 大类 -->
		<view class="bg-fff tabtop">
			<view class="m-015">
				<scroll-view scroll-x="true" class="scroll-tap text-center">
					<view class="  ">
						<view class="scroll-tab-item rounded" v-for="(item ,index) in wasteClass_item" :key="index"
							:class="{'active':Inv==index}" @click="changeTab(index)">
							<view class="flex flex-column align-center justify-center text-center">
								<view class="scroll-tab-icon ">
									<image class="w-100 h-100" :src="item.image" mode=""></image>
								</view>
								<view class="scroll-tab-text">{{item.name}}</view>
							</view>
						</view>
					</view>
				</scroll-view>
			</view>
		</view>
		<!-- 大类的子集 -->
		<view class="bg-fff tabbottom">
			<view class="m-015">
				<view class="tabbottom-item flex  flex-wrap">
					<view class=" tabbottom-list rounded position-relative" v-for="( items , index) in child"
						:key="index">
						<view class="flex align-center justify-around">
							<view class="pic-box">
								<image class="w-100 h-100" :src="items.image" mode=""></image>
							</view>
							<view class="text-box">
								<view class="text-title">{{items.name}}</view>
								<view class="text-description">实物为准</view>
							</view>
						</view>
						<view class="tabbottom-xuan position-absolute">
							<view class=" tabbottom-xuan-checked flex align-center justify-center rounded-2">
								<text>√</text>
							</view>
							<view class=" tabbottom-xuan-cancel flex align-center justify-center rounded-2">
								<text>×</text>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { BASE_URL, API_URL } from '@/env.js';
	export default {
		data() {
			return {
				Inv: 0,
				wasteClass_item: [],
				child: []
			}
		},
		onLoad() {
			this.wasteClass()
		},
		methods: {
			changeTab(index) {
				this.Inv = index
				this.child = this.wasteClass_item[index].children
				console.log(this.child)
			},
			wasteClass() {
				let that = this
				uni.request({
					url: API_URL + '请求的接口地址',
					method: 'GET',
					success(res) {
						console.log(res)
						that.wasteClass_item = res.data.data
						that.child = res.data.data[0].children
					}
				})
			}
		}
	}
</script>

<style>
	.tabtop{margin-top:10px;padding:20px 0 9px}
	.tabbottom{margin-top:10px}
	.scroll-tap{white-space:nowrap}
	.scroll-tab-item{display:inline-block;margin-right:10px;padding:6px 30px;border:2px solid #000}
	.active{background:linear-gradient(to right,#52e0a3,#0fe9c4);border-image:linear-gradient(to right,#52e0a3,#0fe9c4)}
	.scroll-tab-item:last-child{margin-right:0}
	.scroll-tab-text{font-size:13px}
	.scroll-tab-icon{width:43rpx;height:39rpx}
	.tabbottom-item{padding:12px 0 17px}
	.tabbottom-list{border:2px solid #000;padding:11px 11px 21px 9px;margin-bottom:10px;margin-right:5px}
	.pic-box{width:30px;height:40px}
	.text-box{margin-left:8px}
	.text-title{font-size:14px}
	.text-description{font-size:12px;color:#666;margin-top:10px}
	.tabbottom-xuan{top:-13%;right:-8%}
	.tabbottom-xuan-checked{width:20px;height:20px;background:linear-gradient(to right,#52e0a3,#0fe9c4)}
	.tabbottom-xuan-cancel{width:20px;height:20px;background:#eee}
</style>

样式仅供参考,有多处自定义样式
我的接口请求回来的数据格式是这样的
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值