<template>
    <div class="el-active_show_detail_pc_1">
        <!--活动详情展示组件1开始-->
        <div class="active_show_detail_pc_1">
            <div class="container">
                <div class="row">
                    <div class="col-lg-5 col-md-5 col-sm-12 col-xs-12">
                        <div class="yanxueyou2-pic">
                            <img v-if="infos.actImgs" :src="infos.actImgs" alt="">
                            <img v-else src="../../theme-chalk/src/images/class-pic01.png" alt="">
                        </div>
                    </div>
                    <div class="col-lg-7 col-md-7 col-sm-12 col-xs-12">
                        <div class="yanxueyou2-info">
               <span class="sp1">
                  {{infos.actTitle}}
                   <!-- <a href="" class="share">分享</a> -->
               </span>
                            <!-- <span class="sp2 clearfix">
                                <span class="spp1">合肥市<i>出发城市</i></span>
                                <span class="spp2">北京、上海、苏州、南京、无锡、常州、扬州<i>出发城市</i></span>
                                <span class="spp3">2020.10.0-2020.11.31<i>活动日期</i></span>
                             </span>-->
                            <span class="sp3">
                  <ul class="clearfix">
                     <li style="width: 100%;"><span>报名时间：</span>{{infos.actStartDate | $toDate}} 至 {{infos.actEndDate | $toDate}}</li>
                      <li><span>区域名称：</span>{{infos.actAreaName}}</li>
                      <li><span>分类名称：</span>{{infos.catName}}</li>
                      <!--<li><span>主办机构：</span>安徽老年协会</li>
                      <li><span>供应商：</span>安徽省中旅国际旅行社</li>
                      <li>
                         <span>活动票种：</span>
                         <select name="" id="">
                            <option value="">北京进出双飞五日游</option>
                         </select>
                      </li> -->
                     <li><span>累计报名人数：</span>{{Number(infos.actSignupNum)}}人</li>
                  </ul>
               </span>
                        </div>
                    </div>
                </div>

                <div class="row">
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                        <div class="yanxueyou2-booking clearfix">
                            <!--
                             <span class="sp1" >
                                <i>出发</i>
                                <select name="" id="">
                                   <option value="">2020-10-01 星期四</option>
                                </select>
                             </span>
                             <span class="sp2" >
                                <i>成人<span>15-65周岁</span></i>
                                <select name="" id="">
                                   <option value="">1</option>
                                </select>
                             </span>
                             <span class="sp2"  >
                                <i>儿童<span>5-15周岁（不含）</span></i>
                                <select name="" id="">
                                   <option value="">0</option>
                                </select>
                             </span>
                             <span class="sp3"  >
                                <i>¥2000.00</i>
                                成人
                             </span>
                             <span class="sp3"  >
                                <i>¥1000.00</i>
                                儿童
                             </span>
                             -->


                            <span class="sp4">
                  总价：<i v-if="Number(infos.actPrice)===0"> 免费</i>
                  <i v-else>¥{{infos.actPrice}}元</i>
               </span>
                            <span class="sp5">

                  <a v-if="hasBuy" href="javascript:void(0)">已预定</a>
                  <a v-else @click="reservation" href="javascript:void(0)">立即预定</a>
               </span>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                        <div class="et4-class-body">
                            <div class="et4-class-body-hd">
                                <ul>
                                    <li style="padding:0;">活动介绍</li>
                                    <!-- <li  class="active">行程安排</li>
                                     <li>活动攻略</li>
                                     <li>活动评价(22)</li> -->
                                </ul>
                            </div>
                            <div class="et4-class-body-bd" v-html="infos.actContent">

                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!--活动详情展示组件1结束-->
    </div>
</template>


<script>
  import formMixin from '../../../src/mixins/formMixin';
  import lenye_base from 'lenye_base';
  import * as $ from 'fy-kit';
  import msg from '../../message';

  import el from '../../../src/locale/lang/el';

  export default {
    name: 'ElActiveShowDetailPc1',
    mixins: [formMixin],
    components: {
      msg
    },
    props: {
      placeholder: {
        type: String,
        default: '总访问量a'
      }
    },
    data() {
      return {
        infos: {},
        isLogin: false,
        hasBuy: false   //是否已报名
      };
    },
    created() {
      if ($.util.storage('userData').get().getValue()) {

        this.isLogin = true;
        this.isBuy();
      }
    },
    filters: {
      $toDate(val) {
        return $.date.moment(val).format('YYYY-MM-DD');
      }
    },
    mounted() {
      this.getInfo();
    },
    computed: {
      defaultAttrs() {
        return {
          placeholder: this.t('ele-form.input') + this.desc._label
        };
      }
    },
    methods: {
      subSign() {
        var Params = JSON.parse(localStorage.Params);
        Params['custId'] = JSON.parse(localStorage.userData).custId;
        $.util
          .ajax(
            lenye_base.base_data.getapiUrl() +
            '/orderform-service/api2/ordShoppingCart/signup.do',
            lenye_base.base_data.getformatting(Params)
          )
          .then(res => {
            if (res.success == '1') {


              var status = res.data.status;
                if(status=='1'){  //待支付
                  msg.success('报名成功！');
                  setTimeout(()=>{
                     window.location.href = '/projectorderpay';
                  },1000);
                }else if(status=='2'){
                  msg.warning("已有待付订单！");
                   setTimeout(()=>{
                     window.location.href = '/personcenter';
                  },1000);
                }else if(status=='3'){
                  msg.success("报名成功！");
                }else{
                  msg.error('报名失败！');
                }
            } else {
              msg.error(res.message);
            }
          });
      },
      reservation() {
        if (lenye_base.user_data.getuserData()) {
          //todo.. 验证跳转
          $.util
            .ajax(
              lenye_base.base_data.getapiUrl() +
              '/travel-service/api2/actActivityMemer/signUp.do',
              lenye_base.base_data.getformatting({
                actId: $.util.urlParams('actId')
              })
            )
            .then(res => {
              if (res.success !== '1') {
                return msg.warning(res.message);
              } else {
                if (res.data.status === '2') {
                  window.parent.location = '/old/html/pay.html?pcode=payorder&orderId=' + res.data.orderId;
                  window.location.href = '/old/html/pay.html?pcode=payorder&orderId=' + res.data.orderId;
                } else {
                  msg.warning(res.data.msg);
                }
              }
            });
        } else {
          msg.warning('请先登录再预定！');
          return false;
        }
      },
      //是否报名
      isBuy() {
        $.util
          .ajax(
            lenye_base.base_data.getapiUrl() +

            '/travel-service/common/actActivityMemer/isSignUp.do',
            lenye_base.base_data.getformatting({
              actId: $.util.urlParams('actId')
            })
          )
          .then(res => {
            if (res.success == '1') {
              if (res.data.length > 0) {
                this.hasBuy = true;
              }
            } else {
              msg.error(res.message);
            }
          });
      },
      getInfo(num) {

        $.util
          .ajax(
            lenye_base.base_data.getapiUrl() +

            '/travel-service/common/actActivity/queryById.do',
            lenye_base.base_data.getformatting({
              actId: $.util.urlParams('actId')
            })
          )
          .then(res => {
            if (res.success == '1') {
              this.infos = res.data;
            } else {
              msg.error(res.message);
            }
          });

      }

    }
  };
</script>

