index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <div class='item-con' :style="{maxHeight: data.length>0?height:'0px'}">
  3. <div @click="goto(item.webSite)" class="item-item" :style="{paddingLeft:(split-260)+ 'px'}" v-for="(item,i) in data" :key="i">
  4. <div class="item">
  5. <div class="type">
  6. <vcenter>
  7. <span>{{typeArr[item['sceneType']]}}</span>
  8. </vcenter>
  9. </div>
  10. <div class="title">
  11. <img :src="item.homepic" alt="">
  12. <div class="title-txt">
  13. <vcenter>
  14. <div v-html="maskTitle(item.sceneName)"></div>
  15. <div class="sub">{{item.nickName}}</div>
  16. </vcenter>
  17. </div>
  18. </div>
  19. <div class="date">
  20. <vcenter>
  21. <div>{{format(item.createTime.time)}}</div>
  22. </vcenter>
  23. </div>
  24. </div>
  25. </div>
  26. </div>
  27. </template>
  28. <script>
  29. // 这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  30. // 例如:import 《组件名称》 from '《组件路径》';
  31. import vcenter from '@/components/vcenter'
  32. export default {
  33. // import引入的组件需要注入到对象中才能使用
  34. props: {
  35. data: {
  36. default: () => {
  37. return []
  38. },
  39. type: Array
  40. },
  41. split: {
  42. default: 0,
  43. type: Number
  44. },
  45. searchTxt: {
  46. default: '',
  47. type: String
  48. }
  49. },
  50. components: {vcenter},
  51. data () {
  52. let typeArr = ['其他', '博物馆', '房地产', '其他', '餐饮', '家居']
  53. // 这里存放数据
  54. return {
  55. typeArr
  56. }
  57. },
  58. // 监听属性 类似于data概念
  59. computed: {
  60. height () {
  61. return window.innerHeight - (68 + 145 + 145 - 27) + 'px'
  62. }
  63. },
  64. // 监控data中的数据变化
  65. watch: {},
  66. // 方法集合
  67. methods: {
  68. format (time) {
  69. let date = new Date(time)
  70. return date.format('yyyy-MM-dd')
  71. },
  72. goto (url) {
  73. window.open(url.replace('http://', 'https://'), '_blank')
  74. },
  75. maskTitle (name) {
  76. let html = ''
  77. var arr = name.split(this.searchTxt)
  78. html = arr.join('<span style="background:#feced4;">' + this.searchTxt + '</span>')
  79. return html
  80. }
  81. },
  82. // 生命周期 - 创建完成(可以访问当前this实例)
  83. created () {
  84. },
  85. // 生命周期 - 挂载完成(可以访问DOM元素)
  86. mounted () {
  87. }
  88. }
  89. </script>
  90. <style lang="scss" scoped>
  91. $lHeight: 120px;
  92. .item-con {
  93. overflow-y: scroll;
  94. transition: max-height 0.6s ease;
  95. background: #fff;
  96. .item-item {
  97. background-color: #fff;
  98. border-bottom: 1px solid #e5e5e5;
  99. color: #414141;
  100. cursor: pointer;
  101. &:hover{
  102. background-color: #f6f6f6;
  103. }
  104. .item{
  105. max-width: 1200px;
  106. height: $lHeight;
  107. font-size: 0;
  108. position: relative;
  109. .type{
  110. display: inline-block;
  111. width: 260px;
  112. height: $lHeight;
  113. padding-left: 62px;
  114. color: #f9082a;
  115. font-size: 18px;
  116. span{
  117. color: #414141;
  118. }
  119. }
  120. .title{
  121. border-left: 1px solid #e5e5e5;
  122. display: inline-block;
  123. font-size: 18px;
  124. height: $lHeight;
  125. img{
  126. width: 186px;
  127. height: 121px;
  128. display: inline-block;
  129. font-size: 0;
  130. }
  131. .title-txt{
  132. display: inline-block;
  133. height: $lHeight;
  134. line-height: 1;
  135. padding: 40px 0;
  136. padding-left: 45px;
  137. .sub{
  138. color: #414141;
  139. font-size: 14px;
  140. margin-top: 8px;
  141. }
  142. }
  143. }
  144. .date{
  145. display: inline-block;
  146. font-size: 18px;
  147. height: $lHeight;
  148. position: absolute;
  149. right: 0;
  150. }
  151. }
  152. }
  153. }
  154. </style>