<template>
	<view class="unleased-pages-main">
		<!-- <navBar type="index"/> -->
		<!-- #ifdef MP-WEIXIN -->
		<view :style="{height: `${statusBarHeight + 30}px`}"></view>
		<!-- #endif -->
		<!-- #ifdef APP -->
		<view :style="{height: `${statusBarHeight}px`}"></view>
		<!-- #endif -->


		<view v-if="!isShow">
			<view style="margin: 0 50rpx 0rpx;height: 420rpx;">
				<u-swiper v-if="img_list.length!=0" :list="img_list" @change="tapSwiper" :autoplay="false" mode="none"
					:height="420" bgColor="transparent" class="custom-swiper">
				</u-swiper>
			</view>
			<view class="car-model-step">
				<view style="padding-top: 80rpx;margin-bottom: 60rpx;">
					<view class="recommend-car-name w_100 text-center">{{moder_info.model_name}}</view>
					<view class="recommend-car-tip w_100 text-center line2">{{moder_info.title || $t('续航开新路') + $t('路遥见实力')}}</view>
					<!-- <view class="car-speed-view">
						<view class="car-speed">72 <text class="company">km</text></view>
						<text>{{ $t('全速续航') }}</text>
					</view> -->
					<!-- <view class="car-speed-view">
						<view class="car-speed">52 <text class="company">km/h</text></view>
						<text>{{ $t('极速可达') }}</text>
					</view> -->
				</view>
				<view class="flex-row" @tap="navCarDetail" style="justify-content: center;">
					<view class="more-btn flex-row">
						<view class="more-btn-text">{{ $t('了解更多') }}</view>
						<img class="more-btn-img" src="https://qiniu.bms16.com/Fi2Lg800Mc1MhCnvHT1DkvOEdJB1" alt="">
					</view>
				</view>
				<view class="flex-row dot-view">
					<view v-for="(item,index) in img_list" :key="index" :class="['dot', { active: index === current }]">
					</view>
				</view>
				<view class="flex-row flex-around">
					<view @tap="navCarDetail" class="lease-btn">{{ $t('租赁设备') }}</view>
					<view class="binding-btn">{{ $t('绑定设备') }}</view>
				</view>
			</view>
		</view>
		<view v-else>
			<view style="margin: 0 50rpx 0rpx;height: 420rpx;">
				<u-swiper  :list="['https://qiniu.bms16.com/Fqf6jeV9PQGeHXkXMHOi_jlPsTme']" :autoplay="false" mode="none"
					:height="420" bgColor="transparent" class="custom-swiper">
				</u-swiper>
			</view>
			<view class="car-model-step">
				<view style="padding-top: 80rpx;margin-bottom: 60rpx;">
					<view class="recommend-car-name w_100 text-center">{{ $t('全新车型，即将发布！') }}</view>
					<view class="recommend-car-tip w_100 text-center line2">{{ $t('更智能、更高效，全新车型即将亮相，敬请期待！') }}</view>
					<!-- <view class="car-speed-view">
						<view class="car-speed">72 <text class="company">km</text></view>
						<text>{{ $t('全速续航') }}</text>
					</view> -->
					<!-- <view class="car-speed-view">
						<view class="car-speed">52 <text class="company">km/h</text></view>
						<text>{{ $t('极速可达') }}</text>
					</view> -->
					
				</view>
				<view class="flex-row" @tap="navCarDetail1" style="justify-content: center;">
					<view class="more-btn flex-row">
						<view class="more-btn-text">{{ $t('了解更多') }}</view>
						<img class="more-btn-img" src="https://qiniu.bms16.com/Fi2Lg800Mc1MhCnvHT1DkvOEdJB1" alt="">
					</view>
				</view>
				<view style="height: 160rpx;"></view>
				<view class="flex-row flex-around">
					<view @tap="navCarDetail1" class="lease-btn">{{ $t('租赁设备') }}</view>
					<view class="binding-btn">{{ $t('绑定设备') }}</view>
				</view>
			</view>
		</view>

	</view>
</template>
<script module="tools" lang="wxs" src="@/pages/common/wxs/tools.wxs"></script>
<script module="tools" lang="sjs" src="@/pages/common/wxs/tools.sjs"></script>
<script>
	const config = require('@/common/config.js');
	const common = require('@/common/common.js');
	const http = require('@/common/http.js');
	const storage = require('@/common/storage.js');
	export default {
		props: {
			model_list: {
				type: Array,
				default: []
			},
			img_list: {
				type: Array,
				default: []
			},
		},
		data() {
			return {
				isShow:false,
				current: 0,
				model_id: '', //租赁设备编号
				moder_info: {},
				statusBarHeight: 0
			};
		},
		mounted() {
			this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight || 0
		}
		/**
		 * 生命周期函数--监听页面加载
		 */
		,
		watch: {
			model_list(newVal) {
				console.log("子组件 props 更新:", newVal);
				if (newVal.length > 0) {
					this.isShow = true
					if (newVal[0]) {
						this.moder_info = newVal[0]
						this.model_id = newVal[0].model_id
					}
				}else{
					this.moder_info = {}
					this.model_id = 0
					this.isShow = false
				}

			}
		},
		methods: {
			tapSwiper(e) {
				this.setData({
					current: e,
					moder_info: this.model_list[e],
					model_id: this.model_list[e].model_id
				})
			},
			navCarDetail1(){
				uni.switchTab({
					url:"/pages/service/service"
				});
			},
			navCarDetail() {
				const me = this
				uni.navigateTo({
					url: '/pages/carDetail/carDetail?model_id=' + me.model_id
				})
			}
		}
	};
</script>
<style>
	@import './unleasedPages.css';
</style>