diff --git a/css/index.css b/css/index.css index 697eab4..e883f51 100644 --- a/css/index.css +++ b/css/index.css @@ -1,9 +1,17 @@ +.index-footer { + margin-top: 0 !important; +} +header.page-header .box .tab-list .item.pitch { + color: #FDDF6D !important; +} +header.page-header .box .tab-list .item.pitch::after { + background-color: #fddf6d !important; +} * { margin: 0; padding: 0; box-sizing: border-box; font-family: 'PingFangSC-Regular', 'PingFang SC', sans-serif; - font-style: normal; } /* Webkit浏览器(Chrome、Safari等) */ *::-webkit-scrollbar { @@ -59,6 +67,7 @@ #answer-app { min-width: 1200px; overflow-x: hidden; + word-break: break-all; } #answer-app header { background: #f6f6f6; @@ -102,6 +111,17 @@ height: 20px; cursor: pointer; } +#answer-app header .top .right .searchInput .clear-search .cross-circle-black { + width: 14px; + height: 14px; + cursor: pointer; +} +#answer-app header .top .right .searchInput .clear-search .halving-line { + width: 1px; + height: 13px; + background-color: #ebebeb; + margin: 0 17px; +} #answer-app header .top .right .searchInput .history-box { position: absolute; top: 36px; @@ -168,6 +188,7 @@ } #answer-app header .tab-box { width: 100%; + min-width: 1200px; z-index: 1; background-color: #f6f6f6; padding: 5px 0; @@ -243,7 +264,7 @@ font-size: 14px; height: 20px; cursor: pointer; - width: 400px; + max-width: 400px; padding-right: 20px; margin-right: 20px; border-right: 1px solid #ebebeb; @@ -343,6 +364,9 @@ color: #000000; line-height: 22px; } +#answer-app .main .list-box .list .item .content .issue-title .issue em { + color: #ff0000; +} #answer-app .main .list-box .list .item .content .answer { color: #555; height: 22px; @@ -350,6 +374,9 @@ font-size: 13px; margin-bottom: 18px; } +#answer-app .main .list-box .list .item .content .answer em { + color: #ff0000; +} #answer-app .main .list-box .list .item .content .bottom { font-size: 12px; justify-content: flex-end; @@ -401,6 +428,28 @@ overflow-x: hidden; display: flex; flex-direction: column; + position: relative; +} +#answer-app .main .details-area-box .loading-bj { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: 1; + background-color: rgba(255, 255, 255, 0.5); +} +#answer-app .main .details-area-box .loading-bj svg { + width: 100px; + animation: spin 2s linear infinite; +} +@keyframes spin { + 0% { + transform: rotate(0deg); + } + 100% { + transform: rotate(360deg); + } } #answer-app .main .details-area-box .details-box { width: 688px; @@ -443,6 +492,7 @@ padding-top: 24px; margin-bottom: 28px; position: relative; + word-break: break-all; } #answer-app .main .details-area-box .details-box .details-issue .icon { background-color: #72db86; @@ -555,6 +605,7 @@ line-height: 26px; padding: 0 24px; margin-bottom: 20px; + word-break: break-all; } #answer-app .main .details-area-box .details-box .answer-box-item .answer-text img { max-width: 100%; @@ -642,12 +693,16 @@ #answer-app .main .details-area-box .details-box .answer-box-item .comments-box .comments-item .comments-header .comments-header-right .menu-box { position: relative; } +#answer-app .main .details-area-box .details-box .answer-box-item .comments-box .comments-item .comments-header .comments-header-right .menu-box:hover .report-box { + display: flex; +} #answer-app .main .details-area-box .details-box .answer-box-item .comments-box .comments-item .comments-header .comments-header-right .menu-box .menu-icon { width: 14px; height: 14px; cursor: pointer; } #answer-app .main .details-area-box .details-box .answer-box-item .comments-box .comments-item .comments-header .comments-header-right .menu-box .report-box { + display: none; position: absolute; top: 24px; right: 0; @@ -658,6 +713,15 @@ border-radius: 5px; font-size: 12px; color: #7F7F7F; + cursor: pointer; +} +#answer-app .main .details-area-box .details-box .answer-box-item .comments-box .comments-item .comments-header .comments-header-right .menu-box .report-box::after { + content: ""; + width: 58px; + height: 36px; + position: absolute; + top: -14px; + right: 0; } #answer-app .main .details-area-box .details-box .answer-box-item .comments-box .comments-item .comments-header .comments-header-right .comment-icon { width: 14px; @@ -844,6 +908,14 @@ #answer-app .main .details-area-box .details-box .operate-box .operate-list .operate-item.operate-transmit { position: relative; } +#answer-app .main .details-area-box .details-box .operate-box .operate-list .operate-item.operate-transmit::after { + content: ""; + width: 100%; + height: 100%; + position: absolute; + top: 20px; + z-index: 10; +} #answer-app .main .details-area-box .details-box .operate-box .operate-list .operate-item.operate-transmit .transmit-box { width: 628px; border: 1px solid #ebebeb; @@ -857,7 +929,7 @@ background: #fff; justify-content: space-between; padding: 40px 35px 42px; - z-index: 1; + z-index: 3; } #answer-app .main .details-area-box .details-box .operate-box .operate-list .operate-item.operate-transmit .transmit-box .transmit-title { font-weight: 650; @@ -1464,6 +1536,7 @@ margin-right: 12px; } #answer-app .i-answer-box .question-middle .question-textarea { + height: 412px; width: 100%; border: none; outline: none; @@ -1555,3 +1628,166 @@ transform: translate(-50%, 0); } } +.alert-form { + display: block; + position: fixed; + z-index: 2100; + left: 0; + top: 0; + width: 100vw; + height: 100vh; + background-color: rgba(0, 0, 0, 0.7); +} +.alert-form * { + box-sizing: border-box; +} +.alert-form .reports { + height: 440px; +} +.alert-form .reports .radio-area { + margin-bottom: 40px; +} +.alert-form .reports .radio-area .radio-area-item { + color: #606266; + font-size: 14px; + margin-right: 10px; + cursor: pointer; +} +.alert-form .reports .radio-area .radio-area-item.pitch .radio-area-frame { + background-color: #50E3C2; + border-color: #50E3C2; +} +.alert-form .reports .radio-area .radio-area-item.pitch .radio-area-frame::after { + -webkit-transform: rotate(45deg) scaleY(1); + transform: rotate(45deg) scaleY(1); +} +.alert-form .reports .radio-area .radio-area-item .radio-area-frame { + border: 1px solid #DCDFE6; + border-radius: 2px; + width: 14px; + height: 14px; + -webkit-transition: border-color 0.25s cubic-bezier(0.71, -0.46, 0.29, 1.46), background-color 0.25s cubic-bezier(0.71, -0.46, 0.29, 1.46); + transition: border-color 0.25s cubic-bezier(0.71, -0.46, 0.29, 1.46), background-color 0.25s cubic-bezier(0.71, -0.46, 0.29, 1.46); + position: relative; + margin-right: 10px; +} +.alert-form .reports .radio-area .radio-area-item .radio-area-frame::after { + -webkit-box-sizing: content-box; + box-sizing: content-box; + content: ""; + border: 1px solid #FFF; + border-left: 0; + border-top: 0; + height: 7px; + left: 4px; + position: absolute; + top: 1px; + -webkit-transform: rotate(45deg) scaleY(0); + transform: rotate(45deg) scaleY(0); + width: 3px; + -webkit-transition: -webkit-transform 0.15s ease-in 0.05s; + transition: -webkit-transform 0.15s ease-in 0.05s; + transition: transform 0.15s ease-in 0.05s; + transition: transform 0.15s ease-in 0.05s, -webkit-transform 0.15s ease-in 0.05s; + -webkit-transform-origin: center; + transform-origin: center; +} +.alert-form .el-checkbox-group { + font-size: 0; +} +.alert-form .comments { + display: block; + position: fixed; + z-index: 11; + left: 50%; + top: 50%; + width: 740px; + height: 440px; + max-width: 90vw; + max-height: 90vh; + transform: translate(-50%, -50%); + background-color: #ffffff; + border: none; + border-radius: 8px 8px 6px 6px; +} +.alert-form .comments .text-box { + position: relative; +} +.alert-form .comments .text-num { + position: absolute; + right: 10px; + bottom: 10px; + color: #999; + font-size: 12px; +} +.alert-form .comments .form { + display: block; + width: 100%; + padding: 34px 30px 40px; +} +.alert-form .comments .form textarea { + height: 172px; + margin-bottom: 30px; + display: block; + width: 100%; + background: #f7f7f7; + padding: 18px; + font-size: 14px; + border: 1px solid #F7F7F7; + border-radius: 5px; + outline: none; + resize: none; + line-height: 22px; +} +.alert-form .head { + padding: 0 18px 0 30px; + display: flex; + height: 56px; + align-items: center; + justify-content: space-between; + background: #333333; + color: #fff; + font-size: 17px; + border-radius: 6px 6px 0 0; +} +.alert-form .head .close { + color: #b3b3b3; + font-size: 14px; + cursor: pointer; +} +.alert-form .footer { + display: flex; + justify-content: center; + align-items: center; +} +.alert-form .footer button[type=button] { + margin-right: 20px; +} +.alert-form .footer button { + border: 1px #999999 solid; + border-radius: 5px; + background-color: #ffffff; + width: 128px; + height: 38px; + color: #333; + font-size: 14px; + outline: none; + cursor: pointer; +} +.alert-form .footer button[type=submit] { + background-color: #50E3C2; + border-color: #50E3C2; + color: #fff; +} +.alert-form .el-checkbox__input.is-checked .el-checkbox__inner, +.alert-form .el-checkbox__input.is-indeterminate .el-checkbox__inner { + background-color: #50E3C2; + border-color: #50E3C2; +} +.alert-form .el-checkbox__input.is-focus .el-checkbox__inner, +.alert-form .el-checkbox__inner:hover { + border-color: #50E3C2; +} +.alert-form .el-checkbox__input.is-checked + .el-checkbox__label { + color: #50E3C2; +} diff --git a/css/index.less b/css/index.less index 92d3407..394ce26 100644 --- a/css/index.less +++ b/css/index.less @@ -1,9 +1,21 @@ +.index-footer { + margin-top: 0 !important; +} + +header.page-header .box .tab-list .item.pitch { + color: #FDDF6D !important; +} + +header.page-header .box .tab-list .item.pitch::after { + background-color: rgba(253, 223, 109, 1) !important; +} + * { margin: 0; padding: 0; box-sizing: border-box; font-family: 'PingFangSC-Regular', 'PingFang SC', sans-serif; - font-style: normal; + // font-style: normal; } /* Webkit浏览器(Chrome、Safari等) */ @@ -72,6 +84,7 @@ #answer-app { min-width: 1200px; overflow-x: hidden; + word-break: break-all; header { background: rgba(246, 246, 246, 1); @@ -121,6 +134,21 @@ cursor: pointer; } + .clear-search { + .cross-circle-black { + width: 14px; + height: 14px; + cursor: pointer; + } + + .halving-line { + width: 1px; + height: 13px; + background-color: #ebebeb; + margin: 0 17px; + } + } + .history-box { position: absolute; top: 36px; @@ -201,6 +229,7 @@ .tab-box { width: 100%; + min-width: 1200px; z-index: 1; background-color: #f6f6f6; padding: 5px 0; @@ -295,7 +324,7 @@ font-size: 14px; height: 20px; cursor: pointer; - width: 400px; + max-width: 400px; .search-keyword-cross { width: 14px; @@ -440,6 +469,10 @@ font-size: 14px; color: #000000; line-height: 22px; + + em { + color: #ff0000; + } } } @@ -449,6 +482,10 @@ line-height: 22px; font-size: 13px; margin-bottom: 18px; + + em { + color: #ff0000; + } } .bottom { @@ -520,6 +557,32 @@ display: flex; flex-direction: column; + position: relative; + + .loading-bj { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: 1; + background-color: rgba(255, 255, 255, 0.5); + + svg { + width: 100px; + animation: spin 2s linear infinite; + } + + @keyframes spin { + 0% { + transform: rotate(0deg); + } + + 100% { + transform: rotate(360deg); + } + } + } .details-box { width: 688px; @@ -567,6 +630,7 @@ padding-top: 24px; margin-bottom: 28px; position: relative; + word-break: break-all; // .icon-boxb { // border: 4px solid #fbfbfb; @@ -714,6 +778,7 @@ line-height: 26px; padding: 0 24px; margin-bottom: 20px; + word-break: break-all; img { max-width: 100%; @@ -819,15 +884,22 @@ .comments-header-right { .menu-box { + position: relative; + + &:hover .report-box { + display: flex; + } + .menu-icon { width: 14px; height: 14px; cursor: pointer; + } - position: relative; .report-box { + display: none; position: absolute; top: 24px; right: 0; @@ -838,6 +910,16 @@ border-radius: 5px; font-size: 12px; color: #7F7F7F; + cursor: pointer; + + &::after { + content: ""; + width: 58px; + height: 36px; + position: absolute; + top: -14px; + right: 0; + } } } @@ -1074,8 +1156,24 @@ &.operate-transmit { position: relative; // z-index: 1; + // &:hover { + &::after { + content: ""; + width: 100%; + height: 100%; + position: absolute; + top: 20px; + z-index: 10; + } + + // .transmit-box { + // display: flex; + + // } + // } .transmit-box { + // display: none; width: 628px; // height: 300px; border: 1px solid rgba(235, 235, 235, 1); @@ -1090,7 +1188,7 @@ background: #fff; justify-content: space-between; padding: 40px 35px 42px; - z-index: 1; + z-index: 3; .transmit-title { font-weight: 650; @@ -1870,7 +1968,7 @@ } .question-textarea { - // height: 412px; + height: 412px; width: 100%; border: none; outline: none; @@ -1983,4 +2081,198 @@ opacity: 1; transform: translate(-50%, 0); } +} + +.alert-form { + display: block; + position: fixed; + z-index: 2100; + left: 0; + top: 0; + width: 100vw; + height: 100vh; + background-color: rgba(0, 0, 0, 0.7); +} + +.alert-form * { + box-sizing: border-box; +} + +.alert-form .reports { + height: 440px; +} + +.alert-form .reports .radio-area { + margin-bottom: 40px; + + .radio-area-item { + color: #606266; + font-size: 14px; + margin-right: 10px; + cursor: pointer; + + &.pitch { + .radio-area-frame { + background-color: #50E3C2; + border-color: #50E3C2; + + &::after { + -webkit-transform: rotate(45deg) scaleY(1); + transform: rotate(45deg) scaleY(1); + } + } + } + + .radio-area-frame { + border: 1px solid #DCDFE6; + border-radius: 2px; + width: 14px; + height: 14px; + -webkit-transition: border-color .25s cubic-bezier(.71, -.46, .29, 1.46), background-color .25s cubic-bezier(.71, -.46, .29, 1.46); + transition: border-color .25s cubic-bezier(.71, -.46, .29, 1.46), background-color .25s cubic-bezier(.71, -.46, .29, 1.46); + + position: relative; + margin-right: 10px; + + &::after { + + -webkit-box-sizing: content-box; + box-sizing: content-box; + content: ""; + border: 1px solid #FFF; + border-left: 0; + border-top: 0; + height: 7px; + left: 4px; + position: absolute; + top: 1px; + -webkit-transform: rotate(45deg) scaleY(0); + transform: rotate(45deg) scaleY(0); + width: 3px; + -webkit-transition: -webkit-transform .15s ease-in .05s; + transition: -webkit-transform .15s ease-in .05s; + transition: transform .15s ease-in .05s; + transition: transform .15s ease-in .05s, -webkit-transform .15s ease-in .05s; + -webkit-transform-origin: center; + transform-origin: center; + } + + // } + } + } +} + + +.alert-form .el-checkbox-group { + font-size: 0; +} + +.alert-form .comments { + display: block; + position: fixed; + z-index: 11; + left: 50%; + top: 50%; + width: 740px; + height: 440px; + max-width: 90vw; + max-height: 90vh; + transform: translate(-50%, -50%); + background-color: #ffffff; + border: none; + border-radius: 8px 8px 6px 6px; +} + +.alert-form .comments .text-box { + position: relative; +} + +.alert-form .comments .text-num { + position: absolute; + right: 10px; + bottom: 10px; + color: #999; + font-size: 12px; +} + +.alert-form .comments .form { + display: block; + width: 100%; + padding: 34px 30px 40px; +} + +.alert-form .comments .form textarea { + height: 172px; + margin-bottom: 30px; + display: block; + width: 100%; + background: #f7f7f7; + padding: 18px; + font-size: 14px; + border: 1px solid #F7F7F7; + border-radius: 5px; + outline: none; + resize: none; + line-height: 22px; +} + +.alert-form .head { + padding: 0 18px 0 30px; + display: flex; + height: 56px; + align-items: center; + justify-content: space-between; + background: #333333; + color: #fff; + font-size: 17px; + border-radius: 6px 6px 0 0; +} + +.alert-form .head .close { + color: #b3b3b3; + font-size: 14px; + cursor: pointer; +} + +.alert-form .footer { + display: flex; + justify-content: center; + align-items: center; +} + +.alert-form .footer button[type=button] { + margin-right: 20px; +} + +.alert-form .footer button { + border: 1px #999999 solid; + border-radius: 5px; + background-color: #ffffff; + width: 128px; + height: 38px; + color: #333; + font-size: 14px; + outline: none; + cursor: pointer; +} + +.alert-form .footer button[type=submit] { + background-color: #50E3C2; + border-color: #50E3C2; + color: #fff; +} + +.alert-form .el-checkbox__input.is-checked .el-checkbox__inner, +.alert-form .el-checkbox__input.is-indeterminate .el-checkbox__inner { + background-color: #50E3C2; + border-color: #50E3C2; +} + +.alert-form .el-checkbox__input.is-focus .el-checkbox__inner, +.alert-form .el-checkbox__inner:hover { + border-color: #50E3C2; +} + +.alert-form .el-checkbox__input.is-checked+.el-checkbox__label { + color: #50E3C2; } \ No newline at end of file diff --git a/img/cross-circle-black.png b/img/cross-circle-black.png new file mode 100644 index 0000000..1b7df23 Binary files /dev/null and b/img/cross-circle-black.png differ diff --git a/index.html b/index.html index dcd0977..fb4b10d 100644 --- a/index.html +++ b/index.html @@ -9,8 +9,6 @@ - - @@ -21,6 +19,10 @@
+
历史搜索
@@ -42,37 +44,38 @@
-
All
+
All
-
-
{{ keywordText }}
+
{{ keywordText }}
共 {{ total }} 条问答
-
+
{{ list.lenght }}
- +
{{ item['answers'] == 0 ? '暂无回答' : `共${ item['answers'] }个回答` }}
-
-
我来回答
+
@@ -85,8 +88,16 @@
+ +
+ + + +
+
-
+ +
@@ -102,7 +113,7 @@
{{ handleDate(detailsInfo['publicationdate']) }}
@@ -118,10 +129,10 @@ 收藏
-
+
转发 -
+
转发网页版
@@ -196,7 +207,7 @@ {{ item['collectionnum'] == 0 ? '收藏' : item['collectionnum'] }}
-
+
转发
@@ -238,13 +249,13 @@
{{ it['nickname'] }}
{{ handleDate(it['timestamp']) }}
- -
提问者
+
提问者
+
回答者
-
@@ -406,7 +418,7 @@
{{ item['nickname'] }}
-
{{ item['publicationdate'] }}
+
{{ handleDate(item['publicationdate']) }}
提问:{{ item['title'] }}
@@ -469,16 +481,9 @@
-
+
- - -
+
选择提问所属主题
@@ -489,7 +494,7 @@
-
+
Q
@@ -538,7 +543,7 @@
Q
{{ IAnswerInfo['title'] }}
-
+
A
@@ -576,6 +581,31 @@
+ +
+
+
+ 举报投诉 +
+
+
+
+
+
{{ s }} +
+
+
+ +
{{ 200 - alertText.length}}
+
+ +
+
+
+
diff --git a/js/index.js b/js/index.js index 5902d64..290d04f 100644 --- a/js/index.js +++ b/js/index.js @@ -1,7 +1,5 @@ -// 提交问题 -// 切换头部分类 -// 转发的链接和title -// 图片上传有一些错误 +// 评论的回答者 提问者 +// 列表 hot标签 Object.assign(window, Vue) const forumApp = Vue.createApp({ @@ -13,16 +11,16 @@ const forumApp = Vue.createApp({ onMounted(() => { getUrlParams() getUserData() - getList() getListClass() + window.addEventListener('scroll', handleScroll); getHistoricalSearchList() - }) onUnmounted(() => { + window.removeEventListener('keydown', handleKeydown) window.removeEventListener('scroll', handleScroll); }); @@ -40,7 +38,10 @@ const forumApp = Vue.createApp({ initParams = params if (params['uniqid']) getDetails(params['uniqid']) + if (params['keyword']) keyword.value = params['keyword'] + if (params['tid']) typePitch.value = params['tid'] + getList() } // 获取当前url @@ -122,7 +123,7 @@ const forumApp = Vue.createApp({ getList() - replaceState() + deleteState(['keyword']) } let historicalSearchState = ref(false) // 历史记录弹窗状态 @@ -136,7 +137,8 @@ const forumApp = Vue.createApp({ const clientHeight = document.documentElement.clientHeight; // 列表下 滑动到底部 获取新数据 - if (scrollTop + clientHeight >= scrollHeight) getList() + // console.log("type.value == 'list'", type.value == 'list', scrollTop + clientHeight, scrollHeight); + // if (scrollTop + clientHeight >= scrollHeight - 40 && type.value == 'list') getList() // 列表下 滚动到顶部 触发类型的固定状态 if (scrollTop > 115 && type.value == 'list') tabListFixeState.value = true @@ -213,10 +215,19 @@ const forumApp = Vue.createApp({ let detailsIsmyself = ref(0) // 详情信息 let detailsToken = '' // 详情信息 let detailShare = ref({}) // 详情信息 + let detailLoading = ref(false) // 详情加载 + // 获取详情 const getDetails = (uniqid, index, isOpenAnswer) => { - // uniqid = "fubm5CnD05qj" // 标记一下 + if (detailLoading.value) return + detailLoading.value = true + + // uniqid = "fubm5CnD05qj" // 标记一下 8yr1m1fOH5CS + detailsInfo.value = {} + answerList.value = [] + answerPage.value = 0 + $ajax("/api/details", { uniqid }).then(res => { if (res.code != 200) return let data = res.data @@ -231,29 +242,7 @@ const forumApp = Vue.createApp({ type.value = 'details' if (index !== null && index !== undefined) cut(index) - else { - let targetList = [...list.value] - let valve = false - targetList.forEach((element, index) => { - - if (element['uniqid'] == uniqid) { - cut(index) - valve = true - } - }) - - if (!valve) { - list.value.unshift({ - answers: data.info['answers'], - content: data.info['content'], - publicationdate: data.info['publicationdate'], - title: data.info['title'], - uniqid, - }) - cut(0) - } - - } + else calculateListIndex(data.info, uniqid) answerList.value = [] answerPage.value = 1 @@ -264,9 +253,41 @@ const forumApp = Vue.createApp({ if (isOpenAnswer) openIAnswer() replaceState({ uniqid }) + }).finally(() => { + detailLoading.value = false }) } + + // + const calculateListIndex = (info, uniqid) => { + let targetList = [...list.value] + if (targetList.length == 0 && isSearchMode.value == false) { + setTimeout(() => calculateListIndex(info, uniqid), 200) + return + } + let valve = false + targetList.forEach((element, index) => { + if (element['uniqid'] == uniqid) { + cut(index) + valve = true + } + }) + + if (!valve) { + let content = "" + if (info['content'].indexOf(' { if (res.code == 200) { + answerList.value = [] + answerPage.value = 1 getAnswerList() closeIAnswer() isNeedNewAnswersData = true handleMsg('success', res['message'] || '操作成功') if (!IAnswerInfo.value['token']) myCount.value['answer']++ - } else { - } }) @@ -449,7 +470,11 @@ const forumApp = Vue.createApp({ getAnswerCommentPublic(index).then(res => { if (res.code != 200) return let data = res.data + let slice3 = data.data.slice(3) + console.log(answerList.value[index]['commentList'], "commentList"); + answerList.value[index]['commentList'] = answerList.value[index]['commentList'].concat(data.data.slice(3)) + answerList.value[index]['commentList'] = merged handleMsg('success', res['message'] || '操作成功') }) } @@ -496,6 +521,7 @@ const forumApp = Vue.createApp({ if (i != null) { let targetData = { + id: data['commentid'], content, isauthor: 1, islike: 0, @@ -507,9 +533,10 @@ const forumApp = Vue.createApp({ } targetAnswerList[index]['commentList'][ind]['child'].unshift(targetData) - + targetAnswerList[index]['commentList'][ind]['childnum']++ } else if (ind != null) { let targetData = { + id: data['commentid'], content, isauthor: 1, islike: 0, @@ -518,6 +545,7 @@ const forumApp = Vue.createApp({ ...data, } targetAnswerList[index]['commentList'][ind]['child'].unshift(targetData) + targetAnswerList[index]['commentList'][ind]['childnum']++ } else { let targetData = { @@ -529,12 +557,10 @@ const forumApp = Vue.createApp({ child: [] } targetAnswerList[index]['commentList'].unshift(targetData) - } closeAnswerCommentsChild() - console.log("targetAnswerList", targetAnswerList); handleMsg('success', res['message'] || '操作成功') }) } @@ -601,7 +627,7 @@ const forumApp = Vue.createApp({ const alsoCommentsData = (index, ind) => { const targetAnswerList = [...answerList.value] const parentid = targetAnswerList[index]['commentList'][ind]['id'] - const token = targetAnswerList[index]['commentList'][ind]['token'] + const token = targetAnswerList[index]['token'] $ajax("/api/comment/childrenList", { token, @@ -610,12 +636,12 @@ const forumApp = Vue.createApp({ page: 1, childlimit: 1, }).then(res => { - console.log("res", res); if (res.code != 200) return let data = res.data - targetAnswerList[index]['commentList'][ind]['child'] = targetAnswerList[index]['commentList'][ind]['child'].concat(data.data) + let merged = [...targetAnswerList[index]['commentList'][ind]['child'], ...data.data.filter(item2 => !targetAnswerList[index]['commentList'][ind]['child'].find(item1 => item1.id == item2.id))]; + targetAnswerList[index]['commentList'][ind]['child'] = merged answerList.value = targetAnswerList }) } @@ -646,9 +672,13 @@ const forumApp = Vue.createApp({ let myCollectionList = ref([]) // 我的收藏列表 let myCollectionCount = ref(0) // 我的收藏数量 let myCollectionPage = 1 // 我的收藏页数 + let myCollectionLading = false // 我的收藏加载中 + // 获取我的收藏 const getMyCollection = () => { - if (myCollectionPage == 0) return + if (myCollectionPage == 0 || myCollectionLading) return + myCollectionLading = true + $ajax("/api/user/collect", { limit: 20, page: myCollectionPage, @@ -663,7 +693,7 @@ const forumApp = Vue.createApp({ if (myCollectionList.value.length != data['count']) myCollectionPage++ else myCollectionPage = 0 - }) + }).finally(() => myCollectionLading = false) } // 取消收藏 @@ -681,19 +711,18 @@ const forumApp = Vue.createApp({ // 监听 我的收藏滚动到底部 const handleCollectionScroll = (e) => { const el = e.target; - // 判断滚动到底部 - if (el.scrollHeight - el.scrollTop !== el.clientHeight) return + if (el.scrollHeight - el.scrollTop >= el.clientHeight + 10) return getMyCollection() } let myAnswerList = ref([]) // 我的回答数据 let myAnswerCount = ref(0) // 我的回答数量 let myAnswerPage = 1 - + let myAnswerloadimg = false // 获取我的回答 const getMyAnswer = () => { - if (myAnswerPage == 0) return - + if (myAnswerPage == 0 || myAnswerloadimg) return + myAnswerloadimg = true $ajax("/api/user/answer", { limit: 20, page: myAnswerPage, @@ -713,14 +742,14 @@ const forumApp = Vue.createApp({ myType.value = 'answers' isNeedNewAnswersData = false - }) + }).finally(() => myAnswerloadimg = false) } // 我的回答 的滚动到底部事件 const handleAnswersScroll = e => { const el = e.target; // 判断滚动到底部 - if (el.scrollHeight - el.scrollTop !== el.clientHeight) return + if (el.scrollHeight - el.scrollTop >= el.clientHeight + 10) return getMyAnswer() } @@ -753,9 +782,11 @@ const forumApp = Vue.createApp({ let myQuestionsList = ref([]) // 我的提问数据 let myQuestionsCount = ref(0) // 我的提问数量 let myQuestionsPage = 0 // 我的提问页数 + let myQuestionsloading = false // 我的提问页数 // 获取我的提问 const getMyQuestions = () => { - if (myQuestionsPage == 0) return + if (myQuestionsPage == 0 || myQuestionsloading) return + myQuestionsloading = true $ajax("/api/user/questions", { limit: 20, page: myQuestionsPage, @@ -769,14 +800,15 @@ const forumApp = Vue.createApp({ if (myQuestionsList.value.length != data['count']) myQuestionsPage++ else myQuestionsPage = 0 - }) + }).finally(() => myQuestionsloading = false) } // 我的提问 的滚动到底部 事件 const handleQuestionsScroll = e => { const el = e.target; // 判断滚动到底部 - if (el.scrollHeight - el.scrollTop !== el.clientHeight) return + console.log(el.scrollHeight - el.scrollTop >= el.clientHeight + 10); + if (el.scrollHeight - el.scrollTop >= el.clientHeight + 10) return getMyQuestions() } @@ -850,15 +882,23 @@ const forumApp = Vue.createApp({ // 发布问题 const postingIssue = () => { - // 还没有分类 - console.log("发布问题", questionsObj.value); - $ajax("/api/publish/questionsSubmit", questionsObj.value).then(res => { - console.log("res", res); - - myCount.value['questions']++ if (res.code == 200) { + myCount.value['questions']++ + questionsSetp.value = 0 + questionsObj.value = { + token: "", + title: "", + content: "", + tags: "", + tid: "", + anonymous: 0, + } handleMsg('success', res['message'] || '操作成功') + let data = res.data + // calculateListIndex(res) + getDetails(data['uniqid']) + return } handleMsg('error', res['message'] || '刷新重试!!!') }) @@ -942,20 +982,37 @@ const forumApp = Vue.createApp({ const $ajax = (url, data) => { url = url.indexOf('//') > -1 ? url : baseURL + url; return new Promise(function (resolve, reject) { + // var xhr = new XMLHttpRequest() + // xhr.responseType = "json" + // xhr.withCredentials = true + // xhr.onreadystatechange = function () { + // if (xhr.readyState === 4) { + // if (xhr.status === 200) { + // if (xhr.response.code != 200) handleMsg('error', xhr.response['message'] || '报错了,请重试!!!') + // resolve(xhr.response) + // } else { + // if (xhr.response.status == 401) window.location.href = 'https://passport.gter.net'; + // } + // } + // } + // xhr.open("POST", url, true) + // xhr.setRequestHeader("Content-Type", "application/json") + // xhr.setRequestHeader("authorization", "63c9bef150557f9c90e93f98d2e2497e") + // xhr.send(JSON.stringify(data)) + axios.post(url, data, { emulateJSON: true, withCredentials: true, headers: { - // authorization: "9l3vfdx6h5xhu2hbw4fv5ygbog1dhtly" - // authorization: "194cdc367ed40c938f2eaaf1c6dfa5ff" - authorization: "63c9bef150557f9c90e93f98d2e2497e" + authorization: "efd8239b3f9ab533ac59311096738096" } }).then(function (res) { var data = null try { data = typeof res.data == 'string' ? JSON.parse(res.data) : res.data; - if (data['code'] != 200) handleMsg('error', data['message'] || '报错了,请重试!!!') + if (data['code'] == 401) window.location.href = 'https://passport.gter.net'; + } catch (error) { } resolve(data) }).catch(err => { @@ -965,7 +1022,7 @@ const forumApp = Vue.createApp({ } // 处理时间 - const handleDate = (dateTimeStamp) => { + const handleDate = (dateTimeStamp = new Date()) => { dateTimeStamp = dateTimeStamp ? dateTimeStamp : null; var timestamp = new Date(dateTimeStamp) timestamp = timestamp.getTime() @@ -1024,12 +1081,7 @@ const forumApp = Vue.createApp({ // 统计转发次数 const countForwardingTimes = (token) => { - console.log("token", token); - - // return - $ajax("/api/operate/share", { token }).then(res => { - console.log("res", res); - }) + $ajax("/api/operate/share", { token }).then() } // 关闭详情模式 @@ -1042,9 +1094,7 @@ const forumApp = Vue.createApp({ // 全部的启动到底部 const handleListScroll = (e) => { const el = e.target; - // 判断滚动到底部 - if (el.scrollHeight - el.scrollTop !== el.clientHeight) return - + if (el.scrollHeight - el.scrollTop >= el.clientHeight + 40) return getList() } @@ -1052,31 +1102,23 @@ const forumApp = Vue.createApp({ const handlePaste = (event) => { const items = (event.clipboardData || event.originalEvent.clipboardData).items; for (const item of items) { - console.log(item); if (item.type.indexOf('image') === 0) { + // 如果包含图片,阻止默认行为 + event.preventDefault(); + handleMsg('warning', '上传图片中') const file = item.getAsFile(); const reader = new FileReader(); + reader.onload = (e) => { const base64 = e.target.result - // console.log("base64", base64); uploadImg(base64).then(res => { const questionTextarea = document.querySelector(".question-textarea") - const imgElements = questionTextarea.querySelectorAll("img"); - // console.log("imgElements1111", imgElements); - if (imgElements.length == 0) { - questionTextarea.innerHTML += `` - handleInput() - } else { - imgElements.forEach(img => { - // console.log("src", img.getAttribute("src")); - // if (img.getAttribute("src") == base64) { - if (img.getAttribute("data-aid") == null && img.getAttribute('data-custom') == null) { - img.setAttribute("src", res.url); - img.setAttribute("data-aid", res.aid); - } - }); - } - + let imgNode = document.createElement('img'); + imgNode.setAttribute('src', res.url); + imgNode.setAttribute('data-aid', res.aid); + questionTextarea.appendChild(imgNode); + handleInput() + handleMsg('warning', '上传成功') }) }; reader.readAsDataURL(file); @@ -1157,13 +1199,6 @@ const forumApp = Vue.createApp({ const replaceState = (obj = {}) => { // 获取当前URL参数 let params = new URLSearchParams(window.location.search); - - // 循环删除所有参数 - for (let key of params.keys()) { - params.delete(key); - } - // 修改URL参数 - // params.set('paramName', 'paramValue'); for (const key in obj) { params.set(key, obj[key]); } @@ -1171,21 +1206,27 @@ const forumApp = Vue.createApp({ // 替换当前URL,但不刷新页面 window.history.replaceState({}, '', `${window.location.pathname}?${params}`); } + // 删除 url 参数的key + const deleteState = (keys = []) => { + let params = new URLSearchParams(window.location.search); + keys.forEach(key => { + params.delete(key); + }) + window.history.replaceState({}, '', `${window.location.pathname}?${params}`); + } // 我的打开 详情 const myOpenDetails = (value) => { - getDetails(value['uniqid']) + getDetails(value.data['uniqid']) myType.value = "" } // 详情页滚动事件 const handleDetailsScroll = e => { - // console.log("e", e); const el = e.target; // 判断滚动到底部 if (el.scrollHeight - el.scrollTop !== el.clientHeight) return - // console.log("底部"); getAnswerList() } @@ -1196,9 +1237,17 @@ const forumApp = Vue.createApp({ if (e.target.tagName === 'IMG') { var src = e.target.getAttribute('src'); dialogSrc.value = src + window.addEventListener('keydown', handleKeydown) } } + // 大图的监听 esc 键盘按钮 + const handleKeydown = event => { + if (event.key !== 'Escape') return + dialogSrc.value = "" + window.removeEventListener('keydown', handleKeydown) // 取消监听 + } + // 切换顶部的 type const cutType = (id) => { @@ -1206,12 +1255,56 @@ const forumApp = Vue.createApp({ page = 1 list.value = [] type.value = 'list' + pitchIndex.value = null + if (id != null) { + replaceState({ tid: id }) + deleteState(['uniqid']) + } else deleteState(['tid', 'uniqid']) + getList() } + // 打开举报 + const handleMenuState = (index, ind, i) => { + if (i === undefined) reportToken = answerList.value[index].commentList[ind]['token'] + else reportToken = answerList.value[index].commentList[ind]['child'][i]['token'] + alertShow.value = true + } + + // 举报 token + let reportToken = "" + const reasonList = ['广告', '辱骂', '重复发送', '不良信息', '其他'] + let checkList = ref([]) + let alertShow = ref(false) + let alertText = ref("") + const selectRadio = value => { + const index = checkList.value.indexOf(value); + if (index === -1) checkList.value.push(value); + else checkList.value.splice(index, 1); + } + // 举报提交 + const alertSubmit = () => { + checkList.value.push(alertText.value) + $ajax("/api/operate/report", { + message: checkList.value, + token: reportToken, + }).then(res => { + checkList.value = [] + reportToken = "" + alertShow.value = false + handleMsg('success', '举报成功') + }) + } return { + handleMenuState, + reasonList, + checkList, + alertShow, + alertText, + selectRadio, + alertSubmit, cutType, dialogSrc, answerPage, @@ -1242,6 +1335,7 @@ const forumApp = Vue.createApp({ detailsIscollection, detailsIsmyself, detailShare, + detailLoading, answerList, operateLike, operateCollect,