home.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <template>
  2. <view class="home-page">
  3. <gf-yinsi @handleAgree="handleAgree"></gf-yinsi>
  4. </view>
  5. </template>
  6. <script>
  7. export default {
  8. data() {
  9. return {
  10. }
  11. },
  12. onLoad() {
  13. },
  14. methods: {
  15. handleAgree(e) {
  16. uni.switchTab({
  17. url: "/pages/index/index"
  18. })
  19. if (uni.getStorageSync("city") && uni.getStorageSync("city").city_id) {
  20. this.$store.commit('setdefaultcity', uni.getStorageSync("city"))
  21. } else {
  22. this.$amapPlugin.getRegeo({
  23. success: (res) => {
  24. //成功回调
  25. // console.log(res[0]);
  26. this.$store.commit('setcity', {
  27. city: res[0].regeocodeData.addressComponent.city,
  28. userLocation: `${res[0].longitude},${res[0].latitude}`,
  29. city_id: '',
  30. province_id: '',
  31. })
  32. },
  33. fail: (info) => {
  34. //失败回调
  35. // console.log(info)
  36. this.$store.commit('setcity', {
  37. city: '温州市',
  38. userLocation: '120.699279,27.993849',
  39. city_id: 2,
  40. province_id: 1
  41. })
  42. }
  43. })
  44. }
  45. },
  46. }
  47. }
  48. </script>
  49. <style lang="scss">
  50. .home-page {}
  51. </style>