| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- <template>
- <view class="content">
- <empty v-if="loaded && goodList.length == 0"></empty>
- <view class="good flex" v-for="item in goodList" @click="navTo('/pages/product/product?id=' + item.id)">
- <view class="good-img">
- <image :src="item.image" mode=""></image>
- </view>
- <view class="good-info flex">
- <view class="good-name clamp2">
- {{item.store_name}}
- </view>
- <view class="good-price">
- <view class="old-price" v-if="item.ot_price*1 > item.price*1">
- <text class="old-left">¥{{item.ot_price}}</text>
- <image src="../../static/icon/down.png" mode="widthFix"></image>
- <text class="old-right">直降{{item.ot_price*1 - item.price*1}}元</text>
- </view>
- <view class="new-price flex">
- <view class="">
- ¥{{item.price}}
- </view>
- <view class="good-tip">
- 立即购买
- </view>
- </view>
- </view>
- </view>
- </view>
- <uni-load-more :status="loadingType" v-if="!(loaded && goodList.length == 0)"></uni-load-more>
- </view>
- </template>
- <script>
- import {getProducts } from '@/api/product.js'
- export default {
- data() {
- return {
- goodList: [],
- page: 1,
- limit: 10,
- loadingType: 'more',
- loaded:false
- }
- },
- onLoad() {
- this.getGoodList()
- },
- onShow() {
- },
- onReachBottom() {
- this.getGoodList()
- },
- onReady() {
- },
- methods: {
- navTo(url) {
- if (url.indexOf('http') != -1) {
- window.location.href = url
- } else {
- uni.navigateTo({
- url,
- fail() {
- uni.switchTab({
- url
- })
- }
- })
- }
- },
- getGoodList() {
- let obj = this
- if (obj.loadingType == 'loading' || obj.loadingType == 'noMore') {
- return
- }
- obj.loadingType = 'loading'
- getProducts({
- page: obj.page,
- limit: obj.limit
- }).then(res => {
- obj.goodList = obj.goodList.concat(res.data)
- obj.page++
- if (obj.limit == res.data.length) {
- obj.loadingType = 'more'
- } else {
- obj.loadingType = 'noMore'
- }
- obj.loaded = true
- })
- },
- }
- }
- </script>
- <style lang="scss">
- .content {
- padding-top: 20rpx;
- }
- .good {
- width: 690rpx;
- height: 276rpx;
- background: #FFFFFF;
- box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
- border-radius: 10rpx;
- margin: auto;
- padding: 20rpx 15rpx;
- margin-bottom: 20rpx;
- &:last-of-type {
- margin-bottom: 0rpx;
- }
-
- .good-img {
- flex-shrink: 0;
- width: 236rpx;
- height: 236rpx;
- border-radius: 10rpx;
- margin-right: 22rpx;
-
- image {
- width: 236rpx;
- height: 236rpx;
- border-radius: 10rpx;
- }
- }
-
- .good-info {
- flex-grow: 1;
- height: 100%;
- flex-direction: column;
- justify-content: space-between;
- align-items: flex-start;
-
- .good-name {
- font-size: 32rpx;
- font-weight: bold;
- padding-top: 10rpx;
- color: #333333;
- }
-
- .good-price {
- width: 100%;
-
- image {
- width: 14rpx;
- margin: 0 6rpx 0 10rpx;
- }
-
- .old-price {
- .old-left {
- font-size: 26rpx;
- font-weight: 500;
- text-decoration: line-through;
- color: #999999;
- }
-
- .old-right {
- font-size: 24rpx;
- font-weight: bold;
- color: #B59467;
- }
- }
-
- .new-price {
- width: 100%;
- font-size: 36rpx;
- font-weight: bold;
- color: #FF4C4C;
- justify-content: space-between;
-
- .good-tip {
- width: 137rpx;
- height: 52rpx;
- background: $base-color;
- border-radius: 26rpx;
- position: relative;
- font-size: 26rpx;
- font-weight: 500;
- color: #FFFFFF;
- line-height: 52rpx;
- text-align: center;
- }
- }
- }
- }
- }
- </style>
|