list.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. <template>
  2. <div>
  3. <!-- <div class="head">
  4. <img @click="back" src="@/assets/images/back.png" class="arrow_img" />
  5. <span>{{ $t('lang217') }}</span>
  6. </div> -->
  7. <div class="header">
  8. <div class="btn_box">
  9. <van-button
  10. :class="[typeIndex == 2 ? 'cc_btn cc_active' : 'cc_btn']"
  11. :icon="typeIndex == 2 ? 'https://teaclub.oss-cn-chengdu.aliyuncs.com/mall/mul_1.png' : 'https://teaclub.oss-cn-chengdu.aliyuncs.com/mall/mul.png'"
  12. @click="changeType(2)"
  13. >
  14. <!-- <img src="@/assets/images/index/mul.png" class="icon" /> -->
  15. {{ $t('lang319') }}</van-button
  16. >
  17. <van-button
  18. :class="[typeIndex == 1 ? 'cc_btn cc_active' : 'cc_btn']"
  19. :icon="typeIndex == 1 ? 'https://teaclub.oss-cn-chengdu.aliyuncs.com/mall/single_1.png' : 'https://teaclub.oss-cn-chengdu.aliyuncs.com/mall/single.png'"
  20. @click="changeType(1)"
  21. >{{ $t('lang320') }}</van-button
  22. >
  23. <van-button class="cc_btn" icon="https://teaclub.oss-cn-chengdu.aliyuncs.com/mall/teamine.png" @click="navigatorToPage('storing')">{{ $t('lang38') }}</van-button>
  24. </div>
  25. <van-field v-model="title" :placeholder="$t('lang496')" class="input" right-icon="search" @click-right-icon="search" />
  26. <div class="sort flex jsb">
  27. <span class="w1">{{ $t('lang495') }}</span>
  28. <div class="flex jsb">
  29. <div class="flex w2" @click="handlePriceSort">
  30. <span>{{ $t('lang494') }}</span>
  31. <img src="@/assets/images/index/j0.png" alt="" style="width: 14px" v-if="day_num == 0" />
  32. <img src="@/assets/images/index/j2.png" alt="" style="width: 14px" v-else-if="day_num == 1" />
  33. <img src="@/assets/images/index/j1.png" alt="" style="width: 14px" v-else-if="day_num == 2" />
  34. </div>
  35. <div class="flex w3" @click="handleVolumeSort">
  36. <span>APY</span>
  37. <img src="@/assets/images/index/j0.png" alt="" style="width: 14px" v-if="income_reta == 0" />
  38. <img src="@/assets/images/index/j2.png" alt="" style="width: 14px" v-else-if="income_reta == 1" />
  39. <img src="@/assets/images/index/j1.png" alt="" style="width: 14px" v-else-if="income_reta == 2" />
  40. </div>
  41. <!-- <van-dropdown-menu active-color="#3d3d3d">
  42. <van-dropdown-item v-model="type_id" :options="indexinfo.type_list" @change="search" />
  43. </van-dropdown-menu> -->
  44. <!-- <svg width="30" height="30" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
  45. <path
  46. d="M70,35
  47. C56,28 38,40 40,54
  48. C40,64 50,74 70,66"
  49. fill="none"
  50. stroke="black"
  51. stroke-width="6"
  52. stroke-linecap="round"
  53. />
  54. <line x1="52" y1="29" x2="52" y2="73" stroke="black" stroke-width="5.2" stroke-linecap="round" />
  55. <line x1="63" y1="29" x2="63" y2="73" stroke="black" stroke-width="5.2" stroke-linecap="round" />
  56. </svg> -->
  57. </div>
  58. </div>
  59. </div>
  60. <div class="home_page">
  61. <div class="bare" v-if="total < 1">
  62. <span>{{ $t('lang60') }}</span>
  63. </div>
  64. <van-list class="pd goods_box" v-model="loading" :finished="finished" :finished-text="$t('lang202')" @load="onLoad" v-else>
  65. <div class="goods_list jsb" v-for="(item, index) in list" :key="index">
  66. <div class="box" @click="toPage(item.id)">
  67. <div class="box_top">
  68. <span class="ellipsis name">{{ item.title }}</span>
  69. <div class="box_arraw">
  70. <span>{{ $t('lang323') }}</span>
  71. <van-icon name="arrow" />
  72. </div>
  73. </div>
  74. <div class="box_bottom">
  75. <div class="flex">
  76. <div v-if="Object.values(item.product_list).length > 1">
  77. <img
  78. v-for="(item1, index1) in [Object.values(item.product_list)[0], Object.values(item.product_list)[1]]"
  79. :key="index1"
  80. :src="item1.thum"
  81. alt=""
  82. :class="[typeIndex == 1 ? 'goods_img typeimg' : 'goods_img']"
  83. />
  84. </div>
  85. <div v-else>
  86. <img v-for="(item1, index1) in Object.values(item.product_list)" :key="index1" :src="item1.thum" alt="" :class="[typeIndex == 1 ? 'goods_img typeimg' : 'goods_img']" />
  87. </div>
  88. <div class="ellipsis_box">
  89. <van-icon name="ellipsis" v-if="Object.values(item.product_list).length > 2" />
  90. </div>
  91. </div>
  92. <div class="right">
  93. <div class="flex_col">
  94. <span class="value_1">{{ item.day_num }}</span>
  95. <span class="key">{{ $t('lang324') }}</span>
  96. </div>
  97. <div class="flex_col">
  98. <span class="value_2">{{ Math.round(Number(item.income_reta) * 100 * 100) / 100 }}</span>
  99. <span class="key">APY</span>
  100. </div>
  101. </div>
  102. </div>
  103. </div>
  104. </div>
  105. </van-list>
  106. </div>
  107. <BottomNavigation></BottomNavigation>
  108. </div>
  109. </template>
  110. <script>
  111. import { mapState } from 'vuex';
  112. import { homeApi } from '@/api/index';
  113. import { dateFormat } from '@/utils/formatTool.js';
  114. import BottomNavigation from '@/components/BottomNavigation.vue';
  115. export default {
  116. data() {
  117. return {
  118. typeIndex: 2, //1单 2组
  119. time: 30 * 60 * 60 * 1000,
  120. showLoading: true,
  121. list: [],
  122. page: 0,
  123. current: parseInt(new Date().getTime() / 1000), //1743648326
  124. title: '',
  125. day_num: 0, //1倒序2正序
  126. income_reta: 0, //1倒序2正序
  127. loading: false,
  128. finished: false,
  129. total: 1,
  130. };
  131. },
  132. components: {
  133. BottomNavigation,
  134. },
  135. mounted() {
  136. this.onLoad();
  137. },
  138. methods: {
  139. onLoad() {
  140. console.log('onLoad');
  141. this.page += 1;
  142. this.pledgeList();
  143. },
  144. //返回上一页
  145. back() {
  146. this.$router.back();
  147. },
  148. dateFormatFn(date) {
  149. return dateFormat(new Date(date * 1000), 'MM/dd hh:mm');
  150. },
  151. handleScroll(event) {
  152. const container = event.target;
  153. const scrollTop = container.scrollTop; // 滚动距离
  154. const scrollHeight = container.scrollHeight; // 内容总高度
  155. const clientHeight = container.clientHeight; // 可视区域高度
  156. // 判断是否滑动到底部
  157. if (scrollTop + clientHeight >= scrollHeight - 10) {
  158. console.log('Bottom');
  159. if (this.page != -1) {
  160. this.page++; // 页数加 1
  161. this.pledgeList(); // 触发加载更多
  162. }
  163. }
  164. },
  165. handlePriceSort() {
  166. this.income_reta = 0
  167. if (this.day_num == 0) {
  168. this.day_num = 1;
  169. } else if (this.day_num == 1) {
  170. this.day_num = 2;
  171. } else if (this.day_num == 2) {
  172. this.day_num = 1;
  173. }
  174. this.search();
  175. },
  176. handleVolumeSort() {
  177. this.day_num = 0
  178. if (this.income_reta == 0) {
  179. this.income_reta = 1;
  180. } else if (this.income_reta == 1) {
  181. this.income_reta = 2;
  182. } else if (this.income_reta == 2) {
  183. this.income_reta = 1;
  184. }
  185. this.search();
  186. },
  187. search() {
  188. this.total = 1
  189. this.page = 0;
  190. this.list = []; // 重置列表数据
  191. this.onLoad(); // 触发重新获取列表数据
  192. },
  193. pledgeList() {
  194. this.loading = true;
  195. this.finished = false;
  196. homeApi.pledgeList({ type_id: this.typeIndex, page: this.page, title: this.title, day_num: this.day_num, income_reta: this.income_reta }).then(res => {
  197. // if (res.code == 200) {
  198. // if (this.list.length >= res.data.total) {
  199. // this.page = -1; // 重置为 -1,表示没有更多数据
  200. // } else {
  201. // this.list = [...this.list, ...res.data.data];
  202. // if (this.list.length >= res.data.total) {
  203. // this.page = -1; // 重置为 -1,表示没有更多数据
  204. // }
  205. // }
  206. // } else {
  207. // }
  208. if (res.code == 200) {
  209. let rows = res.data.data;
  210. // 如果返回的数组是空或数组长度是0
  211. if (rows == null || rows.length === 0) {
  212. this.loading = false; // 关闭加载状态
  213. this.finished = true; // 加载结束
  214. this.total = 0
  215. return;
  216. }
  217. this.loading = false; // 关闭加载状态
  218. this.total = res.data.total; //数据总条数
  219. this.list = this.list.concat(rows); //合并数组
  220. console.log(this.list);
  221. // 如果合并之后的数组长度大于返回的数据总条数
  222. if (this.list.length >= this.total) {
  223. this.finished = true; // 加载结束
  224. }
  225. } else {
  226. this.total = 0;
  227. this.loading = false; // 关闭加载状态
  228. this.finished = true; // 加载结束
  229. }
  230. });
  231. },
  232. changeType(index) {
  233. this.typeIndex = index;
  234. this.list = [];
  235. this.page = 0;
  236. this.search();
  237. },
  238. navigatorToPage(name, id) {
  239. this.$router.push({ name, query: { id: id } });
  240. },
  241. toPage(id) {
  242. if (this.typeIndex == 2) {
  243. this.$router.push({ name: 'MulStorageDetail', query: { id } });
  244. } else if (this.typeIndex == 1) {
  245. this.$router.push({ name: 'SingleStorageDetail', query: { id } });
  246. }
  247. },
  248. toSiniglePage(id) {},
  249. },
  250. computed: {
  251. ...mapState(['account']),
  252. },
  253. };
  254. </script>
  255. <style lang="less" scoped>
  256. .head {
  257. position: fixed;
  258. top: 0;
  259. left: 0;
  260. width: 100%;
  261. display: flex;
  262. align-items: center;
  263. justify-content: center;
  264. color: rgba(#000, 0.8);
  265. letter-spacing: 1.5px;
  266. font-weight: 550;
  267. background: #fff;
  268. padding: 14px 0;
  269. z-index: 99;
  270. .arrow_img {
  271. position: absolute;
  272. left: 20px;
  273. width: 10px;
  274. height: 16px;
  275. // transform: translate(0, -50%);
  276. }
  277. }
  278. .header {
  279. width: 100%;
  280. position: fixed;
  281. top: 0;
  282. z-index: 99;
  283. box-sizing: border-box;
  284. padding: 10px 16px 0;
  285. background-color: #fff;
  286. .input {
  287. width: 100%;
  288. // height: 35px;
  289. // line-height: 35px;
  290. border: 1px solid #29b286;
  291. border-radius: 20px;
  292. margin: 10px 0 0px;
  293. ::v-deep .van-field__control {
  294. letter-spacing: 1px;
  295. font-size: 13px;
  296. padding: 6px 13px;
  297. }
  298. ::v-deep .van-icon-search {
  299. font-size: 22px;
  300. color: #29b286;
  301. font-weight: bold;
  302. margin-right: 10px;
  303. }
  304. }
  305. .sort {
  306. color: #9d9d9d;
  307. width: 100%;
  308. font-size: 12px;
  309. letter-spacing: 1px;
  310. font-weight: 600;
  311. padding: 14px 0;
  312. .w1 {
  313. // width: 60%;
  314. padding-left: 12px
  315. }
  316. .w2 {
  317. margin-right: 28px;
  318. }
  319. .w3 {
  320. margin-right: 27px;
  321. }
  322. /deep/.van-ellipsis {
  323. color: #9d9d9d;
  324. font-size: 12px !important;
  325. }
  326. }
  327. }
  328. .btn_box {
  329. width: 100%;
  330. box-sizing: border-box;
  331. display: flex;
  332. align-items: center;
  333. justify-content: space-between;
  334. // padding: 10px 16px;
  335. .cc_btn {
  336. width: 31%;
  337. height: 36px;
  338. color: #29b286;
  339. line-height: 36px;
  340. font-size: 13px;
  341. // letter-spacing: 2px;
  342. text-align: center;
  343. // white-space: nowrap;
  344. padding: 0 10px;
  345. border: none;
  346. border-radius: 8px;
  347. // border: 1px solid #29b286;
  348. background-color: #f3f3f3;
  349. .van-button__text {
  350. overflow: hidden; //超出的文本隐藏
  351. text-overflow: ellipsis; //溢出用省略号显示
  352. white-space: nowrap; //溢出不换行
  353. }
  354. }
  355. .cc_active {
  356. color: #fff;
  357. background-color: #29b286;
  358. }
  359. }
  360. .jsb {
  361. justify-content: space-between;
  362. }
  363. .home_page {
  364. padding: 138px 0 80px;
  365. height: 100vh;
  366. overflow: auto;
  367. .pd {
  368. padding: 14px;
  369. // background-color: #fff;
  370. }
  371. .goods_box {
  372. // margin: 14px;
  373. border-radius: 14px;
  374. .good_icon {
  375. width: 16px;
  376. height: 16px;
  377. margin-right: 5px;
  378. }
  379. }
  380. .goods_list {
  381. color: #000;
  382. // padding: 14px;
  383. border-radius: 10px;
  384. margin-bottom: 16px;
  385. background-color: #fff;
  386. &_img {
  387. width: 125px;
  388. height: 125px;
  389. border-radius: 0 10px 10px 0 !important;
  390. }
  391. /deep/.van-image {
  392. border-radius: 0 10px 10px 0 !important;
  393. }
  394. .box {
  395. font-size: 13px;
  396. padding: 14px;
  397. box-sizing: border-box;
  398. // padding: 6px 0;
  399. &_top {
  400. display: flex;
  401. align-items: center;
  402. justify-content: space-between;
  403. .name {
  404. font-size: 16px;
  405. font-weight: 600;
  406. letter-spacing: 1px;
  407. max-width: 85%;
  408. }
  409. }
  410. &_arraw {
  411. display: flex;
  412. align-items: center;
  413. font-size: 11px;
  414. color: #7f7f7f;
  415. }
  416. &_bottom {
  417. display: flex;
  418. align-items: center;
  419. justify-content: space-between;
  420. padding-top: 20px;
  421. .goods_img {
  422. width: 52px;
  423. height: 52px;
  424. border-radius: 50%;
  425. margin-right: 6px;
  426. }
  427. .typeimg {
  428. width: 63px;
  429. height: 63px;
  430. }
  431. .ellipsis_box {
  432. width: 17px;
  433. }
  434. .flex {
  435. color: #7f7f7f;
  436. font-size: 17px;
  437. font-weight: 700;
  438. }
  439. .flex::after {
  440. content: ' ';
  441. width: 1px;
  442. height: 28px;
  443. margin-left: 10px;
  444. background-color: #e4e4e4;
  445. }
  446. .right {
  447. display: flex;
  448. // align-items: center;
  449. flex: 1;
  450. padding: 0 0 0 14px;
  451. .flex_col {
  452. width: 50%;
  453. // white-space: nowrap;
  454. text-align: center;
  455. .value_1 {
  456. color: #29b286;
  457. font-size: 21px;
  458. font-weight: 600;
  459. }
  460. .value_1::after {
  461. content: 'TeaC';
  462. font-size: 15px;
  463. font-weight: normal;
  464. }
  465. .value_2::after {
  466. content: '%';
  467. font-size: 15px;
  468. font-weight: normal;
  469. }
  470. .value_2 {
  471. color: #ed5111;
  472. font-size: 21px;
  473. font-weight: 600;
  474. }
  475. .key {
  476. color: #4b4b4b;
  477. font-size: 12px;
  478. padding-top: 10px;
  479. }
  480. }
  481. }
  482. }
  483. }
  484. .buy {
  485. display: flex;
  486. align-items: flex-end;
  487. &_btn {
  488. height: 30px;
  489. min-width: 102px;
  490. line-height: 26px;
  491. font-size: 12px;
  492. letter-spacing: 1px;
  493. text-align: center;
  494. white-space: nowrap;
  495. padding: 0 20px;
  496. border: none;
  497. border-radius: 30px;
  498. background-color: #29b286;
  499. }
  500. .will {
  501. background-color: #585858;
  502. .van-button__text {
  503. display: flex;
  504. align-items: center;
  505. flex-direction: column;
  506. line-height: 108%;
  507. }
  508. .countdown {
  509. font-size: 9px;
  510. letter-spacing: 0;
  511. }
  512. /deep/.van-count-down {
  513. line-height: 116% !important;
  514. color: #fff !important;
  515. }
  516. }
  517. .finish {
  518. color: #585858;
  519. background-color: #dedede;
  520. }
  521. }
  522. }
  523. }
  524. .icon {
  525. width: 20px;
  526. height: 20px;
  527. }
  528. .bare {
  529. text-align: center;
  530. font-size: 14px;
  531. padding: 60px 14px;
  532. color: #888;
  533. }
  534. .flex {
  535. display: flex;
  536. align-items: center;
  537. }
  538. .flex_col {
  539. display: flex;
  540. align-items: center;
  541. flex-direction: column;
  542. }
  543. .flex_end {
  544. align-items: flex-end;
  545. }
  546. ::v-deep .van-cascader__option {
  547. color: #000;
  548. }
  549. .ellipsis {
  550. display: -webkit-box;
  551. -webkit-line-clamp: 2;
  552. -webkit-box-orient: vertical;
  553. overflow: hidden;
  554. }
  555. </style>