product_detail.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <div class="content">
  3. <div class="title">
  4. <div class="logo">
  5. <img :src="logo" alt="" mode="aspectFit" />
  6. </div>
  7. <div class="name">
  8. {{ name }}
  9. </div>
  10. </div>
  11. <div class="fwb" v-html="company">
  12. <u-parse :content="company"/>
  13. </div>
  14. <!-- <div style="width: 100%">
  15. <footer-share
  16. style="width: 100%"
  17. :isCollection="true"
  18. @collectionPages="collectionPage"
  19. @sharePages="sharePage"
  20. ></footer-share>
  21. </div> -->
  22. </div>
  23. </template>
  24. <script>
  25. import uParse from '@/components/gaoyia-parse/parse.vue'
  26. export default {
  27. components: {
  28. uParse
  29. },
  30. onLoad(option) {
  31. this.getRich(option.id);
  32. },
  33. data() {
  34. return {
  35. company: "",
  36. logo: getApp().globalData.company_logo,
  37. name: getApp().globalData.company_name,
  38. };
  39. },
  40. methods: {
  41. replaceImg(html) {
  42. let result = html.replace(
  43. /<img [^>]*src=['"]([^'"]+)[^>]*>/gi,
  44. function (match, capture) {
  45. if(capture.includes('http')){
  46. return (
  47. "<img src=" +
  48. capture +
  49. ' style="max-width:100%;height:auto;display:block;margin:10px 0;"/>'
  50. );
  51. }else {
  52. return (
  53. "<img src=" +
  54. getApp().globalData.shareUrl +
  55. capture +
  56. ' style="max-width:100%;height:auto;display:block;margin:10px 0;"/>'
  57. );
  58. }
  59. }
  60. );
  61. return result;
  62. },
  63. getRich(ids) {
  64. uni.request({
  65. url: `https://kiq.xazhima.com/content/company_product/${Math.floor(
  66. ids / 1000
  67. )}/${ids}.html`,
  68. method: "GET",
  69. header: {
  70. "content-type": "application/x-www-form-urlencoded",
  71. },
  72. success: (res) => {
  73. if (res.statusCode === 200) {
  74. this.company = this.replaceImg(res.data);
  75. }
  76. },
  77. fail: () => {
  78. console.log("连接失败");
  79. },
  80. });
  81. },
  82. },
  83. };
  84. </script>
  85. <style lang="scss">
  86. .content {
  87. padding: 4%;
  88. font-size: 30rpx;
  89. .title {
  90. display: flex;
  91. align-items: center;
  92. border-radius: 10rpx;
  93. margin-bottom: 50rpx;
  94. box-shadow: rgba(0, 0, 0, 0.35) 0rpx 5rpx 15rpx;
  95. .logo {
  96. image {
  97. width: 150rpx;
  98. height: 100rpx;
  99. margin: 0 30rpx;
  100. }
  101. }
  102. }
  103. }
  104. </style>