init.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. onReady() {
  39. },
  40. methods: {
  41. goIndex(){
  42. uni.setStorage({
  43. key: 'version',
  44. data: this.config.version
  45. });
  46. uni.switchTab({
  47. url: '/pages/index/index',
  48. fail(err) {
  49. // console.log(err)
  50. }
  51. });
  52. },
  53. goGuide(){
  54. uni.setStorage({
  55. key: 'version',
  56. data: this.config.version
  57. });
  58. uni.redirectTo({
  59. url: '/pages/index/guide',
  60. fail(err) {
  61. // console.log(err)
  62. }
  63. });
  64. },
  65. goLogin(){
  66. uni.redirectTo({
  67. url: '/pages/login/loginType',
  68. fail(err) {
  69. // console.log(err)
  70. }
  71. });
  72. },
  73. }
  74. }
  75. </script>
  76. <style scoped>
  77. </style>