feat: 新增标签top排名的计算,并调整行业和概念组件
This commit is contained in:
parent
7bb4fe6b06
commit
f80e614a15
|
|
@ -49,7 +49,7 @@
|
||||||
<view class="recommend-industry">
|
<view class="recommend-industry">
|
||||||
<view class="recommend-industry-top">
|
<view class="recommend-industry-top">
|
||||||
<view class="label">预期风口</view>
|
<view class="label">预期风口</view>
|
||||||
<view class="right" @click="selectRandomTags">
|
<view class="right" @click="handleChange">
|
||||||
<view class="icon"></view>
|
<view class="icon"></view>
|
||||||
<view class="text">换一换</view>
|
<view class="text">换一换</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -78,13 +78,17 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { getTopConceptPeriod } from "@/api/newsInfo";
|
import { getTopConceptPeriod } from "@/api/newsInfo";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import { onMounted, ref, watch } from "vue";
|
import { computed, onMounted, ref, watch } from "vue";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
tagList: {
|
tagList: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
|
allTagList: {
|
||||||
|
type: Array,
|
||||||
|
default: () => [],
|
||||||
|
},
|
||||||
});
|
});
|
||||||
const emit = defineEmits(["onChange", "onBack"]);
|
const emit = defineEmits(["onChange", "onBack"]);
|
||||||
|
|
||||||
|
|
@ -102,33 +106,16 @@ const handleBack = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const myTagList = ref([]);
|
const myTagList = ref([]);
|
||||||
const industryList = ref([]);
|
const page = ref(0);
|
||||||
const industryListAll = ref([]);
|
const industryList = computed(() => {
|
||||||
const start_time = dayjs().subtract(1, "month").format("YYYY-MM-DD");
|
const arr = [...props.allTagList]
|
||||||
const end_time = dayjs().format("YYYY-MM-DD");
|
return arr.splice(page.value, 10);
|
||||||
const limit_num = 20;
|
|
||||||
// 热门行业top10
|
|
||||||
async function getTopIndustry_dFn() {
|
|
||||||
industryListAll.value = await getTopConceptPeriod({
|
|
||||||
start_time: start_time,
|
|
||||||
end_time: end_time,
|
|
||||||
limit_num: limit_num,
|
|
||||||
});
|
});
|
||||||
selectRandomTags();
|
|
||||||
|
const handleChange = () => {
|
||||||
|
page.value = page.value ? 0 : 10
|
||||||
}
|
}
|
||||||
|
|
||||||
// 从所有标签中随机选择10个
|
|
||||||
function selectRandomTags() {
|
|
||||||
industryList.value = [];
|
|
||||||
const availableTags = [...industryListAll.value];
|
|
||||||
for (let i = 0; i < 10; i++) {
|
|
||||||
if (availableTags.length === 0) break;
|
|
||||||
|
|
||||||
const randomIndex = Math.floor(Math.random() * availableTags.length);
|
|
||||||
industryList.value.push(availableTags[randomIndex]);
|
|
||||||
availableTags.splice(randomIndex, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 是否选中
|
// 是否选中
|
||||||
function isSelected(tag) {
|
function isSelected(tag) {
|
||||||
|
|
@ -161,7 +148,7 @@ function handleSearchTag() {
|
||||||
if (!input.value) {
|
if (!input.value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
industryList.value = industryListAll.value.filter((item) => {
|
industryList.value = props.allTagList.filter((item) => {
|
||||||
if (!item || !item.content) return false;
|
if (!item || !item.content) return false;
|
||||||
|
|
||||||
return item.content.includes(input.value);
|
return item.content.includes(input.value);
|
||||||
|
|
@ -196,10 +183,6 @@ watch(
|
||||||
immediate: true,
|
immediate: true,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
getTopIndustry_dFn();
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@
|
||||||
<view class="page-main">
|
<view class="page-main">
|
||||||
<view class="banner">
|
<view class="banner">
|
||||||
<view class="text-1">{{ tagList[current]?.content }}</view>
|
<view class="text-1">{{ tagList[current]?.content }}</view>
|
||||||
<view class="text-2">风口概念近一个月排名Top5</view>
|
<view class="text-2" v-if="tagList[current]?.index">风口概念近一个月排名{{ tagList[current]?.index }}</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="news-list">
|
<view class="news-list">
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
<CustomView
|
<CustomView
|
||||||
v-if="isShowCustom && userStore.isLogin"
|
v-if="isShowCustom && userStore.isLogin"
|
||||||
:tagList="tagList"
|
:tagList="tagList"
|
||||||
|
:allTagList="allTagList"
|
||||||
@onChange="handleChangeTag"
|
@onChange="handleChangeTag"
|
||||||
@onBack="handleHideCustom"
|
@onBack="handleHideCustom"
|
||||||
/>
|
/>
|
||||||
|
|
@ -34,6 +35,22 @@ import LoginDialog from "@/components/loginPopup/index.vue";
|
||||||
import CustomView from "./components/CustomView.vue";
|
import CustomView from "./components/CustomView.vue";
|
||||||
import List from "./components/List.vue";
|
import List from "./components/List.vue";
|
||||||
import { getMyTags, updateMyTags } from "@/api";
|
import { getMyTags, updateMyTags } from "@/api";
|
||||||
|
import { getTopConceptPeriod } from "@/api/newsInfo";
|
||||||
|
import dayjs from "dayjs";
|
||||||
|
|
||||||
|
|
||||||
|
const allTagList = ref([]);
|
||||||
|
const start_time = dayjs().subtract(1, "month").format("YYYY-MM-DD");
|
||||||
|
const end_time = dayjs().format("YYYY-MM-DD");
|
||||||
|
const limit_num = 20;
|
||||||
|
// 热门行业top10
|
||||||
|
async function getTopIndustry_dFn() {
|
||||||
|
allTagList.value = await getTopConceptPeriod({
|
||||||
|
start_time: start_time,
|
||||||
|
end_time: end_time,
|
||||||
|
limit_num: limit_num,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const isShowCustom = ref(false);
|
const isShowCustom = ref(false);
|
||||||
|
|
||||||
|
|
@ -65,9 +82,13 @@ const getTagList = async () => {
|
||||||
const result = await getMyTags();
|
const result = await getMyTags();
|
||||||
if (result.code === 200) {
|
if (result.code === 200) {
|
||||||
tagList.value = result.data.map((item: any) => {
|
tagList.value = result.data.map((item: any) => {
|
||||||
|
const name = item.primaryName + "-" + item.secondaryName;
|
||||||
|
const content = item.secondaryName;
|
||||||
|
const index = allTagList.value.findIndex((tag: any) => tag.content === name);
|
||||||
return {
|
return {
|
||||||
name: item.primaryName + "-" + item.secondaryName,
|
name,
|
||||||
content: item.secondaryName,
|
content,
|
||||||
|
index: index + 1,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -105,7 +126,8 @@ onMounted(async () => {
|
||||||
handleShowLogin();
|
handleShowLogin();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
getTagList();
|
await getTopIndustry_dFn();
|
||||||
|
await getTagList();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@
|
||||||
<view class="recommend-industry">
|
<view class="recommend-industry">
|
||||||
<view class="recommend-industry-top">
|
<view class="recommend-industry-top">
|
||||||
<view class="label">推荐行业</view>
|
<view class="label">推荐行业</view>
|
||||||
<view class="right" @click="selectRandomTags">
|
<view class="right" @click="handleChange">
|
||||||
<view class="icon"></view>
|
<view class="icon"></view>
|
||||||
<view class="text">换一换</view>
|
<view class="text">换一换</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -78,13 +78,17 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { getTopIndustryPeriod } from "@/api/newsInfo";
|
import { getTopIndustryPeriod } from "@/api/newsInfo";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import { onMounted, ref, watch } from "vue";
|
import { computed, onMounted, ref, watch } from "vue";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
tagList: {
|
tagList: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
|
allTagList: {
|
||||||
|
type: Array,
|
||||||
|
default: () => [],
|
||||||
|
},
|
||||||
});
|
});
|
||||||
const emit = defineEmits(["onChange", "onBack"]);
|
const emit = defineEmits(["onChange", "onBack"]);
|
||||||
|
|
||||||
|
|
@ -102,32 +106,14 @@ const handleBack = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const myTagList = ref([]);
|
const myTagList = ref([]);
|
||||||
const industryList = ref([]);
|
const page = ref(0);
|
||||||
const industryListAll = ref([]);
|
const industryList = computed(() => {
|
||||||
const start_time = dayjs().subtract(1, "month").format("YYYY-MM-DD");
|
const arr = [...props.allTagList]
|
||||||
const end_time = dayjs().format("YYYY-MM-DD");
|
return arr.splice(page.value, 10);
|
||||||
const limit_num = 20;
|
|
||||||
// 热门行业top10
|
|
||||||
async function getTopIndustry_dFn() {
|
|
||||||
industryListAll.value = await getTopIndustryPeriod({
|
|
||||||
start_time: start_time,
|
|
||||||
end_time: end_time,
|
|
||||||
limit_num: limit_num,
|
|
||||||
});
|
});
|
||||||
selectRandomTags();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 从所有标签中随机选择10个
|
const handleChange = () => {
|
||||||
function selectRandomTags() {
|
page.value = page.value ? 0 : 10
|
||||||
industryList.value = [];
|
|
||||||
const availableTags = [...industryListAll.value];
|
|
||||||
for (let i = 0; i < 10; i++) {
|
|
||||||
if (availableTags.length === 0) break;
|
|
||||||
|
|
||||||
const randomIndex = Math.floor(Math.random() * availableTags.length);
|
|
||||||
industryList.value.push(availableTags[randomIndex]);
|
|
||||||
availableTags.splice(randomIndex, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 是否选中
|
// 是否选中
|
||||||
|
|
@ -161,7 +147,7 @@ function handleSearchTag() {
|
||||||
if (!input.value) {
|
if (!input.value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
industryList.value = industryListAll.value.filter((item) => {
|
industryList.value = props.allTagList.filter((item) => {
|
||||||
if (!item || !item.content) return false;
|
if (!item || !item.content) return false;
|
||||||
|
|
||||||
return item.content.includes(input.value);
|
return item.content.includes(input.value);
|
||||||
|
|
@ -196,10 +182,6 @@ watch(
|
||||||
immediate: true,
|
immediate: true,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
getTopIndustry_dFn();
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@
|
||||||
<view class="page-main">
|
<view class="page-main">
|
||||||
<view class="banner">
|
<view class="banner">
|
||||||
<view class="text-1">{{ tagList[current]?.content }}</view>
|
<view class="text-1">{{ tagList[current]?.content }}</view>
|
||||||
<view class="text-2">热门行业近一个月排名Top5</view>
|
<view class="text-2" v-if="tagList[current]?.index">热门行业近一个月排名{{ tagList[current]?.index }}</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="news-list">
|
<view class="news-list">
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
<CustomView
|
<CustomView
|
||||||
v-if="isShowCustom && userStore.isLogin"
|
v-if="isShowCustom && userStore.isLogin"
|
||||||
:tagList="tagList"
|
:tagList="tagList"
|
||||||
|
:allTagList="allTagList"
|
||||||
@onChange="handleChangeTag"
|
@onChange="handleChangeTag"
|
||||||
@onBack="handleHideCustom"
|
@onBack="handleHideCustom"
|
||||||
/>
|
/>
|
||||||
|
|
@ -34,6 +35,21 @@ import LoginDialog from "@/components/loginPopup/index.vue";
|
||||||
import CustomView from "./components/CustomView.vue";
|
import CustomView from "./components/CustomView.vue";
|
||||||
import List from "./components/List.vue";
|
import List from "./components/List.vue";
|
||||||
import { getMyIndustries, updateMyIndustries } from "@/api";
|
import { getMyIndustries, updateMyIndustries } from "@/api";
|
||||||
|
import { getTopIndustryPeriod } from "@/api/newsInfo";
|
||||||
|
import dayjs from "dayjs";
|
||||||
|
|
||||||
|
const allTagList = ref([]);
|
||||||
|
const start_time = dayjs().subtract(1, "month").format("YYYY-MM-DD");
|
||||||
|
const end_time = dayjs().format("YYYY-MM-DD");
|
||||||
|
const limit_num = 20;
|
||||||
|
// 热门行业top10
|
||||||
|
async function getTopIndustry_dFn() {
|
||||||
|
allTagList.value = await getTopIndustryPeriod({
|
||||||
|
start_time: start_time,
|
||||||
|
end_time: end_time,
|
||||||
|
limit_num: limit_num,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const isShowCustom = ref(false);
|
const isShowCustom = ref(false);
|
||||||
|
|
||||||
|
|
@ -65,9 +81,13 @@ const getTagList = async () => {
|
||||||
const result = await getMyIndustries({});
|
const result = await getMyIndustries({});
|
||||||
if (result.code === 200) {
|
if (result.code === 200) {
|
||||||
tagList.value = result.data.map((item: any) => {
|
tagList.value = result.data.map((item: any) => {
|
||||||
|
const name = item.primaryName + "-" + item.secondaryName;
|
||||||
|
const content = item.secondaryName;
|
||||||
|
const index = allTagList.value.findIndex((tag: any) => tag.content === name);
|
||||||
return {
|
return {
|
||||||
name: item.primaryName + "-" + item.secondaryName,
|
name,
|
||||||
content: item.secondaryName,
|
content,
|
||||||
|
index: index + 1,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -105,7 +125,8 @@ onMounted(async () => {
|
||||||
handleShowLogin();
|
handleShowLogin();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
getTagList();
|
await getTopIndustry_dFn();
|
||||||
|
await getTagList();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue