points-view - wx.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <view >
  3. <swiper class="screen-swiper square-dot margin-sm" style="height: 260rpx;min-height: 268rpx;"
  4. :indicator-dots="true" :circular="true" :autoplay="true" interval="5000" duration="500">
  5. <swiper-item>
  6. <div>
  7. <div id="launch-btn"></div>
  8. </div>
  9. </swiper-item>
  10. <swiper-item v-if="item.type!=0" v-for="(item,index) in adsList" :key="index">
  11. <u-image @click="jump(item.path)" style="width: 100%;height: 268rpx;" :src="item.url"
  12. mode="aspectFill"></u-image>
  13. </swiper-item>
  14. </swiper>
  15. <goods :goodsList="goodsList" :activityId="activityId"></goods>
  16. <view style="height: 50rpx;">
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. import goods from "@/components/goods/goods.vue"
  22. import {
  23. wx_launch
  24. } from "../../common/utils/wx_launch.js"; // 引入公共js文件
  25. export default {
  26. components: {
  27. goods
  28. },
  29. props: {
  30. activityId: {
  31. type: String,
  32. default: '',
  33. }
  34. },
  35. data() {
  36. return {
  37. goodsList: [],
  38. adsList: [],
  39. appletList: []
  40. }
  41. },
  42. created() {
  43. this.$shareConfig({}, this)
  44. this.fetchGoodsList();
  45. },
  46. async mounted() {
  47. let res = await this.$u.api.pointsGoods.ads({
  48. activityId: this.activityId
  49. })
  50. this.adsList = res.records;
  51. this.appletList = this.adsList.filter(item => item.type == 0)
  52. let image=this.appletList[0].url
  53. let appid=this.appletList[0].path
  54. let page=this.appletList[0].page
  55. // 自定义html内容
  56. let content = `
  57. <image class="img" src="${image}"
  58. mode="scaleToFill"></image>
  59. <style>
  60. .img{
  61. z-index:999,
  62. width:100%;
  63. height: 268rpx;
  64. }
  65. </style>
  66. `
  67. let launchParams = {
  68. eleId: "launch-btn", // 元素id
  69. url: page+".html", // 跳转小程序的页面路径
  70. appid,
  71. content // 自定义的html内容
  72. };
  73. wx_launch(launchParams);
  74. },
  75. methods: {
  76. async fetchAds() {
  77. let res = await this.$u.api.pointsGoods.ads({
  78. activityId: this.activityId
  79. })
  80. this.adsList = res.records;
  81. this.appletList = this.adsList.filter(item => item.type == 0)
  82. },
  83. fetchGoodsList() {
  84. this.$u.api.pointsGoods.list({
  85. activityId: this.activityId
  86. }).then(res => {
  87. this.goodsList = res.records;
  88. })
  89. },
  90. jump(url) {
  91. uni.navigateTo({
  92. url: '/pages/web-view/web-view?url=' + url
  93. })
  94. }
  95. }
  96. }
  97. </script>
  98. <style>
  99. </style>