chartItem.vue 2.2 KB

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