index.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <template>
  2. <view>
  3. <home v-show="current == 0" ref="home"></home>
  4. <my v-show="current == 1" ref="refMy"></my>
  5. <u-tabbar v-model="current" :list="list" active-color="#2F4379" :before-switch="beforeSwitch"></u-tabbar>
  6. </view>
  7. </template>
  8. <script>
  9. import home from '@/components/home.vue';
  10. import my from '@/components/my.vue';
  11. import {mapGetters} from 'vuex';
  12. export default {
  13. components: {
  14. home,
  15. my
  16. },
  17. data() {
  18. return {
  19. list: [
  20. {
  21. iconPath: '/static/nav1.png',
  22. selectedIconPath: '/static/nav1_on.png',
  23. text: '学习中心',
  24. customIcon: false
  25. },
  26. {
  27. iconPath: '/static/nav4.png',
  28. selectedIconPath: '/static/nav4_on.png',
  29. text: '我的',
  30. customIcon: false
  31. }
  32. ],
  33. current: 0
  34. };
  35. },
  36. onLoad(option) {},
  37. onShow() {
  38. this.$refs.home.init();
  39. },
  40. onShareAppMessage(res) {
  41. var self = this;
  42. return {
  43. title: '中正',
  44. path: `/pages/index/index?inviteCode=`+userInfo==null?'':userInfo.userAccount,
  45. };
  46. },
  47. methods: {
  48. beforeSwitch(index) {
  49. let that = this;
  50. if (index == this.current) {
  51. return false;
  52. }
  53. if (!this.$method.isLogin()) {
  54. this.$navTo.togo('/pages/login/login');
  55. return false;
  56. } else {
  57. if (index == 1) {
  58. this.$refs.refMy.init();
  59. }
  60. return true;
  61. }
  62. }
  63. },
  64. onReachBottom() {},
  65. onPullDownRefresh() {},
  66. computed: {...mapGetters(['userInfo'])}
  67. };
  68. </script>
  69. <style scoped></style>