onedetail.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template>
  2. <view style="padding: 20upx 32upx;">
  3. <rich-text :nodes="nodes"></rich-text>
  4. <view v-if="aricte.ad_type!=0" class="aricte" :class="isclose?'closeacrile':''">
  5. <view style="display: flex;justify-content: space-between;">
  6. <view>{{aricte.ad_title}}</view>
  7. <view style="color:#4399FC;" @click="close">x关闭</view>
  8. </view>
  9. <view @click="godetail" style="padding: 10upx 0upx;position: relative;">
  10. <image :src=" pictureUrl + '/' + aricte.ad_image" style="height: 600upx;width: 100%;" />
  11. <view style="color: #fff;position: absolute;bottom: 20upx;left: 20upx;">广告</view>
  12. </view>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. export default {
  18. data() {
  19. return {
  20. isclose: false,
  21. pictureUrl: this.pictureUrl,
  22. article_id: '',
  23. nodes:'',
  24. aricte: {}
  25. }
  26. },
  27. onLoad(a) {
  28. this.article_id = a.id;
  29. let name = a.name;
  30. uni.setNavigationBarTitle({
  31. title: name
  32. });
  33. this.getactrile();
  34. },
  35. methods: {
  36. godetail() {
  37. if(this.aricte.ad_type == 1) {
  38. //商品
  39. let id = this.aricte.goods_id; // 商品Id
  40. let store_id = this.aricte.store_id; // 商品Id
  41. uni.navigateTo({
  42. url:`/pages/index/shop?id=${id}&store_id=${store_id}`
  43. })
  44. // uni.navigateTo({
  45. // url:`/pages/index/shop/?id=${id}&store_id=${store_id}`
  46. // })
  47. }else if(this.aricte.ad_type == 2) {
  48. //商品
  49. let id = this.aricte.store_id; // 商品Id
  50. uni.navigateTo({
  51. url: `/pages/index/hotel?id=${id}`
  52. });
  53. }
  54. },
  55. close() {
  56. this.isclose = true;
  57. },
  58. getactrile() {
  59. this.request({
  60. url: '/v1/entry/news_desc',
  61. method: 'post',
  62. data: {
  63. article_id: this.article_id
  64. },
  65. success: (res) => {
  66. let { data } = res.data;
  67. this.aricte = data;
  68. const regex = new RegExp('<img', 'gi');
  69. data.article_content =data.article_content.replace(regex,
  70. `<img class="changeimg"`);
  71. this.nodes = data.article_content;
  72. }
  73. })
  74. }
  75. },
  76. }
  77. </script>
  78. <style>
  79. .aricte {
  80. background-color: #EEEEEE;
  81. }
  82. .closeacrile {
  83. display: none;
  84. }
  85. .changeimg {
  86. width: 100%;
  87. height: auto!important;
  88. display: block;
  89. text-align: center;
  90. }
  91. </style>