App.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <script>
  2. // #ifdef APP-PLUS
  3. import APPUpdate, {
  4. getCurrentNo
  5. } from '@/uni_modules/zhouWei-APPUpdate/js_sdk/appUpdate';
  6. import {
  7. callErrorCode
  8. } from "@/utils/commonDicts.js";
  9. // #endif
  10. import {
  11. simpleDebounce
  12. } from "@/utils/util.js";
  13. export default {
  14. data() {
  15. return {
  16. g_wakelock: null,
  17. }
  18. },
  19. onLaunch: function() {
  20. //#ifdef APP-PLUS
  21. APPUpdate();
  22. getCurrentNo((data) => {
  23. this.$store.commit("app/SET_CURRENTVERSION", data.versionName);
  24. });
  25. plus.globalEvent.addEventListener('plusMessage', (msg) => {
  26. if (msg.data.args.data.name == 'postMessage') {
  27. const {
  28. type,
  29. data,
  30. action
  31. } = msg.data.args.data.arg;
  32. if (action === "message") {
  33. uni.$u.toast("e:" + data);
  34. } else if (action == "singInState") {
  35. this.$store.commit("app/SET_SIGNINSTATE", data)
  36. } else if (action == "registerInfo") {
  37. this.$store.commit("app/SET_REDIS_INFO", data)
  38. } else if (action == "disconnected") {
  39. // 重连不上 重新创建
  40. this.$store.dispatch("app/createWv");
  41. } else if (action === "phoneStatus") {
  42. this.$store.commit("app/SET_DIALING", data)
  43. } else if (action == "outbound") {
  44. data.action = "outbound";
  45. this.$store.dispatch("app/saveUnionAppCall", data)
  46. } else if (action == "incoming") {
  47. data.action = "incoming";
  48. // this.$store.commit("app/SET_ISREJECT", false);
  49. this.$store.dispatch("app/saveUnionAppCall", data).then(res => {
  50. uni.navigateTo({
  51. url: `/pages/callweb/callweb?phone=${data.phone}`
  52. })
  53. })
  54. }
  55. }
  56. });
  57. // this.addFlags();
  58. this.$store.dispatch("call/startPhoneListener");
  59. // #endif
  60. },
  61. onShow: function() {
  62. this.$store.dispatch("app/register");
  63. },
  64. methods: {
  65. wakeLock() {
  66. //Android
  67. var main = plus.android.runtimeMainActivity();
  68. var Context = plus.android.importClass("android.content.Context");
  69. var PowerManager = plus.android.importClass("android.os.PowerManager");
  70. var pm = main.getSystemService(Context.POWER_SERVICE);
  71. this.g_wakelock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "ANY_NAME");
  72. this.g_wakelock.acquire();
  73. },
  74. // 禁止截屏
  75. addFlags() {
  76. // #ifdef APP-PLUS
  77. let osname = plus.os.name
  78. if (osname == "Android") {
  79. var activity = plus.android.runtimeMainActivity()
  80. plus.android.invoke(plus.android.invoke(activity, "getWindow"), "addFlags", 0x00002000)
  81. }
  82. // #endif
  83. },
  84. clearFlags() {
  85. // #ifdef APP-PLUS
  86. let osname = plus.os.name
  87. if (osname == "Android") {
  88. var activity = plus.android.runtimeMainActivity()
  89. plus.android.invoke(plus.android.invoke(activity, "getWindow"), "clearFlags", 0x00002000)
  90. }
  91. // #endif
  92. },
  93. },
  94. }
  95. </script>
  96. <style lang="scss">
  97. .card_wrap {
  98. margin: 0 20px;
  99. background-color: #fff;
  100. border-radius: 20rpx;
  101. overflow: hidden;
  102. margin-bottom: 20px;
  103. .header_wrap {
  104. display: flex;
  105. justify-content: space-between;
  106. padding: 10px;
  107. border-bottom: 1px solid #ddd;
  108. background-color: #fff;
  109. .header_left {
  110. font-size: 30rpx;
  111. }
  112. .haeder_right {
  113. display: flex;
  114. align-items: center;
  115. text {
  116. font-size: 28rpx;
  117. color: #b8b8b8;
  118. margin-right: 20rpx;
  119. }
  120. ::v-deep .u-icon__icon {
  121. font-size: 24rpx !important;
  122. }
  123. }
  124. }
  125. }
  126. /*#ifndef APP-NVUE*/
  127. .required {
  128. &::after {
  129. content: "*";
  130. color: red;
  131. margin-left: 6rpx;
  132. }
  133. }
  134. .form_required {
  135. position: relative;
  136. &::after {
  137. position: absolute;
  138. left: 12rpx;
  139. top: 50%;
  140. transform: translate(0%, -50%);
  141. content: "*";
  142. color: red;
  143. margin-left: 6rpx;
  144. }
  145. }
  146. /*#endif*/
  147. .u-cell__value {
  148. color: #999999 !important;
  149. }
  150. /*#ifndef APP-NVUE*/
  151. page {
  152. background-color: $uni-bg-color;
  153. }
  154. /*#endif*/
  155. .u-nav-slot {
  156. color: #108cff;
  157. }
  158. // 时间选择器不要高
  159. /*#ifndef APP-NVUE*/
  160. ::v-deep .uni-date__x-input {
  161. height: auto !important;
  162. font-size: 28rpx !important;
  163. }
  164. /*#endif*/
  165. .u-navbar__content__title {
  166. font-weight: bold;
  167. }
  168. @import "@/uni_modules/uview-ui/index.scss";
  169. /*每个页面公共css */
  170. </style>