get-app-authorize-setting.uvue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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="albumAuthorized" />
  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="bluetoothAuthorized" />
  19. </view>
  20. </view>
  21. <view class="uni-list-cell">
  22. <view class="uni-pd">
  23. <view class="uni-label" style="width:180px;">是否授权使用摄像头</view>
  24. </view>
  25. <view class="uni-list-cell-db">
  26. <input type="text" :disabled="true" placeholder="未获取" :value="cameraAuthorized" />
  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="locationAuthorized" />
  35. </view>
  36. </view>
  37. <view class="uni-list-cell">
  38. <view class="uni-pd">
  39. <view class="uni-label" style="width:180px;">定位准确度</view>
  40. </view>
  41. <view class="uni-list-cell-db">
  42. <input type="text" :disabled="true" placeholder="未获取" :value="locationAccuracy" />
  43. </view>
  44. </view>
  45. <view class="uni-list-cell">
  46. <view class="uni-pd">
  47. <view class="uni-label" style="width:180px;">是否授权使用麦克风</view>
  48. </view>
  49. <view class="uni-list-cell-db">
  50. <input type="text" :disabled="true" placeholder="未获取" :value="microphoneAuthorized" />
  51. </view>
  52. </view>
  53. <view class="uni-list-cell">
  54. <view class="uni-pd">
  55. <view class="uni-label" style="width:180px;">是否授权通知</view>
  56. </view>
  57. <view class="uni-list-cell-db">
  58. <input type="text" :disabled="true" placeholder="未获取" :value="notificationAuthorized" />
  59. </view>
  60. </view>
  61. <!-- #ifdef APP-IOS -->
  62. <view class="uni-list-cell">
  63. <view class="uni-pd">
  64. <view class="uni-label" style="width:180px;">是否允许通知带有提醒</view>
  65. </view>
  66. <view class="uni-list-cell-db">
  67. <input type="text" :disabled="true" placeholder="未获取" :value="notificationAlertAuthorized" />
  68. </view>
  69. </view>
  70. <view class="uni-list-cell">
  71. <view class="uni-pd">
  72. <view class="uni-label" style="width:180px;">是否允许通知带有标记</view>
  73. </view>
  74. <view class="uni-list-cell-db">
  75. <input type="text" :disabled="true" placeholder="未获取" :value="notificationBadgeAuthorized" />
  76. </view>
  77. </view>
  78. <view class="uni-list-cell">
  79. <view class="uni-pd">
  80. <view class="uni-label" style="width:180px;">是否允许通知带有声音</view>
  81. </view>
  82. <view class="uni-list-cell-db">
  83. <input type="text" :disabled="true" placeholder="未获取" :value="notificationSoundAuthorized" />
  84. </view>
  85. </view>
  86. <!-- #endif -->
  87. </view>
  88. <view class="uni-padding-wrap">
  89. <view class="uni-btn-v">
  90. <button type="primary" @tap="getAppAuthorizeSetting">获取App授权设置</button>
  91. </view>
  92. </view>
  93. </view>
  94. </template>
  95. <script>
  96. export default {
  97. data() {
  98. return {
  99. title: 'getAppAuthorizeSetting',
  100. cameraAuthorized: "",
  101. albumAuthorized: "",
  102. locationAuthorized: "",
  103. locationAccuracy: "",
  104. microphoneAuthorized: "",
  105. bluetoothAuthorized: "",
  106. notificationAuthorized: "",
  107. notificationAlertAuthorized: "",
  108. notificationBadgeAuthorized: "",
  109. notificationSoundAuthorized: ""
  110. }
  111. },
  112. onUnload: function () {
  113. },
  114. methods: {
  115. getAppAuthorizeSetting: function () {
  116. const res = uni.getAppAuthorizeSetting();
  117. this.albumAuthorized = res.albumAuthorized;
  118. this.bluetoothAuthorized = res.bluetoothAuthorized;
  119. this.cameraAuthorized = res.cameraAuthorized;
  120. this.locationAuthorized = res.locationAuthorized;
  121. this.locationAccuracy = res.locationAccuracy ?? "unsupported";
  122. this.microphoneAuthorized = res.microphoneAuthorized;
  123. this.notificationAuthorized = res.notificationAuthorized;
  124. // #ifdef APP-IOS
  125. this.notificationAlertAuthorized = res.notificationAlertAuthorized;
  126. this.notificationBadgeAuthorized = res.notificationBadgeAuthorized;
  127. this.notificationSoundAuthorized = res.notificationSoundAuthorized;
  128. // #endif
  129. }
  130. }
  131. }
  132. </script>
  133. <style>
  134. .uni-pd {
  135. padding-left: 15px;
  136. }
  137. </style>