App.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <script>
  2. import Vue from 'vue'
  3. import appUpdate from 'common/util/appUpdate.js'
  4. import api from "@/api/api";
  5. import store from '@/store/index.js'
  6. export default {
  7. created() {
  8. uni.getSystemInfo({
  9. success: function(e) {
  10. // #ifdef APP-PLUS
  11. // 检测升级
  12. appUpdate()
  13. // #endif
  14. // #ifndef MP
  15. Vue.prototype.StatusBar = e.statusBarHeight;
  16. if (e.platform == 'android') {
  17. Vue.prototype.CustomBar = e.statusBarHeight + 50;
  18. } else {
  19. Vue.prototype.CustomBar = e.statusBarHeight + 45;
  20. };
  21. // #endif
  22. // #ifdef MP-WEIXIN
  23. Vue.prototype.StatusBar = e.statusBarHeight;
  24. let custom = wx.getMenuButtonBoundingClientRect();
  25. Vue.prototype.Custom = custom;
  26. Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
  27. // #endif
  28. // #ifdef MP-ALIPAY
  29. Vue.prototype.StatusBar = e.statusBarHeight;
  30. Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
  31. // #endif
  32. // #ifdef APP-PLUS
  33. // #endif
  34. },
  35. })
  36. },
  37. mounted() {
  38. /**
  39. *判断浏览器窗口是刷新或者关闭操作
  40. * 无论任何浏览器不管是刷新或者是关闭都会执行下面两个方法 onbiforeunload onunload
  41. * 根据时间差来实现
  42. * 在点击刷新或者关闭时开始计时记录下这一刻的时间戳
  43. * 因为刷新和关闭 在执行onunload方法时的时间不一样,一般情况下经过测试
  44. * 关闭时时间差不大于3毫秒
  45. * 刷新时即使只有一个简单的helloworld页面都不少于10毫秒
  46. * 而一般网站网页内容更多,时间差达到了100多毫秒
  47. *
  48. *
  49. * 下面方法的缺点是不管你开了多少窗口,都会在关闭一个窗口时清空所有localStorage缓存
  50. * 造成所有页面都需要重新登录,其实这也是针对项目而言的,目前本项目就不认为这是缺点
  51. * 而能更好的保护用户信息
  52. **/
  53. let beginTime = 0; //开始时间
  54. let differTime = 0; //时间差
  55. window.onunload = function() {
  56. differTime = new Date().getTime() - beginTime;
  57. if (differTime <= 5) {
  58. api.logout().then(res => {
  59. /* uni.clearStorageSync() */
  60. /* store.commit('SET_TOKEN', ""); */
  61. })
  62. }
  63. };
  64. window.onbeforeunload = function() {
  65. beginTime = new Date().getTime();
  66. };
  67. }
  68. }
  69. </script>
  70. <style>
  71. @import "plugin/colorui/main.css";
  72. @import "plugin/colorui/icon.css";
  73. @import "plugin/colorui/animation.css";
  74. .nav-list {
  75. display: flex;
  76. flex-wrap: wrap;
  77. padding: 0px 40upx 0px;
  78. justify-content: space-between;
  79. }
  80. .nav-li {
  81. padding: 30upx;
  82. border-radius: 12upx;
  83. width: 45%;
  84. margin: 0 2.5% 40upx;
  85. background-image: url(https://cdn.nlark.com/yuque/0/2019/png/280374/1552996358352-assets/web-upload/cc3b1807-c684-4b83-8f80-80e5b8a6b975.png);
  86. background-size: cover;
  87. background-position: center;
  88. position: relative;
  89. z-index: 1;
  90. }
  91. .nav-li::after {
  92. content: "";
  93. position: absolute;
  94. z-index: -1;
  95. background-color: inherit;
  96. width: 100%;
  97. height: 100%;
  98. left: 0;
  99. bottom: -10%;
  100. border-radius: 10upx;
  101. opacity: 0.2;
  102. transform: scale(0.9, 0.9);
  103. }
  104. .nav-li.cur {
  105. color: #fff;
  106. background: rgb(94, 185, 94);
  107. box-shadow: 4upx 4upx 6upx rgba(94, 185, 94, 0.4);
  108. }
  109. .nav-title {
  110. font-size: 32upx;
  111. font-weight: 300;
  112. }
  113. .nav-title::first-letter {
  114. font-size: 40upx;
  115. margin-right: 4upx;
  116. }
  117. .nav-name {
  118. font-size: 28upx;
  119. text-transform: Capitalize;
  120. margin-top: 20upx;
  121. position: relative;
  122. }
  123. .nav-name::before {
  124. content: "";
  125. position: absolute;
  126. display: block;
  127. width: 40upx;
  128. height: 6upx;
  129. background: #fff;
  130. bottom: 0;
  131. right: 0;
  132. opacity: 0.5;
  133. }
  134. .nav-name::after {
  135. content: "";
  136. position: absolute;
  137. display: block;
  138. width: 100upx;
  139. height: 1px;
  140. background: #fff;
  141. bottom: 0;
  142. right: 40upx;
  143. opacity: 0.3;
  144. }
  145. .nav-name::first-letter {
  146. font-weight: bold;
  147. font-size: 36upx;
  148. margin-right: 1px;
  149. }
  150. .nav-li text {
  151. position: absolute;
  152. right: 30upx;
  153. top: 30upx;
  154. font-size: 52upx;
  155. width: 60upx;
  156. height: 60upx;
  157. text-align: center;
  158. line-height: 60upx;
  159. }
  160. .text-light {
  161. font-weight: 300;
  162. }
  163. @keyframes show {
  164. 0% {
  165. transform: translateY(-50px);
  166. }
  167. 60% {
  168. transform: translateY(40upx);
  169. }
  170. 100% {
  171. transform: translateY(0px);
  172. }
  173. }
  174. @-webkit-keyframes show {
  175. 0% {
  176. transform: translateY(-50px);
  177. }
  178. 60% {
  179. transform: translateY(40upx);
  180. }
  181. 100% {
  182. transform: translateY(0px);
  183. }
  184. }
  185. </style>