index.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template>
  2. <view>
  3. <home v-show="current == 0"></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 { mapState, mapMutations } 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. onShareAppMessage: function(res) {
  39. var self = this;
  40. return {
  41. title: '中正',
  42. path: `/pages/index/index`,
  43. success(res) {
  44. if (self.$store.state.userInfo !== null) {
  45. console.log('已登录');
  46. var data = {
  47. taskType: 3
  48. };
  49. self.$api.taskShare(data).then(result => {});
  50. }
  51. },
  52. fail(res) {
  53. uni.showToast({
  54. title: '分享失败',
  55. icon: 'none'
  56. });
  57. }
  58. };
  59. },
  60. methods: {
  61. beforeSwitch(index) {
  62. let that = this;
  63. if (index == this.current) {
  64. return false;
  65. }
  66. if (!this.$method.isLogin()) {
  67. this.$navTo.togo('/pages/login/login');
  68. return false;
  69. } else {
  70. if (index == 1) {
  71. this.$refs.refMy.init();
  72. }
  73. return true;
  74. }
  75. }
  76. },
  77. onReachBottom() {},
  78. onPullDownRefresh() {},
  79. computed: { ...mapState(['login']) }
  80. };
  81. </script>
  82. <style scoped></style>