list.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. <template>
  2. <div>
  3. <!-- <Header :logoImg="indexinfo.system_logo" style="margin-top: 20px"></Header> -->
  4. <!-- <div class="head">
  5. <img @click="back" src="@/assets/images/back.png" class="arrow_img" />
  6. <span>{{ $t('lang216') }}</span>
  7. </div> -->
  8. <van-tabs v-model="navActive" color="#29B286" title-active-color="#29B286" title-inactive-color="#c8c9cc" class="van-tabs" @disabled="onClickDisabled" @change="changeTab">
  9. <van-tab :title="$t('lang245')"></van-tab>
  10. <van-tab :title="$t('lang216')" disabled></van-tab>
  11. <van-tab :title="$t('lang246')"></van-tab>
  12. </van-tabs>
  13. <div class="home_page" @scroll="handleScroll">
  14. <div class="pd1">
  15. <div class="btn_box">
  16. <van-button v-for="(item, index) in typeList" :key="index" :class="[typeIndex == index ? 'cc_btn cc_active' : 'cc_btn']" @click="changeType(item, index)"> {{ item.title }}</van-button>
  17. </div>
  18. <van-field v-model="key" :placeholder="$t('lang4')" class="input" right-icon="search" @click-right-icon="search" />
  19. <div class="sort flex jsb">
  20. <span class="w1">{{ $t('lang244') }}</span>
  21. <!-- <div class="flex"> -->
  22. <div class="flex w2" @click="handlePriceSort">
  23. <span>{{ $t('lang247') }}</span>
  24. <img src="@/assets/images/index/j0.png" alt="" style="width: 14px" v-if="sort == 0" />
  25. <img src="@/assets/images/index/j2.png" alt="" style="width: 14px" v-else-if="sort == 1" />
  26. <img src="@/assets/images/index/j1.png" alt="" style="width: 14px" v-else-if="sort == 2" />
  27. </div>
  28. <!-- <div class="flex w3" @click="handleVolumeSort">
  29. <span>{{ $t('lang342') }}</span>
  30. <img src="@/assets/images/index/j0.png" alt="" style="width: 14px" v-if="volume == 0" />
  31. <img src="@/assets/images/index/j2.png" alt="" style="width: 14px" v-else-if="volume == 1" />
  32. <img src="@/assets/images/index/j1.png" alt="" style="width: 14px" v-else-if="volume == 2" />
  33. </div> -->
  34. <!-- <van-dropdown-menu active-color="#3d3d3d">
  35. <van-dropdown-item v-model="type_id" :options="indexinfo.type_list" @change="search" />
  36. </van-dropdown-menu> -->
  37. <!-- <svg width="30" height="30" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
  38. <path
  39. d="M70,35
  40. C56,28 38,40 40,54
  41. C40,64 50,74 70,66"
  42. fill="none"
  43. stroke="black"
  44. stroke-width="6"
  45. stroke-linecap="round"
  46. />
  47. <line x1="52" y1="29" x2="52" y2="73" stroke="black" stroke-width="5.2" stroke-linecap="round" />
  48. <line x1="63" y1="29" x2="63" y2="73" stroke="black" stroke-width="5.2" stroke-linecap="round" />
  49. </svg> -->
  50. <!-- </div> -->
  51. </div>
  52. </div>
  53. <div class="goods_box" v-if="list.length > 0">
  54. <div class="goods_list jsb" v-for="(item, index) in list" :key="index" @click="navigatorToPage('typeDetail', item.product_id)">
  55. <div class="info">
  56. <van-image class="goods_list_img" radius="10" :src="item.img_url" />
  57. <div class="name_box">
  58. <span class="name ellipsis">{{ item.name }}</span>
  59. <span class="time_text t2 ellipsis">{{ $t('lang301') + item.issue }}{{ $t('lang7') + '/' + $t('lang302') }}{{ item.issue }}{{ $t('lang7') }}</span>
  60. </div>
  61. <div @click.stop="changeStar(item, index)" class="star">
  62. <span v-if="item.collect == 0">
  63. <svg t="1746757181645" class="icon" viewBox="0 0 1058 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2027" width="15" height="15">
  64. <path
  65. d="M274.72727305 953.81818174c-5.4545458 0-10.90909073 0-16.36363653-2.72727247-13.63636406-5.4545458-24.54545479-13.63636406-32.72727305-27.27272724-5.4545458-10.90909073-8.18181826-21.81818145-5.45454492-35.45454551L263.81818144 634.72727305 81.09090898 454.72727305c-21.81818145-21.81818145-21.81818145-54.54545449 0-76.36363682 8.18181826-8.18181826 19.09090898-13.63636406 29.99999971-16.36363652l253.63636436-38.18181797 114.5454539-229.09090869c5.4545458-13.63636406 16.36363653-21.81818145 32.72727305-27.27272725 13.63636406-5.4545458 27.27272724-2.72727247 40.90909131 2.72727246 10.90909073 5.4545458 19.09090898 13.63636406 24.5454539 24.54545479l114.54545479 229.09090869 253.63636347 38.18181797c29.99999971 5.4545458 49.09090869 32.72727305 46.36363624 62.72727275-2.72727247 10.90909073-8.18181826 21.81818145-16.36363565 30.00000059L792.90909072 634.72727305l43.63636377 253.63636348c2.72727247 13.63636406 0 29.99999971-8.18181826 40.90909042s-21.81818145 19.09090898-35.4545455 21.81818233c-10.90909073 2.72727247-24.54545479 0-35.45454552-5.45454581L525.63636406 828.36363623l-226.36363711 119.99999971c-8.18181826 5.4545458-16.36363653 5.4545458-24.5454539 5.4545458zM525.63636406 124.72727276l-125.4545455 256.36363593L116.5454545 419.27272754l204.54545477 199.09090899-49.09090956 280.90909071 253.63636435-133.63636377 253.63636348 133.63636377-49.09090957-280.90909072 204.54545479-199.09090898-280.90909073-40.90909131L525.63636406 124.72727276z"
  66. fill="#919090"
  67. p-id="2028"
  68. ></path>
  69. </svg>
  70. </span>
  71. <span v-else>
  72. <svg t="1746757109445" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1562" width="15" height="15">
  73. <path
  74. d="M547.978 84.41l114.854 232.476c5.536 11.07 16.606 19.373 30.444 22.141l256 37.362c31.827 4.152 45.665 44.281 22.14 67.806l-186.81 179.891c-9.687 9.687-13.838 22.141-11.07 34.595l42.896 256c5.536 31.827-29.059 56.735-58.118 41.514l-229.709-120.39c-11.07-5.535-24.908-5.535-37.362 0l-229.708 120.39c-29.06 15.221-63.654-9.687-58.119-41.514l44.281-254.616c2.768-12.454-1.383-26.292-11.07-34.595L53.967 444.195c-23.524-23.525-11.07-62.27 22.141-67.806l256-37.362c12.454-1.384 23.524-9.686 30.443-22.14L477.405 84.41c13.838-29.06 55.352-29.06 70.573 0z m0 0"
  75. fill="#FFBE11"
  76. p-id="1563"
  77. ></path>
  78. </svg>
  79. </span>
  80. </div>
  81. </div>
  82. <div class="w2">
  83. <span class="fw">{{ item.price || '--' }}</span>
  84. </div>
  85. <!-- <div class="w3">
  86. <span class="fw">88</span>
  87. </div> -->
  88. </div>
  89. </div>
  90. <div class="bare" v-else>
  91. <span>{{ $t('lang60') }}</span>
  92. </div>
  93. </div>
  94. <BottomNavigation></BottomNavigation>
  95. </div>
  96. </template>
  97. <script>
  98. import Header from '@/components/Header.vue';
  99. import { mapState } from 'vuex';
  100. import { homeApi } from '@/api/index';
  101. import BottomNavigation from '@/components/BottomNavigation.vue';
  102. import { Notify } from 'vant';
  103. import { dateFormat } from '@/utils/formatTool.js';
  104. export default {
  105. data() {
  106. return {
  107. key: '',
  108. sort: 0,
  109. volume: 0,
  110. type_id: 0,
  111. list: [],
  112. page: 1,
  113. navActive: 0,
  114. typeList: [],
  115. typeIndex: 0,
  116. starValue: 0,
  117. };
  118. },
  119. mounted() {
  120. this.init();
  121. },
  122. methods: {
  123. //返回上一页
  124. back() {
  125. this.$router.back();
  126. },
  127. init() {
  128. this.getPopularType();
  129. this.getTransferList();
  130. },
  131. handleScroll(event) {
  132. const container = event.target;
  133. const scrollTop = container.scrollTop; // 滚动距离
  134. const scrollHeight = container.scrollHeight; // 内容总高度
  135. const clientHeight = container.clientHeight; // 可视区域高度
  136. // 判断是否滑动到底部
  137. if (scrollTop + clientHeight >= scrollHeight - 10) {
  138. console.log('Bottom');
  139. if (this.page != -1) {
  140. this.page++; // 页数加 1
  141. if (this.navActive == 0) {
  142. this.getTransferList(); // 触发加载更多
  143. } else if (this.navActive == 2) {
  144. this.getTransferCollectList();
  145. }
  146. }
  147. }
  148. },
  149. search() {
  150. this.page = 1;
  151. this.list = []; // 重置列表数据
  152. // this.getTransferList(); // 触发重新获取列表数据
  153. if (this.navActive == 0) {
  154. this.getTransferList();
  155. } else if (this.navActive == 2) {
  156. this.getTransferCollectList();
  157. }
  158. },
  159. getPopularType() {
  160. homeApi.getPopularType({}).then(res => {
  161. if (res.code == 200) {
  162. this.typeList = res.data;
  163. } else {
  164. }
  165. });
  166. },
  167. getTransferList() {
  168. homeApi.getTransferList({ sort: this.sort, type_id: this.type_id, key_val: this.key, page: this.page }).then(res => {
  169. if (res.code == 200) {
  170. if (this.list.length >= res.data.total) {
  171. this.page = -1; // 重置为 -1,表示没有更多数据
  172. } else {
  173. this.list = [...this.list, ...res.data.data];
  174. if (this.list.length >= res.data.total) {
  175. this.page = -1; // 重置为 -1,表示没有更多数据
  176. }
  177. }
  178. } else {
  179. }
  180. });
  181. },
  182. getTransferCollectList() {
  183. homeApi.getTransferCollectList({ sort: this.sort, type_id: this.type_id, key_val: this.key, page: this.page }).then(res => {
  184. if (res.code == 200) {
  185. if (this.list.length >= res.data.total) {
  186. this.page = -1; // 重置为 -1,表示没有更多数据
  187. } else {
  188. this.list = [...this.list, ...res.data.data];
  189. if (this.list.length >= res.data.total) {
  190. this.page = -1; // 重置为 -1,表示没有更多数据
  191. }
  192. }
  193. } else {
  194. }
  195. });
  196. },
  197. navigatorToPage(name, id) {
  198. this.$router.push({ name, query: { id: id } });
  199. },
  200. handlePriceSort() {
  201. console.log(this.sort);
  202. if (this.sort == 0) {
  203. this.sort = 1;
  204. } else if (this.sort == 1) {
  205. this.sort = 2;
  206. } else if (this.sort == 2) {
  207. this.sort = 1;
  208. }
  209. this.search();
  210. },
  211. handleVolumeSort() {
  212. console.log(this.volume);
  213. if (this.volume == 0) {
  214. this.volume = 1;
  215. } else if (this.volume == 1) {
  216. this.volume = 2;
  217. } else if (this.volume == 2) {
  218. this.volume = 1;
  219. }
  220. this.search();
  221. },
  222. onClickDisabled(name, title) {
  223. this.$toast(this.$t('lang2'));
  224. },
  225. changeStar(item, index) {
  226. if (this.list[index].collect == 0) {
  227. // this.list[index].collect = 1;
  228. this.$set(this.list[index], 'collect', 1)
  229. } else {
  230. // this.list[index].collect = 0;
  231. this.$set(this.list[index], 'collect', 0)
  232. }
  233. homeApi.collect({ market_id: item.product_id }).then(res => {
  234. if (res.code == 200) {
  235. } else {
  236. this.$toast(res.msg);
  237. // this.list[index].collect = 0;
  238. this.$set(this.list[index], 'collect', 0)
  239. }
  240. });
  241. },
  242. changeType(item, index) {
  243. this.typeIndex = index;
  244. this.type_id = item.id;
  245. this.page = 1;
  246. this.list = [];
  247. if (this.navActive == 0) {
  248. this.getTransferList();
  249. } else if (this.navActive == 2) {
  250. this.getTransferCollectList();
  251. }
  252. },
  253. changeTab(item) {
  254. console.log(item);
  255. this.page = 1;
  256. this.list = [];
  257. if (item == 0) {
  258. this.getTransferList();
  259. } else if (item == 2) {
  260. this.getTransferCollectList();
  261. }
  262. },
  263. },
  264. computed: {
  265. ...mapState(['account']),
  266. },
  267. watch: {},
  268. components: {
  269. Header,
  270. BottomNavigation,
  271. },
  272. };
  273. </script>
  274. <style lang="less" scoped>
  275. .head {
  276. position: fixed;
  277. top: 0;
  278. left: 0;
  279. width: 100%;
  280. display: flex;
  281. align-items: center;
  282. justify-content: center;
  283. color: rgba(#000, 0.8);
  284. letter-spacing: 1.5px;
  285. font-weight: 550;
  286. background: #fff;
  287. padding: 14px 0;
  288. z-index: 99;
  289. .arrow_img {
  290. position: absolute;
  291. left: 20px;
  292. width: 10px;
  293. height: 16px;
  294. // transform: translate(0, -50%);
  295. }
  296. }
  297. .bare {
  298. text-align: center;
  299. font-size: 14px;
  300. padding: 60px 14px;
  301. color: #888;
  302. }
  303. .van-tabs {
  304. position: fixed;
  305. top: 0;
  306. width: 100%;
  307. z-index: 99;
  308. }
  309. .home_page {
  310. padding: 46px 0 100px;
  311. height: 100vh;
  312. overflow: auto;
  313. background-color: #fff;
  314. .pd {
  315. padding: 14px;
  316. // background-color: #fff;
  317. }
  318. .pd1 {
  319. padding: 14px 13px 0;
  320. background-color: #fff;
  321. .input {
  322. width: 100%;
  323. // height: 35px;
  324. // line-height: 35px;
  325. border: 1px solid #29b286;
  326. border-radius: 20px;
  327. margin: 10px 0 0px;
  328. ::v-deep .van-field__control {
  329. padding: 6px 12px;
  330. }
  331. ::v-deep .van-icon-search {
  332. font-size: 22px;
  333. color: #29b286;
  334. font-weight: bold;
  335. margin-right: 10px;
  336. }
  337. }
  338. ::v-deep .van-popup {
  339. padding: 10px 20px 30px;
  340. }
  341. ::v-deep .van-dropdown-item__option {
  342. border-bottom: 1px solid rgba(#adadad, 0.2);
  343. padding: 10px 0 !important;
  344. }
  345. ::v-deep .van-dropdown-menu__bar {
  346. box-shadow: none;
  347. }
  348. ::v-deep .van-dropdown-item__option {
  349. color: #aaaaaa;
  350. }
  351. ::v-deep .van-ellipsis {
  352. color: #3d3d3d;
  353. font-size: 14px;
  354. }
  355. }
  356. .top {
  357. display: flex;
  358. justify-content: space-between;
  359. align-items: center;
  360. .cha {
  361. width: 100px;
  362. }
  363. .input {
  364. width: calc(100% - 110px);
  365. border: 1px solid #29b286;
  366. border-radius: 20px;
  367. }
  368. ::v-deep .van-field__control {
  369. padding: 6px 12px;
  370. }
  371. ::v-deep .van-icon-search {
  372. font-size: 20px;
  373. color: #29b286;
  374. font-weight: bold;
  375. margin-right: 10px;
  376. }
  377. }
  378. .notice {
  379. font-size: 13px;
  380. margin: 8px 0;
  381. .notice-ico {
  382. padding: 0 8px;
  383. border-radius: 20px;
  384. margin-right: 10px;
  385. background-color: #e8e8e8;
  386. }
  387. }
  388. ::v-deep .van-notice-bar {
  389. padding: 0 !important;
  390. }
  391. .banner {
  392. height: 160px;
  393. color: #fff;
  394. font-size: 22px;
  395. border-radius: 12px;
  396. .my-swipe {
  397. width: 100%;
  398. height: 100%;
  399. border-radius: 12px;
  400. }
  401. }
  402. .jsb {
  403. justify-content: space-between;
  404. }
  405. .goods_box {
  406. // margin: 14px;
  407. // border-radius: 14px;
  408. padding: 0 13px 14px;
  409. background-color: #fff;
  410. .good_icon {
  411. width: 16px;
  412. height: 16px;
  413. margin-right: 5px;
  414. }
  415. }
  416. .sort {
  417. color: #9d9d9d;
  418. font-size: 12px;
  419. font-weight: 600;
  420. padding: 14px 0;
  421. .w1 {
  422. width: 66%;
  423. }
  424. /deep/.van-ellipsis {
  425. color: #9d9d9d;
  426. font-size: 12px !important;
  427. }
  428. }
  429. .w2 {
  430. width: 24%;
  431. text-align: right;
  432. white-space: nowrap;
  433. justify-content: flex-end;
  434. }
  435. .w3 {
  436. width: 18%;
  437. text-align: center;
  438. white-space: nowrap;
  439. justify-content: flex-end;
  440. }
  441. .fw {
  442. font-weight: 600;
  443. font-size: 15px;
  444. padding-right: 10px;
  445. }
  446. .goods_list {
  447. display: flex;
  448. align-items: center;
  449. color: #000;
  450. margin-bottom: 16px;
  451. &_img {
  452. width: 68px;
  453. height: 68px;
  454. border-radius: 10px;
  455. }
  456. .info {
  457. display: flex;
  458. align-items: center;
  459. width: 70%;
  460. .name_box {
  461. width: calc(100% - 90px);
  462. display: flex;
  463. flex-direction: column;
  464. line-height: 180%;
  465. font-size: 13px;
  466. box-sizing: border-box;
  467. padding: 0 6px;
  468. // padding: 6px 0;
  469. .name {
  470. font-weight: 600;
  471. }
  472. .time_text {
  473. color: #7f7f7f;
  474. font-weight: normal;
  475. font-size: 11px;
  476. white-space: nowrap;
  477. padding: 2px 0;
  478. }
  479. }
  480. .star {
  481. }
  482. }
  483. .buy {
  484. display: flex;
  485. align-items: flex-end;
  486. &_btn {
  487. height: 26px;
  488. line-height: 26px;
  489. font-size: 10px;
  490. background-color: #29b286;
  491. border: none;
  492. padding: 0 10px;
  493. white-space: nowrap;
  494. border-radius: 30px;
  495. }
  496. }
  497. }
  498. .btn_box {
  499. width: 100%;
  500. box-sizing: border-box;
  501. display: flex;
  502. align-items: center;
  503. justify-content: space-between;
  504. flex-wrap: nowrap;
  505. overflow: auto;
  506. // padding: 10px 0;
  507. background-color: #fff;
  508. .cc_btn {
  509. min-width: 100px;
  510. height: 38px;
  511. color: #29b286;
  512. line-height: 38px;
  513. font-size: 12px;
  514. text-align: center;
  515. white-space: nowrap;
  516. padding: 0 10px;
  517. border: none;
  518. border-radius: 4px;
  519. margin-right: 8px;
  520. background-color: #f3f3f3;
  521. .van-button__text {
  522. overflow: hidden; //超出的文本隐藏
  523. text-overflow: ellipsis; //溢出用省略号显示
  524. white-space: nowrap; //溢出不换行
  525. }
  526. }
  527. .cc_active {
  528. color: #fff;
  529. background-color: #29b286;
  530. }
  531. }
  532. }
  533. .goods_list1 {
  534. flex-wrap: wrap;
  535. &_img {
  536. width: 100%;
  537. height: 70px;
  538. border-radius: 10px;
  539. margin-right: 10px;
  540. }
  541. .item {
  542. width: 45%;
  543. margin-bottom: 10px;
  544. .cen {
  545. padding-top: 4px;
  546. .mon_t {
  547. font-size: 11px;
  548. color: #7f7f7f;
  549. }
  550. .money::after {
  551. content: 'CHA/年';
  552. }
  553. }
  554. }
  555. }
  556. .bind_box {
  557. color: #000;
  558. padding: 20px 20px 30px;
  559. .address_field {
  560. border-bottom: 1px solid #cccccc9d;
  561. padding: 10px 0;
  562. margin: 20px 10px 20px;
  563. }
  564. .bind_button {
  565. color: #fff;
  566. text-align: center;
  567. background: #7938cf;
  568. border-radius: 20px;
  569. padding: 10px 0;
  570. }
  571. }
  572. .flex {
  573. display: flex;
  574. align-items: center;
  575. }
  576. .flex_end {
  577. align-items: flex-end;
  578. }
  579. ::v-deep .van-cascader__option {
  580. color: #000;
  581. }
  582. .ellipsis {
  583. overflow: hidden; /* 确保超出容器的文本被裁剪 */
  584. white-space: nowrap; /* 确保文本在一行内显示 */
  585. text-overflow: ellipsis; /* 使用省略号表示文本超出 */
  586. }
  587. </style>