gardenItem.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  1. <template>
  2. <view class="garden-item-page">
  3. <view class="report-content">
  4. <view class="home-search">
  5. <view class="search-wrap">
  6. <up-search placeholder="搜索品种" v-model="typeSearch"></up-search>
  7. </view>
  8. </view>
  9. <view class="tips" v-show="panelHeight!==50">
  10. <view class="tips-content">
  11. <view class="line-l"></view>
  12. <image class="down-icon" :src="`${config.BASIC_IMG}home/down-icon.png`" mode=""></image>
  13. 下拉查看溯源报告
  14. <view class="line-r"></view>
  15. </view>
  16. </view>
  17. <view class="swipe-item">
  18. <source-report-vue :showStep="false"></source-report-vue>
  19. </view>
  20. </view>
  21. <l-floating-panel v-model:height="panelHeight" ref="floatingPanelRef" @heightChange="changePanel" :anchors="anchors" :defaultAnchor="2" :content-draggable="false">
  22. <view class="panel-content" ref="scrollViewRef">
  23. <view class="panel-title">
  24. <view class="title-l">
  25. <image class="garden-img" :src="gardenDetail?.icon" mode=""></image>
  26. <view class="title-info">
  27. <view class="title-garden">
  28. {{gardenInfo?.farmName}}
  29. </view>
  30. <view class="btn-second">
  31. 有味指数
  32. <text>{{gardenInfo?.youweiIndex}}分</text>
  33. </view>
  34. </view>
  35. </view>
  36. <!-- <view class="title-r">
  37. +
  38. <text class="add-text">关注</text>
  39. </view> -->
  40. </view>
  41. <view class="garden-home" v-show="activeMenu === 0">
  42. <view class="panel-video">
  43. <!-- <video class="video-dom" src="https://birdseye-img.sysuimars.com/temp/5-25lby.mp4" controls></video> -->
  44. <video :src="gardenDetail?.coverVideo" object-fit="cover" :show-fullscreen-btn="false"
  45. :autoplay="true" class="video-dom" loop muted controls>
  46. </video>
  47. </view>
  48. <!-- 果园热卖 -->
  49. <view class="hot-box" v-if="currentFarmId">
  50. <hot-component-vue :isGardeItem="true" :farmId="currentFarmId"></hot-component-vue>
  51. </view>
  52. <view class="garden-detail">
  53. <view class="detial-item" v-if="gardenDetail?.ecology">
  54. <view class="sub-title">
  55. <view class="line-l"></view>
  56. <view class="title-text">
  57. 果园生态
  58. </view>
  59. <view class="line-r"></view>
  60. </view>
  61. <view class="detail-img">
  62. <up-image class="img-dom" radius="8" width="100%" :src="gardenDetail?.ecology" mode="widthFix"></up-image>
  63. </view>
  64. </view>
  65. <view class="detial-item" v-if="gardenDetail?.plantImage">
  66. <view class="sub-title">
  67. <view class="line-l"></view>
  68. <view class="title-text">
  69. 果园种植
  70. </view>
  71. <view class="line-r"></view>
  72. </view>
  73. <view class="detail-img">
  74. <up-image class="img-dom" radius="8" width="100%" :src="gardenDetail.plantImage" mode="widthFix"></up-image>
  75. </view>
  76. </view>
  77. <view class="detial-item" v-if="gardenDetail?.varietyImage">
  78. <view class="sub-title">
  79. <view class="line-l"></view>
  80. <view class="title-text">
  81. 果园品种
  82. </view>
  83. <view class="line-r"></view>
  84. </view>
  85. <view class="detail-img">
  86. <up-image class="img-dom" radius="8" width="100%" :src="gardenDetail.varietyImage" mode="widthFix"></up-image>
  87. </view>
  88. </view>
  89. </view>
  90. </view>
  91. <!-- 好味 -->
  92. <!-- 列表 -->
  93. <view class="discover-content" v-show="activeMenu === 1">
  94. <view class="discover-filter">
  95. <view class="filter-item" :class="{'active': filterIndex === 0}" @click="selectFilter(0)">
  96. 综合
  97. </view>
  98. <view class="filter-item" :class="{'active': filterIndex === 1}" @click="selectFilter(1)">
  99. 价格
  100. <div class="filter-icon">
  101. <image v-show="filterIndex !== 1" style="width: 14px; height: 14px;padding-top: 2px;" :src="`${config.BASIC_IMG}home/filter-icon.png`" mode=""></image>
  102. <image v-show="filterIndex === 1 && orderType===true" style="width: 14px; height: 14px;padding-top: 2px;" :src="`${config.BASIC_IMG}home/filter-icon-1.png`" mode=""></image>
  103. <image v-show="filterIndex === 1 && orderType===false" style="width: 14px; height: 14px;padding-top: 2px;" :src="`${config.BASIC_IMG}home/filter-icon-2.png`" mode=""></image>
  104. </div>
  105. </view>
  106. <view class="filter-item" :class="{'active': filterIndex === 2}" @click="selectFilter(2)">
  107. 销量
  108. <div class="filter-icon">
  109. <image v-show="filterIndex !== 2" style="width: 14px; height: 14px;padding-top: 2px;" :src="`${config.BASIC_IMG}home/filter-icon.png`" mode=""></image>
  110. <image v-show="filterIndex === 2 && orderType===true" style="width: 14px; height: 14px;padding-top: 2px;" :src="`${config.BASIC_IMG}home/filter-icon-1.png`" mode=""></image>
  111. <image v-show="filterIndex === 2 && orderType===false" style="width: 14px; height: 14px;padding-top: 2px;" :src="`${config.BASIC_IMG}home/filter-icon-2.png`" mode=""></image>
  112. </div>
  113. </view>
  114. </view>
  115. <view class="discover-list">
  116. <view class="list-line">
  117. <view class="list-item" v-for="(item, index) in discoverData" :key="index">
  118. <image class="item-img" :src="`${config.BASIC_IMG}home/fruit.png`" mode=""></image>
  119. <view class="item-desc">
  120. <view class="item-text">
  121. {{item.name}}
  122. </view>
  123. <view class="item-subtext">
  124. <text class="subtext-text">坏单包退</text>
  125. <text class="subtext-text">包邮</text>
  126. </view>
  127. <view class="info-price">
  128. <view class="price-text">
  129. <text class="price-unit">¥</text>{{item.price}}
  130. </view>
  131. <view class="info-sold">
  132. 已售{{item.sold}}
  133. </view>
  134. </view>
  135. </view>
  136. </view>
  137. </view>
  138. <view class="no-data" v-if="!discoverData || !discoverData.length">
  139. 当前果园暂未上架商品,请耐心等候
  140. </view>
  141. </view>
  142. </view>
  143. </view>
  144. <view class="bottom-menu">
  145. <view class="menu-item" :class="{'active': activeMenu === 0}" @click="changeMenu(0)">
  146. 首页
  147. </view>
  148. <view class="menu-item" :class="{'active': activeMenu === 1}" @click="changeMenu(1)">
  149. 好味
  150. </view>
  151. </view>
  152. </l-floating-panel>
  153. </view>
  154. </template>
  155. <script setup>
  156. import {
  157. nextTick,
  158. ref
  159. } from 'vue'
  160. import config from "@/api/config.js"
  161. import hotComponentVue from '../hotComponent.vue'
  162. import sourceReportVue from './sourceReport.vue'
  163. import { onLoad, onShow } from '@dcloudio/uni-app'
  164. import HOME from '@/api/home'
  165. const typeSearch = ref(null)
  166. const {
  167. windowHeight
  168. } = uni.getSystemInfoSync()
  169. const anchors = [
  170. 50,
  171. Math.round(0.5 * windowHeight),
  172. Math.round(0.92 * windowHeight),
  173. ];
  174. const panelHeight = ref(anchors[2]);
  175. function changePanel({height}) {
  176. if (height === 50) {
  177. uni.navigateTo({
  178. url: `/pages/tabBar/home/subPages/sourceReport?farmId=${currentFarmId.value}`
  179. })
  180. }
  181. }
  182. const activeMenu = ref(0)
  183. const scrollViewRef = ref(null)
  184. function changeMenu(i) {
  185. activeMenu.value = i
  186. }
  187. const currentFarmId = ref(null)
  188. onLoad(({farmId})=>{
  189. currentFarmId.value = farmId||766
  190. getFarmInfo()
  191. getFarmDetail()
  192. getGoodsList()
  193. })
  194. const floatingPanelRef = ref(null)
  195. onShow(() => {
  196. nextTick(() => {
  197. floatingPanelRef.value && floatingPanelRef.value.toAnchor(2)
  198. })
  199. })
  200. const gardenInfo = ref({})
  201. function getFarmInfo() {
  202. HOME.fetchGardenInfo({farmId: currentFarmId.value, isLighten: 1}).then(({data}) => {
  203. gardenInfo.value = data
  204. })
  205. }
  206. const gardenDetail = ref({})
  207. function getFarmDetail() {
  208. HOME.fetchGardenDetail({farmId: currentFarmId.value}).then(({data}) => {
  209. gardenDetail.value = data
  210. })
  211. }
  212. // 好味
  213. const filterIndex = ref(0)
  214. const activeType = ref(0)
  215. const discoverData = ref([])
  216. let sortObj = {
  217. 0: "id",
  218. 1: "price",
  219. 2: "salesVal"
  220. }
  221. const orderType = ref(true)
  222. function selectFilter(i) {
  223. if (filterIndex.value !== i) {
  224. orderType.value = false
  225. }
  226. filterIndex.value = i
  227. sort.value = sortObj[i]
  228. orderType.value = !orderType.value
  229. getGoodsList()
  230. }
  231. const sort = ref("id")
  232. function getGoodsList() {
  233. let params = {sort: sort.value, farmId: currentFarmId.value,}
  234. if (filterIndex.value !== 0) {
  235. params = {
  236. ...params,
  237. order: orderType.value ? "asc" : "desc"
  238. }
  239. }
  240. HOME.fetchGoodsList(params).then(({
  241. data
  242. }) => {
  243. discoverData.value = data
  244. })
  245. }
  246. </script>
  247. <style lang="scss" scoped>
  248. .garden-item-page {
  249. width: 100%;
  250. height: 100vh;
  251. .report-content {
  252. width: 100%;
  253. height: calc(100% - 120rpx);
  254. position: relative;
  255. .home-search {
  256. position: absolute;
  257. z-index: 2;
  258. top: 20rpx;
  259. left: 24rpx;
  260. display: flex;
  261. align-items: center;
  262. width: calc(100% - 48rpx);
  263. border: 2rpx solid rgba(255, 255, 255, 0.39);
  264. border-radius: 40rpx;
  265. margin-bottom: 40rpx;
  266. background-color: rgba(0, 0, 0, 0.31);
  267. .search-wrap {
  268. flex: 1;
  269. // padding-left: 22rpx;
  270. ::v-deep {
  271. .u-search {
  272. .u-search__content {
  273. background-color: transparent !important;
  274. .u-search__content__input {
  275. background-color: transparent !important;
  276. }
  277. }
  278. .uni-input-input {
  279. color: rgba(255, 255, 255, 0.8);
  280. }
  281. .u-search__action {
  282. text-align: center;
  283. line-height: 52rpx;
  284. border-radius: 40rpx;
  285. font-size: 28rpx;
  286. background-color: rgba(255, 255, 255, 0.3);
  287. color: rgba(255, 255, 255, 0.3);
  288. margin: 6rpx 8rpx;
  289. width: 112rpx;
  290. height: 52rpx;
  291. }
  292. }
  293. }
  294. }
  295. }
  296. .tips {
  297. position: absolute;
  298. z-index: 2;
  299. top: 110rpx;
  300. left: 0;
  301. color: #FFFFFF;
  302. font-size: 24rpx;
  303. width: 100%;
  304. text-align: center;
  305. .tips-content {
  306. position: relative;
  307. display: flex;
  308. align-items: center;
  309. justify-content: center;
  310. .down-icon {
  311. width: 14rpx;
  312. height: 14rpx;
  313. padding-right: 20rpx;
  314. }
  315. .line-l {
  316. width: 208rpx;
  317. height: 2rpx;
  318. background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.2));
  319. margin-right: 20rpx;
  320. }
  321. .line-r {
  322. margin-left: 20rpx;
  323. width: 208rpx;
  324. height: 2rpx;
  325. background: linear-gradient(90deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0));
  326. }
  327. }
  328. }
  329. .swipe-item {
  330. width: 100%;
  331. height: 100%;
  332. .video-wrap {
  333. width: 100%;
  334. height: 100%;
  335. object-fit: cover;
  336. }
  337. ::v-deep {
  338. .uni-video-video {
  339. object-fit: cover !important;
  340. }
  341. }
  342. }
  343. }
  344. }
  345. .panel-content {
  346. padding: 0 24rpx 24rpx;
  347. height: calc(100vh - 420rpx);
  348. overflow: auto;
  349. .panel-title {
  350. display: flex;
  351. align-items: center;
  352. justify-content: space-between;
  353. .title-l {
  354. flex: 1;
  355. display: flex;
  356. align-items: center;
  357. .garden-img {
  358. width: 100rpx;
  359. height: 100rpx;
  360. border-radius: 10rpx;
  361. }
  362. .title-info {
  363. padding-left: 20rpx;
  364. .title-garden {
  365. color: #000000;
  366. font-size: 28rpx;
  367. font-weight: 600;
  368. padding-bottom: 10rpx;
  369. }
  370. .btn-second {
  371. padding: 0 30rpx;
  372. border-radius: 40rpx;
  373. font-size: 24rpx;
  374. color: #C49600;
  375. background: rgba(255, 217, 94, 0.2);
  376. height: 56rpx;
  377. line-height: 56rpx;
  378. }
  379. }
  380. }
  381. .title-r {
  382. display: flex;
  383. font-size: 24rpx;
  384. padding: 8rpx 22rpx;
  385. background: #FFD95E;
  386. border-radius: 30rpx;
  387. .add-text {
  388. padding-left: 6rpx;
  389. font-weight: 600;
  390. }
  391. }
  392. }
  393. .panel-video {
  394. padding: 20rpx 0;
  395. height: 300rpx;
  396. width: 100%;
  397. .video-dom {
  398. width: 100%;
  399. height: 100%;
  400. object-fit: cover;
  401. border-radius: 10rpx;
  402. }
  403. ::v-deep {
  404. .uni-video-video {
  405. object-fit: cover !important;
  406. }
  407. }
  408. }
  409. .discover-content {
  410. .discover-filter {
  411. padding-top: 30rpx;
  412. color: #A6A6A6;
  413. font-size: 28rpx;
  414. display: flex;
  415. align-items: center;
  416. .filter-item {
  417. padding: 12rpx 20rpx;
  418. display: flex;
  419. align-items: center;
  420. &.active {
  421. color: #000000;
  422. }
  423. .filter-icon {
  424. padding-left: 4rpx;
  425. }
  426. }
  427. }
  428. .discover-list {
  429. padding-top: 20rpx;
  430. .no-data {
  431. padding-top: 40rpx;
  432. font-size: 26rpx;
  433. color: rgba(0, 0, 0, 0.6);
  434. text-align: center;
  435. }
  436. .list-line {
  437. padding-bottom: 20rpx;
  438. display: flex;
  439. flex-wrap: wrap;
  440. .list-item {
  441. background-color: #FFFFFF;
  442. border-radius: 10rpx;
  443. width: calc(50% - 16rpx);
  444. margin-bottom: 20rpx;
  445. border: 2rpx solid rgba(0, 0, 0, 0.1);
  446. .item-img {
  447. width: 100%;
  448. height: 340rpx;
  449. object-fit: cover;
  450. border-radius: 10rpx 10rpx 0 0;
  451. }
  452. .item-desc {
  453. padding: 0 10rpx 10rpx;
  454. .item-text {
  455. width: calc(100% - 22rpx);
  456. overflow: hidden;
  457. text-overflow: ellipsis;
  458. color: #000000;
  459. font-size: 28rpx;
  460. line-height: 42rpx;
  461. font-weight: 600;
  462. white-space: nowrap;
  463. }
  464. .item-subtext {
  465. color: #AFAFAF;
  466. font-size: 24rpx;
  467. line-height: 36rpx;
  468. .subtext-text + .subtext-text {
  469. padding-left: 10rpx;
  470. }
  471. }
  472. .info-price {
  473. display: flex;
  474. align-items: baseline;
  475. justify-content: space-between;
  476. .price-text {
  477. color: #FF7700;
  478. font-size: 36rpx;
  479. .price-unit {
  480. font-size: 23rpx;
  481. }
  482. }
  483. .info-sold {
  484. font-size: 20rpx;
  485. color: #C4C4C4;
  486. }
  487. }
  488. }
  489. }
  490. .list-item:nth-child(2n) {
  491. margin-left: 20rpx;
  492. }
  493. }
  494. }
  495. }
  496. .garden-detail {
  497. padding: 20rpx 0;
  498. .detial-item {
  499. padding-bottom: 20rpx;
  500. .sub-title {
  501. display: flex;
  502. align-items: center;
  503. justify-content: center;
  504. padding-bottom: 20rpx;
  505. .line-l {
  506. width: 120rpx;
  507. height: 2rpx;
  508. background: linear-gradient(90deg, rgba(102, 102, 102, 0), rgba(0, 0, 0, 0.5));
  509. margin-right: 20rpx;
  510. }
  511. .line-r {
  512. width: 120rpx;
  513. height: 2rpx;
  514. background: linear-gradient(90deg, rgba(0, 0, 0, 0.5), rgba(102, 102, 102, 0));
  515. margin-left: 20rpx;
  516. }
  517. .title-text {
  518. font-size: 32rpx;
  519. font-family: "PangMenZhengDao";
  520. color: #000;
  521. }
  522. }
  523. .detail-img {
  524. text-align: center;
  525. .img-dom {
  526. margin: 0 auto;
  527. }
  528. }
  529. }
  530. }
  531. }
  532. .bottom-menu {
  533. position: fixed;
  534. bottom: 0;
  535. display: flex;
  536. align-items: center;
  537. justify-content: center;
  538. background-color: #FFFFFF;
  539. width: 100%;
  540. height: 100rpx;
  541. .menu-item {
  542. padding: 0 72rpx;
  543. position: relative;
  544. color: #898989;
  545. font-size: 32rpx;
  546. &.active {
  547. color: #000000;
  548. font-weight: 600;
  549. }
  550. }
  551. .menu-item + .menu-item {
  552. &::before {
  553. content: "";
  554. position: absolute;
  555. left: 0%;
  556. top: 16rpx;
  557. background-color: rgba(0, 0, 0, 0.42);
  558. width: 2rpx;
  559. height: 20rpx;
  560. }
  561. }
  562. }
  563. </style>