templateH.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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" ></image>
  5. <view class="cm-cover" v-if="pageData.floorContent.templateClassify === 4"></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.adsImage === '' && item.linkType === -1) {
  52. return
  53. }else if(item.linkType === -1){
  54. uni.navigateTo({
  55. url:`/pages/h5/activity/activity-detail?adsImage=${item.adsImage}&title=${item.name}`
  56. })
  57. }else{
  58. caimeiApi.FlooryNavigateTo(item)
  59. }
  60. }
  61. }
  62. }
  63. </script>
  64. <style lang="scss">
  65. .picture{
  66. width: 100%;
  67. .section{
  68. float: left;
  69. position: relative;
  70. margin-bottom: 14rpx;
  71. margin-right: 14rpx;
  72. width: 224rpx;
  73. height: 157rpx;
  74. overflow: hidden;
  75. border-radius: 16rpx;
  76. image{
  77. width: 224rpx;
  78. height: 257rpx;
  79. }
  80. &:nth-child(1),
  81. &:nth-child(2),
  82. &:nth-child(3){
  83. margin-top: 0;
  84. }
  85. &:nth-child(3n){
  86. margin-right: 0;
  87. }
  88. .cm-cover{
  89. z-index: 99;
  90. top: 0;
  91. left: 0;
  92. position: absolute;
  93. width: 100%;
  94. height: 100%;
  95. background: url(https://static.caimei365.com/app/img/icon2/cm_player.png) no-repeat center;
  96. background-size: 40rpx 40rpx;
  97. }
  98. }
  99. }
  100. </style>