123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964 |
- <template>
- <!-- 课程详情 -->
- <div>
- <div v-if="isData" v-loading="loading" class="CourseDetail">
- <div class="main">
- <div class="bookDetail">
- <div class="rightUp">
- <span>HOT</span>
- </div>
- <div class="text">
- <p class="p1 nowrap-ellipsis" :title="CourseData.name">{{ CourseData.name }}</p>
- <!-- 机构名称 -->
- <p>{{ CourseData.org_name }}</p>
- <p>
- <template v-if="CourseData.teacher_list.length > 0">
- <span v-for="item in CourseData.teacher_list" :key="item.teacher_id">
- {{ item.teacher_name }}
- </span>
- </template>
- </p>
- <p class="intro">
- {{ CourseData.intro }}
- </p>
- <p>
- <span> {{ CourseData.begin_date }} </span>
- <span>-</span>
- <span> {{ CourseData.end_date }} </span>
- </p>
- <p v-if="backTime" class="tip">距离关闭购买渠道还有</p>
- <div class="operation">
- <div v-if="backTime" class="countdown">
- <div class="time">
- <div>
- <div class="time-num">{{ backTime.days }}</div>
- <div class="time-name">天</div>
- </div>
- <div>
- <div class="time-num">{{ backTime.hours }}</div>
- <div class="time-name">小时</div>
- </div>
- <div>
- <div class="time-num">{{ backTime.minutes }}</div>
- <div class="time-name">分</div>
- </div>
- <div>
- <div class="time-num">{{ backTime.seconds }}</div>
- <div class="time-name">秒</div>
- </div>
- </div>
- </div>
- <div v-else>购买渠道已关闭</div>
- <div v-if="!readonly">
- <span class="price">
- ¥
- <span class="price_1" v-text="changePrice('1', CourseData.price)" />
- <span class="price_2" v-text="changePrice('2', CourseData.price)" />
- </span>
- <button class="get" @click="getPurchase">
- {{ is_buy ? '去学习' : '获取课程' }}
- </button>
- <span class="collection" @click="addOrDeleteMyCollection">
- <svg-icon :icon-class="collection ? 'collection-solid' : 'collection'" />
- </span>
- </div>
- </div>
- </div>
- </div>
- <div class="more">
- <div class="moreTitle">配套教材</div>
- <div class="moreList">
- <div v-for="(item, i) in CourseData.book_list" :key="i" class="moreOne">
- <div>
- <img :src="item.book_picture_url" alt="">
- </div>
- <div class="text">
- <p class="p1">{{ item.book_name }}</p>
- <p>{{ item.book_org_name }}</p>
- <p>{{ item.book_author }}</p>
- <div class="operation">
- <span class="price">
- ¥
- <span class="price_1" v-text="changePrice('1', item.book_price)" />
- <span class="price_2" v-text="changePrice('2', item.book_price)" />
- </span>
- <button v-if="!readonly" :class="['get', is_buy ? 'acquired' : '']" @click="goBook(item.book_id)">
- {{ is_buy ? '已' : '' }}购买
- </button>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="more">
- <div class="moreTitle">授课教师</div>
- <div class="moreList teacherList">
- <div v-for="(item, i) in CourseData.teacher_list" :key="i" class="moreOne">
- <div>
- <img :src="item.teacher_image_url" alt="">
- </div>
- <div class="text">
- <p class="p1">{{ item.teacher_name }}</p>
- <p>{{ item.teacher_org_name }}</p>
- <p />
- </div>
- </div>
- </div>
- </div>
- <div class="course-arrangement">
- <div class="moreTitle">课程安排</div>
- <div v-for="(item, i) in CourseData.cs_item_list" :key="i" class="course-list">
- <div class="courseOne">
- <div class="title">
- <div>
- <span>{{ i + 1 }}.</span>
- <span>{{ item.name }}</span>
- </div>
- <div class="courseOne-time">{{ item.begin_time }} ~ {{ item.end_time }}</div>
- </div>
- </div>
- <div class="course-content">
- <el-collapse @change="handleChange(item.id)">
- <el-collapse-item :name="item.id">
- <div slot="title" class="Coursetasks">
- 课程任务
- <img
- class="arrow"
- :src="
- openList.includes(item.id)
- ? require('../../assets/course_details/open1.png')
- : require('../../assets/course_details/open2.png')
- "
- >
- </div>
- <div class="courseContent">
- <template v-for="li in courseContentList">
- <div v-if="item[li.id].length > 0" :key="li.id" class="tasks">
- <div class="title">
- <span class="red-circle" /><span>{{ li.name }}任务</span>
- </div>
- <div class="content">
- <el-collapse-item v-for="(it, it_i) in item[li.id]" :key="it_i" :name="it.id">
- <div slot="title" :class="openList.includes(it.id) ? 'contenttitle2' : 'contenttitle'">
- <span :title="it.name">{{ it.name }}</span>
- <span>
- <span class="gray">{{ it.begin_time }} ~ {{ it.end_time }}</span>
- <span class="gray">···</span>
- </span>
- </div>
- <div class="detail">
- <div>
- <span>说明</span>
- <p>
- {{ it.content }}
- </p>
- </div>
- <div v-if="it.courseware_list.length > 0">
- <span>课件</span>
- <div>
- <div
- v-for="(courseware, courseware_i) in it.courseware_list"
- :key="courseware_i"
- class="btn"
- >
- <img src="../../assets/course_details/file.png" alt="">
- <span> {{ courseware.courseware_name }} </span>
- </div>
- </div>
- </div>
- <div v-if="it.accessory_list.length > 0">
- <span>附件</span>
- <div>
- <div
- v-for="(accessory, accessory_i) in it.accessory_list"
- :key="accessory_i"
- class="btn"
- >
- <img src="../../assets/course_details/fileType1.png" alt="">
- <span> {{ accessory.file_name }} </span>
- </div>
- </div>
- </div>
- </div>
- </el-collapse-item>
- </div>
- </div>
- </template>
- </div>
- </el-collapse-item>
- </el-collapse>
- </div>
- </div>
- </div>
- <el-dialog
- class="orderDialog"
- title="商品详情"
- :visible.sync="auditShow"
- width="720px"
- :before-close="closeaudit"
- >
- <audit :goods-id="goods_id" :data="CourseData" :goods-type="goods_type" />
- </el-dialog>
- </div>
- </div>
- <div v-else-if="!loading" class="non-existent">
- <h1>该课程已下架</h1>
- </div>
- </div>
- </template>
- <script>
- import Audit from '@/components/payment/Audit';
- import {
- GetCourseInfoBox,
- CheckMyGoodsBuyStatus,
- AddMyCollection,
- CancelMyGoodsCollection,
- CheckMyGoodsCollectionStatus
- } from '@/api/course';
- export default {
- components: {
- Audit
- },
- data() {
- let query = this.$route.query;
- return {
- goods_id: query.goods_id,
- goods_type: Number(query.goods_type),
- readonly: 'readonly' in query ? query.readonly : false,
- collection: false,
- openList: [],
- timer: null, // 获取倒计时
- backTime: 0,
- auditShow: false,
- loading: false,
- is_buy: false,
- CourseData: null,
- isData: false,
- courseContentList: [
- { id: 'pre_task_list', name: '课前' },
- { id: 'mid_task_list', name: '课中' },
- { id: 'after_task_list', name: '课后' }
- ]
- };
- },
- created() {
- // 获取课程详情
- this.loading = true;
- CheckMyGoodsBuyStatus({ goods_type: this.goods_type, goods_id: this.goods_id }).then(({ is_buy }) => {
- this.is_buy = is_buy === 'true';
- });
- GetCourseInfoBox({ id: this.goods_id })
- .then(res => {
- this.CourseData = res;
- this.isData = 'id' in res;
- this.getBackTime();
- this.checkMyGoodsCollectionStatus();
- this.loading = false;
- })
- .catch(() => {
- this.loading = false;
- });
- },
- beforeDestroy() {
- // 清空定时器
- clearInterval(this.timer);
- },
- // 方法集合
- methods: {
- // 课程任务的打开和关闭
- handleChange(val) {
- this.openList.includes(val) ? this.openList.splice(this.openList.indexOf(val), 1) : this.openList.push(val);
- },
- goBook(book_id) {
- if (!this.is_buy) {
- window.location.href = `/GCLS-Book/#/GoodsDetail?goods_id=${book_id}&goods_type=101`;
- }
- },
- checkMyGoodsCollectionStatus() {
- CheckMyGoodsCollectionStatus({ goods_type: this.goods_type, goods_id: this.CourseData.id }).then(
- ({ is_collection }) => {
- this.collection = is_collection === 'true';
- }
- );
- },
- // 处理价格
- changePrice(type, item) {
- if (!item) return;
- let str = String(item);
- if (str.includes('.')) {
- if (type === '1') {
- return str.split('.')[0];
- }
- return '.' + str.split('.')[1];
- } else if (type === '1') {
- return str;
- }
- },
- // 收藏
- addOrDeleteMyCollection() {
- if (!this.collection) {
- let goods_person_name_desc = '';
- this.CourseData.teacher_list.forEach(item => {
- goods_person_name_desc += item.teacher_name;
- });
- AddMyCollection({
- goods_id: this.goods_id,
- goods_type: this.goods_type,
- goods_name: this.CourseData.name,
- goods_person_name_desc,
- goods_picture_id: this.CourseData.picture_id,
- goods_price: this.CourseData.price
- }).then(() => {
- this.$message.success('收藏课程成功');
- this.collection = true;
- });
- } else {
- CancelMyGoodsCollection({ goods_type: this.goods_type, goods_id_list: [this.CourseData.id] }).then(() => {
- this.$message.success('取消收藏成功');
- this.collection = false;
- });
- }
- },
- // 购买 需要先加入课程 审核 审核通过之后才能购买课程
- getPurchase() {
- // 购买通道关闭
- if (this.is_buy) {
- return this.$router.push('/');
- }
- if (!this.backTime) {
- this.$message.warning('购买渠道已关闭');
- return;
- }
- this.auditShow = true;
- },
- closeaudit() {
- this.auditShow = false;
- },
- // 获取当前时间到指定时间的倒计时
- getBackTime() {
- let date = new Date(this.CourseData.end_date);
- let targetTime = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 23, 59, 59).getTime();
- console.log(new Date(date.getFullYear(), date.getMonth(), date.getDate(), 23, 59, 59).toString());
- // 目标时间戳 - 当前时间戳 = 倒计时
- this.timer = setInterval(() => {
- let backTime = targetTime - new Date().getTime();
- if (backTime > 0) {
- backTime = this.formatduring(backTime);
- this.backTime = backTime;
- } else {
- this.backTime = 0;
- clearInterval(this.timer);
- }
- }, 1000);
- },
- // 倒计时时间戳转换为 天 小时 分钟 秒
- formatduring(mss) {
- let days = parseInt(mss / (1000 * 60 * 60 * 24));
- let hours = parseInt((mss % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
- let minutes = parseInt((mss % (1000 * 60 * 60)) / (1000 * 60));
- let seconds = parseInt((mss % (1000 * 60)) / 1000);
- // 如果到时间了返回false 关闭购买通道 无法购买
- if (days <= 0 && hours <= 0 && minutes <= 0 && seconds <= 0) {
- return false;
- }
- return {
- days,
- hours,
- minutes,
- seconds
- };
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .CourseDetail {
- .main {
- min-height: 100%;
- padding: 52px 0 20px;
- background: #e5e5e5;
- .bookDetail {
- position: relative;
- display: flex;
- width: 1200px;
- height: 524px;
- padding: 64px;
- margin: 0 auto;
- overflow: hidden;
- background: url('../../assets/course_details/Rectangle113.png');
- border-radius: 8px;
- .rightUp {
- position: absolute;
- top: 0;
- right: 0;
- width: 72px;
- height: 72px;
- background: url('../../assets/course_details/Rectangle903.png');
- span {
- position: absolute;
- top: 10px;
- left: 30px;
- color: #fff;
- transform: translateX(4px) translateY(4px) rotateZ(45deg);
- }
- }
- .text {
- width: 1100px;
- color: #fff;
- .tip:not(.p1) {
- margin-top: 36px;
- }
- p {
- font-size: 16px;
- }
- .p1 {
- margin-top: 16px;
- font-size: 40px;
- }
- .intro {
- display: box;
- height: 36px;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 2;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- > :not(.p1) {
- margin-top: 20px;
- }
- .price {
- font-size: 24px;
- .price_2 {
- font-size: 16px;
- }
- }
- .operation {
- display: flex;
- align-items: center;
- justify-content: space-between;
- .countdown {
- > p {
- color: rgba(255, 255, 255, 70%);
- }
- // 倒计时
- .time {
- display: flex;
- height: 75px;
- div {
- width: 48px;
- margin-right: 48px;
- text-align: center;
- }
- &-num {
- font-size: 30px;
- }
- &-name {
- margin-top: 12px;
- font-size: 24px;
- }
- }
- }
- }
- .get {
- width: 200px;
- height: 56px;
- margin-left: 30px;
- font-size: 20px;
- color: #fff;
- cursor: pointer;
- background: $basicColor;
- border-style: none;
- border-radius: 4px;
- outline: none;
- }
- .acquired {
- width: 120px;
- height: 40px;
- margin-left: 30px;
- font-size: 16px;
- color: #fff;
- cursor: pointer;
- background: #d5d5d5;
- border-style: none;
- border-radius: 4px;
- outline: none;
- }
- .collection {
- margin-left: 24px;
- font-size: 24px;
- vertical-align: middle;
- cursor: pointer;
- }
- }
- }
- .more {
- width: 1200px;
- margin: 0 auto;
- margin-top: 30px;
- .moreTitle {
- font-size: 20px;
- font-weight: 600;
- color: #000;
- }
- .moreTitle::before {
- margin-right: 16px;
- color: $basicColor;
- content: '|';
- background: $basicColor;
- }
- .moreList {
- display: flex;
- flex-wrap: wrap;
- width: 1300px;
- margin: 0 auto;
- .moreOne {
- display: flex;
- width: 598px;
- height: 236px;
- margin-top: 20px;
- margin-right: 20px;
- background: #fff;
- border-radius: 8px;
- > div {
- margin-top: 32px;
- margin-left: 32px;
- img {
- width: 120px;
- height: 160px;
- }
- }
- .text {
- width: 390px;
- margin-right: 23px;
- > p:not(.p1) {
- margin-top: 10px;
- font-size: 16px;
- color: #2c2c2c;
- opacity: 70%;
- }
- .p1 {
- font-size: 20px;
- font-weight: 600;
- color: #2c2c2c;
- }
- .operation {
- margin-top: 10px;
- text-align: right;
- }
- .get {
- width: 120px;
- height: 40px;
- margin-left: 30px;
- font-size: 20px;
- color: #fff;
- cursor: pointer;
- background: $basicColor;
- border-style: none;
- border-radius: 4px;
- outline: none;
- }
- .acquired {
- @extend .get;
- background: #d5d5d5;
- }
- .price {
- font-size: 24px;
- .price_2 {
- font-size: 16px;
- }
- }
- }
- }
- }
- .teacherList {
- .moreOne {
- > div {
- img {
- width: 120px;
- height: 120px;
- border-radius: 50%;
- }
- }
- }
- }
- }
- .course-arrangement {
- width: 1200px;
- margin: 0 auto;
- margin-top: 30px;
- .moreTitle {
- font-size: 20px;
- font-weight: 600;
- color: #000;
- }
- .moreTitle::before {
- margin-right: 16px;
- color: $basicColor;
- content: '|';
- background: $basicColor;
- }
- .course-list {
- width: 1200px;
- padding: 40px 68px 40px 40px;
- margin-top: 30px;
- font-size: 18px;
- background: #fff;
- > :not(.courseOne) {
- padding-left: 40px;
- margin-top: 16px;
- }
- .courseOne {
- .title {
- display: flex;
- justify-content: space-between;
- > div:nth-child(1) {
- font-size: 20px;
- font-weight: bold;
- span {
- margin-right: 24px;
- }
- }
- }
- &-time {
- color: #737373;
- }
- }
- .course-content {
- width: 670px;
- }
- .Coursetasks {
- display: flex;
- align-items: center;
- font-size: 16px;
- cursor: pointer;
- .arrow {
- width: 24px;
- margin-left: 8px;
- }
- }
- .courseContent {
- .tasks {
- padding-left: 10px;
- .title {
- font-size: 16px;
- color: #2c2c2c;
- .red-circle {
- position: relative;
- right: 3px;
- display: inline-block;
- width: 8px;
- height: 8px;
- margin-right: 16px;
- background: #fe6d68;
- border-radius: 50%;
- }
- }
- .content {
- padding-bottom: 10px;
- padding-left: 20px;
- margin-top: 16px;
- border-left: 1px solid #fe6d68;
- .contenttitle {
- display: flex;
- align-items: center;
- justify-content: space-between;
- width: 670px;
- padding: 0 10px;
- font-size: 16px;
- cursor: pointer;
- background: #fff;
- border: 1px solid #e6e6e6;
- border-radius: 8px;
- img {
- width: 16px;
- margin-left: 8px;
- }
- span {
- margin-left: 16px;
- }
- > span:first-child {
- width: 180px;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .gray {
- opacity: 50%;
- }
- }
- .contenttitle2 {
- @extend .contenttitle;
- background: #f9f9f9;
- border-bottom-right-radius: 0;
- border-bottom-left-radius: 0;
- }
- .detail {
- width: 599px;
- padding-bottom: 24px;
- background: #fff;
- border: 1px solid #e7e7e7;
- border-bottom-right-radius: 8px;
- border-bottom-left-radius: 8px;
- box-shadow: 0 2px 8px rgba(0, 0, 0, 10%);
- > div {
- display: flex;
- align-items: center;
- margin-top: 24px;
- > :nth-child(1) {
- width: 78px;
- min-width: 78px;
- margin-left: 24px;
- font-size: 16px;
- color: #000;
- }
- > :nth-child(2) {
- margin-left: 16px;
- img {
- width: 24px;
- }
- .btn {
- display: flex;
- align-items: center;
- width: 270px;
- height: 40px;
- cursor: pointer;
- background: #fff;
- border: 1px solid #dbdbdb;
- border-radius: 4px;
- img {
- margin-right: 8px;
- margin-left: 16px;
- }
- }
- .btn:not(:nth-child(1)) {
- margin-top: 8px;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- .cutDownOrimg {
- width: 1200px;
- margin: 0 auto;
- margin-top: 24px;
- .sele {
- display: flex;
- align-items: center;
- width: 318px;
- height: 48px;
- font-size: 20px;
- color: #9f9f9f;
- background: #ebebeb;
- border-radius: 30px;
- > div {
- width: 158px;
- height: 48px;
- line-height: 48px;
- text-align: center;
- cursor: pointer;
- border-radius: 30px;
- }
- .select {
- color: #fff;
- background: $basicColor;
- box-shadow: 0 2px 8px rgba(255, 153, 0, 15%);
- }
- }
- }
- .Catalogue {
- display: flex;
- width: 1200px;
- height: 710px;
- margin: 24px auto;
- background: #fff;
- .left {
- width: 340px;
- height: 710px;
- border-right: 1px solid #d9d9d9;
- .title {
- width: 80%;
- margin: 29px auto;
- font-size: 24px;
- font-weight: 600;
- color: #000;
- }
- }
- .right {
- width: 860px;
- height: 710px;
- }
- }
- .Resources {
- display: flex;
- width: 1200px;
- height: 710px;
- margin: 24px auto;
- background: #fff;
- div {
- display: flex;
- align-items: center;
- justify-content: center;
- height: 40px;
- padding: 0 10px;
- margin: 10px;
- cursor: pointer;
- border: 1px solid rgba(44, 44, 44, 15%);
- border-radius: 4px;
- img {
- width: 24px;
- margin: 0 10px;
- }
- span {
- width: 182px;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- }
- }
- }
- }
- .non-existent {
- margin-top: 15vh;
- text-align: center;
- }
- </style>
- <style lang="scss">
- .el-collapse {
- border-style: none;
- &-item + &-item {
- margin-top: 12px;
- }
- .el-collapse-item__header {
- border-style: none;
- .l-collapse-item__arrow,
- .el-icon-arrow-right {
- display: none;
- }
- }
- .el-collapse-item__wrap {
- border-style: none;
- }
- .el-collapse-item__content {
- padding-bottom: 0;
- }
- }
- .orderDialog {
- .el-dialog__header {
- padding: 32px 20px 24px 32px;
- .el-dialog__title {
- font-size: 20px;
- line-height: 150%;
- color: #000;
- }
- }
- .el-dialog__body {
- padding: 0 32px 32px;
- }
- }
- </style>
|