AndroidUnlockAuth.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <u-popup v-model="showDialog" mode="bottom" border-radius="28" @close="close">
  3. <view class="dialog-content">
  4. <view class="title">{{ $t('开启感应解锁') }}</view>
  5. <view class="tips">
  6. 为保证 感应解锁 的正常使用,请依次开以下权限,开启后可以显著提高解锁成功率,且不会明显增加手机电量消耗
  7. </view>
  8. <view class="authorization-wrap">
  9. <view class="corner-mark">{{ $t('授权引导') }}</view>
  10. <view class="step-item-container">
  11. <view v-for="(item, idx) in authStepList" :key="idx" @tap="enablePermissions(item)" class="step-item">
  12. <view :class="['icon', `icon_${item.type}`]" />
  13. <view class="desc-wrap">
  14. <view class="title-row">
  15. <view class="title">{{ item.title }}</view>
  16. <view :class="['turn-on-switch', item.state && 'is-open']">
  17. {{ item.state ? $t('已开启') : $t('未开启') }}
  18. </view>
  19. </view>
  20. <view class="desc">{{ item.desc }}</view>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="btn" @tap="linkTo">{{ $t('我已开启') }}</view>
  26. </view>
  27. </u-popup>
  28. </template>
  29. <script>
  30. var app = getApp();
  31. var bluetooth = require('@/common/bluetooth.js');
  32. var common = require('@/common/common.js');
  33. import permision from "@/js_sdk/wa-permission/permission.js"
  34. export default {
  35. props: {
  36. value: {
  37. type: Boolean,
  38. default: false
  39. }
  40. },
  41. created(){
  42. // bluetooth.initBluetooth()
  43. // this.bluetoothClose()
  44. },
  45. data() {
  46. return {
  47. showDialog: this.value,
  48. permisionCheckObj: {},
  49. authStepList:[],
  50. isOpenAllPermission:false,//是否打开所有需要权限
  51. }
  52. },
  53. // computed: {
  54. // authStepList() {
  55. // const lang = v => this.$t(v)
  56. // return [
  57. // { title: ('位置权限'), type: 'location', desc: '打开手机定位,并运行APP始终使用' },
  58. // { title: ('电池优化'), type: 'battery', desc: '打开电池优化设置, 将弗兰克APP加入保护名单' },
  59. // // { title: ('后台运行'), type: 'backstage', desc: '打开后台运行权限 清选择手动控制' },
  60. // // { title: ('打开应用锁'), type: 'appLock', desc: '打开应用权限锁' }
  61. // ]
  62. // }
  63. // },
  64. watch: {
  65. value(newValue) {
  66. this.showDialog = newValue
  67. if (newValue) {
  68. this._initCheckdPermission()
  69. }
  70. }
  71. },
  72. methods: {
  73. async _initCheckdPermission() {
  74. this.authStepList=app.globalData.permissionArr
  75. },
  76. // vue的method里编写如下代码
  77. async requestAndroidPermission(permisionID) {
  78. const AUTHORIZ = 1 // 已授权
  79. const result = await permision.requestAndroidPermission(permisionID)
  80. console.log(123456, result)
  81. return result == AUTHORIZ
  82. // var strStatus
  83. // if (result == 1) {
  84. // strStatus = "已获得授权"
  85. // } else if (result == 0) {
  86. // strStatus = "未获得授权"
  87. // } else {
  88. // strStatus = "被永久拒绝权限"
  89. // }
  90. // permision.gotoAppPermissionSetting()
  91. // uni.showModal({
  92. // content: permisionID + strStatus,
  93. // showCancel: false
  94. // });
  95. },
  96. enablePermissions({ type }) {
  97. console.log(type,'type');
  98. // if (!this.permisionCheckObj[type]) {
  99. // permision.gotoAppPermissionSetting()
  100. // }
  101. },
  102. linkTo() {
  103. uni.navigateTo({ url: '/pages/bluetoothUnlock/bluetoothPair' })
  104. // if (!this.isOpenAllPermission) {
  105. // this.close()
  106. // uni.navigateTo({ url: '/pages/bluetoothUnlock/bluetoothPair' })
  107. // } else {
  108. // permision.gotoAppPermissionSetting()
  109. // }
  110. },
  111. close() {
  112. this.$emit('input', false)
  113. },
  114. bluetoothClose: function() {
  115. bluetooth.closeBluetoothAdapter();
  116. bluetooth.closeDevice(
  117. "900000997",
  118. () => {
  119. // this.setData({
  120. // bt_loading: false
  121. // });
  122. },
  123. () => {}
  124. );
  125. bluetooth.offCharacteristicStateChange("900000997", 'home');
  126. bluetooth.offConnectionStateChange("900000997", 'home');
  127. },
  128. }
  129. }
  130. </script>
  131. <style lang="scss" scoped>
  132. .dialog-content {
  133. width: 100%;
  134. height: 100%;
  135. background: #F1F3F4;
  136. padding: 40rpx 32rpx;
  137. .title {
  138. font-family: PingFangSC, PingFang SC;
  139. font-weight: 600;
  140. font-size: 40rpx;
  141. color: #060809;
  142. }
  143. .tips {
  144. font-family: PingFangSC, PingFang SC;
  145. font-weight: 400;
  146. font-size: 24rpx;
  147. color: #828DA2;
  148. line-height: 40rpx;
  149. margin: 32rpx 0 40rpx;
  150. }
  151. .authorization-wrap {
  152. background: #fff;
  153. width: 100%;
  154. border-radius: 40rpx;
  155. position: relative;
  156. .corner-mark {
  157. width: 224rpx;
  158. height: 100rpx;
  159. background: #0A59F7;
  160. border-radius: 40rpx 0 0 0;
  161. display: flex;
  162. color: #fff;
  163. line-height: 86rpx;
  164. text-align: center;
  165. justify-content: flex-end;
  166. &::after {
  167. content: "";
  168. width: 86rpx;
  169. height: 80rpx;
  170. background: url('https://qiniu.bms16.com/FibAaPERzqi6m95EP2jREUKixjUi');
  171. background-size: 100%;
  172. }
  173. }
  174. .step-item-container {
  175. background: #fff;
  176. border-top-left-radius: 40rpx;
  177. padding: 30rpx 24rpx;
  178. margin-top: -24rpx;
  179. }
  180. .step-item {
  181. width: 100%;
  182. background: #F4F5F6;
  183. border-radius: 24rpx;
  184. padding: 32rpx 28rpx;
  185. margin-bottom: 24rpx;
  186. display: flex;
  187. align-items: center;
  188. &:last-child {
  189. margin-bottom: 0;
  190. }
  191. .desc-wrap {
  192. flex: 1;
  193. margin-left: 24rpx;
  194. }
  195. .title-row {
  196. display: flex;
  197. justify-content: space-between;
  198. margin-bottom: 24rpx;
  199. .title {
  200. font-family: PingFangSC, PingFang SC;
  201. font-weight: 500;
  202. font-size: 32rpx;
  203. color: #060809;
  204. font-weight: bold;
  205. }
  206. .turn-on-switch {
  207. background: #FF791A;
  208. border-radius: 20rpx;
  209. font-size: 22rpx;
  210. color: #FFFFFF;
  211. display: flex;
  212. align-items: center;
  213. justify-content: center;
  214. padding: 8rpx 20rpx;
  215. &.is-open {
  216. background: #2ADA62;
  217. }
  218. }
  219. }
  220. .desc {
  221. font-size: 24rpx;
  222. color: #060809;
  223. }
  224. .icon {
  225. width: 66rpx;
  226. height: 70rpx;
  227. }
  228. .icon_location {
  229. background: url('https://qiniu.bms16.com/FpNU0wp-E5Iin60nT8_NwT1_h_xm');
  230. background-size: 100% 100%;
  231. }
  232. .icon_battery {
  233. background: url('https://qiniu.bms16.com/FjD4CXHuNUL85_JYI7w2MDucjeI-');
  234. background-size: 100% 100%;
  235. }
  236. .icon_backstage {
  237. background: url('https://qiniu.bms16.com/Fo7RGbv1gokn1iUQpF8tca5aUWkD');
  238. background-size: 100% 100%;
  239. }
  240. .icon_appLock {
  241. background: url('https://qiniu.bms16.com/FoWg_FjfV5_v9fxvFQ2dHzXOCDPD');
  242. background-size: 100% 100%;
  243. }
  244. }
  245. }
  246. .btn {
  247. margin-top: 40rpx;
  248. width: 100%;
  249. height: 80rpx;
  250. background: #060809;
  251. border-radius: 40rpx;
  252. color: #fff;
  253. display: flex;
  254. align-items: center;
  255. justify-content: center;
  256. font-family: PingFangSC, PingFang SC;
  257. font-weight: 500;
  258. font-size: 32rpx;
  259. &:active {
  260. opacity: 0.8;
  261. }
  262. }
  263. }
  264. </style>