diff --git a/pages/index/index.vue b/pages/index/index.vue index eebf694..5ada534 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -567,6 +567,7 @@ import SquareStyleCourse from '@/components/Course/squareStyleCourse.vue'; import Advert from '@/components/Advert/index.vue'; import { SET_POSITION } from "@/store/types/muations-types"; import { getLocation } from './getLocation.js'; +import { changeCategory } from '@/api/learning'; const QQMapWx = require('../../libs/qqmap-wx-jssdk.min.js'); @@ -794,7 +795,7 @@ export default { return `/pages/index/unified_list?type=${item.type}&title=${item.title}&recommend_id=${item.id}`; } }, - getNavHrefTaber(item, bo) { + async getNavHrefTaber(item, bo) { if (item.type === 1) { uni.navigateTo({ url: `/pages/activity/event?id=${this.id}`, @@ -804,7 +805,17 @@ export default { uni.switchTab({ url: `/pages/course/special_cate` }); - } else { + } else if (item.link.indexOf('/learning/index') > -1) { + const subject_id = item.link.split('=')[1]; + try { + const { data } = await changeCategory({ subject_id: subject_id}); + uni.switchTab({ + url: item.link + }); + } catch (err) { + console.log(err); + } + } else { uni.navigateTo({ url: item.link }); diff --git a/pages/learning/index.vue b/pages/learning/index.vue index 40522ca..51de0cd 100644 --- a/pages/learning/index.vue +++ b/pages/learning/index.vue @@ -127,6 +127,7 @@ import store from "@/store"; ], learningData: {}, scrollTop: 0, + subject_id: 0 }; }, computed: { @@ -151,10 +152,15 @@ import store from "@/store"; methods: { async getLearningData() { try { - const { data } = await getLearningData({ + const params = { city: this.position, - }); + }; + if (this.subject_id) { + params.subject_id = this.subject_id; + } + const { data } = await getLearningData(params); console.log(data); + uni.setStorageSync('subject_id', ''); this.learningData = { ...data }; } catch (err) { console.log(err);