import { C as f } from './index.9169d438.js'
import { S as p } from './index.2778830d.js'
import { U as E } from './index.fdb44d83.js'
import { r as n, p as F } from './index.9e4b607f.js'
import {
  d as I,
  g as a,
  T as A,
  D as l,
  a as r,
  K as v,
  j as c,
  B as h
} from './vendor.3506a68e.js'
import { o as s, a as D } from './orderStatus.81f9c36b.js'
import { C as b } from './index.9a4c80cd.js'
import { C as Y } from './index.e311a214.js'
import './index.f15b595a.js'
/* empty css              */ /* empty css               */ /* empty css               */ import './icon_teacher.cb128c00.js'
import './icon_timer2.5fb1750d.js'
import './icon-jiaozi.20e415ca.js'
/* empty css               */ const g = '_introduction_17dsu_1',
  B = '_tips_17dsu_12',
  j = '_btnMore_17dsu_35'
var d = {
    'live-detail': '_live-detail_17dsu_1',
    introduction: g,
    tips: B,
    btnMore: j
  },
  T =
    'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAMAAADW3miqAAAAAXNSR0IArs4c6QAAASNQTFRFAAAA/wAA/4AA/6pV/5kz/4Ar/4BA/49A/445/4BA/4xA/4VD/4pA/4U9/4lA/4g7/4M+/4Y5/4Y9/4VA/4g+/4U9/4g8/4Y8/4Q+/4U//4U9/4g8/4Y+/4c9/4Y9/4c8/4c+/4c+/4U9/4Y+/4Y9/4Y8/4c+/4Y+/4c9/4Y9/4Y8/4Y9/4c9/4Y9/4Y8/4Y+/4U+/4U9/4c9/4Y8/4U+/4Y9/4c8/4Y8/4Y+/4Y9/4Y+/4c+/4c9/4Y9/4c+/4Y9/4Y9/4Y8/4c9/4Y9/4Y8/4Y9/4U9/4c9/4Y8/4c9/4Y9/4Y9/4Y9/4c9/4Y8/4Y+/4Y9/4Y9/4U8/4Y9/4Y9/4Y9/4Y8/4Y9/4Y9/4Y8/4Y9/4Y9/4Y9/4c9/4Y8/4Y9/4Y9qWZ60gAAAGB0Uk5TAAECAwUGEBASFBQXGBkcHiUoKiwtLi83OkFLTU5TVFVXYmRnaXJzdH1+h42Ok5SUlZeXmJmgoaWlp6qusLGys7u+w8rL0NbW19jZ3d7j5OTn7O3t8vP19/j5+fr7/P3+TBv5LQAAAThJREFUOMvF1OszQkEYx/FK6KakXMpBSDfkknIJSYUuKIVOl+P7//8VXmiOc057mDHTeF7t85vP7uzu7KzFMrE6eY3/jhQebD8Lf7IMdMtJvynx5oaMapjzik2oBdxnEonjO6AVEhmpD4Wlr/HiNfSlcRPsIG99t5tdOkGjsZb4WNcGawolqwFFYE+f7ELEgIq0Z/XJzAtFfeIYkDHu4IiBQxeEYewwEoR1QRTGzhKAqC6IgceIPBDTBXFwG5Eb4v+JUmKU0rS2LGJE1qa9AKXpNCJnU9FeQpW6T/TEfHWqatMjLX6saXrquEHNJTKuGg21SYD8LCgZkiqyX2JSV3bNwqvpU0EdSNY//QJzGwujidMr2/MmqA7tm7P9w4vbN3g0QUXtjvMmaGo5lq88vcutyvlOYEIf2ydPMlkWBCFozgAAAABJRU5ErkJggg==',
  H = I({
    name: 'LiveDetail',
    data() {
      const e = this.$route.query
      return {
        joinRoom: e.joinRoom,
        recomUserId: e.recomUserId,
        groupId: e.groupId,
        courseId: e.classId,
        live: {}
      }
    },
    computed: {
      userInfo() {
        var i, m
        const e = this.live,
          u = e.planList || [],
          t = ((i = u[0]) == null ? void 0 : i.startTime) || new Date(),
          o = ((m = u[0]) == null ? void 0 : m.endTime) || new Date()
        return {
          headUrl: e.avatar,
          username: e.userName || `\u6E38\u5BA2${e.teacherId || ''}`,
          startTime:
            `${a(t).format('YYYY-MM-DD')} ${a(t).format('HH:mm')}~${a(o).format(
              'HH:mm'
            )}` || '',
          buyNum: e.studentCount,
          lessonPrice: e.coursePrice,
          lessonNum: e.courseNum,
          lessonDesc: e.courseIntroduce,
          lessonCoverUrl: e.backgroundPic || e.backgroundPicTemplate,
          lessonName: e.courseGroupName,
          auditVersion: e.auditVersion || 0,
          isDegree: !!e.degreeFlag,
          isTeacher: !!e.teacherFlag
        }
      },
      courseInfo() {
        const e = []
        return (
          (this.live.planList || []).forEach(t => {
            const o = t.startTime || new Date(),
              i = t.endTime || new Date()
            e.push({
              courseTime: `${a(o).format('YYYY-MM-DD')} ${a(o).format(
                'HH:mm'
              )}~${a(i).format('HH:mm')}`,
              coursePlan: t.plan,
              roomUid: t.roomUid,
              liveState: t.liveState,
              id: t.courseId
            })
          }),
          e || []
        )
      },
      salesEndDate() {
        const e = this.live
        return a(e.salesEndDate || new Date()).format('YYYY-MM-DD')
      },
      liveStatus() {
        const e = this.live.planList || [],
          u = { status: !1, liveStatus: 0, roomUid: '' }
        return (
          e.forEach(t => {
            t.courseId === Number(this.courseId) &&
              ((u.status = !0),
              (u.liveStatus = t.liveStatus),
              (u.roomUid = t.roomUid))
          }),
          u
        )
      }
    },
    async mounted() {
      await this._init()
    },
    methods: {
      async _init() {
        try {
          const e = await n.get(
            '/api-student/courseGroup/queryLiveCourseInfo',
            { params: { groupId: this.groupId } }
          )
          this.live = e.data || {}
        } catch {}
      },
      async onJoinRoom() {
        try {
          const t =
            (
              (
                await n.get('/api-student/courseGroup/queryLiveCourseInfo', {
                  params: { groupId: this.groupId }
                })
              ).data || {}
            ).planList || []
          let o = {}
          t.forEach(i => {
            i.courseId === Number(this.courseId) && (o = i)
          }),
            console.log(o, this.live, 'tempObj'),
            o && o.liveState === 1
              ? F({
                  api: 'joinLiveRoom',
                  content: { roomId: o.roomUid, teacherId: this.live.teacherId }
                })
              : o && o.liveState === 2
              ? setTimeout(() => {
                  A('\u8BFE\u7A0B\u5DF2\u7ED3\u675F')
                }, 100)
              : setTimeout(() => {
                  A(
                    '\u8BFE\u7A0B\u5C1A\u672A\u5F00\u59CB\uFF0C\u8BF7\u8010\u5FC3\u7B49\u5019'
                  )
                }, 100)
        } catch {}
      },
      async onBuy() {
        try {
          const e = this.live
          if (
            ((s.orderObject.orderType = 'LIVE'),
            (s.orderObject.orderName = '\u76F4\u64AD\u8BFE\u8D2D\u4E70'),
            (s.orderObject.orderDesc = '\u76F4\u64AD\u8BFE\u8D2D\u4E70'),
            (s.orderObject.actualPrice = e.coursePrice),
            (s.orderObject.recomUserId = this.recomUserId),
            (s.orderObject.orderNo = ''),
            (s.orderObject.orderList = [
              {
                orderType: 'LIVE',
                goodsName: '\u76F4\u64AD\u8BFE\u8D2D\u4E70',
                courseGroupId: e.courseGroupId,
                courseGroupName: e.courseGroupName,
                coursePrice: e.coursePrice,
                teacherName: e.userName || `\u6E38\u5BA2${e.teacherId || ''}`,
                teacherId: e.teacherId,
                avatar: e.avatar,
                courseInfo: this.courseInfo,
                recomUserId: this.recomUserId
              }
            ]),
            e.coursePrice <= 0)
          ) {
            await D(() => {
              l.alert({
                message: '\u9886\u53D6\u6210\u529F',
                confirmButtonText: '\u786E\u5B9A',
                confirmButtonColor: '#01C1B5'
              }).then(() => {
                this._init()
              })
            })
            return
          }
          const t = (
            await n.post('/api-student/userOrder/getPendingOrder', {
              data: { goodType: 'LIVE', bizId: this.groupId }
            })
          ).data
          t
            ? l
                .confirm({
                  title: '\u63D0\u793A',
                  message:
                    '\u60A8\u6709\u4E00\u4E2A\u672A\u652F\u4ED8\u7684\u8BA2\u5355\uFF0C\u662F\u5426\u7EE7\u7EED\u652F\u4ED8\uFF1F',
                  confirmButtonColor: '#269a93',
                  cancelButtonText: '\u53D6\u6D88\u8BA2\u5355',
                  confirmButtonText: '\u7EE7\u7EED\u652F\u4ED8'
                })
                .then(async () => {
                  ;(s.orderObject.orderNo = t.orderNo),
                    (s.orderObject.actualPrice = t.actualPrice),
                    (s.orderObject.discountPrice = t.discountPrice),
                    this.routerTo()
                })
                .catch(() => {
                  l.close(), this.cancelPayment(t.orderNo)
                })
            : this.routerTo()
        } catch {}
      },
      routerTo() {
        const e = this.live
        this.$router.push({
          path: '/orderDetail',
          query: { orderType: 'LIVE', courseGroupId: e.courseGroupId }
        })
      },
      async cancelPayment(e) {
        try {
          await n.post('/api-student/userOrder/orderCancel', {
            data: { orderNo: e }
          })
        } catch {}
      }
    },
    render() {
      return r('div', { class: [d['live-detail'], 'mb12'] }, [
        r(b, null, null),
        r(E, { userInfo: this.userInfo, showBuy: !1 }, null),
        r(
          p,
          { border: !0 },
          {
            default: () => [
              r('p', { class: d.introduction }, [this.userInfo.lessonDesc])
            ]
          }
        ),
        r(
          p,
          {
            title: '\u8BFE\u7A0B\u5217\u8868',
            icon: 'courseList',
            border: !0,
            contentStyle: { paddingTop: '0' }
          },
          {
            default: () => [
              this.courseInfo.length > 0 &&
                r(
                  f,
                  {
                    courseInfo: this.courseInfo,
                    courseId: Number(this.courseId) || 0
                  },
                  null
                )
            ]
          }
        ),
        r('div', { class: d.tips }, [
          r('h3', null, [
            r(v, { name: T, size: 15 }, null),
            c('\u6E29\u99A8\u63D0\u793A')
          ]),
          r('p', null, [
            c(
              '1\u3001\u8BE5\u76F4\u64AD\u8BFE\u7A0B\u9500\u552E\u622A\u6B62\u540E\uFF0C\u62A5\u540D\u4EBA\u6570\u82E5\u5C11\u4E8E'
            ),
            this.live.mixStudentNum || 0,
            c(
              '\u4EBA\u5C06\u53D6\u6D88\u5F00\u8BFE\uFF0C\u5DF2\u8D2D\u4E70\u5B66\u5458\u4ED8\u8D39\u91D1\u989D\u5C06\u81EA\u52A8\u8FD4\u8FD8\uFF0C\u8BF7\u60A8\u653E\u5FC3\u8D2D\u4E70\uFF1B'
            ),
            r('br', null, null),
            c(
              '2\u3001\u76F4\u64AD\u8BFE\u6559\u5B66\u8BA1\u5212\u4E2D\u7684\u4E0A\u8BFE\u65F6\u95F4\u4E3A\u8001\u5E08\u9884\u8BA1\u65F6\u95F4\uFF0C\u5B9E\u9645\u4E0A\u8BFE\u65F6\u95F4\u4EE5\u8001\u5E08\u5F00\u542F\u76F4\u64AD\u65F6\u95F4\u4E3A\u51C6\uFF1B'
            ),
            r('br', null, null),
            c(
              '3\u3001\u82E5\u60A8\u9519\u8FC7\u8001\u5E08\u76F4\u64AD\uFF0C\u53EF\u901A\u8FC7\u89C6\u9891\u56DE\u653E\u89C2\u770B\u5B8C\u6574\u8BFE\u7A0B\u3002'
            )
          ])
        ]),
        this.courseInfo.length > 0 &&
          this.live.existBuy !== 1 &&
          r(
            Y,
            { position: 'bottom', background: 'white' },
            {
              default: () => [
                r('div', { class: ['btnGroup', d.btnMore] }, [
                  r(
                    h,
                    {
                      block: !0,
                      round: !0,
                      type: 'primary',
                      onClick: this.onBuy
                    },
                    {
                      default: () => [
                        this.live.coursePrice <= 0
                          ? '\u514D\u8D39\u9886\u53D6'
                          : '\u7ACB\u5373\u8D2D\u4E70'
                      ]
                    }
                  )
                ])
              ]
            }
          ),
        this.joinRoom == '1' &&
          this.liveStatus.liveStatus !== 2 &&
          r(
            Y,
            { position: 'bottom', background: 'white' },
            {
              default: () => [
                r(
                  'div',
                  { class: ['btnGroup'], style: { paddingTop: '12px' } },
                  [
                    r(
                      h,
                      {
                        block: !0,
                        round: !0,
                        type: 'primary',
                        onClick: this.onJoinRoom
                      },
                      { default: () => [c('\u8FDB\u5165\u76F4\u64AD\u95F4')] }
                    )
                  ]
                )
              ]
            }
          )
      ])
    }
  })
export { H as default }
