index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  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. <view class="option_item">
  142. <view class="item_left">
  143. <text class="label">定位服务</text>
  144. </view>
  145. <view class="item-right">
  146. <text v-if="systemLocation">已开启</text>
  147. <text v-else>未开启</text>
  148. <icon-img :value="systemLocation"></icon-img>
  149. </view>
  150. </view>
  151. <view class="option_item">
  152. <view class="item_left">
  153. <text class="label">定位权限</text>
  154. </view>
  155. <view class="item-right">
  156. <text v-if="isLocation">已授权</text>
  157. <text class="btn" v-else @click="handleOpenSet">点击授权</text>
  158. <icon-img :value="isLocation"></icon-img>
  159. </view>
  160. </view>
  161. <view class="option_item">
  162. <view class="item_left">
  163. <text class="label">X5引擎</text>
  164. </view>
  165. <view class="item-right">
  166. <text v-if="isX5">启用</text>
  167. <text v-else>不启用</text>
  168. <icon-img :value="isX5"></icon-img>
  169. </view>
  170. </view>
  171. <view class="option_item">
  172. <view class="item_left">
  173. <text class="label">品牌型号</text>
  174. </view>
  175. <view class="item-right">
  176. <text>{{ deviceBrand }}</text>
  177. </view>
  178. </view>
  179. <view class="option_item">
  180. <view class="item_left">
  181. <text class="label">所用系统</text>
  182. </view>
  183. <view class="item-right">
  184. <text>{{ system }}</text>
  185. </view>
  186. </view>
  187. </view>
  188. <view class="tips_wrap" @longpress="handleOpenSet">
  189. <view class="left">
  190. <image src="../../static/circumstances/success.png" mode="" class="icon_img">
  191. </image>
  192. <text>正常</text>
  193. </view>
  194. <view class="right">
  195. <image src="../../static/circumstances/error.png" mode="" class="icon_img"></image>
  196. <text>不正常</text>
  197. </view>
  198. </view>
  199. </view>
  200. </template>
  201. <script>
  202. import {
  203. mapState
  204. } from "vuex";
  205. import iconImg from "./components/iconImg.vue";
  206. import permision from "@/js_sdk/wa-permission/permission.js";
  207. export default {
  208. components: {
  209. iconImg,
  210. },
  211. computed: {
  212. ...mapState({
  213. nickName: (state) => state.user.userInfo.nickName,
  214. callAccount: (state) => state.app.callAccount,
  215. signInState: (state) => state.app.signInState,
  216. ipAddress: (state) =>
  217. state.app.registerInfo && state.app.registerInfo.register ?
  218. state.app.registerInfo.register["IPv4"].slice(-3) : "异常",
  219. redisStatus: (state) => state.app.redisStatus,
  220. callSystem: (state) => state.app.callSystem,
  221. uuid: (state) => state.user.uuid,
  222. isCallOff: (state) => state.user.netConfig.isCallOff,
  223. // 从call store获取权限状态
  224. isAutoRecord: (state) => state.call.isAutoRecord,
  225. hasStoragePermission: (state) => state.call.hasStoragePermission,
  226. hasReadPhoneStatePermission: (state) => state.call.hasReadPhoneStatePermission,
  227. hasCallPhonePermission: (state) => state.call.hasCallPhonePermission,
  228. hasReadCallLogPermission: (state) => state.call.hasReadCallLogPermission,
  229. hasReadPhoneNumbersPermission: (state) => state.call.hasReadPhoneNumbersPermission,
  230. }),
  231. },
  232. data() {
  233. return {
  234. isX5: false,
  235. isRecord: false,
  236. isLocation: false,
  237. system: "",
  238. deviceBrand: "",
  239. systemLocation: false,
  240. };
  241. },
  242. methods: {
  243. // 刷新
  244. handleReset() {
  245. this.getAllStatus();
  246. uni.$u.toast("刷新成功");
  247. },
  248. // 打开设置
  249. handleOpenSet() {
  250. this.$store.dispatch('call/handleOpenSet');
  251. },
  252. // 请求文件访问权限
  253. requestStoragePermission() {
  254. this.$store.dispatch('call/requestStoragePermission');
  255. },
  256. // 跳转到通话录音设置页面
  257. toCallRecorderSettings() {
  258. this.$store.dispatch('call/toCallRecorderSettings');
  259. },
  260. // 跳转到系统通话录音界面
  261. toSystemRecorderSettings() {
  262. this.$store.dispatch('call/toSystemRecorderSettings');
  263. },
  264. // 注册
  265. handleRegisterFun() {
  266. this.$store
  267. .dispatch("app/getExtensionByUserId", {
  268. userId: this.$store.state.user.userInfo.userId,
  269. })
  270. .then((res) => {
  271. Promise.all([
  272. permision.requestAndroidPermission(
  273. "android.permission.RECORD_AUDIO"
  274. ),
  275. permision.requestAndroidPermission(
  276. "android.permission.MODIFY_AUDIO_SETTINGS"
  277. ),
  278. ]).then((result) => {
  279. const flag = result.every((v) => v == 1);
  280. if (flag) {
  281. this.$store.dispatch("app/createWv");
  282. }
  283. });
  284. });
  285. },
  286. // 检测定位服务是否开启
  287. checkSystemEnableLocation() {
  288. let context = plus.android.importClass("android.content.Context");
  289. let locationManager = plus.android.importClass(
  290. "android.location.LocationManager"
  291. );
  292. let main = plus.android.runtimeMainActivity();
  293. let mainSvr = main.getSystemService(context.LOCATION_SERVICE);
  294. let result = mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER);
  295. return result;
  296. },
  297. getAllStatus() {
  298. uni.getSystemInfo({
  299. success: (res) => {
  300. this.deviceBrand = res.deviceBrand + " " + res.model;
  301. this.system = res.system ? res.system : "获取失败";
  302. this.isX5 = res.browserName.includes("x5");
  303. },
  304. });
  305. // 检查麦克风权限
  306. permision
  307. .requestAndroidPermission("android.permission.RECORD_AUDIO")
  308. .then((result) => {
  309. this.isRecord = result == "1";
  310. });
  311. // 检查定位服务状态
  312. this.systemLocation = this.checkSystemEnableLocation();
  313. // 检查定位权限
  314. permision
  315. .requestAndroidPermission("android.permission.ACCESS_FINE_LOCATION")
  316. .then((result) => {
  317. this.isLocation = result == "1";
  318. });
  319. // 从store检查所有其他权限状态
  320. this.$store.dispatch('call/checkAllPermissions');
  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>