get-system-setting.uvue 2.5 KB
Newer Older
1
<template>
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
2 3 4 5 6 7
  <page-head :title="title"></page-head>
  <view class="uni-common-mt">
    <view class="uni-list">
      <view class="uni-list-cell">
        <view class="uni-pd">
          <view class="uni-label" style="width:180px;">蓝牙的系统开关</view>
H
hdx 已提交
8
        </view>
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
9 10
        <view class="uni-list-cell-db">
          <input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="bluetoothEnabled" />
H
hdx 已提交
11
        </view>
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
12 13 14 15 16 17 18 19 20 21 22 23
      </view>
      <view class="uni-list-cell">
        <view class="uni-pd">
          <view class="uni-label" style="width:180px;">地理位置的系统开关</view>
        </view>
        <view class="uni-list-cell-db">
          <input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="locationEnabled" />
        </view>
      </view>
      <view class="uni-list-cell">
        <view class="uni-pd">
          <view class="uni-label" style="width:180px;">Wi-Fi 的系统开关</view>
H
hdx 已提交
24
        </view>
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
25 26
        <view class="uni-list-cell-db">
          <input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="wifiEnabled" />
H
hdx 已提交
27 28
        </view>
      </view>
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
29 30 31
      <view class="uni-list-cell">
        <view class="uni-pd">
          <view class="uni-label" style="width:180px;">设备方向</view>
H
hdx 已提交
32
        </view>
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
33 34 35 36 37 38 39 40
        <view class="uni-list-cell-db">
          <input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="deviceOrientation" />
        </view>
      </view>
    </view>
    <view class="uni-padding-wrap">
      <view class="uni-btn-v">
        <button type="primary" @tap="getSystemSetting">获取系统设置</button>
H
hdx 已提交
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
      </view>
    </view>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        title: 'getSystemSetting',
        bluetoothEnabled: "",
        locationEnabled: "",
        wifiEnabled: "",
        deviceOrientation: ""
      }
    },
    onUnload: function () {
    },
    methods: {
      getSystemSetting: function () {
        const res = uni.getSystemSetting();
        this.bluetoothEnabled = (res.bluetoothEnabled ?? false) ? "开启" : "关闭";
        this.locationEnabled = res.locationEnabled ? "开启" : "关闭";
        this.wifiEnabled = (res.wifiEnabled ?? false) ? "开启" : "关闭";
        this.deviceOrientation = res.deviceOrientation
      }
    }
  }
69 70 71
</script>

<style>
H
hdx 已提交
72 73 74 75
  .uni-pd {
    padding-left: 15px;
  }
</style>