gardenList.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <view class="list-page">
  3. <view class="garden-list">
  4. <view class="garden-item" v-for="farm in gardenList" :key="farm.farmId || farm.id"
  5. >
  6. <view class="garden-l" v-if="farm.coverVideo">
  7. <video :src="farm.coverVideo" :show-progress="false" :show-play-btn="false"
  8. :show-center-play-btn="false" object-fit="cover" :show-fullscreen-btn="false"
  9. disablePictureInPicture :autoplay="true" class="video-dom"
  10. loop muted>
  11. </video>
  12. </view>
  13. <view class="garden-l" v-else>
  14. <image class="garden-img" :src="`${config.BASIC_IMG}home/garden.png`" mode=""></image>
  15. <text class="img-text">无人机实拍视频</text>
  16. </view>
  17. <view class="garden-r" @click="goGardenItem(farm)">
  18. <view class="garden-title">
  19. {{ farm.name }}
  20. </view>
  21. <view class="garden-info">
  22. 品种:荔枝({{ farm.pz }})
  23. </view>
  24. <view class="garden-info">
  25. 位置:{{ (farm.cityName + farm.countyName) || '—' }}
  26. </view>
  27. <view class="garden-btn-group">
  28. <view class="btn-second">
  29. 有味指数
  30. <text>{{ farm.envScore || '—' }}分</text>
  31. </view>
  32. <view class="btn-primary" @click.stop="goSourceReport(farm)">
  33. 溯源报告
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </template>
  41. <script setup>
  42. import {
  43. onMounted,
  44. ref
  45. } from "vue";
  46. import config from "@/api/config.js"
  47. import HOME from '@/api/home'
  48. onMounted(() => {
  49. getGardenList()
  50. })
  51. const gardenList = ref([])
  52. function getGardenList() {
  53. HOME.getAllFarm().then(({
  54. data
  55. }) => {
  56. gardenList.value = data.filter(item => item.recommend !== null)
  57. })
  58. }
  59. function goGardenItem(farm) {
  60. const id = farm?.farmId
  61. uni.navigateTo({
  62. url: `/pages/tabBar/home/subPages/gardenItem?farmId=${id}`
  63. });
  64. }
  65. function goSourceReport(farm) {
  66. const id = farm?.farmId
  67. uni.navigateTo({
  68. url: `/pages/tabBar/home/subPages/sourceReport?farmId=${id}`
  69. });
  70. }
  71. </script>
  72. <style lang="scss" scoped>
  73. .list-page {
  74. padding: 20rpx 40rpx;
  75. .garden-list {
  76. .garden-item {
  77. display: flex;
  78. .garden-l {
  79. position: relative;
  80. .video-dom {
  81. width: 234rpx;
  82. height: 200rpx;
  83. object-fit: cover;
  84. border-radius: 10rpx;
  85. &::-webkit-media-controls-volume-control-container {
  86. display: none !important;
  87. }
  88. &::-internal-media-controls-overflow-button {
  89. display: none !important;
  90. }
  91. }
  92. .garden-img {
  93. width: 254rpx;
  94. height: 200rpx;
  95. object-fit: cover;
  96. border-radius: 10rpx;
  97. }
  98. .img-text {
  99. position: absolute;
  100. left: 0%;
  101. top: 0%;
  102. background: rgba(0, 0, 0, 0.3);
  103. backdrop-filter: 8rpx;
  104. border-radius: 10rpx 0 10rpx 0;
  105. font-size: 20rpx;
  106. color: #FFFFFF;
  107. padding: 6rpx 14rpx;
  108. }
  109. }
  110. .garden-r {
  111. padding-left: 20rpx;
  112. .garden-title {
  113. font-size: 28rpx;
  114. line-height: 42rpx;
  115. color: #000000;
  116. font-weight: 600;
  117. padding-bottom: 10rpx;
  118. }
  119. .garden-info {
  120. color: rgba(0, 0, 0, 0.5);
  121. font-size: 24rpx;
  122. line-height: 36rpx;
  123. }
  124. .garden-btn-group {
  125. padding-top: 20rpx;
  126. display: flex;
  127. align-items: center;
  128. .btn-second {
  129. padding: 0 20rpx;
  130. border-radius: 40rpx;
  131. font-size: 24rpx;
  132. color: #C49600;
  133. background: rgba(255, 217, 94, 0.2);
  134. height: 56rpx;
  135. line-height: 56rpx;
  136. }
  137. .btn-primary {
  138. padding: 0 20rpx;
  139. border-radius: 40rpx;
  140. font-size: 24rpx;
  141. color: #000000;
  142. background: #FFD95E;
  143. font-weight: bold;
  144. height: 56rpx;
  145. line-height: 56rpx;
  146. }
  147. }
  148. }
  149. }
  150. .garden-item+.garden-item {
  151. margin-top: 20rpx;
  152. }
  153. }
  154. }
  155. </style>