App.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <script>
  2. import store from "./store";
  3. import {getItem} from "./pages/util/storageHelper";
  4. import wfc from "./wfc/client/wfc";
  5. export default {
  6. onLaunch: function () {
  7. console.log("App Launch");
  8. // #ifdef APP-PLUS
  9. plus.push.getClientInfoAsync((info) => {
  10. let cid = info["clientid"];
  11. if (cid) {
  12. console.log('push clientId', cid);
  13. wfc.setDeviceToken(7, cid);
  14. }
  15. });
  16. // #endif
  17. },
  18. onShow: function () {
  19. console.log("App Show");
  20. store.state.misc.isAppHidden = false;
  21. // #ifdef H5
  22. let userId = getItem('userId');
  23. let token = getItem('token')
  24. if (token) {
  25. wfc.connect(userId, token);
  26. this.go2ConversationList();
  27. } else {
  28. uni.redirectTo({
  29. url: '/pages/login/LoginPage',
  30. })
  31. }
  32. // #endif
  33. },
  34. onHide: function () {
  35. console.log("App Hide");
  36. store.state.misc.isAppHidden = true;
  37. },
  38. methods: {
  39. go2ConversationList() {
  40. uni.switchTab({
  41. url: '/pages/conversationList/ConversationListPage',
  42. success: () => {
  43. console.log('to conversation list success');
  44. },
  45. fail: e => {
  46. console.log('to conversation list error', e);
  47. },
  48. complete: () => {
  49. console.log('switch tab complete')
  50. }
  51. });
  52. }
  53. }
  54. }
  55. </script>
  56. <style>
  57. /*每个页面公共css */
  58. @import './global.css';
  59. @import './wfc.css';
  60. @import './static/iconfonts/customicons.css';
  61. @import './static/iconfonts/icomoon/style.css';
  62. :root {
  63. --uni-tabbar-height: 50px;
  64. //app-plus header 和 tabbar 是原生的
  65. /* #ifdef APP-PLUS */
  66. --uni-page-header-height: 0;
  67. --page-full-height-without-header-and-tabbar: 100vh;
  68. --page-full-height-without-header: 100vh;
  69. /* #endif */
  70. /* #ifdef H5 */
  71. --uni-page-header-height: 44px;
  72. --page-full-height-without-header-and-tabbar: calc(100vh - 44px - 50px);
  73. --page-full-height-without-header: calc(100vh - 44px);
  74. /* #endif */
  75. }
  76. </style>