index.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. console.log(34)
  48. },
  49. onLoad(option) {
  50. this.$refs.home.init();
  51. this.getDict()
  52. // this.$refs.recruitment.inits();
  53. },
  54. onShow() {},
  55. onShareAppMessage(res) {
  56. var self = this;
  57. return {
  58. title: '中正',
  59. path: `/pages/index/index?inviteCode=` + userInfo == null ? '' : userInfo.userAccount
  60. };
  61. },
  62. methods: {
  63. getDict(){
  64. let that = this
  65. this.$api.dictList().then(res => {
  66. if (res.data.code === 200) {
  67. let newList = {}
  68. let list = res.data.data
  69. for(let i =0 ;i<list.length;i++){
  70. let item = list[i]
  71. if(newList.hasOwnProperty(item.dictType)){
  72. newList[item.dictType].push(item.dictLabel)
  73. }else{
  74. newList[item.dictType] = [item.dictLabel]
  75. }
  76. }
  77. that.$store.state.dictObj = newList;
  78. console.log(newList)
  79. }
  80. });
  81. },
  82. updateHomePlan() {
  83. this.$refs.home.init();
  84. },
  85. beforeSwitch(index) {
  86. let that = this;
  87. if (index == 1) {
  88. this.isClick1 = true;
  89. }
  90. if (index == this.current) {
  91. return false;
  92. }
  93. if (!this.$method.isLogin()) {
  94. if (index == 0 || index == 1) {
  95. return true;
  96. } else {
  97. this.$navTo.togo('/pages/login/login');
  98. return false;
  99. }
  100. } else {
  101. if (index == 2) {
  102. this.$refs.refMy.init();
  103. }
  104. return true;
  105. }
  106. }
  107. },
  108. onReachBottom() {},
  109. computed: { ...mapGetters(['userInfo']) }
  110. };
  111. </script>
  112. <style scoped></style>