Рендер социальных сетей через цикл
This commit is contained in:
parent
8789bb2e09
commit
e07d34d61e
|
|
@ -10,15 +10,26 @@
|
||||||
<div class="contacts__content">
|
<div class="contacts__content">
|
||||||
<div v-if="contacts" class="contacts__info">
|
<div v-if="contacts" class="contacts__info">
|
||||||
<div v-for="(item, index) in contactsField" :key="index">
|
<div v-for="(item, index) in contactsField" :key="index">
|
||||||
<div class="text contacts__item">
|
<div
|
||||||
|
v-if="item.title !== dictionaryFields.socials"
|
||||||
|
class="text contacts__item"
|
||||||
|
>
|
||||||
<span class="title">{{ item.title }}</span>
|
<span class="title">{{ item.title }}</span>
|
||||||
{{ item.data }}
|
{{ item.data }}
|
||||||
</div>
|
</div>
|
||||||
|
<div v-else class="contacts__socials">
|
||||||
|
<span class="title">{{ item.title }}</span>
|
||||||
|
<div
|
||||||
|
v-for="(href, social) in item.data"
|
||||||
|
:key="social"
|
||||||
|
class="contacts__social"
|
||||||
|
>
|
||||||
|
<a :href="href" :class="['contacts__social', social]"></a>
|
||||||
</div>
|
</div>
|
||||||
<span class="title">Соц. сети</span>
|
|
||||||
<div></div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="contacts__map">
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- <div class="contacts__map">
|
||||||
<div
|
<div
|
||||||
class="contacts__map-frame"
|
class="contacts__map-frame"
|
||||||
style="position: relative; overflow: hidden"
|
style="position: relative; overflow: hidden"
|
||||||
|
|
@ -40,7 +51,7 @@
|
||||||
style="position: relative"
|
style="position: relative"
|
||||||
></iframe>
|
></iframe>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div> -->
|
||||||
<FormKit
|
<FormKit
|
||||||
v-model="formData"
|
v-model="formData"
|
||||||
type="form"
|
type="form"
|
||||||
|
|
@ -116,39 +127,32 @@ export default {
|
||||||
phone: 'Телефон',
|
phone: 'Телефон',
|
||||||
address: 'Адрес',
|
address: 'Адрес',
|
||||||
email: 'Почта',
|
email: 'Почта',
|
||||||
|
socials: 'Соц. сети',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
contactsField() {
|
contactsField() {
|
||||||
const address =
|
const address = this.formatAddress(this.contacts);
|
||||||
this.contacts.city && this.contacts.street && this.contacts.house
|
|
||||||
? `г. ${this.contacts.city}, ул. ${this.contacts.street}, д. ${this.contacts.house}`
|
|
||||||
: null;
|
|
||||||
|
|
||||||
const phone = this.contacts.phone;
|
const phone = this.contacts.phone;
|
||||||
const email = this.contacts.email;
|
const email = this.contacts.email;
|
||||||
|
const socials = {
|
||||||
|
['m--telegram']: this.contacts.telegram_url,
|
||||||
|
['m--vk']: this.contacts.vk_url,
|
||||||
|
};
|
||||||
|
|
||||||
const fields = {
|
const fields = {
|
||||||
address,
|
address,
|
||||||
phone,
|
phone,
|
||||||
email,
|
email,
|
||||||
|
socials,
|
||||||
};
|
};
|
||||||
|
|
||||||
const fieldsWithoutNull = this.removeNullFields(fields);
|
const fieldsWithoutNull = this.removeNullFields(fields);
|
||||||
return this.createArrayContacts(this.dictionaryFields, fieldsWithoutNull);
|
return this.createArrayContacts(this.dictionaryFields, fieldsWithoutNull);
|
||||||
},
|
},
|
||||||
socialsField() {
|
|
||||||
const socials = {
|
|
||||||
telegram: this.contacts.telegram_url,
|
|
||||||
vk: this.contacts.vk_url,
|
|
||||||
};
|
|
||||||
|
|
||||||
return this.removeNullFields(socials);
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
// Получаем объект с бэка
|
|
||||||
app.getSupportInfo().then((responce) => {
|
app.getSupportInfo().then((responce) => {
|
||||||
this.contacts = { ...responce };
|
this.contacts = { ...responce };
|
||||||
});
|
});
|
||||||
|
|
@ -156,7 +160,6 @@ export default {
|
||||||
mounted() {},
|
mounted() {},
|
||||||
methods: {
|
methods: {
|
||||||
submitHandler() {},
|
submitHandler() {},
|
||||||
// Метод удаляет из объекта ключи с null
|
|
||||||
removeNullFields(obj) {
|
removeNullFields(obj) {
|
||||||
const result = {};
|
const result = {};
|
||||||
|
|
||||||
|
|
@ -173,7 +176,6 @@ export default {
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
// Метод формирует массив, на основе словаря и объекта
|
|
||||||
createArrayContacts(dictionary, fields) {
|
createArrayContacts(dictionary, fields) {
|
||||||
const result = [];
|
const result = [];
|
||||||
|
|
||||||
|
|
@ -185,6 +187,12 @@ export default {
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
formatAddress(contacts) {
|
||||||
|
if (contacts.city && contacts.street && contacts.house) {
|
||||||
|
return `г. ${contacts.city}, ул. ${contacts.street}, д. ${contacts.house}`;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue