<template>
	<view class="page">
		<navBar title="定制我家的主灯" :back="true" color="black" background="white" />

		<image :src="picUrl+'/static/other/noMain_img3.png'" mode="" class="topBg"></image>

		<view class="content">
			<view class="topBox">
				<view class="lTxt">
					<image src="/static/index/water.png" mode="" class="water1"></image>
					<view class="main">
						<image src="/static/index/halfCircle_275.png" mode="" style="width: 56rpx;height: 56rpx;">
						</image>
						<text style="z-index: 3;position: relative;">定制我家的主灯</text>
					</view>
				</view>
				<view class="rDes">
					<view class="con">
						详情
					</view>
					<image src="/static/index/halfRight.png" mode="" style="width: 24rpx;height: 8rpx;">
					</image>
				</view>
			</view>

			<view class="label" @click="handleOpenOrClose(1)">
				<view class="txt">
					户型
				</view>
				<image :src="addOrLessIcon1" mode="" class="" :style="{height:addOrLessIcon1=='/static/index/shortLine.png'
					?'2rpx':'22rpx'}" style="width: 22rpx;margin-right: 56rpx;">
				</image>
			</view>

			<view class="parms">
				<view v-if="show1" @click="handleSelHuxing(index)" class="item "
					:class="[currHouseIndex==index?'act':'']" v-for="(item,index) in houseTypeList">
					{{item}}
				</view>
			</view>

			<view class="label" @click="handleOpenOrClose(2)">
				<view class="txt">
					系列
				</view>
				<image :src="addOrLessIcon2" mode="" class="" :style="{height:addOrLessIcon2=='/static/index/shortLine.png'
					?'2rpx':'22rpx'}" style="width: 22rpx;margin-right: 56rpx;">
				</image>
			</view>

			<view class="parms">
				<view v-if="show2" @click="currHouseIndex5=index" class="item "
					:class="[currHouseIndex5==index?'act':'']" v-for="(item,index) in serTypeList">
					{{item}}
				</view>
			</view>

			<view class="label" style="margin-bottom:32rpx;" @click="toSel">
				<view class="txt">
					挑选客厅灯
				</view>
				<image src="/static/index/more.png" mode="" class="" style="width: 44rpx;height: 44rpx;">
				</image>
			</view>

			<view class="parms3">
				<image @click="handleSelKeting(item,i)" class="item3 " :src="picUrl+'/static/other/main_img1.png'"
					:class="[currHouseIndex3==i?'act3':'']" v-for="i in 5">

				</image>
			</view>

			<view class="label" style="margin-bottom:32rpx;">
				<view class="txt">
					挑选餐厅灯
				</view>
				<image src="/static/index/more.png" mode="" class="" style="width: 44rpx;height: 44rpx;">
				</image>
			</view>

			<view class="parms3">
				<image @click="currHouseIndex2=i" class="item3 " :src="picUrl+'/static/other/main_img1.png'"
					:class="[currHouseIndex2==i?'act3':'']" v-for="i in 5">

				</image>
			</view>

			<view class="label" style="margin-bottom:32rpx;">
				<view class="txt">
					挑选卧室灯
				</view>
				<image src="/static/index/more.png" mode="" class="" style="width: 44rpx;height: 44rpx;">
				</image>
			</view>

			<view class="parms3">
				<image @click="currHouseIndex4=i" class="item3 " :src="picUrl+'/static/other/main_img1.png'"
					:class="[currHouseIndex4==i?'act3':'']" v-for="i in 5">

				</image>
			</view>

			<view class="label" style="margin-bottom:32rpx;">
				<view class="txt">
					挑选阳台灯
				</view>
				<image src="/static/index/more.png" mode="" class="" style="width: 44rpx;height: 44rpx;">
				</image>
			</view>

			<view class="parms3">
				<image @click="currHouseIndex6=i" class="item3 " :src="picUrl+'/static/other/main_img1.png'"
					:class="[currHouseIndex6==i?'act3':'']" v-for="i in 5">

				</image>
			</view>



		</view>

		<view class="rule" @click="goRule">
			<image src="/static/index/ruleImg.png" mode=""></image>
			<view class="txt">
				挑选规则
			</view>
		</view>
		<view class="bot">
			<view class="left" @click="showConfig=true">
				<view class="price">
					￥2099，9900
				</view>
				<!-- <image src="/static/index/arrDown.png" mode=""></image> -->
				<image v-if="!showConfig" src="/static/index/arrDown.png" mode="" @click="showConfig=true"></image>
				<image v-else src="/static/index/arrUp.png" mode="" @click="showConfig=false"></image>
			</view>
			<view class="right" @click="previewConfig">
				预览配置
			</view>
		</view>

		<u-popup :show="showConfig" @close="close" @open="open" round='10'>
			<view class="topBar" style="">
				<view class="left">
				</view>
				<view class="cen">
					清单
				</view>
				<view class="close" @click="showConfig=false">
					<u-icon name="close"></u-icon>
				</view>
			</view>
			<view class="pupopCon">
				<view class="item">
					<view class="top">
						<view class="name">
							户型
						</view>
						<view class="info">
							一室两厅
						</view>
					</view>
				</view>
				<view class="item">
					<view class="top">
						<view class="name">
							系列
						</view>
						<view class="info">
							3系
						</view>
					</view>
				</view>
				<view class="item">
					<view class="top">
						<view class="name">
							客厅灯
						</view>
						<view class="info">
							1
						</view>
					</view>
				</view>
				<view class="item">
					<view class="top">
						<view class="name">
							餐厅灯
						</view>
						<view class="info">
							1
						</view>
					</view>
				</view>
				<view class="item">
					<view class="top">
						<view class="name">
							卧室灯
						</view>
						<view class="info">
							2
						</view>
					</view>
				</view>
				<view class="item">
					<view class="top">
						<view class="name">
							阳台灯
						</view>
						<view class="info">
							1
						</view>
					</view>
				</view>
			</view>
		</u-popup>

		<u-modal :show="showHuxing" @confirm="showHuxing=false" title="户型" :content='content' confirmColor="#F7790C">
			<view class="tipContent">
				<view class="card">
					<view class="item">
						<view class="left">
							主灯全套定制
						</view>
						<view class="right">
							￥2781.28
						</view>
					</view>

					<view class="item">
						<view class="left" style="font-weight: normal;">
							灯具
						</view>
						<view class="right">
							3
						</view>
					</view>
				</view>

				<view class="tip">
					<image src="/static/index/more.png" mode=""></image>
					这个套餐为一室两厅，包含3盏灯
				</view>
			</view>
		</u-modal>

		<u-modal :show="showMissItem" title="提示" @confirm="showMissItem=false" content='' confirmColor="#F7790C">
			<view class="tip2">
				客厅灯具少选1盏！
			</view>
		</u-modal>
	</view>
</template>

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

		},
		data() {
			return {
				picUrl: this.$picUrl,

				addOrLessIcon1: '/static/index/add.png',
				addOrLessIcon2: '/static/index/add.png',
				addOrLessIcon3: '/static/index/add.png',
				addOrLessIcon4: '/static/index/add.png',
				addOrLessIcon5: '/static/index/add.png',
				// lessIcon: require('/static/index/shortLine.png'),

				show1: false,
				show2: false,
				show3: false,
				show4: false,
				show5: false,

				showConfig: false,

				showHuxing: false,

				showMissItem: false,

				seledKetingItem: null,

				currHouseIndex: 0,
				currHouseIndex1: 0,
				currHouseIndex2: 0,
				currHouseIndex3: 0,
				currHouseIndex4: 0,
				currHouseIndex5: 0,
				currHouseIndex6: 0,
				houseTypeList: [
					'一室两厅',
					'两室两厅',
					'三室两厅'
				],
				brandTypeList: [
					'品牌1',
					'品牌2',
				],
				lockTypeList: [
					'全屋',
					'客餐厅',
					'主卧室',
				],
				pannelTypeList: [
					'3系',
					'5系',
				],
				chuanglianTypeList: [
					'标准版',
					'智能版',
				],
				ktTypeList: [
					'筒灯',
					'射灯',
					'线性灯',
					'磁吸轨道灯',
				],
				serTypeList: [
					'3系',
					'5系',
				],
			}
		},
		async onLoad(o) {
			let res = await getIndexConfigReq({
				type: 2
			})
			if (res.code == 0) {
				console.log('获取首页配置返回值-主灯: ', res);
				// this.houseTypeList = res.data.house_type
				// this.brandTypeList = res.data.brand
				// this.lockTypeList = res.data.space
				// this.serTypeList = res.data.series
				// this.chuanglianTypeList = res.data.version

				// this.selHx = res.data.house_type[0]
				// this.selKj = res.data.space[0]
				// this.selPp = res.data.brand[0]
				// this.selXl = res.data.series[0]
				// this.selBb = res.data.version[0]
				// this.rule = res.data.rule.content

				// this.getPrice(1, this.selHx.id, this.selKj.id, this.selPp.id, this.selXl.id, this.selBb.id)

			} else {
				uni.showToast({
					title: res.message,
					icon: 'none'
				})
			}

		},
		methods: {
			goRule() {
				uni.navigateTo({
					url: '/pages/index/rule/index?type=main'
				})
			},
			toSel() {
				uni.navigateTo({
					url: '/pages/index/mainList/index'
				})
			},
			handleOpenOrClose(i) {
				if (this['addOrLessIcon' + i] == '/static/index/shortLine.png') {
					this['addOrLessIcon' + i] = '/static/index/add.png'
					this['show' + i] = false
				} else if (this['addOrLessIcon' + i] == '/static/index/add.png') {
					this['addOrLessIcon' + i] = '/static/index/shortLine.png'
					this['show' + i] = true
				}
			},
			handleSelHuxing(index) {
				this.currHouseIndex = index
				this.showHuxing = true
			},
			handleSelKeting(item, index) {
				item = '1'
				this.currHouseIndex3 = index
				this.seledKetingItem = item
			},
			previewConfig() {
				if (!this.seledKetingItem) {
					this.showMissItem = true
					return
				} else {
					uni.navigateTo({
						url: '/pages/index/customMian/index'
					})
				}
			}
		}
	}
</script>

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