index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <div class="body">
  3. <van-swipe class="my-swipe" :autoplay="3000" :height="200" indicator-color="white">
  4. <van-swipe-item v-for="(item, index) in images" :key="index" class="swipe-img">
  5. <img :src="item"/>
  6. </van-swipe-item>
  7. </van-swipe>
  8. <van-grid :column-num="3">
  9. <van-grid-item v-for="(item,index) in routers" :key="index" :icon="item.icon" :text="item.name"
  10. :info="item.name=='消息记录'&&unreadNum>0?unreadNum:''"
  11. :to="item.url">
  12. </van-grid-item>
  13. </van-grid>
  14. <div class="tip">
  15. 新注册用户请登录PC版,完善组织结构信息<br>
  16. http://worktime.ttkuaiban.com
  17. </div>
  18. <Footer page="index"></Footer>
  19. </div>
  20. </template>
  21. <script>
  22. import Footer from "@/components/Footer";
  23. export default {
  24. data() {
  25. return {
  26. user: JSON.parse(localStorage.userInfo),
  27. unreadNum:0,
  28. images: [
  29. require('../../assets/img/index/banner_1.png'),
  30. require('../../assets/img/index/banner_2.png'),
  31. require('../../assets/img/index/banner_3.png'),
  32. ],
  33. routers: [
  34. {
  35. name: '查看日报',
  36. url: '/view',
  37. icon: 'description'
  38. },
  39. {
  40. name: '填写日报',
  41. url: '/edit',
  42. icon: 'edit'
  43. },
  44. ],
  45. };
  46. },
  47. created() {
  48. let index = this.active + 1;
  49. this.list = this[`list${index}`]; // this.list1
  50. },
  51. mounted() {
  52. if (this.user.role == 0) {
  53. //普通员工
  54. if (this.user.leader) {
  55. this.routers.push({
  56. name: '审核日报',
  57. url: '/review',
  58. icon: 'todo-list-o'
  59. });
  60. this.routers.push({
  61. name: '消息记录',
  62. url: '/msg',
  63. icon: 'todo-list-o',
  64. info: this.unreadNum
  65. });
  66. }
  67. } else {
  68. this.routers.push({
  69. name: '审核日报',
  70. url: '/review',
  71. icon: 'todo-list-o'
  72. });
  73. this.routers.push({
  74. name: '项目管理',
  75. url: '/project',
  76. icon: 'label-o'
  77. });
  78. this.routers.push({
  79. name: '消息记录',
  80. url: '/msg',
  81. icon: 'todo-list-o',
  82. info: this.unreadNum
  83. });
  84. }
  85. this.getMessage();
  86. },
  87. components: {
  88. Footer
  89. },
  90. methods: {
  91. getGoods() {
  92. let url = "/goods"; // /api/goods
  93. this.$axios
  94. .get(url)
  95. .then(res => {
  96. console.log("res", res);
  97. })
  98. .catch(err => {
  99. console.log("err", err);
  100. });
  101. },
  102. //获取消息
  103. getMessage() {
  104. this.$axios.post("/information/list", {
  105. })
  106. .then(res => {
  107. if(res.code == "ok") {
  108. var list = res.data;
  109. this.unreadNum = list.filter(l=>l.checked==0).length;
  110. console.log(this.unreadNum);
  111. }
  112. }).catch(err=> {toast.clear();});
  113. },
  114. }
  115. };
  116. </script>
  117. <style lang="less" scoped>
  118. .swipe-img {
  119. img {
  120. width: 100%;
  121. height: 100%;
  122. }
  123. }
  124. .body {
  125. height: calc(100vh - 50px);
  126. position: relative;
  127. }
  128. .tip {
  129. position: absolute;
  130. width: 100%;
  131. bottom: 5px;
  132. font-size: 14px;
  133. color: #8f8f8f;
  134. margin-top: 20px;
  135. text-align: center;
  136. line-height: 30px;
  137. }
  138. </style>