|
|
@@ -12,7 +12,15 @@
|
|
|
</li>
|
|
|
</ul>
|
|
|
<!-- 内容 -->
|
|
|
- <div class="conten" ref="contenSro">
|
|
|
+
|
|
|
+ <van-list
|
|
|
+ class="conten"
|
|
|
+ v-model="loading"
|
|
|
+ :finished="finished"
|
|
|
+ finished-text="没有更多了"
|
|
|
+ @load="onLoad"
|
|
|
+ :immediate-check="false"
|
|
|
+ >
|
|
|
<div
|
|
|
class="row"
|
|
|
v-for="item in dataArr"
|
|
|
@@ -41,10 +49,12 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
+ </van-list>
|
|
|
+
|
|
|
<!-- 底部的回帖按钮 -->
|
|
|
- <div class="postMes" @click="postMesShow=true">我 要 发 贴</div>
|
|
|
- <!-- 富文本 -->
|
|
|
+ <div class="postMes" @click="postMesShow = true">我 要 发 贴</div>
|
|
|
+
|
|
|
+ <!-- 点击我要发贴出来的发帖页面 -->
|
|
|
<div class="postMesShow" v-show="postMesShow">
|
|
|
<div class="postMesBack" @click="postMesShow = false">
|
|
|
<i class="el-icon-arrow-left"></i>
|
|
|
@@ -52,7 +62,7 @@
|
|
|
</div>
|
|
|
<!-- 标题输入框 -->
|
|
|
<el-input
|
|
|
- style="margin:20px 0 10px"
|
|
|
+ style="margin: 20px 0 10px"
|
|
|
type="text"
|
|
|
placeholder="帖子标题字数不能超过30个字。"
|
|
|
v-model="title"
|
|
|
@@ -69,33 +79,61 @@
|
|
|
<el-option label="美丽校园" value="school"></el-option>
|
|
|
<el-option label="文物典藏" value="goods"></el-option>
|
|
|
</el-select>
|
|
|
+ <!-- 上传图片 -->
|
|
|
+ <el-upload
|
|
|
+ accept=".png,.jpg,.jpeg,.gif"
|
|
|
+ title="上传图片"
|
|
|
+ class="upload-demo imgUplod"
|
|
|
+ :action="baseURL + '/web/bbs/upload'"
|
|
|
+ multiple
|
|
|
+ :before-upload="beforethumbUploadImg"
|
|
|
+ :on-success="upload_thumb_successImg"
|
|
|
+ >
|
|
|
+ <i class="w-e-icon-image"></i>
|
|
|
+ </el-upload>
|
|
|
<!-- 富文本 -->
|
|
|
- <div id="div1" style="z-index: 1"></div>
|
|
|
+ <div id="div1" style="z-index: 1">
|
|
|
+ </div>
|
|
|
<!-- 底部姓名和按钮 -->
|
|
|
<div class="postMesFloo">
|
|
|
- <el-input
|
|
|
- style="margin-right: 20px"
|
|
|
- type="text"
|
|
|
- placeholder="请填写您的姓名"
|
|
|
- v-model="creatorName"
|
|
|
- maxlength="8"
|
|
|
- show-word-limit
|
|
|
- >
|
|
|
- </el-input>
|
|
|
- <div class="submit">提 交</div>
|
|
|
+ <el-input
|
|
|
+ style="margin-right: 20px"
|
|
|
+ type="text"
|
|
|
+ placeholder="请填写您的姓名"
|
|
|
+ v-model="creatorName"
|
|
|
+ maxlength="8"
|
|
|
+ show-word-limit
|
|
|
+ >
|
|
|
+ </el-input>
|
|
|
+ <div class="submit" @click="publish">提 交</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { webBbsList, webBbsVisit, webBbsLike } from '@/apis/tab8'
|
|
|
+import axios from '@/utils/request'
|
|
|
+import E from 'wangeditor'
|
|
|
+import { webBbsList, webBbsVisit, webBbsLike, webBbsSave } from '@/apis/tab8'
|
|
|
export default {
|
|
|
neme: 'forumM_list',
|
|
|
components: {},
|
|
|
+ props: {
|
|
|
+ lookInfo: {
|
|
|
+ type: Object,
|
|
|
+ default: () => {}
|
|
|
+ }
|
|
|
+ },
|
|
|
data () {
|
|
|
// 这里存放数据
|
|
|
return {
|
|
|
+ // 服务器前缀地址
|
|
|
+ baseURL: '',
|
|
|
+
|
|
|
+ // vant下拉刷新的数据----------
|
|
|
+ loading: false,
|
|
|
+ finished: false,
|
|
|
+ // vant下拉刷新的数据----------
|
|
|
tabInd: 1,
|
|
|
tab: [
|
|
|
{ id: 1, name: '数字史馆', type: 'scene' },
|
|
|
@@ -110,7 +148,7 @@ export default {
|
|
|
status: 2,
|
|
|
type: 'scene',
|
|
|
pageNum: 1,
|
|
|
- pageSize: 99999,
|
|
|
+ pageSize: 5,
|
|
|
bbsType: 'topic'
|
|
|
},
|
|
|
selectType: 'scene',
|
|
|
@@ -120,7 +158,7 @@ export default {
|
|
|
// 点赞-帖子的开关
|
|
|
likeFlagOne: [],
|
|
|
// 控制富文本的显示和隐藏
|
|
|
- postMesShow: true
|
|
|
+ postMesShow: false
|
|
|
}
|
|
|
},
|
|
|
// 监听属性 类似于data概念
|
|
|
@@ -129,38 +167,117 @@ export default {
|
|
|
watch: {},
|
|
|
// 方法集合
|
|
|
methods: {
|
|
|
+ // 点击发表文章
|
|
|
+ async publish () {
|
|
|
+ if (this.creatorName.trim() === '') {
|
|
|
+ return this.$message.warning('名字不能为空!')
|
|
|
+ }
|
|
|
+ if (this.title.trim() === '') {
|
|
|
+ return this.$message.warning('标题不能为空!')
|
|
|
+ }
|
|
|
+ if (this.editor.txt.html() === '') {
|
|
|
+ return this.$message.warning('内容不能为空')
|
|
|
+ }
|
|
|
+ const res = await webBbsSave({
|
|
|
+ bbsType: 'topic',
|
|
|
+ content: this.editor.txt.html(),
|
|
|
+ creatorName: this.creatorName,
|
|
|
+ title: this.title,
|
|
|
+ type: this.selectType
|
|
|
+ })
|
|
|
+ if (res.code === 0) {
|
|
|
+ this.title = this.creatorName = ''
|
|
|
+ this.editor.txt.html('')
|
|
|
+ this.$message.success('发帖成功,等待审核.')
|
|
|
+ this.fuTxtShow = false
|
|
|
+ } else this.$message.warning(res.msg)
|
|
|
+ },
|
|
|
+ // 上传图片
|
|
|
+ beforethumbUploadImg (file) {
|
|
|
+ // console.log(998, file)
|
|
|
+ // 限制图片大小和格式
|
|
|
+ const sizeOk = file.size / 1024 / 1024 < 5
|
|
|
+ const typeOk =
|
|
|
+ file.type === 'image/png' ||
|
|
|
+ (file.type === 'image/jpeg' && !file.name.includes('.jfif')) ||
|
|
|
+ file.type === 'image/gif'
|
|
|
+
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ if (!typeOk) {
|
|
|
+ this.$message.error('图片格式有误!')
|
|
|
+ reject(file)
|
|
|
+ } else if (!sizeOk) {
|
|
|
+ this.$message.error('图片大小超过5M!')
|
|
|
+ reject(file)
|
|
|
+ } else if (file.name.length > 32) {
|
|
|
+ this.$message.error('图片名字不能超过32个字!')
|
|
|
+ reject(file)
|
|
|
+ } else {
|
|
|
+ resolve(file)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ upload_thumb_successImg (data) {
|
|
|
+ this.$message.success('上传成功')
|
|
|
+ this.editor.txt.append(
|
|
|
+ `<img src="${this.baseURL}${data.data.urlPath}" style="max-width:100%;display: block;margin: 10px auto;"/><p>  </p>`
|
|
|
+ )
|
|
|
+ },
|
|
|
+ // vant下拉刷新触发的函数
|
|
|
+ onLoad () {
|
|
|
+ this.formData.pageNum++
|
|
|
+ this.webBbsList(this.formData)
|
|
|
+ },
|
|
|
+ // 封装消息提示函数
|
|
|
+ notify (message, type) {
|
|
|
+ this.$notify({
|
|
|
+ message,
|
|
|
+ position: 'bottom-right',
|
|
|
+ type,
|
|
|
+ duration: 1000
|
|
|
+ })
|
|
|
+ },
|
|
|
// 点击点赞
|
|
|
async likeClick (item) {
|
|
|
if (!this.likeFlagOne.includes(item.id)) {
|
|
|
const res = await webBbsLike('upVote', item.id)
|
|
|
if (res.code === 0) {
|
|
|
- this.$message.success('点赞成功.')
|
|
|
+ this.notify('点赞成功', 'success')
|
|
|
this.likeFlagOne.push(item.id)
|
|
|
item.upVote++
|
|
|
item.flag = true
|
|
|
- } else this.$message.warning(res.msg)
|
|
|
- } else this.$message.warning('您已经赞过了.')
|
|
|
+ } else this.notify(res.msg, 'warning')
|
|
|
+ } else this.notify('您已经赞过了', 'warning')
|
|
|
},
|
|
|
// 点击通知父组件切换 动态组件is的值,并且把数据传过去
|
|
|
async skip (item) {
|
|
|
await webBbsVisit(item.id)
|
|
|
- this.$emit('cutComFn', item)
|
|
|
+ const temp = document.querySelector('.conten')
|
|
|
+ this.$emit('cutComFn', { ...item, scrollTop: temp.scrollTop }, true)
|
|
|
},
|
|
|
cutTab (item) {
|
|
|
+ this.dataArr = []
|
|
|
this.tabInd = item.id
|
|
|
this.formData.type = item.type
|
|
|
+ this.formData.pageNum = 1
|
|
|
this.webBbsList(this.formData)
|
|
|
+ this.finished = false
|
|
|
// 让下面的下拉框同步
|
|
|
this.selectType = item.type
|
|
|
// 回到屏幕顶点
|
|
|
- this.$refs.contenSro.scrollTo({ top: 0 })
|
|
|
+ // const temp = document.querySelector('.conten')
|
|
|
+ // temp.scrollTo({ top: 0 })
|
|
|
// console.log('-----------')
|
|
|
// window.scrollTo({ top: 0 })
|
|
|
},
|
|
|
// 封装获取列表的方法
|
|
|
async webBbsList (data) {
|
|
|
const res = await webBbsList(data)
|
|
|
- this.dataArr = res.data.records
|
|
|
+ res.data.records.forEach((v) => {
|
|
|
+ this.dataArr.push(v)
|
|
|
+ })
|
|
|
+ this.loading = false
|
|
|
+ if (res.data.records.length < 5 || this.dataArr.length >= res.data.total) this.finished = true
|
|
|
this.likeFlagOne.forEach((p) => {
|
|
|
this.dataArr.forEach((v) => {
|
|
|
if (p === v.id) v.flag = true
|
|
|
@@ -169,9 +286,35 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
// 生命周期 - 创建完成(可以访问当前this实例)
|
|
|
- created () {},
|
|
|
+ created () {
|
|
|
+ // 获取服务器前缀地址
|
|
|
+ this.baseURL = axios.defaults.baseURL
|
|
|
+ // 调用获取列表方法
|
|
|
+ this.webBbsList(this.formData)
|
|
|
+ },
|
|
|
// 生命周期 - 挂载完成(可以访问DOM元素)
|
|
|
- mounted () {},
|
|
|
+ mounted () {
|
|
|
+ // 初始化富文本
|
|
|
+ // 富文本
|
|
|
+ this.editor = new E('#div1')
|
|
|
+ // 配置字体
|
|
|
+ this.editor.config.fontNames = [
|
|
|
+ '黑体',
|
|
|
+ '仿宋',
|
|
|
+ '楷体',
|
|
|
+ '标楷体',
|
|
|
+ '华文仿宋',
|
|
|
+ '华文楷体',
|
|
|
+ '宋体',
|
|
|
+ '微软雅黑',
|
|
|
+ 'Arial',
|
|
|
+ 'Tahoma',
|
|
|
+ 'Verdana',
|
|
|
+ 'Times New Roman'
|
|
|
+ ]
|
|
|
+ this.editor.config.showLinkVideo = false
|
|
|
+ this.editor.create()
|
|
|
+ },
|
|
|
beforeCreate () {}, // 生命周期 - 创建之前
|
|
|
beforeMount () {}, // 生命周期 - 挂载之前
|
|
|
beforeUpdate () {}, // 生命周期 - 更新之前
|
|
|
@@ -179,8 +322,10 @@ export default {
|
|
|
beforeDestroy () {}, // 生命周期 - 销毁之前
|
|
|
destroyed () {}, // 生命周期 - 销毁完成
|
|
|
activated () {
|
|
|
- // 调用获取列表方法
|
|
|
- this.webBbsList(this.formData)
|
|
|
+ if (this.lookInfo.scrollTop) {
|
|
|
+ const temp = document.querySelector('.conten')
|
|
|
+ temp.scrollTo({ top: this.lookInfo.scrollTop })
|
|
|
+ }
|
|
|
} // 如果页面有keep-alive缓存功能,这个函数会触发
|
|
|
}
|
|
|
</script>
|
|
|
@@ -190,6 +335,7 @@ export default {
|
|
|
height: 100%;
|
|
|
& > h3 {
|
|
|
font-size: 20px;
|
|
|
+ margin-left: 10px;
|
|
|
}
|
|
|
.topTab {
|
|
|
margin: 10px;
|
|
|
@@ -303,20 +449,53 @@ export default {
|
|
|
/deep/.el-input__count-inner {
|
|
|
background-color: transparent;
|
|
|
}
|
|
|
- /deep/.w-e-toolbar {
|
|
|
- background-color: rgba(255, 255, 255, 0.5) !important;
|
|
|
+ // /deep/.w-e-toolbar {
|
|
|
+ // background-color: rgba(255, 255, 255, 0.5) !important;
|
|
|
+ // }
|
|
|
+ // /deep/.w-e-text-container {
|
|
|
+ // background-color: rgba(255, 255, 255, 0.5) !important;
|
|
|
+ // }
|
|
|
+ /deep/.w-e-toolbar .w-e-menu {
|
|
|
+ display: none !important;
|
|
|
}
|
|
|
- /deep/.w-e-text-container {
|
|
|
- background-color: rgba(255, 255, 255, 0.5) !important;
|
|
|
+ /deep/.w-e-toolbar .w-e-menu:nth-of-type(17) {
|
|
|
+ display: flex !important;
|
|
|
}
|
|
|
- #div1{
|
|
|
- height: calc(100vh - 230px);
|
|
|
+
|
|
|
+ .imgUplod {
|
|
|
+ /deep/.w-e-icon-image {
|
|
|
+ color: #999;
|
|
|
+ display: inline-block;
|
|
|
+ width: 40px;
|
|
|
+ height: 40px;
|
|
|
+ line-height: 40px;
|
|
|
+ }
|
|
|
+ /deep/.el-upload-list {
|
|
|
+ display: none !important;
|
|
|
+ }
|
|
|
+ display: flex;
|
|
|
+ justify-content: center;
|
|
|
+ align-items: center;
|
|
|
+ cursor: pointer;
|
|
|
+ position: absolute;
|
|
|
+ z-index: 9999;
|
|
|
+ top: 170px;
|
|
|
+ left: 70px;
|
|
|
+ width: 40px;
|
|
|
+ height: 40px;
|
|
|
+ }
|
|
|
+ #div1 {
|
|
|
+ height: calc(100vh - 240px);
|
|
|
+ margin-top: 10px;
|
|
|
+ /deep/.w-e-text-container{
|
|
|
+ height: calc(100% - 45px) !important;
|
|
|
+ }
|
|
|
}
|
|
|
- .postMesFloo{
|
|
|
+ .postMesFloo {
|
|
|
margin-top: 10px;
|
|
|
display: flex;
|
|
|
justify-content: space-between;
|
|
|
- .submit{
|
|
|
+ .submit {
|
|
|
margin-top: 2px;
|
|
|
width: 60px;
|
|
|
height: 36px;
|