App.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <script>
  2. // #ifdef H5
  3. import { shareConfig } from "./common/wechat";
  4. // #endif
  5. export default {
  6. onLaunch: function(options) {
  7. this.autoLogin();
  8. // #ifdef H5
  9. uni.getSystemInfo({
  10. success(e) {
  11. if (e.windowWidth > 420 && !/iOS|Android/i.test(e.system)) {
  12. window.location.pathname = '/wap/static/html/home.html';
  13. }
  14. }
  15. })
  16. // #endif
  17. },
  18. onShow: function() {
  19. let users = this.$storage.getJson("users");
  20. if(users){
  21. uni.setTabBarBadge({ index: 2, text: users.shop_count.toString() });
  22. }else{
  23. uni.removeTabBarBadge({ index: 2 })
  24. }
  25. },
  26. onHide: function() {
  27. console.log('App Hide')
  28. },
  29. methods: {
  30. autoLogin(){
  31. let users = this.$storage.getJson("users");
  32. if(users != null){
  33. this.$http.autoLogin().then(result=>{
  34. if(result.status===1000){
  35. this.$store.commit("UPDATEUSERS",result.data);
  36. }else{
  37. this.$storage.remove("users");
  38. }
  39. });
  40. }
  41. },
  42. }
  43. }
  44. </script>
  45. <style>
  46. @import '~@/style.css';
  47. page { background-color: #f8f8f8; }
  48. .clear:after { content:" "; font-size:0; display:block; height:0; clear:both; visibility:hidden; }
  49. uni-checkbox .uni-checkbox-input { border-radius: 50rpx; }
  50. // #ifdef H5
  51. uni-toast { z-index: 10099 !important; }
  52. uni-modal { z-index: 10099 !important; }
  53. // #endif
  54. ::-webkit-scrollbar {
  55. display: none;
  56. width: 0 !important;
  57. height: 0 !important;
  58. -webkit-appearance: none;
  59. background: transparent;
  60. }
  61. </style>