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.

confAddress.vue 8.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <template>
  2. <div class="container">
  3. <div class="row" style="text-align:left">
  4. <div class="col-md-4" style="margin-bottom: 1em">
  5. <div class="custom-control custom-switch">
  6. <label>Do you live in a complex or block of flats?</label>
  7. <input
  8. style="margin-left: 1px"
  9. type="checkbox"
  10. class="custom-control-input"
  11. id="thCloseSwitch"
  12. :checked="userAddress.isComplex"
  13. @change="selectionChanged"
  14. />
  15. <label class="custom-control-label" for="thCloseSwitch" style="margin-left: 40px">
  16. {{
  17. isComplex ? "Yes" : "No"
  18. }}
  19. </label>
  20. </div>
  21. </div>
  22. </div>
  23. <div class="row" style="text-align:left">
  24. <div class="col-md-4" style="margin-bottom: 1em">
  25. <button
  26. @click="ShowMap()"
  27. class="btn btn-b-n"
  28. type="button"
  29. data-dismiss="modal"
  30. >Update Address</button>
  31. </div>
  32. <div class="col-md-4" style="margin-bottom: 1em">
  33. <button
  34. @click="GetLocation()"
  35. class="btn btn-b-n"
  36. type="button"
  37. data-dismiss="modal"
  38. >Use My Location</button>
  39. </div>
  40. </div>
  41. <div v-if="userAddress.isComplex" class="row" style="text-align:left">
  42. <div class="col-md-6" style="margin-bottom: 1em">
  43. <label>Complex Name</label>
  44. <div class="input-group-prepend">
  45. <span class="input-group-text">
  46. <eva-icon name="person-outline" fill="#24aae1"></eva-icon>
  47. </span>
  48. <input
  49. class="form-control"
  50. type="text"
  51. name="FirstName"
  52. v-model="userAddress.complexName"
  53. />
  54. </div>
  55. </div>
  56. <div class="col-md-6" style="margin-bottom: 1em">
  57. <label>Unit Number</label>
  58. <div class="input-group-prepend">
  59. <span class="input-group-text">
  60. <eva-icon name="person-outline" fill="#24aae1"></eva-icon>
  61. </span>
  62. <input class="form-control" type="text" name="Surname" v-model="userAddress.unitNumber" />
  63. </div>
  64. </div>
  65. </div>
  66. <div class="row" style="text-align:left">
  67. <div class="col-md-6" style="margin-bottomL 1em">
  68. <div class="row" style="text-align:left">
  69. <div class="col-md-12" style="margin-bottom: 1em">
  70. <label>Street Number</label>
  71. <div class="input-group-prepend">
  72. <span class="input-group-text">
  73. <eva-icon name="person-outline" fill="#24aae1"></eva-icon>
  74. </span>
  75. <input
  76. class="form-control"
  77. type="text"
  78. name="FirstName"
  79. v-model="userAddress.streetNumber"
  80. disabled
  81. />
  82. </div>
  83. </div>
  84. </div>
  85. <div class="row" style="text-align:left">
  86. <div class="col-md-12" style="margin-bottom: 1em">
  87. <label>Street Name</label>
  88. <div class="input-group-prepend">
  89. <span class="input-group-text">
  90. <eva-icon name="person-outline" fill="#24aae1"></eva-icon>
  91. </span>
  92. <input
  93. class="form-control"
  94. type="text"
  95. name="FirstName"
  96. v-model="userAddress.streetName"
  97. disabled
  98. />
  99. </div>
  100. </div>
  101. </div>
  102. <div class="row" style="text-align:left">
  103. <div class="col-md-12" style="margin-bottom: 1em">
  104. <label>Suburb</label>
  105. <div class="input-group-prepend">
  106. <span class="input-group-text">
  107. <eva-icon name="person-outline" fill="#24aae1"></eva-icon>
  108. </span>
  109. <input
  110. class="form-control"
  111. type="text"
  112. name="FirstName"
  113. v-model="userAddress.suburb"
  114. disabled
  115. />
  116. </div>
  117. </div>
  118. </div>
  119. <div class="row" style="text-align:left">
  120. <div class="col-md-12" style="margin-bottom: 1em">
  121. <label>City</label>
  122. <div class="input-group-prepend">
  123. <span class="input-group-text">
  124. <eva-icon name="person-outline" fill="#24aae1"></eva-icon>
  125. </span>
  126. <input
  127. class="form-control"
  128. type="text"
  129. name="FirstName"
  130. v-model="userAddress.city"
  131. disabled
  132. />
  133. </div>
  134. </div>
  135. </div>
  136. <div class="row" style="text-align:left">
  137. <div class="col-md-12" style="margin-bottom: 1em">
  138. <label>Province</label>
  139. <div class="input-group-prepend">
  140. <span class="input-group-text">
  141. <eva-icon name="person-outline" fill="#24aae1"></eva-icon>
  142. </span>
  143. <input
  144. class="form-control"
  145. type="text"
  146. name="FirstName"
  147. v-model="userAddress.province"
  148. disabled
  149. />
  150. </div>
  151. </div>
  152. </div>
  153. <div class="row" style="text-align:left">
  154. <div class="col-md-12" style="margin-bottom: 1em">
  155. <label>Postal Code</label>
  156. <div class="input-group-prepend">
  157. <span class="input-group-text">
  158. <eva-icon name="person-outline" fill="#24aae1"></eva-icon>
  159. </span>
  160. <input
  161. class="form-control"
  162. type="text"
  163. name="FirstName"
  164. v-model="userAddress.postalCode"
  165. disabled
  166. />
  167. </div>
  168. </div>
  169. </div>
  170. <div class="row">
  171. <div class="col-md-4" style="margin-bottom: 1em">
  172. <button @click="Continue" class="btn btn-b-n" type="button">Use Above Address</button>
  173. </div>
  174. </div>
  175. </div>
  176. <div class="col-md-6" style="margin-bottomL 1em">
  177. <Map :showAutoComplete="false" :showLocationLabel="false" :setLocation="mapCoords" />
  178. </div>
  179. </div>
  180. <modal name="map" :width="600" :height="620">
  181. <div class="container">
  182. <h2>Update Location</h2>
  183. <br />
  184. <Map :showLocationLabel="false" @GoogleAddress="UpdateAddress" />
  185. <div class="row" style="text-align:left">
  186. <div class="col-md-4" style="margin-bottom: 1em">
  187. <button @click="HideMap()" class="btn btn-b-n" type="button" data-dismiss="modal">Close</button>
  188. </div>
  189. </div>
  190. </div>
  191. </modal>
  192. </div>
  193. </template>
  194. <script>
  195. import Map from "../../shared/mapSetLocation";
  196. import { mapState, mapActions } from "vuex";
  197. import Log from "../../../assets/Log";
  198. export default {
  199. name: "confirmAddress",
  200. components: {
  201. Map,
  202. },
  203. data() {
  204. return {
  205. varbla: false,
  206. };
  207. },
  208. methods: {
  209. ...mapActions("user", ["getUserAddress"]),
  210. selectionChanged() {
  211. this.userAddress.isComplex = !this.userAddress.isComplex;
  212. },
  213. ShowMap() {
  214. this.$modal.show("map");
  215. },
  216. HideMap() {
  217. this.$modal.hide("map");
  218. },
  219. GetLocation() {
  220. navigator.geolocation.getCurrentPosition((position) => {
  221. // this.center = {
  222. // lat: position.coords.latitude,
  223. // lng: position.coords.longitude,
  224. // };
  225. alert(JSON.stringify(position));
  226. });
  227. },
  228. Continue() {
  229. this.order.deliveryAddress = this.userAddress;
  230. this.order.items = this.cartItems;
  231. this.$emit("can-continue", { value: true });
  232. },
  233. UpdateAddress(address) {
  234. this.userAddress.streetNumber = address.streetNumber;
  235. this.userAddress.streetName = address.streetName;
  236. this.userAddress.suburb = address.suburb;
  237. this.userAddress.city = address.city;
  238. this.userAddress.province = address.province;
  239. this.userAddress.country = address.country;
  240. this.userAddress.postalCode = address.postalCode;
  241. this.userAddress.googleMapUrl = address.url;
  242. this.userAddress.latitude = address.coordinates.lat;
  243. this.userAddress.longitude = address.coordinates.lng;
  244. this.$emit("can-continue", { value: true });
  245. },
  246. },
  247. computed: {
  248. ...mapState("user", ["userAddress"]),
  249. ...mapState("cart", ["cartItems"]),
  250. ...mapState("order", ["order"]),
  251. mapCoords() {
  252. var coords = {
  253. lat: this.userAddress.latitude,
  254. lng: this.userAddress.longitude,
  255. };
  256. return coords;
  257. },
  258. CurrentPosition() {
  259. this.$getLocation(options).then((coordinates) => {
  260. alert(coordinates);
  261. });
  262. },
  263. },
  264. mounted() {
  265. this.getUserAddress(Log.userId());
  266. this.CurrentPosition();
  267. },
  268. };
  269. </script>