list.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  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="btn_box">
  8. <van-button
  9. :class="[typeIndex == 2 ? 'cc_btn cc_active' : 'cc_btn']"
  10. :icon="typeIndex == 2 ? 'https://teaclub.oss-cn-chengdu.aliyuncs.com/mall/mul_1.png' : 'https://teaclub.oss-cn-chengdu.aliyuncs.com/mall/mul.png'"
  11. @click="changeType(2)"
  12. >
  13. <!-- <img src="@/assets/images/index/mul.png" class="icon" /> -->
  14. {{ $t('lang319') }}</van-button
  15. >
  16. <van-button
  17. :class="[typeIndex == 1 ? 'cc_btn cc_active' : 'cc_btn']"
  18. :icon="typeIndex == 1 ? 'https://teaclub.oss-cn-chengdu.aliyuncs.com/mall/single_1.png' : 'https://teaclub.oss-cn-chengdu.aliyuncs.com/mall/single.png'"
  19. @click="changeType(1)"
  20. >{{ $t('lang320') }}</van-button
  21. >
  22. <van-button class="cc_btn" icon="https://teaclub.oss-cn-chengdu.aliyuncs.com/mall/teamine.png" @click="navigatorToPage('storing')">{{ $t('lang38') }}</van-button>
  23. </div>
  24. <div class="home_page" @scroll="handleScroll">
  25. <div class="pd goods_box" v-if="list.length > 0">
  26. <div class="goods_list jsb" v-for="(item, index) in list" :key="index">
  27. <div class="box" @click="toPage(item.id)">
  28. <div class="box_top">
  29. <span class="ellipsis name">{{ item.title }}</span>
  30. <div class="box_arraw">
  31. <span>{{ $t('lang323') }}</span>
  32. <van-icon name="arrow" />
  33. </div>
  34. </div>
  35. <div class="box_bottom">
  36. <div class="flex">
  37. <div v-if="Object.values(item.product_list).length > 1">
  38. <img
  39. v-for="(item1, index1) in [Object.values(item.product_list)[0], Object.values(item.product_list)[1]]"
  40. :key="index1"
  41. :src="item1.thum"
  42. alt=""
  43. :class="[typeIndex == 1 ? 'goods_img typeimg' : 'goods_img']"
  44. />
  45. </div>
  46. <div v-else>
  47. <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']" />
  48. </div>
  49. <div class="ellipsis_box">
  50. <van-icon name="ellipsis" v-if="Object.values(item.product_list).length > 2" />
  51. </div>
  52. </div>
  53. <div class="right">
  54. <div class="flex_col">
  55. <span class="value_1">{{ item.day_num }}</span>
  56. <span class="key">{{ $t('lang324') }}</span>
  57. </div>
  58. <div class="flex_col">
  59. <span class="value_2">{{ Number(item.income_reta) * 100 }}</span>
  60. <span class="key">APY</span>
  61. </div>
  62. </div>
  63. </div>
  64. </div>
  65. </div>
  66. </div>
  67. <div class="bare" v-else>
  68. <span>{{ $t('lang60') }}</span>
  69. </div>
  70. </div>
  71. </div>
  72. </template>
  73. <script>
  74. import { mapState } from 'vuex';
  75. import { homeApi } from '@/api/index';
  76. import { dateFormat } from '@/utils/formatTool.js';
  77. export default {
  78. data() {
  79. return {
  80. typeIndex: 2, //1单 2组
  81. time: 30 * 60 * 60 * 1000,
  82. showLoading: true,
  83. list: [],
  84. page: 1,
  85. current: parseInt(new Date().getTime() / 1000), //1743648326
  86. };
  87. },
  88. mounted() {
  89. this.init();
  90. },
  91. methods: {
  92. //返回上一页
  93. back() {
  94. this.$router.back();
  95. },
  96. init() {
  97. this.pledgeList();
  98. },
  99. dateFormatFn(date) {
  100. return dateFormat(new Date(date * 1000), 'MM/dd hh:mm');
  101. },
  102. handleScroll(event) {
  103. const container = event.target;
  104. const scrollTop = container.scrollTop; // 滚动距离
  105. const scrollHeight = container.scrollHeight; // 内容总高度
  106. const clientHeight = container.clientHeight; // 可视区域高度
  107. // 判断是否滑动到底部
  108. if (scrollTop + clientHeight >= scrollHeight - 10) {
  109. console.log('Bottom');
  110. if (this.page != -1) {
  111. this.page++; // 页数加 1
  112. this.pledgeList(); // 触发加载更多
  113. }
  114. }
  115. },
  116. pledgeList() {
  117. homeApi.pledgeList({ type_id: this.typeIndex, page: this.page }).then(res => {
  118. if (res.code == 200) {
  119. if (this.list.length >= res.data.total) {
  120. this.page = -1; // 重置为 -1,表示没有更多数据
  121. } else {
  122. this.list = [...this.list, ...res.data.data];
  123. if (this.list.length >= res.data.total) {
  124. this.page = -1; // 重置为 -1,表示没有更多数据
  125. }
  126. }
  127. } else {
  128. }
  129. });
  130. },
  131. changeType(index) {
  132. this.typeIndex = index;
  133. this.list = [];
  134. this.page = 1;
  135. this.pledgeList();
  136. },
  137. navigatorToPage(name, id) {
  138. this.$router.push({ name, query: { id: id } });
  139. },
  140. toPage(id) {
  141. if (this.typeIndex == 2) {
  142. this.$router.push({ name: 'MulStorageDetail', query: { id } });
  143. } else if (this.typeIndex == 1) {
  144. this.$router.push({ name: 'SingleStorageDetail', query: { id } });
  145. }
  146. },
  147. toSiniglePage(id) {},
  148. },
  149. computed: {
  150. ...mapState(['account']),
  151. },
  152. };
  153. </script>
  154. <style lang="less" scoped>
  155. .head {
  156. position: fixed;
  157. top: 0;
  158. left: 0;
  159. width: 100%;
  160. display: flex;
  161. align-items: center;
  162. justify-content: center;
  163. color: rgba(#000, 0.8);
  164. letter-spacing: 1.5px;
  165. font-weight: 550;
  166. background: #fff;
  167. padding: 14px 0;
  168. z-index: 99;
  169. .arrow_img {
  170. position: absolute;
  171. left: 20px;
  172. width: 10px;
  173. height: 16px;
  174. // transform: translate(0, -50%);
  175. }
  176. }
  177. .btn_box {
  178. width: 100%;
  179. box-sizing: border-box;
  180. position: fixed;
  181. top: 52px;
  182. display: flex;
  183. align-items: center;
  184. justify-content: space-between;
  185. padding: 10px 16px;
  186. background-color: #fff;
  187. .cc_btn {
  188. width: 31%;
  189. height: 36px;
  190. color: #29b286;
  191. line-height: 36px;
  192. font-size: 13px;
  193. // letter-spacing: 2px;
  194. text-align: center;
  195. // white-space: nowrap;
  196. padding: 0 10px;
  197. border: none;
  198. border-radius: 8px;
  199. // border: 1px solid #29b286;
  200. background-color: #f3f3f3;
  201. .van-button__text {
  202. overflow: hidden; //超出的文本隐藏
  203. text-overflow: ellipsis; //溢出用省略号显示
  204. white-space: nowrap; //溢出不换行
  205. }
  206. }
  207. .cc_active {
  208. color: #fff;
  209. background-color: #29b286;
  210. }
  211. }
  212. .home_page {
  213. padding: 100px 0 30px;
  214. height: 100vh;
  215. overflow: auto;
  216. .pd {
  217. padding: 14px;
  218. // background-color: #fff;
  219. }
  220. .jsb {
  221. justify-content: space-between;
  222. }
  223. .goods_box {
  224. // margin: 14px;
  225. border-radius: 14px;
  226. .good_icon {
  227. width: 16px;
  228. height: 16px;
  229. margin-right: 5px;
  230. }
  231. }
  232. .goods_list {
  233. color: #000;
  234. // padding: 14px;
  235. border-radius: 10px;
  236. margin-bottom: 16px;
  237. background-color: #fff;
  238. &_img {
  239. width: 125px;
  240. height: 125px;
  241. border-radius: 0 10px 10px 0 !important;
  242. }
  243. /deep/.van-image {
  244. border-radius: 0 10px 10px 0 !important;
  245. }
  246. .box {
  247. font-size: 13px;
  248. padding: 14px;
  249. box-sizing: border-box;
  250. // padding: 6px 0;
  251. &_top {
  252. display: flex;
  253. align-items: center;
  254. justify-content: space-between;
  255. .name {
  256. font-size: 16px;
  257. font-weight: 600;
  258. letter-spacing: 1px;
  259. }
  260. }
  261. &_arraw {
  262. display: flex;
  263. align-items: center;
  264. font-size: 11px;
  265. color: #7f7f7f;
  266. }
  267. &_bottom {
  268. display: flex;
  269. align-items: center;
  270. justify-content: space-between;
  271. padding-top: 20px;
  272. .goods_img {
  273. width: 52px;
  274. height: 52px;
  275. border-radius: 50%;
  276. margin-right: 6px;
  277. }
  278. .typeimg {
  279. width: 63px;
  280. height: 63px;
  281. }
  282. .ellipsis_box {
  283. width: 17px;
  284. }
  285. .flex {
  286. color: #7f7f7f;
  287. font-size: 17px;
  288. font-weight: 700;
  289. }
  290. .flex::after {
  291. content: ' ';
  292. width: 1px;
  293. height: 28px;
  294. margin-left: 10px;
  295. background-color: #e4e4e4;
  296. }
  297. .right {
  298. display: flex;
  299. // align-items: center;
  300. flex: 1;
  301. padding: 0 0 0 14px;
  302. .flex_col {
  303. width: 50%;
  304. // white-space: nowrap;
  305. text-align: center;
  306. .value_1 {
  307. color: #29b286;
  308. font-size: 21px;
  309. font-weight: 600;
  310. }
  311. .value_1::after {
  312. content: 'TeaC';
  313. font-size: 15px;
  314. font-weight: normal;
  315. }
  316. .value_2::after {
  317. content: '%';
  318. font-size: 15px;
  319. font-weight: normal;
  320. }
  321. .value_2 {
  322. color: #ed5111;
  323. font-size: 21px;
  324. font-weight: 600;
  325. }
  326. .key {
  327. color: #4b4b4b;
  328. font-size: 12px;
  329. padding-top: 10px;
  330. }
  331. }
  332. }
  333. }
  334. }
  335. .buy {
  336. display: flex;
  337. align-items: flex-end;
  338. &_btn {
  339. height: 30px;
  340. min-width: 102px;
  341. line-height: 26px;
  342. font-size: 12px;
  343. letter-spacing: 1px;
  344. text-align: center;
  345. white-space: nowrap;
  346. padding: 0 20px;
  347. border: none;
  348. border-radius: 30px;
  349. background-color: #29b286;
  350. }
  351. .will {
  352. background-color: #585858;
  353. .van-button__text {
  354. display: flex;
  355. align-items: center;
  356. flex-direction: column;
  357. line-height: 108%;
  358. }
  359. .countdown {
  360. font-size: 9px;
  361. letter-spacing: 0;
  362. }
  363. /deep/.van-count-down {
  364. line-height: 116% !important;
  365. color: #fff !important;
  366. }
  367. }
  368. .finish {
  369. color: #585858;
  370. background-color: #dedede;
  371. }
  372. }
  373. }
  374. }
  375. .icon {
  376. width: 20px;
  377. height: 20px;
  378. }
  379. .bare {
  380. text-align: center;
  381. font-size: 14px;
  382. padding: 60px 14px;
  383. color: #888;
  384. }
  385. .flex {
  386. display: flex;
  387. align-items: center;
  388. }
  389. .flex_col {
  390. display: flex;
  391. align-items: center;
  392. flex-direction: column;
  393. }
  394. .flex_end {
  395. align-items: flex-end;
  396. }
  397. ::v-deep .van-cascader__option {
  398. color: #000;
  399. }
  400. .ellipsis {
  401. display: -webkit-box;
  402. -webkit-line-clamp: 2;
  403. -webkit-box-orient: vertical;
  404. overflow: hidden;
  405. }
  406. </style>