App.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <script>
  2. // // #ifdef APP-PLUS
  3. // import {
  4. // registerRequestPermissionTipsListener,
  5. // unregisterRequestPermissionTipsListener,
  6. // setRequestPermissionTips
  7. // } from "@/uni_modules/uni-registerRequestPermissionTips"
  8. // var PermissionTips = {
  9. // "android.permission.CAMERA": "<h4 style=\"font-size:40px;\">正在获取相机、存储权限</h4><font color=#cccccc>该权限用于获取设备拍摄或获取本地应用相册,进行头像或图片上传。</font>",
  10. // "android.permission.WRITE_EXTERNAL_STORAGE": "<h4 style=\"font-size:40px;\">正在获取相机、存储权限</h4><font color=#cccccc>该权限用于获取设备拍摄或获取本地应用相册,进行头像或图片上传。</font>",
  11. // "android.permission.READ_EXTERNAL_STORAGE": "<h4 style=\"font-size:40px;\">正在获取相机、存储权限</h4><font color=#cccccc>该权限用于获取设备拍摄或获取本地应用相册,进行头像或图片上传。</font>",
  12. // "android.permission.RECORD_AUDIO": "<h4 style=\"font-size:40px;\">正在获取麦克风权限</h4><font color=#cccccc>该权限用于获取设备语音通话、语音等录音或通讯场景所需。</font>"
  13. // }
  14. // // #endif
  15. const tabbars = ['/pages/my/my', '/pages/make/index', '/pages/message/mailMessage', '/pages/index/index']
  16. export default {
  17. globalData: {
  18. postHeader: null,
  19. headerSign: '',
  20. uuid: '',
  21. skey: '',
  22. isLogin: 0,
  23. userId: 0,
  24. socket: null,
  25. postHeader: null,
  26. systemInfo: null
  27. },
  28. beforeDestroy() {},
  29. onLaunch: function(options) {
  30. // #ifdef APP-PLUS
  31. // var brand = uni.getSystemInfoSync().deviceBrand
  32. // setRequestPermissionTips(PermissionTips)
  33. // registerRequestPermissionTipsListener({
  34. // onRequest: (e) => {
  35. // console.log(e)
  36. // },
  37. // onConfirm: (e) => {
  38. // console.log(e)
  39. // },
  40. // onComplete: (e) => {
  41. // // 华为手机在权限禁止之后,再次申请权限不会出现权限申请框。此时应该引导用户去系统设置开启此权限,不应该频繁申请。
  42. // if (brand.toLowerCase() == "huawei" || true) {
  43. // var tips = {}
  44. // var hasDeniedPermission = false
  45. // for (var k in PermissionTips) {
  46. // if (e[k] != "denied") {
  47. // tips[k] = PermissionTips[k]
  48. // } else {
  49. // hasDeniedPermission = true
  50. // }
  51. // }
  52. // setRequestPermissionTips(tips) // 更新弹框提醒,防止华为手机不出现权限申请框时权限提醒框闪烁的情况
  53. // if (hasDeniedPermission)
  54. // uni.showModal({
  55. // content: "权限已经被拒绝,请前往设置中开启"
  56. // })
  57. // }
  58. // }
  59. // });
  60. // #endif
  61. let deviceId = "";
  62. let uuid2 = uni.getStorageSync("app_uuid");
  63. if (uuid2 && uuid2.length >= 6) {
  64. deviceId = uuid2;
  65. } else {
  66. deviceId = uni.getSystemInfoSync().deviceId || uni.getDeviceInfo().deviceId;
  67. if (!deviceId || deviceId.length < 6) {
  68. deviceId = this.generateUUID();
  69. } else {
  70. // uni.setStorageSync("app_uuid", deviceId);
  71. }
  72. }
  73. if (deviceId && deviceId.length >= 6) {} else {
  74. deviceId = new Date().getTime()
  75. }
  76. this.globalData.uuid = deviceId;
  77. uni.setStorageSync("app_uuid", deviceId);
  78. // this.globalData.uuid = "";
  79. let skey = uni.getStorageSync("wapptoken");
  80. if (skey != null && skey != "" && skey != undefined) {
  81. this.globalData.skey = skey;
  82. }
  83. if (this.globalData.headerSign == "") {
  84. let headerSignKKK = uni.getStorageSync("headerSign");
  85. if (headerSignKKK != null && headerSignKKK != "" && headerSignKKK != undefined) {
  86. this.globalData.headerSign = headerSignKKK;
  87. }
  88. }
  89. // uni.getPushClientId({
  90. // success: (res) => {
  91. // console.log(res.cid);
  92. // // this.push_token = res.cid;
  93. // },
  94. // fail(err) {
  95. // console.log(err)
  96. // }
  97. // })
  98. // this.$nextTick(async () => {
  99. // for (var i = 0; i < tabbars.length; i++) {
  100. // await this.go(tabbars[i])
  101. // console.log('page:', i);
  102. // }
  103. // // uni.$store.commit('user/setPageState', 'loadmore')
  104. // })
  105. // #ifdef APP
  106. plus.navigator.closeSplashscreen()
  107. // #endif
  108. },
  109. onShow: function(options) {
  110. console.log('App Show');
  111. // setTimeout(()=>{
  112. // uni.hideTabBar()
  113. // },100)
  114. },
  115. onHide: function() {
  116. console.log('App Hide');
  117. },
  118. onExit: function() {
  119. unregisterRequestPermissionTipsListener(null)
  120. },
  121. onAppBackground() {},
  122. methods: {
  123. generateUUID() {
  124. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
  125. const r = Math.random() * 16 | 0;
  126. const v = c === 'x' ? r : (r & 0x3 | 0x8);
  127. return v.toString(16);
  128. });
  129. },
  130. go(url) {
  131. return new Promise((resolve) => {
  132. uni.switchTab({
  133. url,
  134. complete: () => {
  135. setTimeout(() => {
  136. resolve()
  137. }, 100)
  138. }
  139. })
  140. })
  141. },
  142. }
  143. };
  144. </script>
  145. <style lang="scss">
  146. /*每个页面公共css */
  147. @import 'colorui/main.css';
  148. @import 'colorui/icon.css';
  149. @import 'style/FontStyle.css';
  150. body {
  151. -webkit-text-size-adjust: none;
  152. overscroll-behavior-y: contain;
  153. -webkit-overflow-scrolling: touch;
  154. background-color: #161616;
  155. // background: url('./http://c.yujianmate.com/images/v1/bg.png');
  156. // background-size: 750rpx 1624rpx;
  157. background-repeat: repeat-y;
  158. }
  159. /* 超出一行省略号 */
  160. .one-omit {
  161. white-space: nowrap;
  162. /*规定段落中的文本不进行换行*/
  163. overflow: hidden;
  164. /*内容会被修剪,并且其余内容是不可见的。*/
  165. text-overflow: ellipsis;
  166. /*显示省略号来代表被修剪的文本*/
  167. }
  168. .two-omit {
  169. display: -webkit-box;
  170. -webkit-line-clamp: 2;
  171. overflow: hidden;
  172. text-overflow: ellipsis;
  173. -webkit-box-orient: vertical;
  174. }
  175. img {
  176. width: 100%;
  177. }
  178. uni-modal {
  179. z-index: 998 !important;
  180. }
  181. .cu-modal {
  182. z-index: 997 !important;
  183. }
  184. </style>