Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <template>
- <div class="register-form">
- <div v-if="loading">
- <loader :fullscreen="true"></loader>
- </div>
- <div class="loginForm__error" v-if="error&&!loading">
- Er is een fout opgetreden, controleer de ingevulde gegevens.
- <span v-if="error!==true" v-html="error"></span>
- </div>
- <div class="formfield small">
- <span class="label">Geslacht</span>
- <select v-model="user.salutation" name="salutation"
- v-validate="{ required: true, regex: /^([^0-9]*)$/ }"
- :style="computeStyle('salutation')">
- <option value="0" disabled selected hidden>Aanhef</option>
- <option v-for="option in salutationOptions.options"
- :key="option.option"
- :value="option.value">
- {{ option.value }}
- </option>
- </select>
- </div>
- <div class="formfield medium">
- <span class="label">Voornaam</span>
- <input type="text"
- name="firstname"
- placeholder="Voornaam"
- v-model.lazy="user.firstname"
- v-validate="'required'"
- :style="computeStyle('firstname')" />
- </div>
- <div class="formfield small">
- <span class="label">Tussenvoegsel</span>
- <input type="text"
- name="tussenvoegsel"
- placeholder="Tussenvoegsel"
- v-model="user.prefix" />
- </div>
- <div class="formfield medium">
- <span class="label">Achternaam</span>
- <input type="text"
- name="lastname"
- placeholder="Achternaam"
- v-model.lazy="user.lastname"
- v-validate="'required'"
- :style="computeStyle('lastname')" />
- </div>
- <div class="formfield half">
- <span class="label">Geboortedatum</span>
- <select name="birthdate-day"
- v-model="user.inputBirthdate.day"
- v-validate="{ required: true }"
- :style="computeStyle('birthday-day')"
- @change="updateBirthdate()">
- <option value="0" selected hidden disabled>Dag</option>
- <option v-for="day in days">{{ day }}</option>
- </select>
- <select name="birthdate-month"
- v-model="user.inputBirthdate.month"
- v-validate="{ required: true }"
- :style="computeStyle('birthday-month')"
- @change="updateBirthdate()">
- <option value="0" selected hidden disabled>Maand</option>
- <option v-for="month in months">{{ month }}</option>
- </select>
- <select name="birthdate-day"
- v-model="user.inputBirthdate.year"
- v-validate="{ required: true }"
- :style="computeStyle('birthday-year')"
- @change="updateBirthdate()">
- <option value="0" selected hidden disabled>Jaar</option>
- <option v-for="year in years">{{ year }}</option>
- </select>
- </div>
- <div class="formfield half">
- <span class="label">Land</span>
- <select name="countryCode"
- v-model="user.countryCode"
- v-validate="{ required: true }"
- :style="computeStyle('country-code')">
- <option value="0" selected hidden disabled>Landcode</option>
- <option v-for="option in countryCodeOptions.options"
- :key="option.option"
- :value="option.value">
- {{ option.value }}
- </option>
- </select>
- <span class="label">Telefoon</span>
- <input type="tel"
- name="phone"
- placeholder="Telefoon"
- v-model.lazy="user.phone"
- v-validate="'required|numeric'"
- :style="computeStyle('phone')" />
- </div>
- <div class="formfield small">
- <span class="label">Straatnaam</span>
- <input type="text"
- name="street"
- v-model.lazy="user.address.street"
- v-validate="'required'"
- :style="computeStyle('street')" />
- </div>
- <div class="formfield small">
- <span class="label">Huisnummer</span>
- <input type="text"
- name="housenumber"
- placeholder="Nummer"
- v-model="user.address.housenumber"
- v-validate="'required'"
- @keyup="checkZip($event)"
- :style="computeStyle('housenumber')" />
- </div>
- <div class="formfield small">
- <span class="label">Postcode</span>
- <input type="text"
- name="zipcode"
- v-model="user.address.zipcode"
- v-validate="{ required: true, regex: /\d{4} ?[a-zA-Z]{2}/ }"
- pattern="\d{4} ?[a-zA-Z]{2}"
- @keyup="checkZip($event)"
- :style="computeStyle('zipcode')" />
- </div>
- <div class="formfield medium">
- <span class="label">Plaats</span>
- <input type="text"
- name="city"
- v-model.lazy="user.address.city"
- v-validate="'required'"
- :style="computeStyle('city')" />
- </div>
- <div class="loader-zipcode" v-if="loadingZipCode">
- <loader></loader>
- <p>Gegevens worden opgehaald...</p>
- </div>
- <div v-else-if="zipcodeCheck != null">
- <div class="formfield medium">
- <input type="text"
- name="street"
- placeholder="Straatnaam"
- v-model.lazy="user.address.street"
- v-validate="'required'"
- :style="computeStyle('street')" />
- </div>
- <div class="formfield medium">
- <input type="text"
- name="city"
- placeholder="Plaats"
- v-model.lazy="user.address.city"
- v-validate="'required'"
- :style="computeStyle('city')" />
- </div>
- </div>
- <div class="formfield large">
- <span class="label">Emailadres</span>
- <input type="email"
- name="email"
- placeholder="Email"
- v-model.lazy="user.email"
- v-validate="'required|email'"
- :style="computeStyle('email')" />
- </div>
- <div class="formfield large">
- <span class="label">Wachtwoord</span>
- <password :name="'password'"
- :placeholder="'Wachtwoord'"
- :secureLength="8"
- v-model="user.password"
- v-validate="'required|min:8'"
- :style="computeStyle('password')" />
- </div>
- <div class="formfield large">
- <span class="label">Herhaal wachtwoord</span>
- <input type="password"
- name="passwordConfirmation"
- placeholder="Wachtwoord bevestigen"
- v-model.lazy="user.passwordConfirmation"
- v-validate="'required|min:6'"
- :style="computeStyle('passwordConfirmation')" />
- </div>
- <p class="collect-alternative">Wanneer een product helaas niet op voorraad is, wilt u dan dat wij een alternatief product verzamelen?</p>
- <div class="formfield large">
- <span class="arrow"></span>
- <select v-model="user.collectalternatives" name="collectalternatives"
- v-validate="'required'"
- :style="computeStyle('collectalternatives')">
- <option value="0" disabled>Alternatief verzamelen?</option>
- <option v-for="option in collectalternativesoptions"
- :key="option.option"
- :value="option.option" v-html="option.value"></option>
- </select>
- </div>
- <div class="formfield large">
- <div class="select_filiaal">
- <input autocomplete="off" type="text" class="select__filiaal__input" v-model="storeInput" placeholder="Zoek een Poiesz supermarkt op plaatsnaam" />
- </div>
- <div class="select_filiaal__options" :class="{open: storeInput.length>0}">
- <div v-for="store in storeItems" :key="store.name">
- <select-store :store="store" @STORE_SELECTED="storeSelected"></select-store>
- </div>
- </div>
- <div class="selected_filiaal__selected-store" v-if="user.store.name != null">
- <div class="text">Geselecteerde Poiesz: {{ user.store.name }}</div>
- </div>
- </div>
- <div class="formfield large">
- <label class="switch">
- <input type="checkbox" @click="user.isCompany = !user.isCompany">
- <span class="slider round"></span>
- </label>
- <label class="switch-label">Dit is {{ changeAccountText }} account</label>
- </div>
- <transition name="fade">
- <div class="bedrijfs-sectie" v-if="user.isCompany">
- <div class="formfield large">
- <span class="label">Bedrijfsnaam</span>
- <input type="text"
- name="companyName"
- placeholder="Bedrijfsnaam"
- v-model.lazy="user.companyName"
- v-validate="{ rules: { required: this.user.isCompany} }"
- :style="computeStyle('companyName')" />
- </div>
- <div class="formfield large">
- <span class="formfield large">Type bedrijf</span>
- <select name="companyType"
- v-model="user.companyType"
- v-validate="{ required: true }">
- <option value="0" selected hidden disabled>Selecteer bedrijf</option>
- <option v-for="option in companyTypeOptions.options"
- :key="option.option"
- :value="option.value">
- {{ option.value }}
- </option>
- </select>
- </div>
- <div class="formfield large">
- <span class="label">Kvk nummer</span>
- <input type="text"
- name="CoCNumber"
- placeholder="Kvk nummer"
- v-model.lazy="user.CoCNumber"
- v-validate="{ rules: { required: this.user.isCompany} }"
- :style="computeStyle('CoCNumber')" />
- </div>
- <div class="formfield large">
- <label> Factuuradres</label>
- </div>
- <div class="formfield medium">
- <span class="label">Straatnaam</span>
- <input type="text"
- name="companyStreet"
- placeholder="Straatnaam"
- v-model.lazy="user.companyAddress.street"
- v-validate="{ rules: { required: this.user.isCompany} }"
- :style="computeStyle('companyStreet')" />
- </div>
- <div class="formfield small">
- <span class="label">Nummer</span>
- <input type="text"
- name="companyHouseNumber"
- placeholder="Nummer"
- v-model.lazy="user.companyAddress.housenumber"
- v-validate="{ rules: { required: this.user.isCompany} }"
- :style="computeStyle('companyHouseNumber')" />
- </div>
- <div class="formfield small">
- <span class="label">Postcode</span>
- <input type="text"
- name="companyZipcode"
- placeholder="Postcode"
- v-model.lazy="user.companyAddress.zipcode"
- v-validate="{ required: this.user.isCompany, regex: /\d{4} ?[a-zA-Z]{2}/ }"
- :style="computeStyle('companyZipcode')" />
- </div>
- <div class="formfield medium">
- <span class="label">Plaats</span>
- <input type="text"
- name="companyCity"
- placeholder="Plaats"
- v-model.lazy="user.companyAddress.city"
- v-validate="{ rules: { required: this.user.isCompany} }"
- :style="computeStyle('companyCity')" />
- </div>
- <!--<div class="formfield large">-->
- <!--<input-->
- <!--type="text"-->
- <!--name="companyBankAccount"-->
- <!--placeholder="IBAN rekeningnummer"-->
- <!--v-model.lazy="user.companyBankAccount"-->
- <!--v-validate="{ rules: { required: this.user.isCompany} }"-->
- <!--:style="computeStyle('companyBankAccount')"/>-->
- <!--</div>-->
- </div>
- </transition>
- <div class="formfield button half" @click="sendForm">Maak account aan</div>
- </div>
- </template>
- <script>
- import Vue from 'vue';
- import myDatepicker from 'vue-datepicker'
- import VeeValidate from 'vee-validate';
- import { UserApi, StoresApi } from '~/api';
- import { mapActions } from 'vuex';
- import SelectStore from "../orderprocess/SelectStore.vue";
- import Password from 'vue-password-strength-meter'
- import Loader from "../global/Loader.vue";
- Vue.use(VeeValidate);
- export default {
- data() {
- return {
- customErrors: [],
- loading: false,
- user: {
- salutation: 0,
- firstname: '',
- prefix: '',
- lastname: '',
- birthdate: new Date(),
- inputBirthdate: {
- day: 0,
- month: 0,
- year: 0
- },
- countryCode: 0,
- phone: '',
- //street: '',
- //housenumber: '',
- //zipcode: '',
- //city: '',
- email: '',
- password: '',
- passwordConfirmation: '',
- filiaalOpen: false,
- isCompany: false,
- companyName: '',
- companyType: 0,
- CoCNumber: '',
- companyStreet: '',
- companyHouseNumber: '',
- companyZipcode: '',
- companyCity: '',
- companyBankAccount: '',
- store: 0,
- collectalternatives: 0,
- isAdmin: false,
- address: {
- name: '',
- street: '',
- housenumber: '',
- zipcode: '',
- city: ''
- },
- companyAddress: {
- name: '',
- street: '',
- housenumber: '',
- zipcode: '',
- city: ''
- }
- },
- stores: [],
- collectalternativesoptions: [
- { option: 1, value: `Ja, alleen huismerk` },
- { option: 2, value: `Ja, alleen A-merk` },
- { option: 3, value: `Ja, geen voorkeur voor merk` },
- { option: 4, value: `Nee, geen alternatief toegestaan` }
- ],
- salutationOptions: {
- options: [
- { option: 'Dhr', value: 'Dhr' },
- { option: 'Mevr', value: 'Mevr' }
- ]
- },
- error: false,
- storeInput: '',
- storeOpen: false,
- countryCodeOptions: {
- options: [
- { option: '0031', value: '0031' },
- { option: '0032', value: '0032' },
- { option: '0033', value: '0033' },
- { option: '0044', value: '0044' },
- { option: '0049', value: '0049' }
- ]
- },
- companyTypeOptions: {
- options: [
- { option: 'Zorginstelling', value: 'Zorginstelling' },
- { option: 'Kinderopvang', value: 'Kinderopvang' },
- { option: 'School', value: 'School' },
- { option: 'Sportvereniging', value: 'Sportvereniging' },
- { option: 'Overig', value: 'Overig' }
- ]
- },
- zipcodeCheck: null,
- loadingZipCode: true,
- interval: null
- }
- },
- methods: {
- sendForm() {
- const $vm = this;
- Logger.log("Sendform");
- this.customErrors.clear();
- if (this.user.salutation === 0)
- this.customErrors.push('salutation');
- if (this.user.countryCode === 0)
- this.customErrors.push('country-code');
- if (this.user.inputBirthdate.day === 0)
- this.customErrors.push('birthdate-day');
- if (this.user.inputBirthdate.month === 0)
- this.customErrors.push('birthdate-month');
- if (this.user.inputBirthdate.year === 0)
- this.customErrors.push('birthdate-year');
- if (this.user.collectalternatives === 0)
- this.customErrors.push('collectalternatives');
- if (this.user.password != this.user.passwordConfirmation) {
- $vm.error = `Wachtwoorden komen niet overeen`;
- this.customErrors.push('password');
- this.customErrors.push('passwordConfirmation');
- return;
- }
- if (!this.validatePassword()) {
- $vm.error = `Wachtwoord voldoet niet aan de eisen. Wachtwoord moet minimaal bestaan uit: 1 kleine letter, 1 hoofdletter, 1 cijfer, 1 leesteken en 8 karakters.`;
- this.customErrors.push('password');
- return;
- }
- if (this.customErrors.length > 0) {
- $vm.error = `Controleer of alle velden correct zijn ingevuld`;
- return;
- }
- this.error = true;
- this.$validator
- .validateAll()
- .then(function (response) {
- Logger.log("Sendform: ", response);
- if (response) {
- $vm.loading = true;
- UserApi.createUser($vm.user).then(user => {
- $vm.setUser(user);
- $vm.error = false;
- Event.fire('USER_LOGGED_IN', user);
- }).catch(error => {
- Logger.log(error);
- $vm.error = error.response.data.message;
- }).then(() => {
- $vm.loading = false;
- });
- }
- })
- .catch(function (e) {
- Logger.error(e);
- $vm.error = true;
- })
- },
- computeStyle(field) {
- if (this.errors.has(field) || this.customErrors.contains(field))
- return `border: 1px solid #e84e1b;`;
- else
- return ``;
- },
- ...mapActions({
- setUser: 'setUser'
- }),
- storeSelected(store) {
- this.storeOpen = false;
- this.user.store = store;
- this.storeInput = '';
- },
- storeInputChange() {
- console.log('input change');
- this.storeOpen = true;
- },
- updateBirthdate() {
- let str = this.user.inputBirthdate;
- console.log("updatebirthdate", str);
- let temp = [];
- temp.push(this.user.inputBirthdate.year, this.user.inputBirthdate.month, this.user.inputBirthdate.day);
- this.user.birthdate = (new Date(temp.join("-"))).toUTCString();
- console.log(this.user.birthdate);
- },
- validatePassword() {
- let password = this.user.password;
- if (password.length < 8)
- return false;
- let regex = new RegExp(`^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-_=+]).{8,}$`);
- return regex.test(password);
- },
- checkZip(event) {
- clearInterval(this.interval);
- if ((event.which <= 90 && event.which >= 48) || (event.which >= 96 && event.which <= 105) || event.which === 8 || event.which === 46) {
- if (!(this.user.address.zipcode.length > 5 && this.user.address.housenumber.length > 0))
- return;
- this.loadingZipCode = true;
- this.interval = setTimeout(() => {
- UserApi.zipcodeCheck({
- zipcode: this.user.address.zipcode,
- housenumber: this.user.address.housenumber,
- housenumberaddition: this.user.address.housenumberaddition
- }).then(data => {
- console.log(data)
- this.user.address.street = data.streetNen;
- this.user.address.city = data.city;
- }).catch(error => {
- console.error(error)
- });
- this.loadingZipCode = false;
- }, 1000);
- }
- }
- },
- mounted() {
- const $vm = this;
- StoresApi.getStores().then(stores => {
- $vm.stores = stores;
- }).catch(error => {
- Logger.error(error);
- throw error;
- });
- },
- computed: {
- changeAccountText() {
- if (this.user.isCompany) {
- return "geen zakelijk"
- } else {
- return "een zakelijk"
- }
- },
- storeItems() {
- return this.stores.filter(store => {
- let name = `${store.name} ${store.address} ${store.city} ${store.zipcode}`.toLowerCase();
- let input = this.storeInput.toLowerCase();
- return name.contains(input);
- });
- },
- days() {
- let array = [];
- for (let i = 1; i <= 31; i++) {
- if (i.toString().length === 1) {
- array.push('0' + i.toString());
- } else {
- array.push(i.toString());
- }
- }
- return array;
- },
- months() {
- let array = [];
- for (let i = 1; i <= 12; i++) {
- if (i.toString().length === 1) {
- array.push('0' + i.toString());
- } else {
- array.push(i.toString());
- }
- }
- return array;
- },
- years() {
- let array = [];
- for (let i = 1900; i <= ((new Date()).getFullYear() - 18); i++) {
- array.push(i.toString());
- }
- return array;
- }
- },
- components: {
- Loader,
- 'date-picker': myDatepicker,
- SelectStore,
- Password
- }
- }
- </script>
- <style>
- .fade-enter,
- .fade-leave-active {
- opacity: 0;
- }
- .fade-enter-active,
- .fade-leave-active {
- transition: opacity 0.4s ease-out;
- }
- .cov-vue-date {
- width: 100%;
- }
- .cov-datepicker {
- padding-left: 20px !important;
- box-shadow: none !important;
- border: 1px solid #E1E1E1 !important;
- border-radius: 4px !important;
- }
- .cov-date-body {
- font-family: "FagoPro" !important;
- }
- .cov-date-body .day.checked {
- background: #f28808 !important;
- }
- .cov-date-caption {
- color: #f28808 !important;
- }
- .cov-picker-box .week ul li {
- margin: 0;
- }
- </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement