| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535 |
- <template>
- <div>
- <!-- <div class="head">
- <img @click="back" src="@/assets/images/back.png" class="arrow_img" />
- <span>{{ $t('lang217') }}</span>
- </div> -->
- <div class="header">
- <div class="btn_box">
- <van-button
- :class="[typeIndex == 2 ? 'cc_btn cc_active' : 'cc_btn']"
- :icon="typeIndex == 2 ? 'https://teaclub.oss-cn-chengdu.aliyuncs.com/mall/mul_1.png' : 'https://teaclub.oss-cn-chengdu.aliyuncs.com/mall/mul.png'"
- @click="changeType(2)"
- >
- <!-- <img src="@/assets/images/index/mul.png" class="icon" /> -->
- {{ $t('lang319') }}</van-button
- >
- <van-button
- :class="[typeIndex == 1 ? 'cc_btn cc_active' : 'cc_btn']"
- :icon="typeIndex == 1 ? 'https://teaclub.oss-cn-chengdu.aliyuncs.com/mall/single_1.png' : 'https://teaclub.oss-cn-chengdu.aliyuncs.com/mall/single.png'"
- @click="changeType(1)"
- >{{ $t('lang320') }}</van-button
- >
- <van-button class="cc_btn" icon="https://teaclub.oss-cn-chengdu.aliyuncs.com/mall/teamine.png" @click="navigatorToPage('storing')">{{ $t('lang38') }}</van-button>
- </div>
- <van-field v-model="title" :placeholder="$t('lang496')" class="input" right-icon="search" @click-right-icon="search" />
- <div class="sort flex jsb">
- <span class="w1">{{ $t('lang495') }}</span>
- <div class="flex jsb">
- <div class="flex w2" @click="handlePriceSort">
- <span>{{ $t('lang494') }}</span>
- <img src="@/assets/images/index/j0.png" alt="" style="width: 14px" v-if="day_num == 0" />
- <img src="@/assets/images/index/j2.png" alt="" style="width: 14px" v-else-if="day_num == 1" />
- <img src="@/assets/images/index/j1.png" alt="" style="width: 14px" v-else-if="day_num == 2" />
- </div>
- <div class="flex w3" @click="handleVolumeSort">
- <span>APY</span>
- <img src="@/assets/images/index/j0.png" alt="" style="width: 14px" v-if="income_reta == 0" />
- <img src="@/assets/images/index/j2.png" alt="" style="width: 14px" v-else-if="income_reta == 1" />
- <img src="@/assets/images/index/j1.png" alt="" style="width: 14px" v-else-if="income_reta == 2" />
- </div>
- <!-- <van-dropdown-menu active-color="#3d3d3d">
- <van-dropdown-item v-model="type_id" :options="indexinfo.type_list" @change="search" />
- </van-dropdown-menu> -->
- <!-- <svg width="30" height="30" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
- <path
- d="M70,35
- C56,28 38,40 40,54
- C40,64 50,74 70,66"
- fill="none"
- stroke="black"
- stroke-width="6"
- stroke-linecap="round"
- />
- <line x1="52" y1="29" x2="52" y2="73" stroke="black" stroke-width="5.2" stroke-linecap="round" />
- <line x1="63" y1="29" x2="63" y2="73" stroke="black" stroke-width="5.2" stroke-linecap="round" />
- </svg> -->
- </div>
- </div>
- </div>
- <div class="home_page" @scroll="handleScroll">
- <div class="pd goods_box" v-if="list.length > 0">
- <div class="goods_list jsb" v-for="(item, index) in list" :key="index">
- <div class="box" @click="toPage(item.id)">
- <div class="box_top">
- <span class="ellipsis name">{{ item.title }}</span>
- <div class="box_arraw">
- <span>{{ $t('lang323') }}</span>
- <van-icon name="arrow" />
- </div>
- </div>
- <div class="box_bottom">
- <div class="flex">
- <div v-if="Object.values(item.product_list).length > 1">
- <img
- v-for="(item1, index1) in [Object.values(item.product_list)[0], Object.values(item.product_list)[1]]"
- :key="index1"
- :src="item1.thum"
- alt=""
- :class="[typeIndex == 1 ? 'goods_img typeimg' : 'goods_img']"
- />
- </div>
- <div v-else>
- <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']" />
- </div>
- <div class="ellipsis_box">
- <van-icon name="ellipsis" v-if="Object.values(item.product_list).length > 2" />
- </div>
- </div>
- <div class="right">
- <div class="flex_col">
- <span class="value_1">{{ item.day_num }}</span>
- <span class="key">{{ $t('lang324') }}</span>
- </div>
- <div class="flex_col">
- <span class="value_2">{{ Math.round(Number(item.income_reta) * 100 * 100) / 100 }}</span>
- <span class="key">APY</span>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="bare" v-else>
- <span>{{ $t('lang60') }}</span>
- </div>
- </div>
- <BottomNavigation></BottomNavigation>
- </div>
- </template>
- <script>
- import { mapState } from 'vuex';
- import { homeApi } from '@/api/index';
- import { dateFormat } from '@/utils/formatTool.js';
- import BottomNavigation from '@/components/BottomNavigation.vue';
- export default {
- data() {
- return {
- typeIndex: 2, //1单 2组
- time: 30 * 60 * 60 * 1000,
- showLoading: true,
- list: [],
- page: 1,
- current: parseInt(new Date().getTime() / 1000), //1743648326
- title: '',
- day_num: 0, //1倒序2正序
- income_reta: 0, //1倒序2正序
- };
- },
- components: {
- BottomNavigation,
- },
- mounted() {
- this.init();
- },
- methods: {
- //返回上一页
- back() {
- this.$router.back();
- },
- init() {
- this.pledgeList();
- },
- dateFormatFn(date) {
- return dateFormat(new Date(date * 1000), 'MM/dd hh:mm');
- },
- handleScroll(event) {
- const container = event.target;
- const scrollTop = container.scrollTop; // 滚动距离
- const scrollHeight = container.scrollHeight; // 内容总高度
- const clientHeight = container.clientHeight; // 可视区域高度
- // 判断是否滑动到底部
- if (scrollTop + clientHeight >= scrollHeight - 10) {
- console.log('Bottom');
- if (this.page != -1) {
- this.page++; // 页数加 1
- this.pledgeList(); // 触发加载更多
- }
- }
- },
- handlePriceSort() {
- this.income_reta = 0
- if (this.day_num == 0) {
- this.day_num = 1;
- } else if (this.day_num == 1) {
- this.day_num = 2;
- } else if (this.day_num == 2) {
- this.day_num = 1;
- }
- this.search();
- },
- handleVolumeSort() {
- this.day_num = 0
- if (this.income_reta == 0) {
- this.income_reta = 1;
- } else if (this.income_reta == 1) {
- this.income_reta = 2;
- } else if (this.income_reta == 2) {
- this.income_reta = 1;
- }
- this.search();
- },
- search() {
- this.page = 1;
- this.list = []; // 重置列表数据
- this.pledgeList(); // 触发重新获取列表数据
- },
- pledgeList() {
- homeApi.pledgeList({ type_id: this.typeIndex, page: this.page, title: this.title, day_num: this.day_num, income_reta: this.income_reta }).then(res => {
- if (res.code == 200) {
- if (this.list.length >= res.data.total) {
- this.page = -1; // 重置为 -1,表示没有更多数据
- } else {
- this.list = [...this.list, ...res.data.data];
- if (this.list.length >= res.data.total) {
- this.page = -1; // 重置为 -1,表示没有更多数据
- }
- }
- } else {
- }
- });
- },
- changeType(index) {
- this.typeIndex = index;
- this.list = [];
- this.page = 1;
- this.pledgeList();
- },
- navigatorToPage(name, id) {
- this.$router.push({ name, query: { id: id } });
- },
- toPage(id) {
- if (this.typeIndex == 2) {
- this.$router.push({ name: 'MulStorageDetail', query: { id } });
- } else if (this.typeIndex == 1) {
- this.$router.push({ name: 'SingleStorageDetail', query: { id } });
- }
- },
- toSiniglePage(id) {},
- },
- computed: {
- ...mapState(['account']),
- },
- };
- </script>
- <style lang="less" scoped>
- .head {
- position: fixed;
- top: 0;
- left: 0;
- width: 100%;
- display: flex;
- align-items: center;
- justify-content: center;
- color: rgba(#000, 0.8);
- letter-spacing: 1.5px;
- font-weight: 550;
- background: #fff;
- padding: 14px 0;
- z-index: 99;
- .arrow_img {
- position: absolute;
- left: 20px;
- width: 10px;
- height: 16px;
- // transform: translate(0, -50%);
- }
- }
- .header {
- width: 100%;
- position: fixed;
- top: 0;
- z-index: 99;
- box-sizing: border-box;
- padding: 10px 16px 0;
- background-color: #fff;
- .input {
- width: 100%;
- // height: 35px;
- // line-height: 35px;
- border: 1px solid #29b286;
- border-radius: 20px;
- margin: 10px 0 0px;
- ::v-deep .van-field__control {
- letter-spacing: 1px;
- font-size: 13px;
- padding: 6px 13px;
- }
- ::v-deep .van-icon-search {
- font-size: 22px;
- color: #29b286;
- font-weight: bold;
- margin-right: 10px;
- }
- }
- .sort {
- color: #9d9d9d;
- width: 100%;
- font-size: 12px;
- letter-spacing: 1px;
- font-weight: 600;
- padding: 14px 0;
- .w1 {
- // width: 60%;
- }
- .w2 {
- margin-right: 20px;
- }
- /deep/.van-ellipsis {
- color: #9d9d9d;
- font-size: 12px !important;
- }
- }
- }
- .btn_box {
- width: 100%;
- box-sizing: border-box;
- display: flex;
- align-items: center;
- justify-content: space-between;
- // padding: 10px 16px;
- .cc_btn {
- width: 31%;
- height: 36px;
- color: #29b286;
- line-height: 36px;
- font-size: 13px;
- // letter-spacing: 2px;
- text-align: center;
- // white-space: nowrap;
- padding: 0 10px;
- border: none;
- border-radius: 8px;
- // border: 1px solid #29b286;
- background-color: #f3f3f3;
- .van-button__text {
- overflow: hidden; //超出的文本隐藏
- text-overflow: ellipsis; //溢出用省略号显示
- white-space: nowrap; //溢出不换行
- }
- }
- .cc_active {
- color: #fff;
- background-color: #29b286;
- }
- }
- .jsb {
- justify-content: space-between;
- }
- .home_page {
- padding: 138px 0 80px;
- height: 100vh;
- overflow: auto;
- .pd {
- padding: 14px;
- // background-color: #fff;
- }
- .goods_box {
- // margin: 14px;
- border-radius: 14px;
- .good_icon {
- width: 16px;
- height: 16px;
- margin-right: 5px;
- }
- }
- .goods_list {
- color: #000;
- // padding: 14px;
- border-radius: 10px;
- margin-bottom: 16px;
- background-color: #fff;
- &_img {
- width: 125px;
- height: 125px;
- border-radius: 0 10px 10px 0 !important;
- }
- /deep/.van-image {
- border-radius: 0 10px 10px 0 !important;
- }
- .box {
- font-size: 13px;
- padding: 14px;
- box-sizing: border-box;
- // padding: 6px 0;
- &_top {
- display: flex;
- align-items: center;
- justify-content: space-between;
- .name {
- font-size: 16px;
- font-weight: 600;
- letter-spacing: 1px;
- max-width: 85%;
- }
- }
- &_arraw {
- display: flex;
- align-items: center;
- font-size: 11px;
- color: #7f7f7f;
- }
- &_bottom {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding-top: 20px;
- .goods_img {
- width: 52px;
- height: 52px;
- border-radius: 50%;
- margin-right: 6px;
- }
- .typeimg {
- width: 63px;
- height: 63px;
- }
- .ellipsis_box {
- width: 17px;
- }
- .flex {
- color: #7f7f7f;
- font-size: 17px;
- font-weight: 700;
- }
- .flex::after {
- content: ' ';
- width: 1px;
- height: 28px;
- margin-left: 10px;
- background-color: #e4e4e4;
- }
- .right {
- display: flex;
- // align-items: center;
- flex: 1;
- padding: 0 0 0 14px;
- .flex_col {
- width: 50%;
- // white-space: nowrap;
- text-align: center;
- .value_1 {
- color: #29b286;
- font-size: 21px;
- font-weight: 600;
- }
- .value_1::after {
- content: 'TeaC';
- font-size: 15px;
- font-weight: normal;
- }
- .value_2::after {
- content: '%';
- font-size: 15px;
- font-weight: normal;
- }
- .value_2 {
- color: #ed5111;
- font-size: 21px;
- font-weight: 600;
- }
- .key {
- color: #4b4b4b;
- font-size: 12px;
- padding-top: 10px;
- }
- }
- }
- }
- }
- .buy {
- display: flex;
- align-items: flex-end;
- &_btn {
- height: 30px;
- min-width: 102px;
- line-height: 26px;
- font-size: 12px;
- letter-spacing: 1px;
- text-align: center;
- white-space: nowrap;
- padding: 0 20px;
- border: none;
- border-radius: 30px;
- background-color: #29b286;
- }
- .will {
- background-color: #585858;
- .van-button__text {
- display: flex;
- align-items: center;
- flex-direction: column;
- line-height: 108%;
- }
- .countdown {
- font-size: 9px;
- letter-spacing: 0;
- }
- /deep/.van-count-down {
- line-height: 116% !important;
- color: #fff !important;
- }
- }
- .finish {
- color: #585858;
- background-color: #dedede;
- }
- }
- }
- }
- .icon {
- width: 20px;
- height: 20px;
- }
- .bare {
- text-align: center;
- font-size: 14px;
- padding: 60px 14px;
- color: #888;
- }
- .flex {
- display: flex;
- align-items: center;
- }
- .flex_col {
- display: flex;
- align-items: center;
- flex-direction: column;
- }
- .flex_end {
- align-items: flex-end;
- }
- ::v-deep .van-cascader__option {
- color: #000;
- }
- .ellipsis {
- display: -webkit-box;
- -webkit-line-clamp: 2;
- -webkit-box-orient: vertical;
- overflow: hidden;
- }
- </style>
|