App.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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. import { KeepLive } from '@/uni_modules/android-keeplive'
  10. // #endif
  11. import {
  12. simpleDebounce
  13. } from "@/utils/util.js";
  14. // 仅 App 端存在;H5/小程序 下为 null,避免 uni.requireNativePlugin is not a function
  15. const lemonjkFileSelect = (typeof uni !== 'undefined' && typeof uni.requireNativePlugin === 'function')
  16. ? uni.requireNativePlugin('lemonjk-FileSelect')
  17. : null;
  18. export default {
  19. data() {
  20. return {
  21. g_wakelock: null,
  22. }
  23. },
  24. onLaunch: function() {
  25. //#ifdef APP-PLUS
  26. APPUpdate();
  27. getCurrentNo((data) => {
  28. this.$store.commit("app/SET_CURRENTVERSION", data.versionName);
  29. });
  30. plus.globalEvent.addEventListener('plusMessage', (msg) => {
  31. if (msg.data.args.data.name == 'postMessage') {
  32. const {
  33. type,
  34. data,
  35. action
  36. } = msg.data.args.data.arg;
  37. if (action === "message") {
  38. uni.$u.toast("e:" + data);
  39. } else if (action == "singInState") {
  40. this.$store.commit("app/SET_SIGNINSTATE", data)
  41. } else if (action == "registerInfo") {
  42. this.$store.commit("app/SET_REDIS_INFO", data)
  43. } else if (action == "disconnected") {
  44. // 重连不上 重新创建
  45. this.$store.dispatch("app/createWv");
  46. } else if (action === "phoneStatus") {
  47. this.$store.commit("app/SET_DIALING", data)
  48. } else if (action == "outbound") {
  49. data.action = "outbound";
  50. this.$store.dispatch("app/saveUnionAppCall", data)
  51. } else if (action == "incoming") {
  52. data.action = "incoming";
  53. // this.$store.commit("app/SET_ISREJECT", false);
  54. this.$store.dispatch("app/saveUnionAppCall", data).then(res => {
  55. uni.navigateTo({
  56. url: `/pages/callweb/callweb?phone=${data.phone}`
  57. })
  58. })
  59. }
  60. }
  61. });
  62. // this.addFlags();
  63. this.$store.dispatch("call/startPhoneListener");
  64. this.startKeepLive();
  65. // #endif
  66. },
  67. onShow: function() {
  68. this.$store.dispatch("app/register");
  69. },
  70. methods: {
  71. startKeepLive(){
  72. const keep =new KeepLive();
  73. keep.setTitle("时与APP");
  74. keep.setContent("后台运行中");
  75. // keep.setLargeIcon("icon");
  76. keep.setSmallIcon("icon"); //图标名字 图标放在 插件下面的 res/drawable 文件夹下
  77. keep.onAddBackgroundCallback(function(res){
  78. // console.log("后台运行 "+res)
  79. })
  80. keep.onAddScrrenListenerCallback(function(res){
  81. // console.log("屏幕开启状态 "+res)
  82. })
  83. keep.setWakeLock(1,"keeptag");// 设置唤醒类型
  84. keep.setAutoStartEnable(true)
  85. if(!keep.checkAppNotification()){
  86. keep.onOpenNotificationSetting(function(res){
  87. keep.register();
  88. var ignoring= keep.isIgnoringBatteryOptimizations();
  89. if(!ignoring){
  90. keep.requestIgnoreBatteryOptimizations();
  91. }
  92. })
  93. }else{
  94. keep.register();
  95. var ignoring= keep.isIgnoringBatteryOptimizations();
  96. if(!ignoring){
  97. keep.requestIgnoreBatteryOptimizations();
  98. }
  99. }
  100. },
  101. wakeLock() {
  102. //Android
  103. var main = plus.android.runtimeMainActivity();
  104. var Context = plus.android.importClass("android.content.Context");
  105. var PowerManager = plus.android.importClass("android.os.PowerManager");
  106. var pm = main.getSystemService(Context.POWER_SERVICE);
  107. this.g_wakelock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "ANY_NAME");
  108. this.g_wakelock.acquire();
  109. },
  110. // 禁止截屏
  111. addFlags() {
  112. // #ifdef APP-PLUS
  113. let osname = plus.os.name
  114. if (osname == "Android") {
  115. var activity = plus.android.runtimeMainActivity()
  116. plus.android.invoke(plus.android.invoke(activity, "getWindow"), "addFlags", 0x00002000)
  117. }
  118. // #endif
  119. },
  120. clearFlags() {
  121. // #ifdef APP-PLUS
  122. let osname = plus.os.name
  123. if (osname == "Android") {
  124. var activity = plus.android.runtimeMainActivity()
  125. plus.android.invoke(plus.android.invoke(activity, "getWindow"), "clearFlags", 0x00002000)
  126. }
  127. // #endif
  128. },
  129. },
  130. }
  131. </script>
  132. <style lang="scss">
  133. .card_wrap {
  134. margin: 0 20px;
  135. background-color: #fff;
  136. border-radius: 20rpx;
  137. overflow: hidden;
  138. margin-bottom: 20px;
  139. .header_wrap {
  140. display: flex;
  141. justify-content: space-between;
  142. padding: 10px;
  143. border-bottom: 1px solid #ddd;
  144. background-color: #fff;
  145. .header_left {
  146. font-size: 30rpx;
  147. }
  148. .haeder_right {
  149. display: flex;
  150. align-items: center;
  151. text {
  152. font-size: 28rpx;
  153. color: #b8b8b8;
  154. margin-right: 20rpx;
  155. }
  156. ::v-deep .u-icon__icon {
  157. font-size: 24rpx !important;
  158. }
  159. }
  160. }
  161. }
  162. /*#ifndef APP-NVUE*/
  163. .required {
  164. &::after {
  165. content: "*";
  166. color: red;
  167. margin-left: 6rpx;
  168. }
  169. }
  170. .form_required {
  171. position: relative;
  172. &::after {
  173. position: absolute;
  174. left: 12rpx;
  175. top: 50%;
  176. transform: translate(0%, -50%);
  177. content: "*";
  178. color: red;
  179. margin-left: 6rpx;
  180. }
  181. }
  182. /*#endif*/
  183. .u-cell__value {
  184. color: #999999 !important;
  185. }
  186. /*#ifndef APP-NVUE*/
  187. page {
  188. background-color: $uni-bg-color;
  189. }
  190. /*#endif*/
  191. .u-nav-slot {
  192. color: #108cff;
  193. }
  194. // 时间选择器不要高
  195. /*#ifndef APP-NVUE*/
  196. ::v-deep .uni-date__x-input {
  197. height: auto !important;
  198. font-size: 28rpx !important;
  199. }
  200. /*#endif*/
  201. .u-navbar__content__title {
  202. font-weight: bold;
  203. }
  204. @import "uview-plus/theme.scss";
  205. @import "uview-plus/index.scss";
  206. /*每个页面公共css */
  207. </style>