<template>
  <BaseContainer class="thematic-details">
    <NavBar title="线下课详情" />
    <template>
      <view class="base-wrap">
        <view class="swiper-details">
					<view class="special-coverimg">
						<image :src="specialInfo.pic" mode="aspectFill"></image>
					</view>

          <view class="swiper">
            <view class="name txp1">
              {{ specialInfo.title || "加载中" }}
            </view>
						<view class="swiper-info flex flex-center-x">
							<view class="remark">免费课</view>
							<view class="apply-count">{{ specialInfo.apply_count }}人已报名</view>
						</view>
            <view class="swiper-int">
              <view class="advert-info">
              	<image src="@/static/images/advert-time.png" mode="aspectFill"></image>
              	报名时间:{{ specialInfo.apply_start_time }} - {{ specialInfo.apply_end_time }}
              </view>
              <view class="advert-info">
              	<image src="@/static/images/advert-time.png" mode="aspectFill"></image>
              	活动时间:{{ specialInfo.start_time }} - {{ specialInfo.end_time }}
              </view>
              <view class="advert-info">
              	<image src="@/static/images/advert-position.png" mode="aspectFill"></image>
              	活动地址:{{ specialInfo.address }}
              </view>
            </view>
          </view>
          <!-- 导航栏 -->
          <view ref="list" class="swiper-nav">
            <view class="navCon acea-row row-middle">
                <view v-for="nav in cloumnNavlist" :key="nav.value" :class="{ on: active === nav.value }" class="item"
                  @click="active = nav.value">
                  {{ nav.title}}
                </view>
            </view>
          </view>

          <!-- 详情 -->
          <mp-html v-if="active === 1" class="swiper-conter" container-style="padding: 30rpx;background: #ffffff;"
            :content="specialInfo.desc"></mp-html>
					<!-- 规则 -->
					<mp-html v-if="active === 2" class="swiper-conter" container-style="padding: 30rpx;background: #ffffff;"
					  :content="specialInfo.rule"></mp-html>
        </view>
      </view>

      <view class="acea-row row-middle footer" ref="storeMenu">
				<view class="video_footer_btn">
					<text @click="joinNow">立即参与</text>
				</view>
      </view>
    </template>
  </BaseContainer>
</template>

<script>
	import userInfoMixins from "@/mixins/userInfo";
  import {
    getOfflineSpecialInfo,
  } from "@/api/special";
  import mpHtml from "mp-html/dist/uni-app/components/mp-html/mp-html.vue";

  export default {
    mixins: [userInfoMixins],
    components: {
      mpHtml,
    },
    data() {
      return {
				specialInfo: {},
        cloumnNavlist: [
          {
            title: "详情",
            value: 1,
          },
          {
            title: "规则",
            value: 2,
          },
        ],
        active: 1,

      };
    },
    onShow() {
      this.getOfflineSpecialInfo();
    },
    onLoad(options) {
      this.special_id = options.id;
      this.getOfflineSpecialInfo();

    },
    created() {
      //#ifdef MP-WEIXIN
      wx.showShareMenu({
        withShareTicket: true,
        menus: ['shareAppMessage', 'shareTimeline']
      });
      //#endif
    },
    // 分享朋友
    onShareAppMessage() { 
      console.log();
      return { title: this.specialInfo.title, path: '/pages/special/details?id=' + this.special_id +'&spread_uid='+(this.userInfo.uid??0) }
    },
    onShareTimeline() {
      return {
        title: this.specialInfo.title,
        imageUrl: this.swiperlist[0]
      };
    },
    methods: {
      getOfflineSpecialInfo() {
        return getOfflineSpecialInfo(this.special_id)
          .then(({ data }) => {
						this.specialInfo = data;
          })
          .catch((err) => {
            this.$util.showMsg(err.msg);
            setTimeout(() => {
              // #ifndef MP
              uni.reLaunch({
                url: '/pages/index/index'
              })
              // #endif
              // #ifdef MP
              uni.navigateBack({
                fail: (err) => {
                  uni.switchTab({
                    url: '/pages/index/index'
                  });
                }
              })
              // #endif
            }, 2000);
          });
      },
			joinNow() {
				this.$util.checkLogin(() => {
				  uni.navigateTo({
				    url: `/pages/special/offline_apply?id=${this.special_id}`
				  });
				}, true);
			},
    },
  };
</script>

<style>
  page {
    background: #f5f5f5;
  }
</style>
<style scoped lang="scss">
	.swiper-details .special-coverimg {
		width: 100%;
		height: 270rpx;
		> image {
			width: 100%;
			height: 100%;
		}
	}

  .navCon {
    position: relative;
    padding: 0 30rpx;
  }
	.navCon {
		.item {
			margin: 0 72rpx 0 0!important;
			&.on {
				font-weight: normal!important;
				&:after {
					background: linear-gradient(90deg, #24A9E1, #0F74BB);
					border-radius: 3rpx;
				}
			}
			&:last-child {
				margin-right: 0;
				color: #999;
				font-size: 28rpx;
			}
		}
	}
  .video_footer_btn {
    width: 600rpx;
    height: 88rpx;
    border-radius: 44px;
		background: linear-gradient(0deg, #0F74BB 0%, #3293FF 100%);
		color: #FFFFFF;
		font-size: 30rpx;
		text-align: center;
		line-height: 88rpx;
  }

  .base-wrap {
    padding-bottom: calc(100rpx + var(--safe-bottom));
  }

  .thematic-details .footer {
    position: fixed;
    bottom: 0;
    left: 0;
    z-index: 9;
    width: 100%;
    border-top: 1px solid #eee;
    background-color: #ffffff;
		display: flex;
		align-items: center;
		justify-content: center;
		height: 130rpx;
		box-shadow: 0rpx -19rpx 54rpx 0rpx rgba(34,34,34,0.05);
  }

  .thematic-details .footer .link {
    width: 90rpx;
    height: 100rpx;
    line-height: 100rpx;
    text-align: center;
  }

  .thematic-details .footer .link .cont {
    display: inline-block;
    vertical-align: middle;
    font-size: 20rpx;
    line-height: 36rpx;
    color: #666;
  }

  .thematic-details .footer .link image {
    display: block;
    width: 44rpx;
    height: 44rpx;
    margin-right: auto;
    margin-left: auto;
  }

  .thematic-details .footer .wrap {
    flex: 1;
    min-width: 0;
    padding-right: 30rpx;
    padding-left: 30rpx;
  }

  .thematic-details .footer .item {
    border: 1rpx solid #d9d9d9;
    width: 133rpx;
    height: 100rpx;
    border-radius: 10rpx;
    font-size: 24rpx;
    color: #333;
  }

  .thematic-details .footer .item image {
    width: 42rpx;
    height: 46rpx;
  }

  .thematic-details .footer .item.item1 {
    width: 187rpx;
  }

  .thematic-details .footer .item.item2 {
    width: 187rpx;
    background-color: #f9e067;
    border-color: #f9e067;
  }

  .thematic-details .footer .item .money {
    font-size: 36rpx;
    color: #333;
    font-weight: bold;
    margin-bottom: -6rpx;
  }

  .thematic-details .footer .item.on {
    width: 390rpx;
  }

  .thematic-details .footer .item.on .money {
    margin-bottom: 0;
  }

  .thematic-details .swiper-details .swiper-nav {
    background: #ffffff;
		width: 690rpx;
		margin: 20rpx auto 0;
  }
	.thematic-details .swiper-details .swiper-conter {
	  background: #ffffff;
		width: 690rpx;
		margin: 0 auto;
	}

  .thematic-details .swiper-details .swiper {
    background-color: #ffffff;
    // border-radius: 40rpx 40rpx 0 0;
    // position: relative;
    margin: 22rpx auto 0;
    width: 690rpx;
		border-radius: 10rpx;
		padding: 38rpx 30rpx 0;
		.txp1 {
			padding: 0;
			margin-bottom: 20rpx;
		}
		.swiper-info {
			justify-content: flex-end;
			padding-bottom: 27rpx;
			border-bottom: 2rpx solid #f6f6f6;
			.remark {
				height: 39rpx;
				background: #FFEDE9;
				border-radius: 6rpx 0rpx 6rpx 0rpx;
				padding: 0 18rpx;
				line-height: 39rpx;
				color: #FF4B33;
				font-size: 22rpx;
			}
			.apply-count {
				color: #999999;
				font-size: 20rpx;
				margin-left: auto;
			}
		}
  }

  .thematic-details .swiper-details .swiper .name {
    -webkit-line-clamp: 2;
    overflow: hidden;
  }


  .thematic-details .swiper-details .swiper .swiper-int {
		flex-direction: column;
		align-items: flex-start;
		padding: 30rpx 0 40rpx;;
		.advert-info {
			color: #999;
			font-size: 20rpx;
			overflow: hidden;
			text-overflow: ellipsis;
			white-space: nowrap;
			margin-top: 20rpx;
			line-height: 24rpx;
			display: flex;
			align-items: center;
			margin-top: 16rpx;
			>image {
				width: 24rpx;
				height: 24rpx;
				margin-right: 5rpx;
			}
		}
	}

  .txp1 {
    padding: 25rpx 30rpx 0;
    font-size: 32rpx;
    line-height: 50rpx;
    color: #333333;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }
</style>