open-location.uvue 2.6 KB
Newer Older
DCloud-WZF's avatar
DCloud-WZF 已提交
1 2 3 4 5 6 7 8 9 10 11
<template>
  <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">
VK1688's avatar
VK1688 已提交
12
              <input v-model.number="longitude" class="uni-input" type="text" :disabled="true" />
DCloud-WZF's avatar
DCloud-WZF 已提交
13 14 15 16 17 18 19
            </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">
VK1688's avatar
VK1688 已提交
20
              <input v-model.number="latitude" class="uni-input" type="text" :disabled="true" />
DCloud-WZF's avatar
DCloud-WZF 已提交
21 22 23 24 25 26 27
            </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">
VK1688's avatar
VK1688 已提交
28
              <input v-model="name" class="uni-input" type="text" :disabled="true" />
DCloud-WZF's avatar
DCloud-WZF 已提交
29 30 31 32 33 34 35
            </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">
VK1688's avatar
VK1688 已提交
36
              <input v-model="address" class="uni-input" type="text" :disabled="true" />
DCloud-WZF's avatar
DCloud-WZF 已提交
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
            </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>
</template>
<script lang="uts">
  export default {
    data() {
      return {
VK1688's avatar
VK1688 已提交
54 55 56 57 58
        title: 'openLocation',
        longitude: 116.39747,
        latitude: 39.9085,
        name: '天安门',
        address: '北京市东城区东长安街'
DCloud-WZF's avatar
DCloud-WZF 已提交
59 60
      }
    },
61 62 63
    onHide() {
      console.log("Page Hide");
    },
DCloud-WZF's avatar
DCloud-WZF 已提交
64
    methods: {
VK1688's avatar
VK1688 已提交
65
      openLocation: function () {
DCloud-WZF's avatar
DCloud-WZF 已提交
66
        uni.openLocation({
VK1688's avatar
VK1688 已提交
67 68 69 70
          longitude: this.longitude,
          latitude: this.latitude,
          name: this.name,
          address: this.address
DCloud-WZF's avatar
DCloud-WZF 已提交
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
        })
      }
    }
  }
</script>

<style>
  .uni-list-cell-left {
    padding: 0 30rpx;
  }

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