You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
277 lines
7.8 KiB
277 lines
7.8 KiB
import {
|
|
statue2number
|
|
} from "~/utils/constant";
|
|
|
|
export function formatDate(t) {
|
|
return new Date(t).toLocaleDateString().replace(/\//g, '.');
|
|
}
|
|
|
|
export function dateCardFormatDate(date) {
|
|
return date.getFullYear() + "-" + (date.getMonth() + 1).toString().padStart(2, '0') + "-" + date.getDate().toString().padStart(2, '0');
|
|
}
|
|
|
|
export function dateCountDown(date) {
|
|
let days = Math.ceil((new Date(date)-new Date())/1000/24/60/60);
|
|
return days;
|
|
}
|
|
|
|
export function getCurrentTime() {
|
|
let yy = new Date().getFullYear();
|
|
let mm = new Date().getMonth() + 1;
|
|
let dd = new Date().getDate();
|
|
let hh = new Date().getHours();
|
|
let mf = new Date().getMinutes() < 10
|
|
? "0" + new Date().getMinutes()
|
|
: new Date().getMinutes();
|
|
let ss = new Date().getSeconds() < 10
|
|
? "0" + new Date().getSeconds()
|
|
: new Date().getSeconds();
|
|
let sss = new Date().getMilliseconds();
|
|
let gettime = yy + "/" + mm + "/" + dd + " " + hh + ":" + mf + ":" + ss +":"+ sss;
|
|
return gettime;
|
|
}
|
|
|
|
export function addSeperetor(query) {
|
|
if (
|
|
query.substr(query.length - 1) != "&" &&
|
|
query.substr(query.length - 1) != "?"
|
|
)
|
|
query += "&";
|
|
return query;
|
|
}
|
|
export function exhibitionApi2CardType(apiExhibitions) {
|
|
let exhibitionList = []
|
|
for (let i = 0; i < apiExhibitions.length; i++) {
|
|
const item = {
|
|
"id" : apiExhibitions[i].id || '',
|
|
"title" : apiExhibitions[i].name || '',
|
|
"location" : (apiExhibitions[i].region || apiExhibitions[i].country || apiExhibitions[i].city ?
|
|
( apiExhibitions[i].region && apiExhibitions[i].region.name ? apiExhibitions[i].region.name : "") +
|
|
" - " +
|
|
(apiExhibitions[i].country && apiExhibitions[i].country.name ? apiExhibitions[i].country.name : "") +
|
|
" - " +
|
|
(apiExhibitions[i].city && apiExhibitions[i].city.name ? apiExhibitions[i].city.name : "") :
|
|
""),
|
|
"rate" : apiExhibitions[i].rating || 0,
|
|
"rateNumber" : apiExhibitions[i].reviewCount || 0,
|
|
"exhibitNumber" : apiExhibitions[i].exhibitors || '',
|
|
"visitorNumber" : apiExhibitions[i].visitors || '',
|
|
"category" : [],
|
|
"image" : apiExhibitions[i].logo || '',
|
|
"description" : apiExhibitions[i].about || '',
|
|
"startDate" : apiExhibitions[i].startdate || '',
|
|
"endDate" : apiExhibitions[i].enddate || '',
|
|
"favorite" : apiExhibitions[i].isLiked || '',
|
|
"recommend" : apiExhibitions[i].isRecommend || '',
|
|
"status" : statue2number[apiExhibitions[i].status.name] || 0,
|
|
"saved" : false
|
|
};
|
|
item.category = apiExhibitions[i].categories;
|
|
exhibitionList.push(item)
|
|
}
|
|
return exhibitionList;
|
|
}
|
|
export function savedExhibitionApi2CardType(apiExhibitions) {
|
|
let exhibitionList = Array(apiExhibitions.length).fill(1);
|
|
for (let i = 0; i < apiExhibitions.length; i++) {
|
|
exhibitionList[i] = {};
|
|
exhibitionList[i].id = apiExhibitions[i].id;
|
|
exhibitionList[i].title = apiExhibitions[i].name;
|
|
exhibitionList[i].location =
|
|
(apiExhibitions[i].region || apiExhibitions[i].country || apiExhibitions[i].city ?
|
|
( apiExhibitions[i].region && apiExhibitions[i].region.name ? apiExhibitions[i].region.name : "") +
|
|
" - " +
|
|
(apiExhibitions[i].country && apiExhibitions[i].country.name ? apiExhibitions[i].country.name : "") +
|
|
" - " +
|
|
(apiExhibitions[i].city && apiExhibitions[i].city.name ? apiExhibitions[i].city.name : "") :
|
|
"");
|
|
exhibitionList[i].country = apiExhibitions[i].country.id
|
|
exhibitionList[i].rate = apiExhibitions[i].rating;
|
|
// exhibitionList[i].rate = Math.ceil(apiExhibitions[i].rating)
|
|
exhibitionList[i].rateNumber = apiExhibitions[i].reviewCount;
|
|
exhibitionList[i].exhibitNumber = apiExhibitions[i].exhibitors;
|
|
exhibitionList[i].visitorNumber = apiExhibitions[i].visitors;
|
|
exhibitionList[i].category = apiExhibitions[i].categories;
|
|
exhibitionList[i].image = apiExhibitions[i].logo;
|
|
exhibitionList[i].description = apiExhibitions[i].about;
|
|
exhibitionList[i].startDate = apiExhibitions[i].startdate;
|
|
exhibitionList[i].endDate = apiExhibitions[i].enddate;
|
|
exhibitionList[i].favorite = apiExhibitions[i].isLiked;
|
|
exhibitionList[i].recommend = apiExhibitions[i].isRecommend;
|
|
exhibitionList[i].status = statue2number[apiExhibitions[i].status.name];
|
|
exhibitionList[i].saved = false
|
|
}
|
|
return exhibitionList;
|
|
}
|
|
|
|
export async function getData(axios, langQuery) {
|
|
|
|
let data;
|
|
({
|
|
data
|
|
} = await axios.get(
|
|
"/trending/ads" + langQuery
|
|
).catch((err) => {
|
|
console.error(err);
|
|
}));
|
|
let ads = data.ads;
|
|
|
|
({
|
|
data
|
|
} = await axios.get(
|
|
"/trending/banner" + langQuery
|
|
).catch((err) => {
|
|
console.error(err);
|
|
}));
|
|
let banner = data.banner;
|
|
|
|
|
|
let exhibitions = data.exhibitions || [];
|
|
|
|
({
|
|
data
|
|
} = await axios.get(
|
|
"/trending/services" + langQuery
|
|
).catch((err) => {
|
|
console.error(err);
|
|
}));
|
|
let services = data.services;
|
|
|
|
({
|
|
data
|
|
} = await axios.get(
|
|
"/trending/themes/exhibitions" + langQuery
|
|
).catch((err) => {
|
|
console.error(err);
|
|
}));
|
|
let themes = data.themes;
|
|
let themesTitle = data.title;
|
|
|
|
({
|
|
data
|
|
} = await axios.get(
|
|
"/trending/themes/services" + langQuery
|
|
).catch((err) => {
|
|
console.error(err);
|
|
}));
|
|
let serviceThemes = data.themes;
|
|
let serviceThemesTitle = data.title;
|
|
|
|
({
|
|
data
|
|
} = await axios.get(
|
|
"/trending/partnerships" + langQuery
|
|
).catch((err) => {
|
|
console.error(err);
|
|
}));
|
|
let partnerships = data.partnerships;
|
|
|
|
({
|
|
data
|
|
} = await axios.get(
|
|
"/trending/exhibitions/collections" +
|
|
langQuery
|
|
).catch((err) => {
|
|
console.error(err);
|
|
}));
|
|
let collections = data.collections;
|
|
|
|
({
|
|
data
|
|
} = await axios.get(
|
|
"/trending/search/popular" + langQuery
|
|
).catch((err) => {
|
|
console.error(err);
|
|
}));
|
|
let populars = data.search;
|
|
|
|
var slogenQuery = "/trending/slogans" + langQuery;
|
|
({
|
|
data
|
|
} = await axios.get(
|
|
slogenQuery
|
|
).catch((err) => {
|
|
console.error(err);
|
|
}));
|
|
let slogan = data.slogan;
|
|
let subslogan = data.subslogan;
|
|
|
|
({
|
|
data
|
|
} = await axios.get(
|
|
"/trending/services/search/history" +
|
|
langQuery
|
|
).catch((err) => {
|
|
console.error(err);
|
|
}));
|
|
let servicesSearchs = data.searches;
|
|
|
|
({
|
|
data
|
|
} = await axios.get(
|
|
"/trending/services/locations" + langQuery
|
|
).catch((err) => {
|
|
console.error(err);
|
|
}));
|
|
let servicesLocations = data.locations;
|
|
|
|
({
|
|
data
|
|
} = await axios.get(
|
|
"/trending/exhibitions/search/history" +
|
|
langQuery
|
|
).catch((err) => {
|
|
console.error(err);
|
|
}));
|
|
let exhibitionsSearchs = data.searches;
|
|
|
|
({
|
|
data
|
|
} = await axios.get(
|
|
"trending/exhibitions/locations" +
|
|
langQuery
|
|
).catch((err) => {
|
|
console.error(err);
|
|
}));
|
|
let exhibitionsLocations = data.locations;
|
|
exhibitionsLocations = exhibitionsLocations.filter(region => region.region != null);
|
|
for (let i = 0; i < exhibitionsLocations.length; i++) {
|
|
exhibitionsLocations[i].countries = exhibitionsLocations[i].countries.filter(country => country.country != null);
|
|
for (let j = 0; j < exhibitionsLocations[i].countries.length; j++) {
|
|
if (exhibitionsLocations[i].countries[j].cities != null ) {
|
|
exhibitionsLocations[i].countries[j].cities = exhibitionsLocations[i].countries[j].cities.filter(city => city.city != null);
|
|
}
|
|
}
|
|
}
|
|
|
|
({
|
|
data
|
|
} = await axios.get(
|
|
"/trending/exhibitions/categories" +
|
|
langQuery
|
|
).catch((err) => {
|
|
console.error(err);
|
|
}));
|
|
let exhibitionsCategories = data.categories;
|
|
const apiData = {
|
|
ads,
|
|
exhibitions,
|
|
services,
|
|
themes,
|
|
themesTitle,
|
|
serviceThemes,
|
|
serviceThemesTitle,
|
|
partnerships,
|
|
collections,
|
|
slogan,
|
|
subslogan,
|
|
populars,
|
|
servicesSearchs,
|
|
servicesLocations,
|
|
exhibitionsSearchs,
|
|
exhibitionsLocations,
|
|
exhibitionsCategories,
|
|
banner
|
|
};
|
|
return apiData;
|
|
}
|