index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <section>
  3. <!--工具条-->
  4. <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
  5. <div class="nowTime">
  6. <i class="fa fa-clock-o"></i>
  7. {{currentTime}}
  8. </div>
  9. </el-col>
  10. <!-- 卡片列表 -->
  11. <div>
  12. <el-col :span="6" v-for="(item, index) in desktopList" :key="index" class="one_div">
  13. <el-card :body-style="{ padding: '0px' }" shadow="hover" class="one_card">
  14. <div class="one_card_img">
  15. <el-image :src="this.pic_url" class="image" lazy>
  16. <div slot="error" class="image-slot">
  17. <el-image :src="require('../../assets/image/noPic.png')" class="image" lazy></el-image>
  18. </div>
  19. </el-image>
  20. <div :id="'over'+index" class="over">
  21. <el-button type="primary" plain @click.native="jumpTo(item.id)">
  22. <i class="fa fa-link"></i> 所有截图
  23. </el-button>
  24. </div>
  25. </div>
  26. <div class="one_card_txt">
  27. <!-- pic_type 这里需要一个巨长的三目运算符 -->
  28. <!-- 0-编程,1-查资料,2-看文档,3-做设计,4-美工,5-运营,6-看小说,7-打游戏,8-听音乐 -->
  29. <!-- 现在基本都是null -->
  30. <span>{{item.pic_type == null ? 0 : item.pic_type}}</span>
  31. <div class="bottom clearfix">
  32. <el-link>
  33. <i class="fa fa-circle"></i>
  34. {{item.name}}
  35. </el-link>
  36. <time class="time">{{item.time}}</time>
  37. </div>
  38. </div>
  39. </el-card>
  40. </el-col>
  41. </div>
  42. </section>
  43. </template>
  44. <script>
  45. import util from "../../common/js/util";
  46. export default {
  47. data() {
  48. return {
  49. filters: {
  50. keyName: ""
  51. },
  52. user: JSON.parse(sessionStorage.getItem("user")),
  53. timer: "",
  54. currentTime: util.formatDate.format(
  55. new Date(new Date()),
  56. "yyyy-MM-dd hh:mm:ss"
  57. ),
  58. desktopList: []
  59. };
  60. },
  61. methods: {
  62. getTime() {
  63. var _this = this; //声明一个变量指向Vue实例this,保证作用域一致
  64. this.timer = setInterval(function() {
  65. _this.currentTime = util.formatDate.format(
  66. new Date(new Date()),
  67. "yyyy-MM-dd hh:mm:ss"
  68. );
  69. }, 1000);
  70. },
  71. //获取项目列表
  72. getDesktopList() {
  73. this.listLoading = true;
  74. this.http.post(
  75. this.port.desktop.list,
  76. {},
  77. res => {
  78. this.listLoading = false;
  79. if (res.code == "ok") {
  80. this.desktopList = res.data;
  81. } else {
  82. this.$message({
  83. message: res.msg,
  84. type: "error"
  85. });
  86. }
  87. },
  88. error => {
  89. this.listLoading = false;
  90. this.$message({
  91. message: error,
  92. type: "error"
  93. });
  94. }
  95. );
  96. },
  97. jumpTo(id) {
  98. this.$router.push("/desktop/" + id);
  99. }
  100. },
  101. created() {
  102. this.getTime();
  103. },
  104. mounted() {
  105. this.getDesktopList();
  106. },
  107. beforeDestroy() {
  108. if (this.timer) {
  109. clearInterval(this.timer);
  110. }
  111. }
  112. };
  113. </script>
  114. <style lang="scss" scoped>
  115. .nowTime {
  116. height: 35px;
  117. line-height: 28px;
  118. font-size: 18px;
  119. color: #20a0ff;
  120. margin-left: 10px;
  121. i {
  122. margin-right: 10px;
  123. }
  124. }
  125. .one_div {
  126. padding: 15px;
  127. .one_card {
  128. .one_card_img {
  129. position: relative;
  130. .image {
  131. width: 100%;
  132. }
  133. .over {
  134. display: none;
  135. width: 100%;
  136. height: 98%;
  137. background: rgba(0, 0, 0, 0.2);
  138. position: absolute;
  139. top: 0;
  140. text-align: center;
  141. }
  142. }
  143. .one_card_txt {
  144. padding: 13px;
  145. .bottom {
  146. margin-top: 13px;
  147. line-height: 12px;
  148. i {
  149. color: #9ed0ff;
  150. margin-right: 5px;
  151. }
  152. .time {
  153. float: right;
  154. margin-top: 2px;
  155. color: #999;
  156. }
  157. }
  158. }
  159. }
  160. .one_card:hover {
  161. .one_card_img {
  162. .over {
  163. display: block !important;
  164. }
  165. }
  166. }
  167. }
  168. </style>
  169. <style lang="scss">
  170. .image {
  171. .el-image__inner {
  172. height: 11.6vw !important;
  173. }
  174. }
  175. .one_card_img {
  176. .over {
  177. .el-button {
  178. margin-top: 25%;
  179. }
  180. }
  181. }
  182. </style>