提交
This commit is contained in:
parent
5a6d83cc06
commit
d82c425491
@ -14,6 +14,7 @@
|
||||
"svg-sprite-loader": "^6.0.11",
|
||||
"vue": "^2.6.14",
|
||||
"vue-router": "^3.5.1",
|
||||
"vue-sanitize": "^0.2.3",
|
||||
"vuex": "^3.6.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -15,9 +15,14 @@ export default {
|
||||
loading: null,
|
||||
}
|
||||
},
|
||||
watch:{
|
||||
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.$store.dispatch('fetchHistoricalSearch')
|
||||
this.$store.dispatch('getAllForum', this)
|
||||
this.$store.dispatch('fetchHistoricalSearch') // 获取历史搜索记录
|
||||
this.$store.dispatch('getAllForum', this) // 获取全部板块
|
||||
// this.$store.dispatch('getUserInfo', this) /// 获取用户信息
|
||||
},
|
||||
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ export default {
|
||||
props: ["twoCommentData", "popState", "commentContent"],
|
||||
|
||||
mounted() {
|
||||
console.log("子组件");
|
||||
// console.log("子组件");
|
||||
},
|
||||
|
||||
methods: {
|
||||
|
@ -76,36 +76,48 @@ export default {
|
||||
tab: "Offer榜",
|
||||
headMorePopState: false, // 弹窗的状态
|
||||
islogin: false,
|
||||
userInfo: {},
|
||||
userInfo: {}, // 注意 userInfo 写I 是否是大写 ,, 因为 user 已经改为全局,后面要删除传值的 user
|
||||
menu: [],
|
||||
hotSearchkeywords: [], // 热门搜索
|
||||
};
|
||||
},
|
||||
props: ["issearch", "needgetuser", "userinfo"],
|
||||
watch: {
|
||||
needgetuser: {
|
||||
handler(newValue, oldValue) {
|
||||
if (newValue) this.getUserInfoData();
|
||||
},
|
||||
immediate: true,
|
||||
},
|
||||
// needgetuser: {
|
||||
// handler(newValue, oldValue) {
|
||||
// // if (newValue) this.getUserInfoData();
|
||||
// },
|
||||
// immediate: true,
|
||||
// },
|
||||
|
||||
// userinfo(newValue, oldValue) {
|
||||
// this.userInfo = newValue;
|
||||
// this.islogin = newValue.uid > 0 ? true : false;
|
||||
// },
|
||||
|
||||
userinfo(newValue, oldValue) {
|
||||
this.userInfo = newValue;
|
||||
this.islogin = newValue.uid > 0 ? true : false;
|
||||
},
|
||||
headMorePopState(newValue, oldValue) {
|
||||
if (newValue) this.$pageStop();
|
||||
else this.$pageMove();
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.getMenu()
|
||||
let user = this.$store.state.user
|
||||
if (JSON.stringify(user) === "{}") this.$store.dispatch('getUserInfo', this)
|
||||
else {
|
||||
this.userInfo = user
|
||||
this.islogin = user.uid > 0 ? true : false;
|
||||
this.hotSearchkeywords = this.$store.state.hotSearchkeywords
|
||||
}
|
||||
|
||||
// this.getMenu()
|
||||
|
||||
|
||||
},
|
||||
|
||||
components: {
|
||||
SearchBox,
|
||||
},
|
||||
|
||||
methods: {
|
||||
// 处理登录
|
||||
handleRegister() {
|
||||
@ -115,17 +127,17 @@ export default {
|
||||
|
||||
// 获取用户信息
|
||||
getUserInfoData() {
|
||||
return
|
||||
// this.$http.post("/widget/getUser").then((res) => {
|
||||
this.$http.post("/api/index",).then((res) => {
|
||||
if (res.code != 200) return;
|
||||
// this.prototype.userInfo = res.data.user
|
||||
this.userInfo = res.data.user;
|
||||
this.islogin = res.data.user.uid > 0 ? true : false;
|
||||
this.hotSearchkeywords = res.data.hotSearchkeywords
|
||||
|
||||
}).catch(err => {
|
||||
this.$message.error(err.message)
|
||||
});
|
||||
this.$message.error(err.message)
|
||||
});
|
||||
},
|
||||
|
||||
getMenu() {
|
||||
|
@ -53,7 +53,6 @@ export default {
|
||||
mounted() {
|
||||
if (this.searchText.length > 0) this.showClear = true
|
||||
else this.showClear = false
|
||||
|
||||
},
|
||||
|
||||
methods: {
|
||||
|
@ -6,6 +6,8 @@ import ElementUI, { Message, Pagination, loading } from 'element-ui';
|
||||
import 'element-ui/lib/theme-chalk/index.css';
|
||||
import { skipUrl, pageStop, pageMove, goTologin, copy, startupUnderLoading, closeUnderLoading, formattedDate, updateURLSearchParams } from "@/utils/common.js"
|
||||
import http from "@/utils/request"
|
||||
import VueSanitize from 'vue-sanitize'
|
||||
|
||||
import hintBox from '@/components/Hintbox'
|
||||
|
||||
Vue.config.productionTip = false
|
||||
@ -45,6 +47,7 @@ if (!Array.isArray) {
|
||||
Vue.use(ElementUI);
|
||||
Vue.use(Pagination);
|
||||
|
||||
Vue.use(VueSanitize);
|
||||
|
||||
|
||||
new Vue({
|
||||
|
@ -6,10 +6,14 @@ Vue.use(Vuex)
|
||||
export default new Vuex.Store({
|
||||
state: {
|
||||
historicalSearch: [],
|
||||
allForumList: [{}], // 全部板块数据
|
||||
homeRequestState: false, // 首页推荐和收藏接口的数据请求状态
|
||||
allForumList: [], // 全部板块数据
|
||||
homeRequestState: false, // 首页推荐和收藏接口的数据请求状态 这个是是否需要发送请求,因为用户点击收藏后需要重新获取
|
||||
getUserInfoState: false, // 这个是是否在请求状态
|
||||
favoriteList: [],
|
||||
recommendList: [],
|
||||
user: {}, // 用户信息
|
||||
hotSearchkeywords: [], // 热门搜索
|
||||
loading: null,
|
||||
},
|
||||
getters: {
|
||||
},
|
||||
@ -40,6 +44,18 @@ export default new Vuex.Store({
|
||||
state.recommendList = payload
|
||||
},
|
||||
|
||||
setUser(state, payload) {
|
||||
state.user = payload
|
||||
},
|
||||
|
||||
setHotSearchkeywords(state, payload) {
|
||||
state.hotSearchkeywords = payload
|
||||
},
|
||||
|
||||
setgetUserInfoState(state, payload) {
|
||||
state.getUserInfoState = payload
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
actions: {
|
||||
@ -51,6 +67,7 @@ export default new Vuex.Store({
|
||||
|
||||
// 获取全部板块的数据
|
||||
getAllForum({ commit }, that) {
|
||||
// getAllForum(commit, that) {
|
||||
that.$startupUnderLoading(that)
|
||||
that.$http.get("/api/home/allForum").then(res => {
|
||||
if (res.code != 200) return;
|
||||
@ -62,9 +79,38 @@ export default new Vuex.Store({
|
||||
}).finally(() => {
|
||||
that.$closeUnderLoading(that)
|
||||
})
|
||||
// allForumList
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
// 获取用户信息 获取收藏信息那些数据
|
||||
getUserInfo({ state, commit }, that) {
|
||||
if (state.getUserInfoState) return
|
||||
commit('setgetUserInfoState', true)
|
||||
// that.$startupUnderLoading(that)
|
||||
that.$http.post("/api/home").then(res => {
|
||||
if (res.code != 200) return;
|
||||
let data = res.data
|
||||
let { config, favorite, hotSearchkeywords, recommend, user } = data
|
||||
|
||||
commit('setHomeRequestState', true)
|
||||
commit('setUser', user)
|
||||
commit('setFavoriteList', favorite)
|
||||
commit('setRecommendList', recommend)
|
||||
commit('setHotSearchkeywords', hotSearchkeywords)
|
||||
|
||||
if (that.userInfo) { // 这个是顶部用户数据的 这样不用监听是否请求成功
|
||||
that.userInfo = user
|
||||
that.islogin = user.uid > 0 ? true : false;
|
||||
that.hotSearchkeywords = hotSearchkeywords
|
||||
}
|
||||
|
||||
}).catch(err => {
|
||||
that.$message.error(err.message)
|
||||
}).finally(() => {
|
||||
// that.$closeUnderLoading(that)
|
||||
commit('setgetUserInfoState', false)
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
},
|
||||
|
@ -48,6 +48,8 @@ function copy(value, message) {
|
||||
|
||||
// 启动加载中
|
||||
function startupUnderLoading(that) {
|
||||
|
||||
// this.
|
||||
that.loading = that.$loading({
|
||||
lock: true,
|
||||
text: '加载中...',
|
||||
@ -57,7 +59,7 @@ function startupUnderLoading(that) {
|
||||
|
||||
// 关闭加载中
|
||||
function closeUnderLoading(that) {
|
||||
that.loading.close();
|
||||
that.loading && that.loading.close();
|
||||
that.loading = null
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
<header-nav :issearch="true" :needgetuser="true">
|
||||
<template slot="header-title">帖子详情</template>
|
||||
</header-nav>
|
||||
<router-view :key="key"></router-view>
|
||||
<router-view :key="key" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -18,7 +18,6 @@ export default {
|
||||
|
||||
};
|
||||
},
|
||||
|
||||
computed: {
|
||||
key() {
|
||||
return this.$route.path + Math.random()
|
||||
|
@ -18,6 +18,7 @@
|
||||
{{ info.subject }}
|
||||
</div>
|
||||
|
||||
|
||||
<!-- -->
|
||||
<div class="card flexcenter">
|
||||
<div class="card-item shadow" v-if="postList.page == 1">
|
||||
@ -122,8 +123,10 @@
|
||||
|
||||
<template v-else>
|
||||
<div class="offer-content">
|
||||
<div v-html="info.message" style="line-height: normal;" class="vHtmlMessage">
|
||||
</div>
|
||||
<!-- <div v-html="info.message" style="line-height: normal;" class="vHtmlMessage"></div> -->
|
||||
<!-- <div style="line-height: normal;" ref="vHtmlMessage" class="vHtmlMessage">{{ info.message }}</div> -->
|
||||
<div style="line-height: normal;" ref="vHtmlMessage" class="vHtmlMessage"></div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
@ -286,12 +289,7 @@
|
||||
|
||||
<div class="bottom-item flex1 flexacenter">
|
||||
<div class="bottom-operation-box flex1 flexacenter">
|
||||
<div class="bottom-operation-item flex1 flexcolumn flexcenter" @click="tapOperate('like')">
|
||||
<!-- <div class="praise_bubble" id="praise_bubble" @click.stop=""
|
||||
:style="{ height: prepareLiskeState ? '' : '.5333rem' }">
|
||||
<div class="bubble" v-for="(item, index) in listlist" :key="index"></div>
|
||||
</div> -->
|
||||
|
||||
<div class="bottom-operation-item flex1 flexcolumn flexcenter" @click="info.islike == 0 ? tapOperate('like') : ''">
|
||||
<div class="loginBtn" v-if="!islogin" @click.stop="setValue('isloginBtnState', true, 'boolean')">
|
||||
</div>
|
||||
<img v-if="info.islike == 0" class="bottom-operation-icom"
|
||||
@ -300,7 +298,7 @@
|
||||
<img v-else class="bottom-operation-icom"
|
||||
:class="{ 'prepareLiskeAnimateState': prepareLiskeAnimateState }"
|
||||
src="@/assets/img/icon/like-o.png" />
|
||||
<div class="bottom-operation-text">{{ stat.like == 0 ? '' : stat.like }}赞</div>
|
||||
<div class="bottom-operation-text">{{ info.recommend_add == 0 ? '' : info.recommend_add }}赞</div>
|
||||
</div>
|
||||
<div class="bottom-operation-item flex1 flexcolumn flexcenter"
|
||||
@click="tapOperate(info.isfav == 0 ? 'collect' : 'uncollect')">
|
||||
@ -329,6 +327,7 @@
|
||||
<script>
|
||||
import DetailReply from '@/components/DetailReply'
|
||||
import Coins from '@/components/unlock/Coins'
|
||||
|
||||
export default {
|
||||
name: 'detailIndex',
|
||||
data() {
|
||||
@ -337,7 +336,7 @@ export default {
|
||||
// avatar: "https://oss.gter.net/avatar/97KwEWANd_4DHWiY6VbnSUFSCKroYWFjYQ~~/middle",
|
||||
// content: "评论回复",
|
||||
// },
|
||||
popState: "",
|
||||
popState: "", // discussionSingle discussionMulti
|
||||
coinConfig: {
|
||||
strategy: {
|
||||
button: "攒币指南",
|
||||
@ -462,13 +461,13 @@ export default {
|
||||
loading: null, // 加载中
|
||||
|
||||
commentContent: "", // 评论的文本
|
||||
|
||||
operateState: false, // 操作请求的状态
|
||||
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.tid = this.$route.query['tid']
|
||||
this.postList.page = this.$route.query['page']
|
||||
this.postList.page = this.$route.query['page'] || 1
|
||||
|
||||
this.getDetail()
|
||||
|
||||
@ -485,7 +484,6 @@ export default {
|
||||
if (res.code != 200) return
|
||||
|
||||
let data = res.data
|
||||
|
||||
let info = data.info
|
||||
|
||||
const reg = new RegExp("\r\n", "g")
|
||||
@ -496,14 +494,32 @@ export default {
|
||||
|
||||
info["messageList"] = []
|
||||
|
||||
|
||||
info['message'] = info['message'].replace("[hide]作者设置了回复可见[/hide]", `<div class="flexcenter content-unlock content-unlock-no"><img class="unlock-icom" src="./img/unlock.png">作者设置了回复可见</div>`)
|
||||
info['message'] = info['message'].replaceAll("[hide]作者设置了回复可见[/hide]", `<div class="flexcenter content-unlock content-unlock-no replyVisible" @click="aa()"><img class="unlock-icom" src="./img/unlock.png"/>作者设置了回复可见</div>`)
|
||||
|
||||
// if (info.message.indexOf("[hide]作者设置了回复可见[/hide]")) {
|
||||
// `<div class="flexcenter content-unlock content-unlock-no"><img class="unlock-icom" src="@/assets/img/detail/unlock.png">作者设置了回复可见</div>`
|
||||
// }
|
||||
|
||||
// console.log(info['message']);
|
||||
|
||||
// info['message'] = this.$sanitize(info['message'])
|
||||
// console.log(info['message']);
|
||||
|
||||
data.type == 0 ? this.$refs['vHtmlMessage'] ? this.$refs.vHtmlMessage.innerHTML = info['message'] : "" : ""
|
||||
|
||||
let replyVisibleList = document.getElementsByClassName("replyVisible")
|
||||
if (!Array.isArray(replyVisibleList)) {
|
||||
for (let i = 0; i < replyVisibleList.length; i++) {
|
||||
replyVisibleList[i].addEventListener('click', () => {
|
||||
this.$emit("replyVisibleClick")
|
||||
})
|
||||
}
|
||||
this.$on('replyVisibleClick', () => {
|
||||
this.popState = "discussionSingle"
|
||||
})
|
||||
}
|
||||
|
||||
// console.log(info, "offerinfo", data.type);
|
||||
|
||||
this.info = info
|
||||
this.type = data.type
|
||||
@ -564,7 +580,8 @@ export default {
|
||||
})
|
||||
},
|
||||
|
||||
// 获取租房详情 https://app.gter.net/tenement/forum/show
|
||||
|
||||
// 租房
|
||||
getTenementDetails() {
|
||||
this.$http.post("/tenement/forum/show", {
|
||||
token: this.token
|
||||
@ -594,7 +611,6 @@ export default {
|
||||
const reg = new RegExp("\r\n", "g")
|
||||
info['message'] = info['message'].replaceAll(reg, '<br/>')
|
||||
info['message'] = info['message'].replace(/<img[^>]*>/g, (match) => {
|
||||
console.log("match", match);
|
||||
return match.replace(/width="[^"]*"/g, '').replace(/height="[^"]*"/g, '');
|
||||
});
|
||||
|
||||
@ -605,16 +621,16 @@ export default {
|
||||
|
||||
// 获取面经详情
|
||||
getInterviewDetails() {
|
||||
// https://app.gter.net/InterviewExperience/thread
|
||||
|
||||
this.$http.post("/InterviewExperience/thread", {
|
||||
// token: this.token,
|
||||
// tid: this.tid
|
||||
tid: 2322145,
|
||||
uniqid: "--G1tS2SCTOQyoOMiedlLKxTnFvHWjBwQezsJjvVJFwgqOtOFeYr4_LAAG5RV37ETvMl2Zd4tSCc-_dqeKpERxXsx-tPfXrUs0kUysTGLzgxYzU~",
|
||||
token: "5e3c42209eebfbab66e6f0d6c70a53c7",
|
||||
// tid: 2322145,
|
||||
// uniqid: "--G1tS2SCTOQyoOMiedlLKxTnFvHWjBwQezsJjvVJFwgqOtOFeYr4_LAAG5RV37ETvMl2Zd4tSCc-_dqeKpERxXsx-tPfXrUs0kUysTGLzgxYzU~",
|
||||
// token: "5e3c42209eebfbab66e6f0d6c70a53c7",
|
||||
token: this.token
|
||||
}, "tenement").then(res => {
|
||||
console.log(res);
|
||||
// console.log(res);
|
||||
if (res.code != 200) return
|
||||
let data = res.data
|
||||
this.info = { ...this.info, ...data }
|
||||
@ -643,7 +659,7 @@ export default {
|
||||
|
||||
// 处理回复点击弹出弹窗
|
||||
handleReplyPop(item) {
|
||||
console.log(item);
|
||||
// console.log(item);
|
||||
this.popState = "discussionSingle"
|
||||
},
|
||||
|
||||
@ -654,18 +670,26 @@ export default {
|
||||
message: this.commentContent
|
||||
}).then(res => {
|
||||
if (res.code != 200) return
|
||||
let data = res.data
|
||||
console.log(data);
|
||||
// let data = res.data
|
||||
// console.log(data);
|
||||
this.popState = ""
|
||||
|
||||
let { count, limit } = this.postList
|
||||
|
||||
|
||||
let page = Math.ceil((count + 1) / limit)
|
||||
console.log(page, this.postList.page);
|
||||
if (page == this.postList.page) {
|
||||
this.$router.go(0)
|
||||
return
|
||||
}
|
||||
|
||||
let query = {
|
||||
page: Math.ceil((count + 1) / limit),
|
||||
page,
|
||||
tid: this.tid
|
||||
}
|
||||
|
||||
this.$router.push({ path: `/detailIndex`, query })
|
||||
|
||||
})
|
||||
},
|
||||
|
||||
@ -685,6 +709,8 @@ export default {
|
||||
// 点击点赞和收藏操作
|
||||
tapOperate(key) {
|
||||
// like collect uncollect
|
||||
if (this.operateState) return
|
||||
this.operateState = true
|
||||
|
||||
let url = ""
|
||||
if (key == "like") url = "/api/operation/threadLike"
|
||||
@ -694,11 +720,13 @@ export default {
|
||||
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 == "like") this.info.islike = 1
|
||||
if (key == "collect") this.info.isfav = 1
|
||||
if (key == "uncollect") this.info.isfav = 0
|
||||
this.$message.success(res.message)
|
||||
|
||||
}).finally(() => {
|
||||
this.operateState = false
|
||||
})
|
||||
|
||||
},
|
||||
@ -948,6 +976,7 @@ export default {
|
||||
width: .64rem;
|
||||
height: .64rem;
|
||||
margin-right: 0.2rem;
|
||||
vertical-align: middle;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1012,6 +1041,8 @@ export default {
|
||||
width: .64rem;
|
||||
height: .64rem;
|
||||
margin-right: 0.2rem;
|
||||
vertical-align: middle;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
</div>
|
||||
<div class="allSections-right">
|
||||
<div class="allSections-right-item" @click="pitchPlate(i.fid, i.name)"
|
||||
v-for="(i, k) in list[allActive].data" :key="k">
|
||||
v-for="(i, k) in (list[allActive] && list[allActive]['data'])" :key="k">
|
||||
<div class="item-content">
|
||||
<div class="item-title">{{ i.name }}</div>
|
||||
<div v-if="i.description" class="item-text" v-html="i.description.replace(/<[^>]+>/g, '')"></div>
|
||||
@ -51,7 +51,7 @@
|
||||
<script>
|
||||
import plateNavigation from '@/components/PlateNavigation'
|
||||
import indexList from '@/components/IndexList'
|
||||
|
||||
|
||||
export default {
|
||||
name: "AllSections",
|
||||
data() {
|
||||
@ -75,6 +75,17 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
watch: {
|
||||
"$store.state.allForumList": {
|
||||
handler(newV, oldV) {
|
||||
if (!Array.isArray(newV)) return
|
||||
this.list = newV
|
||||
},
|
||||
immediate: true
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.$store.subscribe((mutation, state) => {
|
||||
if (mutation.type == "setAllForumList") this.list = this.$store.state.allForumList
|
||||
@ -96,6 +107,7 @@ export default {
|
||||
handQuery() {
|
||||
if (this.list.length >= 2) {
|
||||
let list = this.list
|
||||
console.log("list", list);
|
||||
list.forEach((el, index) => {
|
||||
if (el.fid == this.onefid) this.allActive = index
|
||||
if (this.twofid) {
|
||||
@ -151,7 +163,7 @@ export default {
|
||||
}).finally(() => {
|
||||
this.postCollectionState = false
|
||||
this.$store.commit('setHomeRequestState', false)
|
||||
this.$parent.init()
|
||||
this.$store.dispatch('getUserInfo', this)
|
||||
})
|
||||
},
|
||||
|
||||
@ -168,7 +180,7 @@ export default {
|
||||
// 获取帖子列表
|
||||
getInvitationList() {
|
||||
this.$startupUnderLoading(this)
|
||||
this.$http.post("/api/home/threadList", {
|
||||
this.$http.get("/api/home/threadList", {
|
||||
page: this.invitationPage,
|
||||
limit: this.invitationLimit,
|
||||
fid: this.twofid
|
||||
@ -229,6 +241,15 @@ export default {
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
|
||||
-ms-overflow-style: none;
|
||||
overflow: -moz-scrollbars-none;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
span {
|
||||
height: 1.28rem;
|
||||
line-height: 1.28rem;
|
||||
|
@ -2,7 +2,7 @@
|
||||
<!-- 收藏版块 -->
|
||||
<div class="collect">
|
||||
<!-- 未收藏 -->
|
||||
<div v-if="favoriteHeadList.length <= 1" class="notCollect">
|
||||
<div v-if="favoriteHeadList.length == 0" class="notCollect">
|
||||
<img class="notCollect-img" src="~assets/img/collect/notCollect.png" alt="未收藏" />
|
||||
<div class="collect-text">收藏你感兴趣的版块,迅速浏览相应的帖子</div>
|
||||
<router-link to="/allSections" class="flexcenter collect-btn">
|
||||
@ -81,12 +81,13 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
allForumList: [], // 所有板块得数据
|
||||
favoriteHeadList: [{
|
||||
name: "全部",
|
||||
fid: 0
|
||||
}],
|
||||
// favoriteHeadIdList: [],
|
||||
favoriteHeadIdList: this.$store.state.favoriteList,
|
||||
favoriteHeadList: [],
|
||||
// {
|
||||
// name: "全部",
|
||||
// fid: 0
|
||||
// }],
|
||||
favoriteHeadIdList: [],
|
||||
// favoriteHeadIdList: this.$store.state.favoriteList,
|
||||
fid: 0, // 选中的收藏板块
|
||||
collect: [1],
|
||||
settingShow: false, //弹窗显示
|
||||
@ -108,69 +109,53 @@ export default {
|
||||
},
|
||||
|
||||
watch: {
|
||||
// "$store.state.homeRequestState": {
|
||||
// handler(newV, oldV) {
|
||||
// console.log("newVnewV", newV);
|
||||
// if (!newV) return
|
||||
// this.$nextTick(() => {
|
||||
// this.favoriteHeadIdList = this.$parent.favorite || []
|
||||
// this.getAllForumList()
|
||||
|
||||
// if (this.fid) this.handleFavoriteHeadList()
|
||||
// })
|
||||
|
||||
// },
|
||||
// immediate: true
|
||||
// },
|
||||
|
||||
fid: {
|
||||
"$store.state.allForumList": {
|
||||
handler(newV, oldV) {
|
||||
if (this.$store.state.homeRequestState && newV) this.handleFavoriteHeadList()
|
||||
if (!Array.isArray(newV)) return
|
||||
this.allForumList = newV
|
||||
if (this.favoriteHeadList.length != 0) this.handleFavoriteHeadList()
|
||||
},
|
||||
immediate: true
|
||||
}
|
||||
},
|
||||
|
||||
favoriteHeadIdList: {
|
||||
handler(newV, oldV) {
|
||||
if (!Array.isArray(newV)) return
|
||||
this.favoriteHeadList = newV
|
||||
if (this.allForumList.length != 0) this.handleFavoriteHeadList()
|
||||
|
||||
},
|
||||
immediate: true
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
let { page, fid } = this.$route.query
|
||||
if (page) this.favorite.page = Number(page)
|
||||
if (fid) this.fid = fid
|
||||
|
||||
this.getCollectList()
|
||||
|
||||
// console.log(this.$store.state.favoriteList, "this.$store.state.favoriteList");
|
||||
if (this.favoriteHeadIdList.length != 0) this.getAllForumList()
|
||||
|
||||
console.log("this.favoriteHeadIdList", this.favoriteHeadIdList, this.favoriteHeadList);
|
||||
|
||||
this.$store.subscribe((mutation, state) => {
|
||||
if (mutation.type == "setHomeRequestState" && mutation.payload) {
|
||||
if (!this.$store.state.homeRequestState) return
|
||||
this.$nextTick(() => {
|
||||
this.favoriteHeadIdList = this.$parent.favorite || []
|
||||
this.getAllForumList()
|
||||
|
||||
if (this.fid) this.handleFavoriteHeadList()
|
||||
})
|
||||
}
|
||||
});
|
||||
this.init()
|
||||
},
|
||||
|
||||
methods: {
|
||||
// 获取收藏列表数据
|
||||
getCollectList() {
|
||||
init() {
|
||||
let { homeRequestState, favoriteList } = this.$store.state
|
||||
console.log("homeRequestState", homeRequestState);
|
||||
if (!homeRequestState) {
|
||||
setTimeout(() => {
|
||||
this.getCollectList()
|
||||
this.init()
|
||||
}, 300);
|
||||
return
|
||||
} else {
|
||||
this.favoriteHeadIdList = favoriteList
|
||||
this.getCollectList()
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
if (favoriteList.length == 0) return
|
||||
// 获取收藏列表数据
|
||||
getCollectList() {
|
||||
|
||||
if (this.favoriteHeadIdList.length == 0) return
|
||||
this.$startupUnderLoading(this)
|
||||
this.$http.post("/api/home/threadList", {
|
||||
this.$http.get("/api/home/threadList", {
|
||||
limit: this.favorite.limit,
|
||||
page: this.favorite.page,
|
||||
fid: this.fid,
|
||||
@ -183,24 +168,12 @@ export default {
|
||||
this.favorite.page = data.page
|
||||
this.favorite.limit = data.limit
|
||||
this.favorite.count = data.count
|
||||
|
||||
}).finally(() => {
|
||||
this.$closeUnderLoading(this)
|
||||
})
|
||||
},
|
||||
|
||||
// 获取全部板块数据
|
||||
getAllForumList() {
|
||||
let allForumList = this.$store.state.allForumList
|
||||
if (allForumList.length == 1) {
|
||||
setTimeout(() => {
|
||||
this.getAllForumList()
|
||||
}, 500);
|
||||
} else {
|
||||
this.allForumList = allForumList
|
||||
this.handleFavoriteHeadList()
|
||||
}
|
||||
},
|
||||
|
||||
// 处理获取收藏板块的值
|
||||
handleFavoriteHeadList() {
|
||||
let allForumList = this.allForumList
|
||||
@ -210,6 +183,7 @@ export default {
|
||||
fid: 0
|
||||
}]
|
||||
|
||||
|
||||
allForumList.forEach((el, index) => {
|
||||
if (!Array.isArray(el.data)) return
|
||||
el.data.forEach(elememt => {
|
||||
@ -265,9 +239,6 @@ export default {
|
||||
if (res.code != 200) return
|
||||
|
||||
let list = this.$store.state.allForumList
|
||||
console.log(list, "list");
|
||||
// list[this.allActive].data[k]['iscollection'] = state == "forumFav" ? 1 : 0
|
||||
|
||||
this.$store.commit('setAllForumList', list)
|
||||
|
||||
this.favoriteHeadList.splice(index, 1)
|
||||
|
@ -34,33 +34,25 @@ export default {
|
||||
return this.$route.path + Math.random()
|
||||
}
|
||||
},
|
||||
|
||||
watch: {
|
||||
"$store.state.homeRequestState": {
|
||||
handler(newV, oldV) {
|
||||
let { favoriteList, recommendList } = this.$store.state
|
||||
this.favorite = favoriteList
|
||||
this.recommend = recommendList
|
||||
},
|
||||
immediate: true
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.init()
|
||||
|
||||
},
|
||||
components: {
|
||||
HeaderNav,
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
let homeRequestState = this.$store.state.homeRequestState
|
||||
if (homeRequestState) {
|
||||
let { favoriteList, recommendList } = this.$store.state
|
||||
this.favorite = favoriteList
|
||||
this.recommend = recommendList
|
||||
return
|
||||
}
|
||||
|
||||
this.$http.post("/api/home").then(res => {
|
||||
let data = res.data
|
||||
this.favorite = data.favorite
|
||||
this.recommend = data.recommend
|
||||
this.$store.commit('setHomeRequestState', true)
|
||||
this.$store.commit('setFavoriteList', data.favorite)
|
||||
this.$store.commit('setRecommendList', data.recommend)
|
||||
|
||||
// console.log(this.$store.state.favoriteList,"this.$store.state.favoriteListthis.$store.state.favoriteList ");
|
||||
})
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -44,7 +44,7 @@ export default {
|
||||
},
|
||||
|
||||
loading: null,
|
||||
allForumList: this.$store.state.allForumList,
|
||||
allForumList: this.$store.state.allForumList || [],
|
||||
}
|
||||
},
|
||||
|
||||
@ -78,13 +78,12 @@ export default {
|
||||
methods: {
|
||||
init() {
|
||||
this.$startupUnderLoading(this)
|
||||
this.$http.post("/api/home/threadList", {
|
||||
this.$http.get("/api/home/threadList", {
|
||||
limit: this.limit,
|
||||
type: "recommend",
|
||||
page: this.page,
|
||||
fid: this.fid,
|
||||
}).then(res => {
|
||||
console.log(res, "ffff");
|
||||
|
||||
if (res.code != 200) return
|
||||
let data = res.data
|
||||
|
@ -1,10 +0,0 @@
|
||||
diff a/src/views/index/recommend/Recommend.vue b/src/views/index/recommend/Recommend.vue (rejected hunks)
|
||||
@@ -23,7 +23,7 @@
|
||||
import plateNavigation from '@/components/PlateNavigation.vue'
|
||||
import indexList from '@/components/IndexList'
|
||||
export default {
|
||||
- name: "Recommend",//推荐阅读hjhjh
|
||||
+ name: "Recommend",//推荐阅读
|
||||
data() {
|
||||
return {
|
||||
hotActive: -1,//热门版块活跃点击
|
Loading…
x
Reference in New Issue
Block a user