list.vue 14 KB

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