get-system-setting.uvue 2.6 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
        <view class="uni-list-cell-db">
10
          <input type="text" :disabled="true" placeholder="未获取" :value="bluetoothEnabled" />
H
hdx 已提交
11
        </view>
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
12 13 14 15 16 17
      </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">
18
          <input type="text" :disabled="true" placeholder="未获取" :value="locationEnabled" />
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
19 20 21 22 23
        </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
        <view class="uni-list-cell-db">
26
          <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
        <view class="uni-list-cell-db">
34
          <input type="text" :disabled="true" placeholder="未获取" :value="deviceOrientation" />
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
35 36 37 38 39 40
        </view>
      </view>
    </view>
    <view class="uni-padding-wrap">
      <view class="uni-btn-v">
        <button type="primary" @tap="getSystemSetting">获取系统设置</button>
H
hdx 已提交
41 42 43
      </view>
    </view>
  </view>
DCloud-WZF's avatar
DCloud-WZF 已提交
44
</template>
H
hdx 已提交
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64

<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) ? "开启" : "关闭";
DCloud-WZF's avatar
DCloud-WZF 已提交
65 66 67 68 69 70 71 72 73
        this.deviceOrientation = res.deviceOrientation

        if (res.bluetoothError != null) {
          this.bluetoothEnabled = "无蓝牙权限"
        }

        if (res.wifiError != null) {
          this.wifiEnabled = "无WiFi权限"
        }
H
hdx 已提交
74 75 76
      }
    }
  }
77 78 79
</script>

<style>
H
hdx 已提交
80 81 82 83
  .uni-pd {
    padding-left: 15px;
  }
</style>