<template>
	<view class="ss-p-x-20">
		<!-- 轮播图 -->
		<swiper
      circular
      :indicator-dots="preferred.carousel.length > 1 ? true : false"
      :autoplay="true"
      :interval="3000"
      :duration="500"
      indicator-active-color="#fff"
	  	style="height: 180px;"
    >
			<swiper-item v-for="(item, index) in preferred.carousel" :key="index">
        <image :src="item" style="width: 100%; height: 100%"></image>
			</swiper-item>
		</swiper>
		<!-- 集团简介 -->
		<view class="ss-m-t-50">
			<!-- 标题 -->
			<uni-title class="ss-m-b-30" type="h1" :title="preferred.introduce.title" align="center"></uni-title>
			<!-- 简介 -->
			<rich-text v-for="(desc, index) in preferred.introduce.describe" :key="index" class="ss-m-b-30 color-666" :nodes="desc" style="display: block;"></rich-text>
			<!-- 小图 -->

			<!-- 大图 -->
			<image class="ss-m-y-30" :src="preferred.introduce?.bigPicture" style="width: 100%; height: 115px;"></image>
		</view>

		<!-- 品牌介绍 -->
		<uni-swiper-dot class="uni-swiper-dot-box" @clickItem="clickItem" :info="preferred.brandIntroduce" :current="current" mode="nav" :dots-styles="dotsStyles" field="content">
			<swiper class="swiper-box" @change="change" :current="swiperDotIndex">
				<swiper-item v-for="(item, index) in 17" :key="index">
					<view class="swiper-item" :class="'swiper-item' + index">
						<text style="color: #fff; font-size: 32px;">{{index+1}}</text>
					</view>
				</swiper-item>
			</swiper>
		</uni-swiper-dot>
	</view>
</template>

<script setup>
import { ref } from 'vue'
import { onShow, onLoad, onShareAppMessage } from '@dcloudio/uni-app'

const title = ref('')
const enterpriseId = ref(null)
const preferred = ref({}) // 当前企业信息
const preferredGroup = ref({}) // 优选集团信息

onLoad((options) => {
	enterpriseId.value = options.id
	uni.request({
	  url: 'https://minio.menduner.com/dev/4bf5186e6a19347acfc858eaf835a7dec5200465a911d940b06688543eb95fd3.json',
	  method: 'GET',
	  success: (res) => {
			preferredGroup.value = res.data
			if (!enterpriseId.value || !preferredGroup.value[enterpriseId.value]) return uni.navigateBack({ delta: 1 })
			preferred.value = preferredGroup.value[enterpriseId.value]
			title.value = preferred.value.title

			console.log(preferred.value, 'preferred.value')
	  },
	  fail: res => {
	    log(res, 'fail')
	  }
	})
})

onShareAppMessage(() => {
  if(!title.value){
		setTimeout(() => {},1000)
	}
  return {
    title: title.value || '门墩儿 专注顶尖招聘',
    path: '/pagesB/preferredGroup/index?id=' + enterpriseId.value
  }
})

const current = ref(0)
const swiperDotIndex = ref(0)
const dotsStyles = ref({})
const clickItem = (item) => {
	console.log(item, 'click')
}
const change = (e) => {
	console.log(e, 'change')
  current.value = e.detail.current
}
</script>

<style scoped lang="scss">

</style>
