| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- <template>
- <view class="content">
- <view class="goods-list">
- <view class="goods-item" v-for="(item, index) in goodsList" :key="index" @click="addCart(item)">
- <image :src="item.image" mode="aspectFill" class="goods-image"></image>
- <view class="goods-name clamp">{{item.store_name}}</view>
- <view class="goods-info">
- <text class="goods-points">{{item.price}} 积分</text>
- <image src="/static/icon/cart.png" mode="widthFix" class="add-cart" ></image>
- </view>
- </view>
- </view>
- <m-tabbar fixed fill current="1" :tabbar="tabbar"></m-tabbar>
- </view>
- </template>
- <script>
- import TabbarConfig from '@/config/tabbar.js'
- import { getProductList } from '@/api/good.js'
- export default {
- data() {
- return {
- tabbar: TabbarConfig,
- page: 1,
- limit: 20,
- list: [],
- loaded: false,
- status: 'more',
- goodsList: []
- };
- },
- methods: {
- // 返回
- getProductList() {
- let that = this
- if(that.status == 'noMore' || that.status == 'loading') return;
- that.status = 'loading'
- getProductList({
- page: that.page,
- pageSize: that.limit,
- }).then(res => {
- let list = res.data.list
- that.goodsList = that.goodsList.concat(list)
- if(that.limit == list.length) {
- that.status = 'more'
- }else {
- that.status = 'noMore'
- }
- that.loaded = true
- })
- },
- // 添加到购物车
- addCart(item) {
- uni.navigateTo({
- url:'/pages/user/jf/detail?id=' + item.id
- })
- }
- },
- onLoad() {
- this.getProductList()
- },
- onReachBottom() {
- this.getProductList()
- }
- };
- </script>
- <style lang="scss">
- page {
- height: 100%;
- background-color: #F5F5F5;
- }
- .content {
- min-height: 100%;
- }
- .header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 0 30rpx;
- height: 80rpx;
- background-color: #FF4444;
-
- .back {
- width: 40rpx;
- height: 40rpx;
-
- image {
- width: 100%;
- height: 100%;
- }
- }
-
- .title {
- font-size: 32rpx;
- font-weight: bold;
- color: #FFFFFF;
- }
-
- .right {
- width: 40rpx;
- }
- }
- .goods-list {
- display: flex;
- flex-wrap: wrap;
- padding: 0 15rpx;
- justify-content: space-between;
- padding-top: 20rpx;
- .goods-item {
- width: 350rpx;
- // margin: 1%;
- background-color: #FFFFFF;
- border-radius: 15rpx;
- overflow: hidden;
- margin-bottom: 20rpx;
- .goods-image {
- width: 350rpx;
- height: 300rpx;
- }
-
- .goods-name {
- width: 330rpx;
- padding: 15rpx ;
- font-size: 26rpx;
- color: #333333;
- line-height: 36rpx;
- height: 72rpx;
- // overflow: hidden;
- // text-overflow: ellipsis;
- // display: -webkit-box;
- // -webkit-line-clamp: 2;
- // -webkit-box-orient: vertical;
- }
-
- .goods-info {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 0 15rpx 15rpx;
-
- .goods-points {
- font-size: 26rpx;
- font-weight: bold;
- color: #FF4444;
- }
-
- .add-cart {
- width: 40rpx;
- height: 40rpx;
- background-color: #FF4444;
- border-radius: 50%;
- display: flex;
- align-items: center;
- justify-content: center;
-
- .cart-icon {
- width: 24rpx;
- height: 24rpx;
- }
- }
- }
- }
- }
- </style>
|