product_detail.vue 2.5 KB

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