chooseNum.vue 2.9 KB
<template>
	<view class="u-page__item">
		<view class="" v-if="itemArr && itemArr.length > 0">
			<u-collapse accordion v-for="item in itemArr" @close="close">
				<view class="" @click="backHub(item)">
					<u-collapse-item :title="item.name">
						<text class="u-collapse-content" v-if="item.children && item.children.length>0"
							v-for="item1 in item.children" @click="backHub1(item1)">{{item1.name}}</text>
					</u-collapse-item>
				</view>
			
			</u-collapse>
		</view>
		<view class="" v-else style="margin-top: 40%;">
 			<u-empty></u-empty>
		</view>
	</view>
	<!-- <view style="margin: 24rpx 0;">
			<u-index-list :index-list="indexList">
					<template v-for="(item, index) in itemArr">
						<!-- #ifdef APP-NVUE -->
	<!-- <u-index-anchor :text="indexList[index]"></u-index-anchor> -->

	<!-- <u-index-item> --> -->
	<!-- #ifndef APP-NVUE
							<u-index-anchor :text="indexList[index]"></u-index-anchor>
							<!-- #endif --> -->
	<!-- <view class="list-cell" v-for="(cell, index1) in item.list" @click="backHub(cell)">
								{{cell.name}}
							</view>
						</u-index-item>
					</template>
				</u-index-list> -->
	
</template>

<script>
	export default {
		data() {
			return {
				indexList: [],

				itemArr: [

				]
			}
		},
		methods: {
			backHub(item) {
				if (item.children && item.children.length > 0) {
					return
				} else {
					this.backHub1(item)
				}

			},
			backHub1(item) {
				let pages = getCurrentPages(); //获取所有页面栈实例列表
				let prevPage = pages[pages.length - 2]; //上一页页面实例
				prevPage.$vm.xh_id = item.id;
				prevPage.$vm.xh_name = item.name;
				uni.navigateBack({ //uni.navigateTo跳转的返回,默认1为返回上一级
					delta: 1
				});
			},
			open(e) {
				// console.log('open', e)
			},
			close(e) {
				console.log('close', e)
			},
			change(e) {
				// console.log('change', e)
			}
		},
		onLoad(option) {
			let brand_id = ''
			let category_id = ''
			if(option && option.category_id !== 'undefined' && option.brand_id !== 'undefined'){
				brand_id = option.brand_id
				category_id = option.category_id
			}
			uni.$u.http.get(`/api/index/xinghao_list?category_id=${category_id}&brand_id=${brand_id}`).then(
				res => {
					// this.indexList = res.data.word
					this.itemArr = res.data.data
				}).catch(err => {
				console.log(err);
			})


		}
	}
</script>

<style scoped lang="scss">
	/deep/ .u-collapse {
		background-color: white;
	}

	.list-cell {
		display: flex;
		box-sizing: border-box;
		width: 100%;
		padding: 10px 24rpx;
		overflow: hidden;
		color: #323233;
		font-size: 14px;
		line-height: 24px;
		background-color: #fff;
	}

	.u-page {
		padding: 0;

		&__item {

			&__title {
				color: $u-tips-color;
				background-color: $u-bg-color;
				padding: 15px;
				font-size: 15px;

				&__slot-title {
					color: $u-primary;
					font-size: 14px;
				}
			}
		}
	}

	.u-collapse-content {
		color: $u-tips-color;
		font-size: 14px;
		margin: 15rpx 10rpx;
	}
</style>