workbench.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <div class="home" v-if="category">
  3. <div class="categorytab">
  4. <!-- <div class="category-ico" @click="$router.push('/editcategory')"><van-icon name="setting-o" /></div> -->
  5. <van-nav-bar
  6. title="工作台"
  7. :left-arrow="false"
  8. />
  9. <div class="workben_header">
  10. <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
  11. <van-swipe-item><img src="../assets/img/pic_gzt_banner.png" alt=""></van-swipe-item>
  12. <van-swipe-item><img src="../assets/img/pic_gzt_banner.png" alt=""></van-swipe-item>
  13. </van-swipe>
  14. </div>
  15. <div class="index_nav">
  16. <p>
  17. <span>考勤打卡</span>
  18. <img src="../assets/img/icon_hp_kqdk.png" alt="">
  19. </p>
  20. <p>
  21. <span>请假申请</span>
  22. <img src="../assets/img/icon_hp_qjsq.png" alt="">
  23. </p>
  24. <p>
  25. <span>待审批</span>
  26. <img src="../assets/img/icon_hp_dsp.png" alt="">
  27. </p>
  28. </div>
  29. </div>
  30. <nav-bar v-bind:active=1></nav-bar>
  31. </div>
  32. </template>
  33. <script>
  34. import NavBar from "@/components/common/Navbar.vue";
  35. import cover from "./cover";
  36. export default {
  37. data() {
  38. return {
  39. category: [],
  40. active: 1
  41. };
  42. },
  43. components: {
  44. NavBar,
  45. cover
  46. },
  47. activated() {
  48. if(localStorage.getItem('newCat')) {
  49. let newCat = JSON.parse(localStorage.getItem('newCat'))
  50. this.category = this.changeCategory(newCat)
  51. this.selectArticle();
  52. }
  53. },
  54. methods: {
  55. async selectCategory() {
  56. if(localStorage.getItem('newCat')) {
  57. return
  58. }
  59. const res = await this.$http.get("/category");
  60. this.category = this.changeCategory(res.data);
  61. this.selectArticle();
  62. },
  63. changeCategory(data) {
  64. const category1 = data.map((item, index) => {
  65. item.list = [];
  66. item.page = 0;
  67. item.finished = false;
  68. item.loading = true;
  69. item.pagesize = 10;
  70. return item;
  71. });
  72. return category1;
  73. },
  74. async selectArticle() {
  75. const categoryitem = this.categoryItem();
  76. const res = await this.$http.get("/detail/" + categoryitem._id, {
  77. params: {
  78. page: categoryitem.page,
  79. pagesize: categoryitem.pagesize
  80. }
  81. });
  82. categoryitem.list.push(...res.data);
  83. categoryitem.loading = false;
  84. if (res.data.length < categoryitem.pagesize) {
  85. categoryitem.finished = true;
  86. }
  87. },
  88. onLoad() {
  89. const categoryitem = this.categoryItem();
  90. setTimeout(() => {
  91. categoryitem.page += 1;
  92. this.selectArticle();
  93. }, 1000);
  94. },
  95. categoryItem() {
  96. const categoryitem = this.category[this.active];
  97. return categoryitem;
  98. }
  99. },
  100. watch: {
  101. active() {
  102. const categoryitem = this.categoryItem();
  103. if (!categoryitem.list.length) {
  104. this.selectArticle();
  105. }
  106. }
  107. },
  108. created() {
  109. console.log(34)
  110. this.selectCategory();
  111. }
  112. };
  113. </script>
  114. <style lang="less" scoped>
  115. .home {
  116. background-color: #fff;
  117. padding: 7.999px;
  118. .categorytab{
  119. width: 100%;
  120. height: 100%;
  121. .workben_header{
  122. margin-bottom: 7.467vw;
  123. .my-swipe .van-swipe-item {
  124. color: #fff;
  125. font-size: 5.333vw;
  126. // line-height: 150px;
  127. text-align: center;
  128. // background-color: #39a9ed;
  129. img{
  130. width: 100%;
  131. height: 100%;
  132. }
  133. }
  134. }
  135. .index_headertr{
  136. background: url('../assets/img/pic_bg_qjjl.png') no-repeat ;
  137. background-size: 100% 100%;
  138. .inhe_one{
  139. p:nth-child(1){
  140. border-right: 1px solid #E09404;
  141. }
  142. }
  143. }
  144. // 第三部分样式
  145. .index_nav{
  146. display: flex;
  147. justify-content: space-around;
  148. align-items: center;
  149. p{
  150. flex: 1;
  151. display: flex;
  152. flex-direction: column-reverse;
  153. align-items: center;
  154. justify-content: center;
  155. span{
  156. font-size: 3.467vw;
  157. font-family: PingFang SC;
  158. font-weight: 400;
  159. color: #343434;
  160. }
  161. img{
  162. width: 18.4vw;
  163. height: 18.4vw;
  164. margin-bottom: 3.467vw;
  165. }
  166. }
  167. }
  168. }
  169. }
  170. </style>