

English
获取系统设置
Type |
---|
GetSystemSettingResult |
name | type | optinal | default | description |
---|---|---|---|---|
bluetoothEnabled | boolean | NO | - | 蓝牙是否开启 |
bluetoothError | string | NO | - | 蓝牙的报错信息 |
locationEnabled | boolean | YES | - | 位置是否开启 |
wifiEnabled | boolean | NO | - | wifi是否开启 |
wifiError | string | NO | - | wifi的报错信息 |
deviceOrientation | string | YES | - | 设备方向 |
Android version | Android uni-app | Android uni-app-x | iOS version | iOS uni-app | iOS uni-app-x |
---|---|---|---|---|---|
4.4 | √ | 3.9+ | 9.0 | √ | 3.9+ |
<template>
<view>
<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>
</view>
<view class="uni-list-cell-db">
<input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="bluetoothEnabled"/>
</view>
</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>
</view>
<view class="uni-list-cell-db">
<input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="wifiEnabled"/>
</view>
</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="deviceOrientation"/>
</view>
</view>
</view>
<view class="uni-padding-wrap">
<view class="uni-btn-v">
<button type="primary" @tap="getSystemSetting">获取系统设置</button>
</view>
</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
}
}
}
</script>
<style>
.uni-pd {
padding-left: 30rpx;
}
</style>
name | type | optinal | default | description |
---|---|---|---|---|
errMsg | string | YES | - | 错误信息 |