wk-field-location.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template>
  2. <view class="wk-field wk-field-location" @click.stop="handleToLocation">
  3. <view v-if="_label" class="wk-field__label">
  4. <view v-if="field.isNull === 1" class="line" />
  5. {{ _label }}
  6. </view>
  7. <view class="wk-field__body">
  8. <view class="wk-field__body-core">
  9. {{ valueStr }}
  10. </view>
  11. <text class="wk wk-position icon-right" />
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. import mixins from './mixins'
  17. import {
  18. bMapTransQQMap,
  19. qqMapTransBMap,
  20. getLocation
  21. } from '@/utils/map.js'
  22. export default {
  23. name: 'WkFieldLocation',
  24. mixins: [mixins],
  25. data() {
  26. return {
  27. guid: null,
  28. locationPoint: {}
  29. }
  30. },
  31. computed: {
  32. valueStr() {
  33. return this.formValue ? (this.formValue.address || '') : ''
  34. }
  35. },
  36. created() {
  37. this.guid = this.$guid()
  38. },
  39. methods: {
  40. handleToLocation() {
  41. if (this.field.disabled) {
  42. if (this.config && this.config.disabledMsg) {
  43. this.$toast(this.config.disabledMsg)
  44. }
  45. return
  46. }
  47. uni.$once('choose-address', this.chooseAddress)
  48. this.$Router.navigateTo({
  49. url: '/pages_common/map/chooseAddress'
  50. })
  51. },
  52. chooseAddress(data) {
  53. const point = qqMapTransBMap(data.longitude, data.latitude)
  54. this.formValue = {
  55. lng: point.longitude,
  56. lat: point.latitude,
  57. address: data.addr || data.address || '',
  58. }
  59. console.log(this.formValue)
  60. this.$emit('input', this.formValue)
  61. this.$emit('change', {
  62. index: this.index,
  63. field: this.field,
  64. value: this.formValue
  65. })
  66. }
  67. }
  68. }
  69. </script>
  70. <style scoped lang="scss">
  71. @import './wkField.scss';
  72. .wk-field-location {
  73. .wk-field__body {
  74. .icon-right {
  75. font-size: $wk-font-large;
  76. }
  77. }
  78. }
  79. </style>