<template>
	<view>
		<view class="banner" v-if="detailData">
			<u-swiper :list="detailData.imgList" @change="e => currentNum = e.current" indicatorStyle="right: 20px;bottom:25px" height="400" circular>
				<view slot="indicator" class="indicator-num">
						<text class="indicator-num__text">{{ currentNum + 1 }}/{{detailData.imgList.length}}</text>
				</view>
			</u-swiper>
		</view>
		<view class="middle">
			<view class="middle-introduce">
				<view>
					<view>
						重庆湖广会馆
					</view>
					<view>
						<view>
							<text>开园中</text>
							<text>09:00~18:30</text>
						</view>
						<view>
							<text>详情</text>
							<u-icon name='arrow-right'></u-icon>
						</view>
					</view>
				</view>
				<view>
					
				</view>
				<view>
					
				</view>
			</view>
			
			<view class="middle-list">
				
			</view>
		</view>
		
	</view>
</template>

<script>
export default {
  data() {
    return {
      ticketList:[],//门票列表
      detailData:'',//详情数据
      currentNum:0,//轮播图下标
    }
  },
  onLoad(option) {
    this.nowTime=parseInt(new Date().Format('hhmm'))
    this.companyId=this.$commonjs.getCompanyId(option)||''
    this.merchantId = this.$commonjs.getKey(option,'merchantId')|| ''
    this.channelType = this.$commonjs.getKey(option,'channelType')|| 0
    this.initProduct()
    this.initDetail()
  },
  methods: {
    //---产品加载
    initProduct(){
      this.ticketList=[]
      let data={
        merchantId:this.merchantId,//商户id
        type:1,//类型：1景区、2酒店、3餐饮
        channelType:this.channelType,//渠道Id
      }
      this.$request('scenic/user/product/findProductList',data).then((res)=>{
        if(res.code=='00'){
          let list=res.data.list||[]
          list.forEach((item,index)=>{
            //营业时间重新组成
            if(item.businessTime){
              item.businessTime=item.businessTime.split(';')
            }
            //等于7为特价
            if(item.channelType!=7){
              this.ticketList.push(item)
            }
          })
        }else{
          uni.showToast({
            title: res.message,
            icon: 'none'
          })
        }
      })
    },
    //---详情加载
    initDetail(){
      let data={
        userId:uni.getStorageSync('userId')||'',
        openid:uni.getStorageSync('openid')||'',
        id:this.merchantId,//商户id
        isDetail:1,//商户详情
      }
      this.$request('scenic/user/merchant/findDetailInfo',data).then((res)=>{
        if(res.code=='00'){
          this.detailData=res.data
          if(this.detailData.tag){
            this.tagArr=this.detailData.tag.split(',')
          }
          let start=''
          let end=''
          if(this.detailData.businessStart){
            start=parseInt(this.$commonjs.changeTime(this.detailData.businessStart.substr(0,5)))
          }
          if(this.detailData.businessEnd){
            end=parseInt(this.$commonjs.changeTime(this.detailData.businessEnd.substr(0,5)))
          }
          if(start<this.nowTime<end){
            this.status='开园中'
          }else{
            this.status='闭园中'
          }
        }else{
          uni.showToast({
            title: res.message,
            icon: 'none'
          })
        }
    
      })
    },
  }
}
</script>

<style scoped lang="scss">
.middle{
	position: relative;
	top: -60rpx;
}
.middle-introduce{
	background: #FFFFFF;
	padding: 30rpx 20rpx 0 20rpx;
	border-radius: 24rpx 24rpx 0 0;
}
</style>