|
@@ -1,12 +1,14 @@
|
|
|
<template>
|
|
|
<view>
|
|
|
- <view class="container">
|
|
|
+ <view v-if="!loginShow" class="container" :style="{ height : `${loginShow ? '100vh' : 'auto' }`,
|
|
|
+ overflow: `${loginShow ? 'hidden' : 'auto' }` }">
|
|
|
<view class="container-poster" style="width: 100%;padding: 0 20rpx;">
|
|
|
- <image show-menu-by-longpress :src="courseDetail.poster?courseDetail.poster:''" mode="widthFix" style="width: 100%;" ></image>
|
|
|
+ <image show-menu-by-longpress :src="courseDetail.poster?courseDetail.poster:''" mode="widthFix"
|
|
|
+ style="width: 100%;"></image>
|
|
|
</view>
|
|
|
<view class="course-tab-list">
|
|
|
- <view class="course-tab-item" v-for="(data, index) in items" :key="index"
|
|
|
- @click="onClickItem(index)" :class="currentTab === index ? 'tab-active' : ''">
|
|
|
+ <view class="course-tab-item" v-for="(data, index) in items" :key="index" @click="onClickItem(index)"
|
|
|
+ :class="currentTab === index ? 'tab-active' : ''">
|
|
|
{{ data }}
|
|
|
</view>
|
|
|
</view>
|
|
@@ -23,7 +25,8 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="content" v-if="currentTab === 1" style="overflow: hidden;">
|
|
|
- <view class="" style="margin-bottom: 140rpx;padding-bottom: 150rpx;height: 100%;overflow: scroll;padding-left: 20rpx;padding-right: 20rpx;">
|
|
|
+ <view class=""
|
|
|
+ style="margin-bottom: 140rpx;padding-bottom: 150rpx;height: 100%;overflow: scroll;padding-left: 20rpx;padding-right: 20rpx;">
|
|
|
<view v-for="(comment, index) in sortedCommentList" :key="index" class="comment-list-item">
|
|
|
<view class="comment-list-left">
|
|
|
<image :src="comment.icon" class="comment-list-avator"></image>
|
|
@@ -47,6 +50,15 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
+ <u-popup v-model="loginShow"
|
|
|
+ :mask="false" :closeable='false' mode="bottom" :mask-close-able='false'
|
|
|
+ safe-area-inset-bottom>
|
|
|
+ <view style="height: 70vh;padding: 40rpx;position: relative;background:none;">
|
|
|
+ <view style="text-align: center;margin: 70rpx 0;">
|
|
|
+ <u-button size="medium" type="error" @click="toLogin">登录查看</u-button>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </u-popup>
|
|
|
</view>
|
|
|
|
|
|
</template>
|
|
@@ -57,7 +69,7 @@
|
|
|
loadCommentList,
|
|
|
sendComment
|
|
|
} from "@/api/edu.js"
|
|
|
-
|
|
|
+ import { getToken } from '@/utils/auth.js'
|
|
|
import {
|
|
|
useAuthStore
|
|
|
} from '@/store/authStore'
|
|
@@ -65,15 +77,19 @@
|
|
|
// const isMember = ref(false)
|
|
|
|
|
|
import {
|
|
|
- ref, computed
|
|
|
+ ref,
|
|
|
+ computed
|
|
|
} from 'vue'
|
|
|
import {
|
|
|
onLoad,
|
|
|
- onShow
|
|
|
+ onShow,
|
|
|
+ onShareAppMessage,
|
|
|
+ onShareTimeline
|
|
|
} from '@dcloudio/uni-app'
|
|
|
|
|
|
const courseDetail = ref({});
|
|
|
const courseId = ref(null);
|
|
|
+ const courseName = ref(null);
|
|
|
const items = ref(['课程简介', '观看评论']);
|
|
|
const currentTab = ref(0);
|
|
|
const comment = ref("");
|
|
@@ -96,56 +112,8 @@
|
|
|
fontSize: '26rpx'
|
|
|
})
|
|
|
// 评论列表
|
|
|
- const commentList = ref([{
|
|
|
- commentId: "01",
|
|
|
- username: "用户名123",
|
|
|
- iocn: "",
|
|
|
- content: "评论内容评论内容评容,大赛冠军的",
|
|
|
- commentTime: "2023-10-10 19:00:00"
|
|
|
- },
|
|
|
- {
|
|
|
- commentId: "02",
|
|
|
- username: "用户名567",
|
|
|
- iocn: "",
|
|
|
- content: "hajdkhd dhasjhd 等哈十九点按时鉴定会撒低级,撒谎客户端喝酒侃大山哈吉斯肯定会大会开始觉得暗黑界的是客户,大赛冠军的",
|
|
|
- commentTime: "2023-10-11 19:00:00"
|
|
|
- },
|
|
|
- {
|
|
|
- commentId: "03",
|
|
|
- username: "用户名567",
|
|
|
- iocn: "",
|
|
|
- content: "hajdkhd dhasjhd ,,大赛冠军的",
|
|
|
- commentTime: "2023-10-12 19:00:00"
|
|
|
- },
|
|
|
- {
|
|
|
- commentId: "04",
|
|
|
- username: "用户名567",
|
|
|
- iocn: "",
|
|
|
- content: "hajdkhd dhasjhd 等哈十九点按时鉴定会撒低级,撒谎客户端喝酒侃大山哈吉斯肯定会大会开始觉得暗黑界的是客户,大赛冠军的",
|
|
|
- commentTime: "2023-10-13 19:00:00"
|
|
|
- },
|
|
|
- {
|
|
|
- commentId: "05",
|
|
|
- username: "用户名567",
|
|
|
- iocn: "",
|
|
|
- content: "hajdkhd dhasjhd 等哈十九点按时鉴定会撒低级,撒谎客户端喝酒侃大山哈吉斯肯定会大会开始觉得暗黑界的是客户,大赛冠军的",
|
|
|
- commentTime: "2023-10-14 19:00:00"
|
|
|
- },
|
|
|
- {
|
|
|
- commentId: "06",
|
|
|
- username: "用户名567",
|
|
|
- iocn: "",
|
|
|
- content: "hajdkhd dhasjhd 等哈十九点按时鉴定会撒低级,撒谎客户端喝酒侃大山哈吉斯肯定会大会开始觉得暗黑界的是客户,大赛冠军的",
|
|
|
- commentTime: "2025-01-17 12:00:00"
|
|
|
- },
|
|
|
- {
|
|
|
- commentId: "07",
|
|
|
- username: "用户名567",
|
|
|
- iocn: "",
|
|
|
- content: "hajdkhd dhasjhd 等哈十九点按时鉴定会撒低级,撒谎客户端喝酒侃大山哈吉斯肯定会大会开始觉得暗黑界的是客户,大赛冠军的",
|
|
|
- commentTime: "2025-01-17 15:30:00"
|
|
|
- }
|
|
|
- ])
|
|
|
+ const commentList = ref([])
|
|
|
+
|
|
|
// 点击tabs,切换
|
|
|
function onClickItem(e) {
|
|
|
if (currentTab.value != e) {
|
|
@@ -205,7 +173,8 @@
|
|
|
|
|
|
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
|
|
}
|
|
|
- function showBuyAction(){
|
|
|
+
|
|
|
+ function showBuyAction() {
|
|
|
if (courseDetail.value.viewMode === '2' &&
|
|
|
!isMember.value &&
|
|
|
!courseDetail.value.hasBuy &&
|
|
@@ -224,56 +193,105 @@
|
|
|
return false
|
|
|
}
|
|
|
const showBuy = ref(false)
|
|
|
- const isMember = computed(()=>{
|
|
|
+ const isMember = computed(() => {
|
|
|
return authStore.userInfo.isMember == '0' ? false : true
|
|
|
})
|
|
|
+ const isLogin = computed(() => {
|
|
|
+ if(getToken() && authStore.isAuthenticated){
|
|
|
+ return true
|
|
|
+ }else{
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ const loginShow = ref(true)
|
|
|
+ function toLogin() {
|
|
|
+ // loginShow.value = false
|
|
|
+ let url = {
|
|
|
+ url: '/pages/goOnEdu/course/courseDetail/courseDetail',
|
|
|
+ id: courseId.value,
|
|
|
+ title: courseName.value
|
|
|
+ }
|
|
|
+ uni.setStorageSync("redirect", url)
|
|
|
+ uni.navigateTo({
|
|
|
+ url: `/pages/login/login`
|
|
|
+ })
|
|
|
+ }
|
|
|
// 初始化页面
|
|
|
onLoad((option) => {
|
|
|
const {
|
|
|
id,
|
|
|
- name
|
|
|
+ title
|
|
|
} = option;
|
|
|
courseId.value = id
|
|
|
+ courseName.value = title
|
|
|
uni.setNavigationBarTitle({
|
|
|
- title: name
|
|
|
+ title: title
|
|
|
});
|
|
|
+ if(isLogin.value){
|
|
|
+ loginShow.value = false
|
|
|
+ }else{
|
|
|
+ loginShow.value = true
|
|
|
+ }
|
|
|
+ // loginShow.value = true
|
|
|
})
|
|
|
- onShow(()=>{
|
|
|
- init(courseId.value)
|
|
|
- getComment(courseId.value)
|
|
|
+ onShow(() => {
|
|
|
+ if(isLogin.value){
|
|
|
+ init(courseId.value)
|
|
|
+ getComment(courseId.value)
|
|
|
+ }
|
|
|
})
|
|
|
-
|
|
|
+
|
|
|
function formatDateS(dateStr) {
|
|
|
return dateStr.replace(" ", "T");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
function formatTime(timeString) {
|
|
|
- const commentDate = new Date(formatDateS(timeString));
|
|
|
- const now = new Date();
|
|
|
- const diff = now - commentDate;
|
|
|
-
|
|
|
- const minutes = Math.floor(diff / 60000);
|
|
|
- const hours = Math.floor(diff / 3600000);
|
|
|
- const days = Math.floor(diff / 86400000);
|
|
|
-
|
|
|
- if (minutes < 1) { // 修改这里以处理0分钟
|
|
|
- return "刚刚";
|
|
|
- } else if (minutes < 60) {
|
|
|
- return `${minutes}分钟前`;
|
|
|
- } else if (hours < 24) {
|
|
|
- return `${hours}小时前`;
|
|
|
- } else {
|
|
|
- return commentDate.toISOString().split('T')[0];
|
|
|
- }
|
|
|
+ const commentDate = new Date(formatDateS(timeString));
|
|
|
+ const now = new Date();
|
|
|
+ const diff = now - commentDate;
|
|
|
+
|
|
|
+ const minutes = Math.floor(diff / 60000);
|
|
|
+ const hours = Math.floor(diff / 3600000);
|
|
|
+ const days = Math.floor(diff / 86400000);
|
|
|
+
|
|
|
+ if (minutes < 1) { // 修改这里以处理0分钟
|
|
|
+ return "刚刚";
|
|
|
+ } else if (minutes < 60) {
|
|
|
+ return `${minutes}分钟前`;
|
|
|
+ } else if (hours < 24) {
|
|
|
+ return `${hours}小时前`;
|
|
|
+ } else {
|
|
|
+ return commentDate.toISOString().split('T')[0];
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
const sortedCommentList = computed(() => {
|
|
|
return commentList.value.sort((a, b) =>
|
|
|
new Date(formatDateS(b.commentTime)) - new Date(formatDateS(a.commentTime))
|
|
|
);
|
|
|
});
|
|
|
+
|
|
|
+ onShareAppMessage(async (res) => {
|
|
|
+ return {
|
|
|
+ title: courseName.value,
|
|
|
+ path: `/pages/goOnEdu/course/courseDetail/courseDetail?id=${courseId.value}&title=${courseName.value}`,
|
|
|
+ imageUrl: courseDetail.value.cover
|
|
|
+ };
|
|
|
+ })
|
|
|
+
|
|
|
+ onShareTimeline(async () => {
|
|
|
+ return {
|
|
|
+ title: courseName.value,
|
|
|
+ query: `id=${courseId.value}&title=${courseName.value}`,
|
|
|
+ imageUrl: courseDetail.value.cover
|
|
|
+ };
|
|
|
+ })
|
|
|
</script>
|
|
|
-
|
|
|
+<style lang="scss">
|
|
|
+ .u-drawer-bottom{
|
|
|
+ background-color: transparent!important;
|
|
|
+ }
|
|
|
+</style>
|
|
|
<style lang="scss" scoped>
|
|
|
.container {
|
|
|
// height: 100vh;
|
|
@@ -299,6 +317,7 @@
|
|
|
border-bottom: 1px solid #0069f6;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
// .container-poster{
|
|
|
// height: calc(100vh - 500rpx - env(safe-area-inset-bottom, 0));
|
|
|
// }
|
|
@@ -307,18 +326,22 @@
|
|
|
// height: calc(100vh - 500rpx - env(safe-area-inset-bottom, 0));
|
|
|
height: 700rpx;
|
|
|
position: relative;
|
|
|
- .content-text{
|
|
|
+
|
|
|
+ .content-text {
|
|
|
padding: 0 20rpx env(safe-area-inset-bottom, 0);
|
|
|
font-size: 38rpx;
|
|
|
- .text-title{
|
|
|
+
|
|
|
+ .text-title {
|
|
|
font-weight: bold;
|
|
|
margin-bottom: 15rpx;
|
|
|
}
|
|
|
- .text-content{
|
|
|
+
|
|
|
+ .text-content {
|
|
|
font-size: 32rpx;
|
|
|
margin-bottom: 20rpx;
|
|
|
}
|
|
|
- .text-tip{
|
|
|
+
|
|
|
+ .text-tip {
|
|
|
color: red;
|
|
|
// margin-bottom: 20rpx;
|
|
|
margin-bottom: env(safe-area-inset-bottom, 0);
|
|
@@ -356,24 +379,28 @@
|
|
|
flex: 0 0 auto;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
.comment-list-item {
|
|
|
display: flex;
|
|
|
padding: 20rpx 0;
|
|
|
font-size: 28rpx;
|
|
|
- .comment-list-left{
|
|
|
+
|
|
|
+ .comment-list-left {
|
|
|
flex: 0 0 auto;
|
|
|
padding-right: 20rpx;
|
|
|
padding-left: 10rpx;
|
|
|
- .comment-list-avator{
|
|
|
+
|
|
|
+ .comment-list-avator {
|
|
|
width: 100rpx;
|
|
|
height: 100rpx;
|
|
|
border-radius: 50%;
|
|
|
}
|
|
|
}
|
|
|
- .comment-list-right{
|
|
|
+
|
|
|
+ .comment-list-right {
|
|
|
flex: 1;
|
|
|
- .comment-list-username{
|
|
|
+
|
|
|
+ .comment-list-username {
|
|
|
padding-right: 25rpx;
|
|
|
font-size: 32rpx;
|
|
|
font-weight: bold;
|