App.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <script>
  2. export default {
  3. onShow() {
  4. // 实时通信
  5. const that = this;
  6. if (that.$store.state.socketTask == null) {
  7. uni.getStorage({
  8. key: 'token',
  9. success: function(res) {
  10. let user = that.$jwt(res.data);
  11. if (user._id) {
  12. //当websocket收到后端发送的消息时,触发
  13. let config = that.$config.wsUrl;
  14. // 开启websocket
  15. that.$store.dispatch('websocketInit', config + `/${user._id}`);
  16. }
  17. }
  18. })
  19. }
  20. },
  21. onLaunch: function() {
  22. const that = this;
  23. that.forceUpdate();
  24. },
  25. methods: {
  26. // 强制更新
  27. forceUpdate() {
  28. const that = this;
  29. let system = that.$config.system;
  30. if (system.uniPlatform == 'mp-weixin') {
  31. const updateManager = uni.getUpdateManager();
  32. updateManager.onCheckForUpdate(function(res) {
  33. // 请求完新版本信息的回调
  34. console.log(res.hasUpdate);
  35. });
  36. updateManager.onUpdateReady(function(res) {
  37. uni.showModal({
  38. title: '更新提示',
  39. content: '新版本已经准备好,是否重启应用?',
  40. success(res) {
  41. if (res.confirm) {
  42. uni.clearStorage();
  43. updateManager.applyUpdate();
  44. }
  45. }
  46. });
  47. });
  48. updateManager.onUpdateFailed(function(res) {
  49. console.log(res);
  50. console.log('更新失败');
  51. });
  52. }
  53. }
  54. }
  55. }
  56. </script>
  57. <style lang="scss">
  58. /*每个页面公共css */
  59. @import '@/uni_modules/uni-scss/index.scss';
  60. @import '@/common/css/font-icon.css';
  61. /* 公用 */
  62. .container {
  63. display: flex;
  64. flex-direction: column;
  65. box-sizing: border-box;
  66. width: 100vw;
  67. height: 100vh;
  68. }
  69. .textOver {
  70. overflow: hidden;
  71. text-overflow: ellipsis;
  72. white-space: nowrap;
  73. }
  74. // 弹框公共样式
  75. .uni-dialog-content {
  76. padding: 2vw !important;
  77. max-height: 40vh;
  78. overflow-y: auto;
  79. align-items: normal !important;
  80. box-sizing: border-box;
  81. }
  82. /* 设置整个项目的公用样式*/
  83. page {
  84. /* 窗口可用高度 */
  85. /* 有头有底 */
  86. --oneHeight: 100vh;
  87. /* 有头无底 */
  88. --twoHeight: 92vh;
  89. /* 可用窗口背景颜色 */
  90. --mainColor: #ffffff;
  91. /* 底部菜单背景颜色 */
  92. --footColor: #f1f1f1;
  93. /* 字体大小 */
  94. --font20Szie: 20px;
  95. --font19Szie: 19px;
  96. --font18Szie: 18px;
  97. --font17Size: 17px;
  98. --font16Size: 16px;
  99. --font15Size: 15px;
  100. --font14Size: 14px;
  101. --font13Size: 13px;
  102. --font12Size: 12px;
  103. /* 颜色 */
  104. --f1Color: #f1f1f1;
  105. --f2Color: #f2f2f2;
  106. --f3Color: #f3f3f3;
  107. --f4Color: #f4f4f4;
  108. --f5Color: #f5f5f5;
  109. --f6Color: #f6f6f6;
  110. --f7Color: #f7f7f7;
  111. --f8Color: #f8f8f8;
  112. --f9Color: #f9f9f9;
  113. --f99Color: #999999;
  114. --f85Color: #858585;
  115. --fcColor: #cccccc;
  116. --f00Color: #000000;
  117. --fffColor: #ffffff;
  118. --ff0Color: #ff0000;
  119. --f0fColor: #0000ff;
  120. --f08Color: #008000;
  121. --f35BColor: #35BD7B;
  122. // 商品详情,加入购物车
  123. --f3CColor: #FF8A18; //FF8A18 //3CB371
  124. --fFB1Color: #FB1438; //FB1438 //6495ED
  125. }
  126. </style>