This commit is contained in:
2025-08-14 16:49:58 +08:00
parent b2009403d8
commit 26c1ac5ced
15 changed files with 1144 additions and 351 deletions

View File

@@ -2,44 +2,81 @@
<view
class="content"
:class="`${options.type == 'detail' ? 'content_detail' : ''}`"
:style="options.statusId == 0 ? 'background-color: #f0f0f026;' : ''"
>
<u-loading-page
:loading="submitLoading"
style="
width: 100vw;
height: 100vh;
z-index: 9999;
top: 0;
background-color: #00000080;
"
loading-text="文章正在发布中请稍后..."
color="#fff"
></u-loading-page>
<z-nav-bar
:title="options.navTitle"
:bgColor="options.type == 'detail' ? '#d8e6ff73' : '#5188e5'"
:fontColor="options.type == 'detail' ? '#5188e5' : '#fff'"
:bgColor="
options.type == 'detail'
? options.statusId == 0
? '#f7f7f7'
: '#d8e6ff73'
: '#5188e5'
"
:fontColor="
options.type == 'detail'
? options.statusId == 0
? '#333'
: '#333'
: '#fff'
"
>
<template v-slot:right>
<view
class="top_right"
style="
background-color: #fff;
margin-right: 10rpx;
border-radius: 4rpx;
"
@tap="handleOpenShowSubmit"
v-if="options.type == 'add'"
>
<text
style="
padding: 4rpx 10rpx;
margin-right: 10rpx;
padding: 2rpx 20rpx;
border-radius: 20rpx;
line-height: 40rpx;
color: #fff;
line-height: 50rpx;
color: #215fc7;
"
>提交</text
>
</view>
<view
v-if="options.type == 'detail'"
v-if="options.type == 'detail' && options.statusId == 1"
class="top_right"
@tap="showDel = true"
style="display: flex; align-items: center"
>
<uni-icons
type="trash-filled"
size="22"
style="color: #aa3629; margin-left: 40rpx"
type="redo-filled"
size="28"
@tap="newOnShare()"
style="color: #66bc54"
></uni-icons>
<text
style="letter-spacing: 4rpx; color: #aa3629; margin-right: 20rpx"
>删除</text
style="
letter-spacing: 2rpx;
color: #66bc54;
margin-right: 20rpx;
margin-left: 10rpx;
font-weight: 600;
"
>分享</text
>
</view>
</template>
@@ -123,15 +160,17 @@
</view>
</scroll-view>
</view>
<view
class="home_wrap home_wrap_analysis"
<scroll-view
:scroll-into-view="targetId"
scroll-y
class="home_wrap home_wrap_analysis home"
ref="homeContainer"
v-if="options.type == 'detail'"
:style="`height: calc(100% - ${
48 + statusBarHeight + 60
}px);padding:40rpx 20rpx;text-align: justify;`"
48 + statusBarHeight + (options.statusId == 0 ? 10 : 60)
}px);padding:0 20rpx;text-align: justify;`"
>
<view class="analysis_box" style="height: auto">
<view class="analysis_box" style="height: auto; padding-top: 40rpx">
<view class="analysis_img_box">
<view class="analysis_img">
<image
@@ -172,7 +211,11 @@
</view>
<view
class="analysis_title analysis_title_detail"
style="color: #302f35; font-size: 32rpx"
style="
color: #302f35;
font-size: 40rpx !important;
line-height: 50rpx;
"
>
{{ articleInfo.title }}
</view>
@@ -210,9 +253,23 @@
</view>
</view>
<view
style="letter-spacing: 1rpx; color: #aaacab; margin-top: 20rpx"
style="
letter-spacing: 1rpx;
color: #aaacab;
margin-top: 20rpx;
margin-bottom: 20rpx;
display: flex;
align-items: center;
"
v-if="articleInfo.createTime"
>{{ articleInfo.createTime }}
<uni-icons
v-if="articleInfo.come == 0"
type="trash-filled"
size="24"
@tap="showDel = true"
style="color: #aa3629; margin-left: 20rpx; margin-right: 20rpx"
></uni-icons>
</view>
<view class="likeList" v-if="likeList.length > 0" style="color: #5188e5">
<uni-icons
@@ -228,6 +285,22 @@
.join(" , ")
}}</view>
</view>
<view v-if="commentData" id="commentData">
<hb-comment
:isDisable="options.statusId == 0 ? true : false"
:isShowList="true"
:articleUserId="articleInfo.userId"
style=""
:user="currentUser"
ref="hbComment"
@add="sendComment"
@del="del"
@focusOn="focusOn"
:deleteTip="'确认删除?'"
:cmData="commentData"
v-if="commentData"
></hb-comment>
</view>
<!-- 显示聊天记录 -->
<!-- <articleDetail
:loading="loading"
@@ -242,7 +315,7 @@
ref="commonMedicalDetail"
></articleDetail> -->
<view class="footer_box">
<!-- <view class="footer_box" v-if="options.statusId != 0">
<template>
<view
class="footer_item"
@@ -280,6 +353,7 @@
<text style="letter-spacing: 4rpx">评论</text>
</view>
<view
v-if="articleInfo.showFlag != 0"
class="footer_item"
style="color: #9a9a9a"
@click.stop="newOnShare"
@@ -294,8 +368,8 @@
<text style="letter-spacing: 4rpx">分享</text>
</view>
</template>
</view>
</view>
</view> -->
</scroll-view>
<view style="padding-bottom: 20px">
<uni-popup ref="share" type="share" safeArea backgroundColor="#fff">
<uni-popup-share :bottom="500" @select="haveSelected"></uni-popup-share>
@@ -368,6 +442,7 @@
>
<view class="slot-content"> 是否立即发布文章? </view>
</u-modal>
</view>
</template>
@@ -387,6 +462,9 @@ export default {
},
data() {
return {
targetId: null,
submitLoading: false,
currentUser: {},
likeList: [],
@@ -495,7 +573,9 @@ export default {
}
},
async onShow() {},
async onShow() {
this.submitLoading = false;
},
async onPullDownRefresh() {
this.isRefreshing = true;
console.log("下拉刷新");
@@ -518,6 +598,14 @@ export default {
}, 800);
},
methods: {
scrollToView(id) {
// commentData
this.targetId = id; // 设置目标元素 id
setTimeout(() => {
this.targetId = null;
}, 1000);
},
confirmDel: throttle(function () {
this.delArticle();
}, 2000),
@@ -534,10 +622,13 @@ export default {
this.$commonJS.showToast("请至少上传一张图片");
return;
}
this.showSubmit = true;
// this.showSubmit = true;
this.confirmSubmit();
},
confirmSubmit: throttle(function () {
this.submitLoading = true;
this.showSubmit = false;
this.handleSubmit("submit");
}, 2000),
@@ -626,9 +717,31 @@ export default {
},
// 自适应判断
judgeImg() {
if (this.fileList1.length == 1) {
this.imgWidth = ((this.windowWidth - 10) * 2) / 3;
this.imgHeight = (this.windowHeight * 3) / 5;
if (this.fileList1.length === 1) {
const firstImg = this.fileList1[0];
// 获取图片的宽高信息
uni.getImageInfo({
src: firstImg, // 获取图片路径
success: (res) => {
const imgWidth = res.width;
const imgHeight = res.height;
// 如果是横向图片(宽大于高)
if (imgWidth > imgHeight) {
// 横向图片尺寸设置
this.imgWidth = ((this.windowWidth - 40) * 2) / 2;
this.imgHeight = (this.windowHeight * 3) / 5;
} else {
// 纵向图片尺寸设置
this.imgWidth = ((this.windowWidth - 40) * 2) / 3;
this.imgHeight = (this.windowHeight * 3) / 5;
}
},
fail: (err) => {
console.error("图片加载失败", err);
},
});
} else if (this.fileList1.length == 4) {
this.imgWidth = (this.windowWidth - 10) / 3.3;
this.imgHeight = this.imgWidth;
@@ -637,6 +750,7 @@ export default {
this.imgHeight = this.imgWidth;
}
},
previewImg(index) {
uni.previewImage({
urls: this.fileList1,
@@ -705,12 +819,18 @@ export default {
})
.then((res) => {
if (res.code == 0) {
this.$commonJS.refreshPrevPageData(1);
setTimeout(() => {
this.$commonJS.refreshPrevPageData(1);
this.submitLoading = false;
}, 2000);
} else {
this.submitLoading = false;
this.$commonJS.showToast(res.msg);
}
})
.catch((err) => {});
.catch((err) => {
this.submitLoading = false;
});
}, 3000),
async addPic(e) {
@@ -955,8 +1075,35 @@ export default {
}
});
},
scrollToComment() {
// 获取容器
const container = this.$refs.homeWrap;
// 先获取目标元素的位置
const query = uni.createSelectorQuery().in(this);
query
.select("#commentData")
.boundingClientRect((rect) => {
if (rect) {
// 获取容器的位置
query
.select("#home_wrap")
.boundingClientRect((containerRect) => {
if (containerRect) {
console.log("containerRect at line 1068:", containerRect);
// 计算相对位置并设置 scrollTop
const scrollTop =
container.scrollTop + (rect.top - containerRect.top);
container.scrollTop = scrollTop; // 滚动容器到目标位置
}
})
.exec(); // 执行容器位置查询
}
})
.exec(); // 执行目标元素位置查询
},
//创建新对话
sendComment(comment, pid) {
sendComment: throttle(function (comment, pid) {
this.$http
.request({
url: "common/taihuTalentArticle/addArticleComment",
@@ -974,11 +1121,19 @@ export default {
console.log("res at line 713:", res);
if (res.code == 0) {
this.getMedicalDetail();
if(pid==0){
setTimeout(() => {
this.scrollToView("commentData");
}, 500);
}
// this.scrollToComment();
} else {
this.$commonJS.showToast("评论失败");
}
});
},
}),
//交谈请求,获取回答
getTree(data) {
@@ -1017,6 +1172,7 @@ export default {
this.loading = false;
this.articleInfo = res.article;
this.options.statusId = res.article.showFlag;
this.medicalForm = { ...this.articleInfo };
console.log("this.medicalForm at line 193:", this.articleInfo);
if (this.articleInfo.img) {
@@ -1550,9 +1706,9 @@ h3 {
}
.analysis_title_detail {
margin-top: 10rpx;
margin-bottom: 10rpx;
margin-bottom: 40rpx;
// color: #1781ff;
font-size: 42rpx;
font-size: 38rpx !important;
font-weight: 700;
}
}
@@ -1642,6 +1798,7 @@ h3 {
}
.allImage {
margin-top: 40rpx;
display: flex;
flex-wrap: wrap;
@@ -1672,4 +1829,26 @@ h3 {
display: flex;
align-items: center;
}
::v-deep rich-text {
text-align: justify;
white-space: pre-wrap;
word-wrap: break-word;
}
::v-deep rich-text p,
h1,
h2 {
text-indent: 0 !important;
}
/deep/ rich-text br {
height: 0 !important;
display: none;
}
::v-deep rich-text h1 {
font-size: 36rpx;
line-height: 40rpx;
}
::v-deep rich-text h2 {
font-size: 32rpx;
line-height: 30rpx;
}
</style>