| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- <template>
- <view class="content">
- <view class="main-item" v-for="(item, index) in list" @click="navToDetailPage(item)">
- <image class="main-image" :src="item.image" mode=""></image>
- <view class="main-title clamp2">{{ item.store_name }}</view>
- <view class="btn-box flex">
- <view class="price">
- <text>原价:¥{{ item.price }}</text>
- {{ item.price }}
- </view>
- <view class="buy-btn">去抢购</view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import { getProducts } from '@/api/product.js';
- export default {
- data() {
- return {
- list: [],
- loadingType: 'more',
- page: 1, //当前页数
- limit: 10 //每次信息条数
- };
- },
- onLoad() {},
- onShow() {
- this.loadData();
- },
- methods: {
- loadData() {
- let obj = this;
- if (obj.loadingType === 'loading') {
- //防止重复加载
- return;
- }
- if (obj.loadingType === 'noMore') {
- //防止重复加载
- return;
- }
- obj.loadingType = 'loading';
- getProducts({ cid: 52, page: obj.page, limit: obj.limit }).then(({ data }) => {
- console.log(data);
- obj.list = obj.list.concat(data);
- obj.page++;
- if (obj.limit == data.length) {
- //判断是否还有数据, 有改为 more, 没有改为noMore
- obj.loadingType = 'more';
- return;
- } else {
- //判断是否还有数据, 有改为 more, 没有改为noMore
- obj.loadingType = 'noMore';
- }
- });
- },
- navToDetailPage(item) {
- let id = item.id;
- uni.navigateTo({
- url: '/pages/product/product?id=' + id + '&isVip=1'
- });
- }
- }
- };
- </script>
- <style lang="scss">
- page,
- .content {
- min-height: 100%;
- height: auto;
- }
- .main-item {
- width: 690rpx;
- background: #ffffff;
- box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
- border-radius: 20rpx;
- margin: 20rpx auto 0;
- .main-image {
- width: 690rpx;
- height: 300rpx;
- border-radius: 20rpx 20rpx 0 0;
- }
- .main-title {
- padding: 18rpx 50rpx 0 22rpx;
- font-size: 32rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #333333;
- }
- .btn-box {
- margin-top: 20rpx;
- padding: 0 15rpx 25rpx 22rpx;
- .price {
- font-size: 40rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #ff4c4c;
- text {
- display: inline-block;
- margin-right: 10rpx;
- font-size: 26rpx;
- font-family: PingFang SC;
- font-weight: 500;
- text-decoration: line-through;
- color: #999999;
- }
- }
- .buy-btn {
- display: flex;
- justify-content: center;
- align-items: center;
- width: 170rpx;
- height: 53rpx;
- background: linear-gradient(30deg, #ff4c4c, #fe6238);
- border-radius: 27rpx;
- font-size: 28rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #ffffff;
- }
- }
- }
- </style>
|