index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. <template>
  2. <view class="cirumstances_wrap">
  3. <u-navbar placeholder :autoBack="true" title="环境监测" v-hideNav>
  4. <view class="u-nav-slot right_btn" slot="right">
  5. <view class="reset" @click="handleReset">
  6. <u-icon name="reload" color="#108CFF"></u-icon>刷新
  7. </view>
  8. </view>
  9. </u-navbar>
  10. <view class="option_list">
  11. <view class="option_item">
  12. <view class="item_left">
  13. <text class="label">登录用户</text>
  14. </view>
  15. <view class="item-right">
  16. <text>{{ nickName }}</text>
  17. </view>
  18. </view>
  19. <template v-if="isCallOff === '1'">
  20. <view class="option_item">
  21. <view class="item_left">
  22. <text class="label">外呼分机号</text>
  23. </view>
  24. <view class="item-right">
  25. <text>{{
  26. callAccount ? callAccount.extenNum : "未配置分机号"
  27. }}</text>
  28. </view>
  29. </view>
  30. <view class="option_item">
  31. <view class="item_left">
  32. <text class="label">外呼注册状态</text>
  33. </view>
  34. <view class="item-right" @longpress="handleRegisterFun">
  35. <text v-if="callAccount != null && callSystem != null">
  36. {{ ipAddress }}
  37. </text>
  38. <text class="btn" v-else @click="handleRegisterFun">点击注册</text>
  39. <icon-img
  40. :value="callAccount != null && callSystem != null"
  41. ></icon-img>
  42. </view>
  43. </view>
  44. <view class="option_item">
  45. <view class="item_left">
  46. <text class="label">外呼签入状态</text>
  47. </view>
  48. <view class="item-right">
  49. <text v-if="signInState">正常</text>
  50. <text class="btn" v-else @click="handleRegisterFun">点击签入</text>
  51. <icon-img :value="signInState"></icon-img>
  52. <icon-img :value="redisStatus"></icon-img>
  53. </view>
  54. </view>
  55. </template>
  56. <template v-else>
  57. <view class="option_item">
  58. <view class="item_left">
  59. <text class="label">呼叫中心</text>
  60. </view>
  61. <view class="item-right" @longpress="handleRegisterFun">
  62. <text>不启用</text>
  63. <icon-img :value="isCallOff === '1'"></icon-img>
  64. </view>
  65. </view>
  66. </template>
  67. <view class="option_item">
  68. <view class="item_left">
  69. <text class="label">麦克风权限</text>
  70. </view>
  71. <view class="item-right">
  72. <text v-if="isRecord">已授权</text>
  73. <text class="btn" v-else @click="handleOpenSet">点击授权</text>
  74. <icon-img :value="isRecord"></icon-img>
  75. </view>
  76. </view>
  77. <!-- 通话自动录音状态 -->
  78. <view class="option_item">
  79. <view class="item_left">
  80. <text class="label">通话自动录音</text>
  81. </view>
  82. <view class="item-right">
  83. <text v-if="isAutoRecord">已开启</text>
  84. <text class="btn" v-else @click="toCallRecorderSettings"
  85. >点击开启</text
  86. >
  87. <icon-img :value="isAutoRecord"></icon-img>
  88. </view>
  89. </view>
  90. <!-- 文件访问权限状态 -->
  91. <view class="option_item">
  92. <view class="item_left">
  93. <text class="label">文件访问权限</text>
  94. </view>
  95. <view class="item-right">
  96. <text v-if="hasStoragePermission">已授权</text>
  97. <text class="btn" v-else @click="requestStoragePermission"
  98. >点击授权</text
  99. >
  100. <icon-img :value="hasStoragePermission"></icon-img>
  101. </view>
  102. </view>
  103. <view class="option_item">
  104. <view class="item_left">
  105. <text class="label">定位服务</text>
  106. </view>
  107. <view class="item-right">
  108. <text v-if="systemLocation">已开启</text>
  109. <text v-else>未开启</text>
  110. <icon-img :value="systemLocation"></icon-img>
  111. </view>
  112. </view>
  113. <view class="option_item">
  114. <view class="item_left">
  115. <text class="label">定位权限</text>
  116. </view>
  117. <view class="item-right">
  118. <text v-if="isLocation">已授权</text>
  119. <text class="btn" v-else @click="handleOpenSet">点击授权</text>
  120. <icon-img :value="isLocation"></icon-img>
  121. </view>
  122. </view>
  123. <view class="option_item">
  124. <view class="item_left">
  125. <text class="label">X5引擎</text>
  126. </view>
  127. <view class="item-right">
  128. <text v-if="isX5">启用</text>
  129. <text v-else>不启用</text>
  130. <icon-img :value="isX5"></icon-img>
  131. </view>
  132. </view>
  133. <view class="option_item">
  134. <view class="item_left">
  135. <text class="label">品牌型号</text>
  136. </view>
  137. <view class="item-right">
  138. <text>{{ deviceBrand }}</text>
  139. </view>
  140. </view>
  141. <view class="option_item">
  142. <view class="item_left">
  143. <text class="label">所用系统</text>
  144. </view>
  145. <view class="item-right">
  146. <text>{{ system }}</text>
  147. </view>
  148. </view>
  149. </view>
  150. <view class="tips_wrap" @longpress="handleOpenSet">
  151. <view class="left">
  152. <image
  153. src="../../static/circumstances/success.png"
  154. mode=""
  155. class="icon_img"
  156. >
  157. </image>
  158. <text>正常</text>
  159. </view>
  160. <view class="right">
  161. <image
  162. src="../../static/circumstances/error.png"
  163. mode=""
  164. class="icon_img"
  165. ></image>
  166. <text>不正常</text>
  167. </view>
  168. </view>
  169. </view>
  170. </template>
  171. <script>
  172. import { mapState } from "vuex";
  173. import iconImg from "./components/iconImg.vue";
  174. import permision from "@/js_sdk/wa-permission/permission.js";
  175. import {
  176. checkIsAutoRecord,
  177. toCallAutoRecorderPage,
  178. navigateToCallRecordingSettings,
  179. jumpToPermissionPage,
  180. } from "@/uni_modules/yao-lister";
  181. export default {
  182. components: {
  183. iconImg,
  184. },
  185. computed: {
  186. ...mapState({
  187. nickName: (state) => state.user.userInfo.nickName,
  188. callAccount: (state) => state.app.callAccount,
  189. signInState: (state) => state.app.signInState,
  190. ipAddress: (state) =>
  191. state.app.registerInfo && state.app.registerInfo.register
  192. ? state.app.registerInfo.register["IPv4"].slice(-3)
  193. : "异常",
  194. redisStatus: (state) => state.app.redisStatus,
  195. callSystem: (state) => state.app.callSystem,
  196. uuid: (state) => state.user.uuid,
  197. isCallOff: (state) => state.user.netConfig.isCallOff,
  198. }),
  199. },
  200. data() {
  201. return {
  202. isX5: false,
  203. isRecord: false,
  204. isLocation: false,
  205. system: "",
  206. deviceBrand: "",
  207. systemLocation: false,
  208. isAutoRecord: false, // 通话自动录音状态
  209. hasStoragePermission: false, // 文件访问权限状态
  210. };
  211. },
  212. methods: {
  213. // 刷新
  214. handleReset() {
  215. this.getAllStatus();
  216. uni.$u.toast("刷新成功");
  217. },
  218. // 打开设置
  219. handleOpenSet() {
  220. permision.gotoAppPermissionSetting("android.permission.RECORD_AUDIO");
  221. },
  222. // 请求文件访问权限
  223. requestStoragePermission() {
  224. jumpToPermissionPage();
  225. },
  226. // 跳转到通话录音设置页面
  227. toCallRecorderSettings() {
  228. toCallAutoRecorderPage();
  229. },
  230. // 跳转到系统通话录音界面
  231. toSystemRecorderSettings() {
  232. navigateToCallRecordingSettings();
  233. },
  234. // 注册
  235. handleRegisterFun() {
  236. this.$store
  237. .dispatch("app/getExtensionByUserId", {
  238. userId: this.$store.state.user.userInfo.userId,
  239. })
  240. .then((res) => {
  241. Promise.all([
  242. permision.requestAndroidPermission(
  243. "android.permission.RECORD_AUDIO"
  244. ),
  245. permision.requestAndroidPermission(
  246. "android.permission.MODIFY_AUDIO_SETTINGS"
  247. ),
  248. ]).then((result) => {
  249. const flag = result.every((v) => v == 1);
  250. if (flag) {
  251. this.$store.dispatch("app/createWv");
  252. }
  253. });
  254. });
  255. },
  256. // 检测定位服务是否开启
  257. checkSystemEnableLocation() {
  258. let context = plus.android.importClass("android.content.Context");
  259. let locationManager = plus.android.importClass(
  260. "android.location.LocationManager"
  261. );
  262. let main = plus.android.runtimeMainActivity();
  263. let mainSvr = main.getSystemService(context.LOCATION_SERVICE);
  264. let result = mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER);
  265. return result;
  266. },
  267. getAllStatus() {
  268. uni.getSystemInfo({
  269. success: (res) => {
  270. this.deviceBrand = res.deviceBrand + " " + res.model;
  271. this.system = res.system ? res.system : "获取失败";
  272. this.isX5 = res.browserName.includes("x5");
  273. // 获取Android版本号
  274. let androidVersion = 0;
  275. if (this.system && this.system.includes("Android")) {
  276. const versionMatch = this.system.match(/Android (\d+\.?\d*)/);
  277. if (versionMatch && versionMatch[1]) {
  278. androidVersion = parseFloat(versionMatch[1]);
  279. }
  280. }
  281. // 检查文件访问权限
  282. if (androidVersion >= 11) {
  283. // Android 11及以上版本,使用MANAGE_EXTERNAL_STORAGE权限(特殊权限)
  284. try {
  285. // 使用Android原生API检查特殊权限
  286. const Environment = plus.android.importClass("android.os.Environment");
  287. const Context = plus.android.importClass("android.content.Context");
  288. const mainActivity = plus.android.runtimeMainActivity();
  289. // 检查是否有管理外部存储的权限
  290. this.hasStoragePermission = Environment.isExternalStorageManager();
  291. console.log('MANAGE_EXTERNAL_STORAGE权限状态:', this.hasStoragePermission);
  292. } catch (e) {
  293. console.error('检查存储权限失败:', e);
  294. this.hasStoragePermission = false;
  295. }
  296. } else {
  297. // Android 11以下版本,使用READ_EXTERNAL_STORAGE权限
  298. permision
  299. .requestAndroidPermission(
  300. "android.permission.READ_EXTERNAL_STORAGE"
  301. )
  302. .then((result) => {
  303. this.hasStoragePermission = result === 1;
  304. });
  305. }
  306. },
  307. });
  308. permision
  309. .requestAndroidPermission("android.permission.RECORD_AUDIO")
  310. .then((result) => {
  311. this.isRecord = result == "1";
  312. });
  313. this.systemLocation = this.checkSystemEnableLocation();
  314. permision
  315. .requestAndroidPermission("android.permission.ACCESS_FINE_LOCATION")
  316. .then((result) => {
  317. this.isLocation = result == "1";
  318. });
  319. // 检查通话自动录音状态
  320. this.isAutoRecord = checkIsAutoRecord();
  321. },
  322. },
  323. mounted() {
  324. this.getAllStatus();
  325. },
  326. };
  327. </script>
  328. <style lang="scss" scoped>
  329. .right_btn {
  330. display: flex;
  331. align-items: center;
  332. font-size: 14px;
  333. .copy_btn {
  334. display: flex;
  335. align-items: center;
  336. margin-right: 20rpx;
  337. }
  338. .reset {
  339. display: flex;
  340. align-items: center;
  341. }
  342. }
  343. .tips_wrap {
  344. display: flex;
  345. align-items: center;
  346. justify-content: space-evenly;
  347. height: 40px;
  348. background: #ececec;
  349. border-radius: 4px;
  350. margin-top: 15px;
  351. margin-left: 15px;
  352. margin-right: 15px;
  353. margin-bottom: 50px;
  354. .right {
  355. display: flex;
  356. align-items: center;
  357. }
  358. .left {
  359. display: flex;
  360. align-items: center;
  361. }
  362. .icon_img {
  363. width: 40rpx;
  364. height: 40rpx;
  365. margin-right: 20rpx;
  366. }
  367. }
  368. .option_list {
  369. margin-top: 30rpx;
  370. padding: 0 30rpx;
  371. .option_item {
  372. display: flex;
  373. justify-content: space-between;
  374. align-items: center;
  375. padding-bottom: 36rpx;
  376. padding-top: 36rpx;
  377. border-bottom: 2rpx solid #dfdfdf;
  378. .item_left {
  379. display: flex;
  380. align-items: center;
  381. image {
  382. width: 32rpx;
  383. height: 32rpx;
  384. margin-right: 20rpx;
  385. }
  386. .label {
  387. font-size: 28rpx;
  388. color: #202020;
  389. }
  390. }
  391. .item-right {
  392. display: flex;
  393. justify-content: space-between;
  394. align-items: center;
  395. text {
  396. font-size: 24rpx;
  397. color: #999999;
  398. margin-right: 10rpx;
  399. }
  400. .btn {
  401. color: #108cff;
  402. }
  403. .icon_img {
  404. width: 40rpx;
  405. height: 40rpx;
  406. }
  407. }
  408. }
  409. }
  410. </style>