productDetail.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <div class="content">
  3. <div class="title">
  4. <div class="logo">
  5. <img :src="logo" alt=""/>
  6. </div>
  7. <div class="name">
  8. {{ name }}
  9. </div>
  10. </div>
  11. <div v-if="titleUrl">
  12. <img :src="titleUrl" alt="logo" class="detail-img"/>
  13. </div>
  14. <div class="fwb" style="text-align: left;" v-html="company"></div>
  15. </div>
  16. </template>
  17. <script>
  18. export default {
  19. components: {
  20. // uParse
  21. },
  22. mounted() {
  23. console.log(this.$route.query);
  24. this.getRich(this.$route.query.id);
  25. this.titleUrl = this.$route.query.imgUrl;
  26. this.logo = this.$route.query.logo;
  27. this.name = this.$route.query.name;
  28. },
  29. data() {
  30. return {
  31. company: "",
  32. titleUrl:'',
  33. logo:'',
  34. name: '',
  35. shareBaseUrl:"https://kiq.xazhima.com/",
  36. };
  37. },
  38. methods: {
  39. replaceImg(html) {
  40. let that = this;
  41. return html.replace(/<img [^>]*src=['"]([^'"]+)[^>]*>/gi,function (match, capture) {
  42. if(capture.includes('http')){
  43. return (
  44. "<img src=" + capture +' style="max-width:100%;height:auto;display:block;margin:10px 0;"/>'
  45. );
  46. }else {
  47. return (
  48. "<img src=" + that.shareBaseUrl + capture +' style="max-width:100%;height:auto;display:block;margin:10px 0;"/>'
  49. );
  50. }
  51. }
  52. );
  53. },
  54. getRich(ids) {
  55. this.$api.totalApi.richHtmlProductApi(ids).then(res=>{
  56. if (res.status === 200) {
  57. this.company = this.replaceImg(res.data);
  58. }
  59. })
  60. },
  61. },
  62. };
  63. </script>
  64. <style scoped>
  65. .content {
  66. padding: 4%;
  67. font-size: 16px;
  68. }
  69. .title {
  70. display: flex;
  71. align-items: center;
  72. border-radius: 5px;
  73. margin-bottom: 10px;
  74. box-shadow: rgba(0, 0, 0, 0.35) 0 3px 7px;
  75. padding:5px;}
  76. .logo img {
  77. width: 50px;
  78. height: 50px;
  79. margin: 0 15px;
  80. }
  81. .detail-img {
  82. width: 100%;
  83. height: 200px;
  84. object-fit: contain;
  85. margin-bottom: 10px;
  86. }
  87. </style>