chartItem.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <view class="chart-item" :data-id="itemData.dragId" @click.stop="itemClick">
  3. <rich-text
  4. class="van-multi-ellipsis--l2 title"
  5. :nodes="formatTitle(itemData.ChartName)"
  6. @longpress.stop="chartTitle(itemData,$event)"
  7. ></rich-text>
  8. <view class="pop-title" v-if="showPopTitle">{{itemData.ChartName}}</view>
  9. <image lazy-load class="img" :src="itemData.ChartImage" mode="aspectFill"/>
  10. </view>
  11. </template>
  12. <script>
  13. export default {
  14. name:"chartItem",
  15. props: {
  16. itemData:{
  17. type: Object,
  18. value: {}
  19. },
  20. searchVal:""
  21. },
  22. data () {
  23. return {
  24. showPopTitle:false,
  25. title:"",
  26. }
  27. },
  28. methods: {
  29. itemClick(){
  30. this.$emit('click')
  31. this.showPopTitle=false
  32. },
  33. formatTitle(e){
  34. const reg=new RegExp(this.searchVal,'gi')
  35. return e.replace(reg,`<span style="color:#FF0000">${this.searchVal}</span>`)
  36. },
  37. // 长按标题
  38. chartTitle(data,e){
  39. this.showPopTitle=true
  40. this.title=data.ChartName
  41. uni.setClipboardData({
  42. data: data.ChartName,
  43. success: (result) => {},
  44. fail: (error) => {}
  45. })
  46. }
  47. }
  48. }
  49. </script>
  50. <style lang='scss' scoped>
  51. .chart-item{
  52. height: 380rpx;
  53. background: #FFFFFF;
  54. box-shadow: 0px 0px 12rpx rgba(154, 141, 123, 0.16);
  55. border-radius: 8rpx;
  56. margin-left: 10rpx;
  57. margin-right: 10rpx;
  58. margin-bottom: 20rpx;
  59. padding: 20rpx 20rpx 33rpx 20rpx;
  60. position: relative;
  61. .title{
  62. font-size: 26rpx;
  63. min-height: 68rpx;
  64. }
  65. .pop-title{
  66. position: absolute;
  67. width: 80%;
  68. font-size: 24rpx;
  69. padding: 8rpx;
  70. border-radius: 4rpx;
  71. top: 80rpx;
  72. left: 10%;
  73. background-color: #fff;
  74. box-shadow: 0px 0px 12rpx rgba(154, 141, 123, 0.16);
  75. }
  76. .img{
  77. margin-top: 10rpx;
  78. width: 100%;
  79. height: 261rpx;
  80. display: block;
  81. margin-left: auto;
  82. margin-right: auto;
  83. background-color: #f6f6f6;
  84. }
  85. }
  86. </style>