From 2049ac392adc2391c629bfda6d29c08bbe0f24f2 Mon Sep 17 00:00:00 2001 From: xiaoronghao <1300399510@qq.com> Date: Fri, 7 Apr 2023 16:49:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 2 + src/assets/css/public.scss | 13 ++ src/assets/img/icon/like-o.png | Bin 0 -> 2029 bytes src/components/SearchBox.vue | 23 +-- src/main.js | 8 + src/store/index.js | 41 ++++- src/views/detail/detailIndex.vue | 159 ++++-------------- src/views/index/allSections/AllSections.vue | 144 ++++++++++------ src/views/index/index.vue | 2 +- src/views/index/recommend/Recommend.vue | 11 +- .../search/searchResult/SearchResult.vue | 27 +-- 11 files changed, 210 insertions(+), 220 deletions(-) create mode 100644 src/assets/img/icon/like-o.png diff --git a/src/App.vue b/src/App.vue index 7ffb7de..7ea2a0e 100755 --- a/src/App.vue +++ b/src/App.vue @@ -12,10 +12,12 @@ export default { name: "App", data() { return { + loading: null, } }, mounted() { this.$store.dispatch('fetchHistoricalSearch') + this.$store.dispatch('getAllForum', this) }, } diff --git a/src/assets/css/public.scss b/src/assets/css/public.scss index 3d79fc2..1355673 100755 --- a/src/assets/css/public.scss +++ b/src/assets/css/public.scss @@ -230,3 +230,16 @@ section { } } + +.result-empty-box { + height: 100%; + width: 100%; + background: #fff; + margin: 0 auto; + border-radius: 0.32rem; + + .result-empty-icon { + width: 2.04rem; + height: 2.4rem; + } +} \ No newline at end of file diff --git a/src/assets/img/icon/like-o.png b/src/assets/img/icon/like-o.png new file mode 100644 index 0000000000000000000000000000000000000000..bf72728736fca1a1f2bfe842086d7da6793f69c8 GIT binary patch literal 2029 zcmeHH`%{u>6n;MuA=I?8Y`X|silrfltrZfYqGFmMS*ewR2#OaZMN?PllkyUqdD%2A z3)9`28a2{%&AhPLW*1GnvK6UQZdt9Qrk1yDzxKDCo&67bXU=)fbLKqfymMyW_b|ub z+Z4A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src/components/SearchBox.vue +++ b/src/components/SearchBox.vue @@ -19,10 +19,10 @@
取消
-
+
历史搜索
- {{ item + {{ item }}
@@ -46,16 +46,14 @@ export default { searchWinShow: false,//显示搜索弹窗 searchText: '', showClear: false, //显示清除按钮 - historicalSearch: this.$store.state.historicalSearch, // 历史搜索 } }, props: ["issearch", "hotSearchkeywords"], + + mounted() { + if (this.searchText.length > 0) this.showClear = true + else this.showClear = false - watch: { - historicalSearch(val, oldval) { - if (val.length > 10) this.historicalSearch.slice(0, 10) - else this.$store.commit('setHistoricalSearch', val) - } }, methods: { @@ -85,20 +83,11 @@ export default { // 跳转搜索结果 toSearchResult(kw) { - if (!kw) return - - console.log(this.historicalSearch); - if (!this.historicalSearch.includes(kw)) this.historicalSearch.unshift(kw) - this.$router.push(`/searchResult?kw=${kw}`) }, }, - mounted() { - if (this.searchText.length > 0) this.showClear = true - else this.showClear = false - } } diff --git a/src/main.js b/src/main.js index c76439d..8881831 100755 --- a/src/main.js +++ b/src/main.js @@ -32,6 +32,14 @@ import './icons' //动态设置fontsize import './utils/fontSize.js' + +// 判断是否是数组的 ,兼容操作 +if (!Array.isArray) { + Array.isArray = function (arg) { + return Object.prototype.toString.call(arg) === '[object Array]'; + } +} + //ElementUI Vue.use(ElementUI); Vue.use(Pagination); diff --git a/src/store/index.js b/src/store/index.js index 5f12ac1..60fd4b1 100755 --- a/src/store/index.js +++ b/src/store/index.js @@ -5,18 +5,29 @@ Vue.use(Vuex) export default new Vuex.Store({ state: { - historicalSearch: [] + historicalSearch: [], + allForumList: [{}], // 全部板块数据 + }, getters: { }, + mutations: { setHistoricalSearch(state, payload) { - // console.log(payload, "payload"); - // payload = [...new Set(payload)] - state.historicalSearch = payload - // localStorage.setItem('historicalSearch', JSON.stringify(payload)); - } + if (!Array.isArray(payload)) payload = [payload] + let targetArr = [...new Set([...payload, ...state.historicalSearch])] + if (targetArr.length > 10) targetArr = targetArr.slice(0, 10) + + state.historicalSearch = targetArr + localStorage.setItem('historicalSearch', JSON.stringify(targetArr)) + }, + + setAllForumList(state, payload) { + state.allForumList = payload + }, + }, + actions: { // 获取历史搜索的数据 fetchHistoricalSearch({ commit }) { @@ -24,6 +35,24 @@ export default new Vuex.Store({ commit('setHistoricalSearch', historicalSearch) }, + // 获取全部板块的数据 + getAllForum({ commit }, that) { + that.$startupUnderLoading(that) + that.$http.get("/api/home/allForum").then(res => { + if (res.code != 200) return; + let allForumList = res.data + commit('setAllForumList', allForumList) + + }).catch(err => { + that.$message.error(err.message) + }).finally(() => { + that.$closeUnderLoading(that) + }) + // allForumList + + } + + }, modules: { diff --git a/src/views/detail/detailIndex.vue b/src/views/detail/detailIndex.vue index 8326a10..28c4227 100755 --- a/src/views/detail/detailIndex.vue +++ b/src/views/detail/detailIndex.vue @@ -20,8 +20,7 @@
- -
+
@@ -46,7 +45,6 @@
-
@@ -76,7 +74,6 @@
- 查看当前捷报详情
@@ -112,12 +109,9 @@
- -
-
@@ -143,7 +137,10 @@
{{ $formattedDate(item.dateline) }}
-
{{ index == 0 ? '楼主' : `${index}楼` }}
+ +
{{ `${(postList.page - 1) * postList.limit + index + 2 }楼` }}
+
{{ `${(postList.page - 1) * postList.limit + index + 1 }楼` }}
+
@@ -261,7 +258,7 @@ -
+
@@ -283,22 +280,27 @@
-
-
+
- +
{{ stat.like == 0 ? '' : stat.like }}赞
-
+
- +
收藏
@@ -338,7 +340,7 @@ export default { }, islogin: true, - prepareLiskeState: false, + // prepareLiskeState: false, prepareLiskeAnimateState: false, stat: { like: 0 @@ -553,8 +555,6 @@ export default { let tenementKey = this.tenementKey let info = { ...this.info, ...res.info } - - info['typeText'] = info.gptype + '>>' + info.type tenementKey[1].name += info['currency'] ? info['currency'] : '港元' @@ -611,14 +611,10 @@ export default { }).then(res => { if (res.code != 200) return let data = res.data - console.log(data); - this.postList.list = data.data this.postList.page = data.page this.postList.limit = data.limit this.postList.count = data.count - - console.log(this.postList); }) @@ -640,73 +636,27 @@ export default { this.getPostList() }, - // 点击点赞 - tapLike() { - this.isState = true - this.prepareLiskeState = true - this.prepareLiskeAnimateState = true + // 点击点赞和收藏操作 + tapOperate(key) { + // like collect uncollect - clearTimeout(this.offerLikesumTimer) - clearTimeout(this.offerLikesumAnimateTimer) + let url = "" + if (key == "like") url = "/api/operation/threadLike" + else if (key == "collect") url = "/api/operation/threadFav" + else if (key == "uncollect") url = "/api/operation/threadunFav" - let praiseBubble = document.getElementById("praise_bubble"); - console.log("praiseBubble", praiseBubble); - let last = 0; - let b = Math.floor(Math.random() * 8) + 1; // 1 到 7的 图片 - // b = 1; // 测试写固定的 - const bl = Math.floor(Math.random() * 11) + 1; // bl1~bl11 - let d = document.createElement("div"); - d.style.backgroundImage = `url('./img/bg${b}.png')` - d.style.backgroundSize = 'contain' - d.className = `bubble`; - // d.style.animation = `bubble_1 bubble_${bl} 1.5s linear 1 forwards, bubble_big_${Math.floor(Math.random() * 3) + 1} 0.8s linear 1 forwards, bubble_y 1.5s linear 1 forwards` - // d.style.animation = `bubble_1 1.5s linear 1 forwards` - - d.dataset.t = String(Date.now()); - praiseBubble.appendChild(d); - - // this.$forceUpdate() - - this.stat.like++ - this.prepareLiskeNum++ - this.offerLikesumAnimateTimer = setTimeout(() => { - this.prepareLiskeAnimateState = false - }, 500) - this.offerLikesumTimer = setTimeout(() => { - this.ispostOfferLike = false - this.postOfferLike() - }, 2000) + this.$http.post(url, { tid: this.tid }).then(res => { + console.log(res); + if (res.code != 200) return + if (key == "like") this.info.like = 1 + if (key == "collect") this.info.isfav = 1 + if (key == "uncollect") this.info.isfav = 0 + this.$message.success(res.message) + + }) + }, - postOfferLike() { - if (this.ispostOfferLike) return - this.ispostOfferLike = true - - this.offerLikesum = 0 - - this.prepareLiskeState = false - let key = new Date().getTime() + '' - // let num = util.base64_encode(key + util.base64_encode(this.data.prepareLiskeNum + '')) - - - - // util.wxpost("/miniprogramApi/offer/behaviour/like", { - // token: this.data.token, - // num, - // key - // }).then(res => { - // if (res.code != 200) return - // let data = res.data - // this.offerLikesum = 0 - // }).finally(() => { - // this.setData({ - // prepareLiskeState: false - // }) - // }) - - }, - - // 点击转发 transmit() { let value = location.href @@ -1245,45 +1195,6 @@ export default { } - .praise_bubble { - width: 50px; - height: 200px; - position: absolute; - bottom: 1.2rem; - background-color: transparent; - - /deep/ { - .bubble { - position: absolute; - width: 40px; - height: 40px; - left: 50%; - bottom: 0px; - background-repeat: no-repeat; - background-size: 100%; - transform-origin: bottom; - animation: like 1.8s ease-out forwards; - // animation-fill-mode: forwards; - } - - @keyframes like { - 0% { - opacity: 1; - transform: translate(-50%, 0); - } - - 100% { - opacity: 0; - transform: translate(-50%, -200px); - } - } - - - } - - - } - } } diff --git a/src/views/index/allSections/AllSections.vue b/src/views/index/allSections/AllSections.vue index 63d33c8..6a0f9b6 100755 --- a/src/views/index/allSections/AllSections.vue +++ b/src/views/index/allSections/AllSections.vue @@ -1,9 +1,9 @@