|
@@ -1,7 +1,7 @@
|
|
|
import { defineStore } from 'pinia';
|
|
|
import { safeJsonParse } from '../utils/common';
|
|
|
-import { analysisKeyword } from '../utils/api';
|
|
|
-import type { FormDataInfo, KeywordInfo } from '@/types';
|
|
|
+import { analysisKeyword, analysisSuggestions } from '../utils/api';
|
|
|
+import type { FormDataInfo, KeywordInfo, RelatedInfoBOItem } from '@/types';
|
|
|
|
|
|
export const useMainStore = defineStore('main', {
|
|
|
state: () => ({
|
|
@@ -10,6 +10,11 @@ export const useMainStore = defineStore('main', {
|
|
|
keywordInfo: {
|
|
|
loading: true,
|
|
|
data: {} as KeywordInfo
|
|
|
+ },
|
|
|
+ suggestionsInfo: {
|
|
|
+ loading: true,
|
|
|
+ autoFinish: false,
|
|
|
+ data: [] as RelatedInfoBOItem[]
|
|
|
}
|
|
|
}),
|
|
|
actions: {
|
|
@@ -25,11 +30,21 @@ export const useMainStore = defineStore('main', {
|
|
|
// 获取竞品
|
|
|
getRival() {},
|
|
|
// 获取推荐
|
|
|
- getSuggestions() {},
|
|
|
+ async getSuggestions() {
|
|
|
+ const { productName, locationName } = this.getFormData;
|
|
|
+ return analysisSuggestions({ productName, locationName })
|
|
|
+ .then((res) => {
|
|
|
+ this.suggestionsInfo.data = res.data.relatedInfoBOList;
|
|
|
+ this.suggestionsInfo.autoFinish = true;
|
|
|
+ setTimeout(() => {
|
|
|
+ this.suggestionsInfo.loading = false;
|
|
|
+ }, 300);
|
|
|
+ })
|
|
|
+ .finally(() => {});
|
|
|
+ },
|
|
|
// 获取关键词
|
|
|
async getKeywordData() {
|
|
|
const { productName, locationName } = this.getFormData;
|
|
|
- console.log(productName, 'productName')
|
|
|
return analysisKeyword({ productName, locationName })
|
|
|
.then((res) => {
|
|
|
this.keywordInfo.data = res.data;
|
|
@@ -40,7 +55,7 @@ export const useMainStore = defineStore('main', {
|
|
|
},
|
|
|
initData() {
|
|
|
this.getKeywordData();
|
|
|
- // this.getSuggestions();
|
|
|
+ this.getSuggestions();
|
|
|
// this.getRival();
|
|
|
// this.getQualitative();
|
|
|
}
|
|
@@ -58,6 +73,12 @@ export const useMainStore = defineStore('main', {
|
|
|
},
|
|
|
getKeywordInfo(): { data: KeywordInfo } & { loading: boolean } {
|
|
|
return this.keywordInfo;
|
|
|
+ },
|
|
|
+ getSuggestionsInfo(): { data: RelatedInfoBOItem[] } & {
|
|
|
+ autoFinish: boolean;
|
|
|
+ loading: boolean;
|
|
|
+ } {
|
|
|
+ return this.suggestionsInfo;
|
|
|
}
|
|
|
}
|
|
|
});
|