| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- <template>
- <view class="content padding-t-20">
- <view class="flex item padding-v-20 padding-c-20" v-for="(item,index) in goodsList">
- <view class="imgbox">
- <image class="img" src="" mode="scaleToFill"></image>
- </view>
- <view class="contentbox padding-l-20 flex">
- <view class="clamp2 title">
- 法国空运高端82年拉菲陈酿 红葡萄酒...
- </view>
- <view class="oldMoneyBox ">
- <view class="flex-start padding-b-10">
- <text class="oldMoney">¥200</text>
- <image class="icon padding-l-10" src="../../static/img/domIcon.png" mode="scaleToFill"></image>
- <text class="domMoney font-size-sm">
- 直降40元
- </text>
- </view>
- <view class="flex">
- <view class="money">¥200</view>
- <view class="buttomPay" @click="navto('/')">立即购买</view>
- </view>
- </view>
- </view>
- </view>
- <uni-load-more :status="loadingType"></uni-load-more>
- </view>
- </template>
- <script>
- import {
- getProducts
- } from '@/api/product.js';
- export default {
- data() {
- return {
- // 列表
- goodsList: [],
- limit: 6, //每次加载数据条数
- page: 1, //当前页数
- loadingType: 'more', //加载更多状态
- };
- },
- onLoad() {
- this.getProducts();
- },
- onShow() {},
- onPullDownRefresh() {
- this.getProducts('refresh');
- },
- methods: {
- navto(url) {
- // #ifdef H5
- console.log(url.indexOf('http'), 'banner');
- if (url.indexOf('http') >= 0) {
- window.location.href = url;
- }
- // #endif
- //测试数据没有写id,用title代替
- uni.navigateTo({
- url: url
- });
- },
- async getProducts(type) {
- let obj = this;
- // 判断是否为重新加载数据
- if (type !== 'refresh') {
- //没有更多数据直接跳出方法
- if (obj.loadingType === 'nomore') {
- return;
- }
- if (obj.loadingType === 'loading') {
- //防止重复加载
- return;
- }
- // 设置当前为数据载入中
- obj.loadingType = 'loading';
- } else {
- this.page = 1;
- obj.goodsList = [];
- //当重新加载数据时更新状态为可继续添加数据
- obj.loadingType = 'more';
- }
- let data = {
- page: obj.page,
- limit: obj.limit,
- };
- getProducts(data).then(e => {
- obj.goodsList = obj.goodsList.concat(e.data);
- //判断是否还有下一页,有是more 没有是nomore
- if (obj.limit == e.data.length) {
- obj.page++;
- obj.loadingType = 'more';
- } else {
- obj.loadingType = 'nomore';
- }
- });
- },
- }
- };
- </script>
- <style lang="scss">
- page,
- .content {
- min-height: 100%;
- height: auto;
- }
- .item {
- border-radius: 10rpx;
- background-color: #FFFFFF;
- width: 690rpx;
- margin: 0 30rpx 20rpx 30rpx;
- align-items: stretch;
- line-height: 1;
- .imgbox {
- background-color: #EE2F72;
- border-radius: 10rpx;
- .img {
- height: 246rpx;
- width: 246rpx;
- }
- }
- .contentbox {
- flex-wrap: wrap;
- .title {
- width: 100%;
- align-self: flex-start;
- font-size: $font-lg;
- color: $font-color-dark;
- line-height: 1.5;
- }
- .money {
- font-size: $font-lg + 4rpx;
- font-weight: bold;
- color: #EE2F72;
- }
- .oldMoneyBox {
- align-self: flex-end;
- width: 100%;
- .oldMoney {
- font-size: $font-sm;
- text-decoration: line-through;
- color: $font-color-light;
- }
- .domMoney {
- color: #B59467;
- }
- .icon {
- width: 14rpx;
- height: 16rpx;
- }
- .buttomPay {
- padding: 14rpx 26rpx;
- font-size: $font-base;
- color: #fff;
- background: linear-gradient(90deg, #FF4A8A, #FF77A7);
- border-radius: 26px;
- }
- }
- }
- }
- </style>
|