open-location.uvue 2.5 KB
Newer Older
1
<template>
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
  <view>
    <page-head :title="title"></page-head>
    <view class="uni-common-mt">
      <form @submit="openLocation">
        <view class="uni-list">
          <view class="uni-list-cell">
            <view class="uni-list-cell-left">
              <view class="uni-label">经度</view>
            </view>
            <view class="uni-list-cell-db">
              <input class="uni-input" type="text" :disabled="true" value="116.39747" name="longitude" />
            </view>
          </view>
          <view class="uni-list-cell">
            <view class="uni-list-cell-left">
              <view class="uni-label">纬度</view>
            </view>
            <view class="uni-list-cell-db">
              <input class="uni-input" type="text" :disabled="true" value="39.9085" name="latitude" />
            </view>
          </view>
          <view class="uni-list-cell">
            <view class="uni-list-cell-left">
              <view class="uni-label">位置名称</view>
            </view>
            <view class="uni-list-cell-db">
              <input class="uni-input" type="text" :disabled="true" value="天安门" name="name" />
            </view>
          </view>
          <view class="uni-list-cell">
            <view class="uni-list-cell-left">
              <view class="uni-label">详细位置</view>
            </view>
            <view class="uni-list-cell-db">
              <input class="uni-input" type="text" :disabled="true" value="北京市东城区东长安街" name="address" />
            </view>
          </view>
        </view>
        <view class="uni-padding-wrap">
          <view class="tips">注意:需要正确配置地图服务商的Key才能正常显示位置</view>
          <view class="uni-btn-v uni-common-mt">
            <button type="primary" formType="submit">查看位置</button>
          </view>
        </view>
      </form>
    </view>
  </view>
49 50
</template>
<script lang="uts">
51
  export default {
DCloud-WZF's avatar
DCloud-WZF 已提交
52
    data() {
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
      return {
        title: 'openLocation'
      }
    },
    methods: {
      openLocation: function (e) {
        console.log(e)
        var value = e.detail.value
        uni.openLocation({
          longitude: Number(value.longitude),
          latitude: Number(value.latitude),
          name: value.name,
          address: value.address
        })
      }
    }
  }
70 71 72
</script>

<style>
73 74 75 76 77 78 79 80 81
  .uni-list-cell-left {
    padding: 0 30rpx;
  }

  .tips {
    font-size: 12px;
    margin-top: 15px;
    opacity: .8;
  }
82
</style>