onedetail.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. console.log(this.aricte.ad_type)
  38. if(this.aricte.ad_type == 1) {
  39. //商品
  40. let id = this.aricte.goods_id; // 商品Id
  41. let store_id = this.aricte.store_id; // 商品Id
  42. uni.navigateTo({
  43. url:`/pages/index/shop?id=${id}&store_id=${store_id}`
  44. })
  45. // uni.navigateTo({
  46. // url:`/pages/index/shop/?id=${id}&store_id=${store_id}`
  47. // })
  48. }else if(this.aricte.ad_type == 2) {
  49. //商品
  50. let id = this.aricte.store_id; // 商品Id
  51. uni.navigateTo({
  52. url: `/pages/index/hotel?id=${id}`
  53. });
  54. }
  55. },
  56. close() {
  57. this.isclose = true;
  58. },
  59. getactrile() {
  60. this.request({
  61. url: '/v1/entry/news_desc',
  62. method: 'post',
  63. data: {
  64. article_id: this.article_id
  65. },
  66. success: (res) => {
  67. let { data } = res.data;
  68. this.aricte = data;
  69. const regex = new RegExp('<img', 'gi');
  70. data.article_content =data.article_content.replace(regex,
  71. `<img class="changeimg"`);
  72. this.nodes = data.article_content;
  73. }
  74. })
  75. }
  76. },
  77. }
  78. </script>
  79. <style>
  80. .aricte {
  81. background-color: #EEEEEE;
  82. }
  83. .closeacrile {
  84. display: none;
  85. }
  86. .changeimg {
  87. width: 100%;
  88. height: auto!important;
  89. display: block;
  90. text-align: center;
  91. }
  92. </style>