templateD.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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>
  6. </view>
  7. </template>
  8. <script>
  9. import caimeiApi from '@/common/config/caimeiApi.js'
  10. export default{
  11. data(){
  12. return{
  13. productList:[]
  14. }
  15. },
  16. props:{
  17. pageData: {
  18. type: Object
  19. },
  20. userIdentity: {
  21. type: Number
  22. },
  23. flag:{
  24. type:Boolean,
  25. default:false
  26. }
  27. },
  28. created() {
  29. this.initData(this.pageData);
  30. },
  31. watch: {
  32. pageData: {
  33. handler: function(el) {
  34. //监听对象的变换使用 function,箭头函数容易出现this指向不正确
  35. this.pageData = el
  36. this.initData(this.pageData)
  37. },
  38. deep: true
  39. }
  40. },
  41. methods:{
  42. initData(data){
  43. if(this.flag){
  44. this.productList = data.floorImageList;
  45. }else{
  46. this.productList = data.floorImageList.slice(0,2);
  47. }
  48. },
  49. navigaitionTo(item){
  50. if (item.adsImage === '' && item.linkType === -1) {
  51. return
  52. }else if(item.linkType === -1){
  53. uni.navigateTo({
  54. url:`/pages/h5/activity/activity-detail?adsImage=${item.adsImage}&title=${item.name}`
  55. })
  56. }else{
  57. caimeiApi.FlooryNavigateTo(item)
  58. }
  59. }
  60. }
  61. }
  62. </script>
  63. <style lang="scss">
  64. .picture{
  65. width: 100%;
  66. .section{
  67. margin-bottom: 24rpx;
  68. width: 702rpx;
  69. height: 360rpx;
  70. overflow: hidden;
  71. border-radius: 16rpx;
  72. image{
  73. width: 702rpx;
  74. height: 360rpx;
  75. }
  76. &:first-child{
  77. margin-top: 0;
  78. }
  79. }
  80. }
  81. </style>