123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272 |
- <template>
- <div class="container">
- <div class="row" style="text-align:left">
- <div class="col-md-4" style="margin-bottom: 1em">
- <div class="custom-control custom-switch">
- <label>Do you live in a complex or block of flats?</label>
- <input
- style="margin-left: 1px"
- type="checkbox"
- class="custom-control-input"
- id="thCloseSwitch"
- :checked="userAddress.isComplex"
- @change="selectionChanged"
- />
- <label class="custom-control-label" for="thCloseSwitch" style="margin-left: 40px">
- {{
- isComplex ? "Yes" : "No"
- }}
- </label>
- </div>
- </div>
- </div>
- <div class="row" style="text-align:left">
- <div class="col-md-4" style="margin-bottom: 1em">
- <button
- @click="ShowMap()"
- class="btn btn-b-n"
- type="button"
- data-dismiss="modal"
- >Update Address</button>
- </div>
- <div class="col-md-4" style="margin-bottom: 1em">
- <button
- @click="GetLocation()"
- class="btn btn-b-n"
- type="button"
- data-dismiss="modal"
- >Use My Location</button>
- </div>
- </div>
- <div v-if="userAddress.isComplex" class="row" style="text-align:left">
- <div class="col-md-6" style="margin-bottom: 1em">
- <label>Complex Name</label>
- <div class="input-group-prepend">
- <span class="input-group-text">
- <eva-icon name="person-outline" fill="#24aae1"></eva-icon>
- </span>
- <input
- class="form-control"
- type="text"
- name="FirstName"
- v-model="userAddress.complexName"
- />
- </div>
- </div>
- <div class="col-md-6" style="margin-bottom: 1em">
- <label>Unit Number</label>
- <div class="input-group-prepend">
- <span class="input-group-text">
- <eva-icon name="person-outline" fill="#24aae1"></eva-icon>
- </span>
- <input class="form-control" type="text" name="Surname" v-model="userAddress.unitNumber" />
- </div>
- </div>
- </div>
- <div class="row" style="text-align:left">
- <div class="col-md-6" style="margin-bottomL 1em">
- <div class="row" style="text-align:left">
- <div class="col-md-12" style="margin-bottom: 1em">
- <label>Street Number</label>
- <div class="input-group-prepend">
- <span class="input-group-text">
- <eva-icon name="person-outline" fill="#24aae1"></eva-icon>
- </span>
- <input
- class="form-control"
- type="text"
- name="FirstName"
- v-model="userAddress.streetNumber"
- disabled
- />
- </div>
- </div>
- </div>
- <div class="row" style="text-align:left">
- <div class="col-md-12" style="margin-bottom: 1em">
- <label>Street Name</label>
- <div class="input-group-prepend">
- <span class="input-group-text">
- <eva-icon name="person-outline" fill="#24aae1"></eva-icon>
- </span>
- <input
- class="form-control"
- type="text"
- name="FirstName"
- v-model="userAddress.streetName"
- disabled
- />
- </div>
- </div>
- </div>
- <div class="row" style="text-align:left">
- <div class="col-md-12" style="margin-bottom: 1em">
- <label>Suburb</label>
- <div class="input-group-prepend">
- <span class="input-group-text">
- <eva-icon name="person-outline" fill="#24aae1"></eva-icon>
- </span>
- <input
- class="form-control"
- type="text"
- name="FirstName"
- v-model="userAddress.suburb"
- disabled
- />
- </div>
- </div>
- </div>
- <div class="row" style="text-align:left">
- <div class="col-md-12" style="margin-bottom: 1em">
- <label>City</label>
- <div class="input-group-prepend">
- <span class="input-group-text">
- <eva-icon name="person-outline" fill="#24aae1"></eva-icon>
- </span>
- <input
- class="form-control"
- type="text"
- name="FirstName"
- v-model="userAddress.city"
- disabled
- />
- </div>
- </div>
- </div>
- <div class="row" style="text-align:left">
- <div class="col-md-12" style="margin-bottom: 1em">
- <label>Province</label>
- <div class="input-group-prepend">
- <span class="input-group-text">
- <eva-icon name="person-outline" fill="#24aae1"></eva-icon>
- </span>
- <input
- class="form-control"
- type="text"
- name="FirstName"
- v-model="userAddress.province"
- disabled
- />
- </div>
- </div>
- </div>
- <div class="row" style="text-align:left">
- <div class="col-md-12" style="margin-bottom: 1em">
- <label>Postal Code</label>
- <div class="input-group-prepend">
- <span class="input-group-text">
- <eva-icon name="person-outline" fill="#24aae1"></eva-icon>
- </span>
- <input
- class="form-control"
- type="text"
- name="FirstName"
- v-model="userAddress.postalCode"
- disabled
- />
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-md-4" style="margin-bottom: 1em">
- <button @click="Continue" class="btn btn-b-n" type="button">Use Above Address</button>
- </div>
- </div>
- </div>
- <div class="col-md-6" style="margin-bottomL 1em">
- <Map :showAutoComplete="false" :showLocationLabel="false" :setLocation="mapCoords" />
- </div>
- </div>
-
- <modal name="map" :width="600" :height="620">
- <div class="container">
- <h2>Update Location</h2>
- <br />
- <Map :showLocationLabel="false" @GoogleAddress="UpdateAddress" />
- <div class="row" style="text-align:left">
- <div class="col-md-4" style="margin-bottom: 1em">
- <button @click="HideMap()" class="btn btn-b-n" type="button" data-dismiss="modal">Close</button>
- </div>
- </div>
- </div>
- </modal>
- </div>
- </template>
-
- <script>
- import Map from "../../shared/mapSetLocation";
- import { mapState, mapActions } from "vuex";
- import Log from "../../../assets/Log";
-
- export default {
- name: "confirmAddress",
- components: {
- Map,
- },
- data() {
- return {
- varbla: false,
- };
- },
- methods: {
- ...mapActions("user", ["getUserAddress"]),
- selectionChanged() {
- this.userAddress.isComplex = !this.userAddress.isComplex;
- },
- ShowMap() {
- this.$modal.show("map");
- },
- HideMap() {
- this.$modal.hide("map");
- },
- GetLocation() {
- navigator.geolocation.getCurrentPosition((position) => {
- // this.center = {
- // lat: position.coords.latitude,
- // lng: position.coords.longitude,
- // };
- alert(JSON.stringify(position));
- });
- },
- Continue() {
- this.order.deliveryAddress = this.userAddress;
- this.order.items = this.cartItems;
- this.$emit("can-continue", { value: true });
- },
- UpdateAddress(address) {
- this.userAddress.streetNumber = address.streetNumber;
- this.userAddress.streetName = address.streetName;
- this.userAddress.suburb = address.suburb;
- this.userAddress.city = address.city;
- this.userAddress.province = address.province;
- this.userAddress.country = address.country;
- this.userAddress.postalCode = address.postalCode;
- this.userAddress.googleMapUrl = address.url;
- this.userAddress.latitude = address.coordinates.lat;
- this.userAddress.longitude = address.coordinates.lng;
- this.$emit("can-continue", { value: true });
- },
- },
- computed: {
- ...mapState("user", ["userAddress"]),
- ...mapState("cart", ["cartItems"]),
- ...mapState("order", ["order"]),
- mapCoords() {
- var coords = {
- lat: this.userAddress.latitude,
- lng: this.userAddress.longitude,
- };
- return coords;
- },
- CurrentPosition() {
- this.$getLocation(options).then((coordinates) => {
- alert(coordinates);
- });
- },
- },
- mounted() {
- this.getUserAddress(Log.userId());
- this.CurrentPosition();
- },
- };
- </script>
|