index.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <view>
  3. <home v-show="current == 0" ref="home"></home>
  4. <recruitment v-show="current == 1" ref="recruitment"></recruitment>
  5. <my v-show="current == 2" ref="refMy"></my>
  6. <u-tabbar v-model="current" :safe-area-inset-bottom="true" :list="list" active-color="#2F4379" :before-switch="beforeSwitch"></u-tabbar>
  7. </view>
  8. </template>
  9. <script>
  10. import home from '@/components/home.vue';
  11. import my from '@/components/my.vue';
  12. import recruitment from '@/components/recruitment.vue';
  13. import { mapGetters } from 'vuex';
  14. export default {
  15. components: {
  16. home,
  17. my,
  18. recruitment
  19. },
  20. data() {
  21. return {
  22. list: [
  23. {
  24. iconPath: '/static/nav1.png',
  25. selectedIconPath: '/static/nav1_on.png',
  26. text: '学习中心',
  27. customIcon: false
  28. },
  29. {
  30. iconPath: '/static/job@3x.png',
  31. selectedIconPath: '/static/job@3xactive.png',
  32. text: '求职',
  33. customIcon: false
  34. },
  35. {
  36. iconPath: '/static/nav4.png',
  37. selectedIconPath: '/static/nav4_on.png',
  38. text: '我的',
  39. customIcon: false
  40. }
  41. ],
  42. current: 0,
  43. isClick1: false
  44. };
  45. },
  46. onPullDownRefresh(){
  47. },
  48. onLoad(option) {
  49. this.$refs.home.init();
  50. this.getDict()
  51. },
  52. onShow() {
  53. /* if(this.current === 2 && this.$method.isLogin()){
  54. this.$refs.refMy.init();
  55. } */
  56. },
  57. onShareAppMessage(res) {
  58. var self = this;
  59. return {
  60. title: '中正',
  61. path: `/pages/index/index?inviteCode=` + userInfo == null ? '' : userInfo.userAccount
  62. };
  63. },
  64. methods: {
  65. getDict(){
  66. let that = this
  67. this.$api.dictList().then(res => {
  68. if (res.data.code === 200) {
  69. let newList = {}
  70. let list = res.data.data
  71. for(let i =0 ;i<list.length;i++){
  72. let item = list[i]
  73. if(newList.hasOwnProperty(item.dictType)){
  74. newList[item.dictType].push(item.dictLabel)
  75. }else{
  76. newList[item.dictType] = [item.dictLabel]
  77. }
  78. }
  79. that.$store.state.dictObj = newList;
  80. }
  81. });
  82. },
  83. updateHomePlan() {
  84. this.$refs.home.init();
  85. },
  86. beforeSwitch(index) {
  87. let that = this;
  88. if (index == 1) {
  89. this.isClick1 = true;
  90. }
  91. if (index == this.current) {
  92. return false;
  93. }
  94. if (!this.$method.isLogin()) {
  95. if (index == 0 || index == 1) {
  96. return true;
  97. } else {
  98. this.$navTo.togo('/pages/login/login');
  99. return false;
  100. }
  101. } else {
  102. if (index == 2) {
  103. this.$refs.refMy.init();
  104. }
  105. return true;
  106. }
  107. }
  108. },
  109. onReachBottom() {},
  110. computed: { ...mapGetters(['userInfo']) }
  111. };
  112. </script>
  113. <style scoped></style>