get-system-setting.uvue 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <page-head :title="title"></page-head>
  3. <view class="uni-common-mt">
  4. <view class="uni-list">
  5. <view class="uni-list-cell">
  6. <view class="uni-pd">
  7. <view class="uni-label" style="width:180px;">蓝牙的系统开关</view>
  8. </view>
  9. <view class="uni-list-cell-db">
  10. <input type="text" :disabled="true" placeholder="未获取" :value="bluetoothEnabled" />
  11. </view>
  12. </view>
  13. <view class="uni-list-cell">
  14. <view class="uni-pd">
  15. <view class="uni-label" style="width:180px;">地理位置的系统开关</view>
  16. </view>
  17. <view class="uni-list-cell-db">
  18. <input type="text" :disabled="true" placeholder="未获取" :value="locationEnabled" />
  19. </view>
  20. </view>
  21. <view class="uni-list-cell">
  22. <view class="uni-pd">
  23. <view class="uni-label" style="width:180px;">Wi-Fi 的系统开关</view>
  24. </view>
  25. <view class="uni-list-cell-db">
  26. <input type="text" :disabled="true" placeholder="未获取" :value="wifiEnabled" />
  27. </view>
  28. </view>
  29. <view class="uni-list-cell">
  30. <view class="uni-pd">
  31. <view class="uni-label" style="width:180px;">设备方向</view>
  32. </view>
  33. <view class="uni-list-cell-db">
  34. <input type="text" :disabled="true" placeholder="未获取" :value="deviceOrientation" />
  35. </view>
  36. </view>
  37. </view>
  38. <view class="uni-padding-wrap">
  39. <view class="uni-btn-v">
  40. <button type="primary" @tap="getSystemSetting">获取系统设置</button>
  41. </view>
  42. </view>
  43. </view>
  44. </template>
  45. <script>
  46. export default {
  47. data() {
  48. return {
  49. title: 'getSystemSetting',
  50. bluetoothEnabled: "",
  51. locationEnabled: "",
  52. wifiEnabled: "",
  53. deviceOrientation: ""
  54. }
  55. },
  56. onUnload: function () {
  57. },
  58. methods: {
  59. getSystemSetting: function () {
  60. const res = uni.getSystemSetting();
  61. this.bluetoothEnabled = (res.bluetoothEnabled ?? false) ? "开启" : "关闭";
  62. this.locationEnabled = res.locationEnabled ? "开启" : "关闭";
  63. this.wifiEnabled = (res.wifiEnabled ?? false) ? "开启" : "关闭";
  64. this.deviceOrientation = res.deviceOrientation
  65. if (res.bluetoothError != null) {
  66. this.bluetoothEnabled = "无蓝牙权限"
  67. }
  68. if (res.wifiError != null) {
  69. this.wifiEnabled = "无WiFi权限"
  70. }
  71. }
  72. }
  73. }
  74. </script>
  75. <style>
  76. .uni-pd {
  77. padding-left: 15px;
  78. }
  79. </style>