index.vue 12 KB

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