templateA.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <view class="picture">
  3. <view class="section" v-for="(item, index) in productList" :key="index" @click="navigaitionTo(item)">
  4. <image :src="item.appletsImage || item.image"></image>
  5. <view class="cm-cover"></view>
  6. </view>
  7. </view>
  8. </template>
  9. <script>
  10. import caimeiApi from '@/common/config/caimeiApi.js'
  11. export default {
  12. data() {
  13. return {
  14. productList: []
  15. }
  16. },
  17. props: {
  18. pageData: {
  19. type: Object
  20. },
  21. userIdentity: {
  22. type: Number
  23. },
  24. flag: {
  25. type: Boolean,
  26. default: false
  27. }
  28. },
  29. created() {
  30. this.initData(this.pageData)
  31. },
  32. watch: {
  33. pageData: {
  34. handler: function(el) {
  35. //监听对象的变换使用 function,箭头函数容易出现this指向不正确
  36. this.pageData = el
  37. this.initData(this.pageData)
  38. },
  39. deep: true
  40. }
  41. },
  42. methods: {
  43. initData(data) {
  44. if (this.flag) {
  45. this.productList = data.floorImageList
  46. } else {
  47. this.productList = data.floorImageList.slice(0, 6)
  48. }
  49. },
  50. navigaitionTo(item) {
  51. if (item.link === '' && item.linkType === -1) {
  52. return
  53. }else if(item.linkType === -1){
  54. const url = `/pages/h5/activity/activity-detail?type=video&videoUrl=${item.link}&title=${item.name}`
  55. return uni.navigateTo({ url })
  56. }else{
  57. caimeiApi.FlooryNavigateTo(item)
  58. }
  59. }
  60. }
  61. }
  62. </script>
  63. <style lang="scss">
  64. .picture {
  65. width: 100%;
  66. .section {
  67. float: left;
  68. position: relative;
  69. margin-bottom: 14rpx;
  70. margin-right: 14rpx;
  71. width: 224rpx;
  72. height: 157rpx;
  73. overflow: hidden;
  74. border-radius: 16rpx;
  75. image {
  76. width: 224rpx;
  77. height: 100%;
  78. }
  79. &:nth-child(1),
  80. &:nth-child(2),
  81. &:nth-child(3) {
  82. margin-top: 0;
  83. }
  84. &:nth-child(3n) {
  85. margin-right: 0;
  86. }
  87. .cm-cover {
  88. z-index: 99;
  89. top: 0;
  90. left: 0;
  91. position: absolute;
  92. width: 100%;
  93. height: 100%;
  94. background: url(https://static.caimei365.com/app/img/icon2/cm_player.png) no-repeat center;
  95. background-size: 40rpx 40rpx;
  96. }
  97. }
  98. }
  99. </style>