init.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <view class="pages">
  3. </view>
  4. </template>
  5. <script>
  6. export default {
  7. data() {
  8. return {
  9. }
  10. },
  11. onShow() {
  12. // console.log('config',this.$getimg);
  13. },
  14. onLoad() {
  15. // 从本地缓存中同步获取指定 key 对应的内容,用于判断是否是第一次打开应用
  16. const launch = uni.getStorageSync('launchFlag');
  17. const haslogin = uni.getStorageSync('hasLogin');
  18. const version = uni.getStorageSync('version');
  19. if(!version){
  20. uni.setStorage({
  21. key: 'version',
  22. data: this.config.version
  23. });
  24. }
  25. if (launch&&version==this.config.version&&haslogin) {
  26. // 如果已经有,直接去首页
  27. this.goIndex();
  28. // this.goLogin();//有问题先每次登录
  29. } else if(launch&&version==this.config.version&&!haslogin){
  30. // this.goLogin();
  31. this.goIndex();
  32. } else {
  33. // 没有值,跳到引导页,并存储,下次打开就不会进去引导页
  34. this.goGuide();
  35. // this.lxfEndtime();
  36. };
  37. //
  38. uni.removeStorage({
  39. key:'beforeLoginPage'
  40. });
  41. },
  42. onReady() {
  43. },
  44. methods: {
  45. goIndex(){
  46. uni.setStorage({
  47. key: 'version',
  48. data: this.config.version
  49. });
  50. uni.switchTab({
  51. url: '/pages/index/index',
  52. fail(err) {
  53. // console.log(err)
  54. }
  55. });
  56. },
  57. goGuide(){
  58. uni.setStorage({
  59. key: 'version',
  60. data: this.config.version
  61. });
  62. uni.redirectTo({
  63. url: '/pages/index/guide',
  64. fail(err) {
  65. // console.log(err)
  66. }
  67. });
  68. },
  69. goLogin(){
  70. uni.redirectTo({
  71. url: '/pages/login/loginType',
  72. fail(err) {
  73. // console.log(err)
  74. }
  75. });
  76. },
  77. }
  78. }
  79. </script>
  80. <style scoped>
  81. </style>