onedetail.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <view style="padding: 20upx 32upx;">
  3. <view style="font-size: 35rpx;padding-bottom: 46upx;">{{aricte.article_title}}</view>
  4. <view style="color: #999;padding-bottom: 46upx;">{{aricte.article_time}}</view>
  5. <rich-text :nodes="nodes"></rich-text>
  6. <view v-if="aricte.ad_type!=0 && nodes!='' " class="aricte" :class="isclose?'closeacrile':''">
  7. <view style="display: flex;justify-content: space-between;padding: 20upx 0;">
  8. <view>{{aricte.ad_title}}</view>
  9. <view style="color:#4399FC;" @click="close">x关闭</view>
  10. </view>
  11. <view @click="godetail" style="padding: 10upx 0upx;position: relative;">
  12. <image :src=" pictureUrl + '/' + aricte.ad_image" style="height: 600upx;width: 100%;" />
  13. <view style="color: #fff;position: absolute;bottom: 20upx;left: 20upx;">广告</view>
  14. </view>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. export default {
  20. data() {
  21. return {
  22. isclose: false,
  23. pictureUrl: this.pictureUrl,
  24. article_id: '',
  25. nodes:'',
  26. article_thumb:'',
  27. aricte: {}
  28. }
  29. },
  30. // onShareAppMessage(res) {
  31. // uni.showShareMenu({
  32. // withShareTicket: true
  33. // });
  34. // let that = this;
  35. // let id = this.article_id; // 酒店id
  36. // console.log(id);
  37. // if (res.from === 'button') {
  38. // // 来自页面内分享按钮
  39. // }
  40. // return {
  41. // title: that.hotelitle,
  42. // path: `/pages/myone/onedetail?id=${id}`,
  43. // imageUrl: this.pictureUrl+'/'+this.article_thumb
  44. // }
  45. // },
  46. onLoad(a) {
  47. console.log(a);
  48. this.article_id = a.id;
  49. this.article_thumb = a.article_thumb;
  50. let name = a.name;
  51. uni.setNavigationBarTitle({
  52. title: name
  53. });
  54. this.getactrile();
  55. },
  56. methods: {
  57. godetail() {
  58. if(this.aricte.ad_type == 1) {
  59. //商品
  60. let id = this.aricte.goods_id; // 商品Id
  61. let store_id = this.aricte.store_id; // 商品Id
  62. uni.navigateTo({
  63. url:`/pages/index/shop?id=${id}&store_id=${store_id}`
  64. })
  65. }else if(this.aricte.ad_type == 2) {
  66. //商品
  67. let id = this.aricte.store_id; // 商品Id
  68. uni.navigateTo({
  69. url: `/pages/index/hotel?id=${id}`
  70. });
  71. }
  72. },
  73. close() {
  74. this.isclose = true;
  75. },
  76. getactrile() {
  77. this.request({
  78. url: '/v1/entry/news_desc',
  79. method: 'post',
  80. data: {
  81. article_id: this.article_id
  82. },
  83. success: (res) => {
  84. let { data } = res.data;
  85. this.aricte = data;
  86. const regex = new RegExp('<img', 'gi');
  87. data.article_content =data.article_content.replace(regex,`<img class="changeimg"`);
  88. this.nodes = data.article_content; // 富文本渲染
  89. }
  90. })
  91. }
  92. },
  93. }
  94. </script>
  95. <style>
  96. .aricte {
  97. background-color: #EEEEEE;
  98. padding: 0 33upx 10upx 33upx;
  99. }
  100. .closeacrile {
  101. display: none;
  102. }
  103. .changeimg {
  104. width: 100%;
  105. height: auto!important;
  106. padding: 8upx 0;
  107. display: block;
  108. text-align: center;
  109. }
  110. </style>