Browse Source

[添加] 商品详情页,我的收藏页面添加骨架屏

master
邓平艺 4 years ago
parent
commit
f0846a003e
  1. 8
      pages/collect/index.vue
  2. 11
      pages/goodsDetail/index.vue

8
pages/collect/index.vue

@ -1,5 +1,6 @@
<template> <template>
<view> <view>
<skeleton :loading="skeletonLoading" :row="6" :showAvatar="false" :showTitle="true">
<view class="list-box"> <view class="list-box">
<view class="lf-row-between list-item" v-for="(item, index) in list" :key="item.id"> <view class="lf-row-between list-item" v-for="(item, index) in list" :key="item.id">
<image class="goods-img" :src="item.goods.cover" @click="enterDetail(index)"></image> <image class="goods-img" :src="item.goods.cover" @click="enterDetail(index)"></image>
@ -25,6 +26,7 @@
<text v-if="list.length" :class="{'loading-more-text': loadingClass}">{{ loadingText }}</text> <text v-if="list.length" :class="{'loading-more-text': loadingClass}">{{ loadingText }}</text>
<my-nocontent v-else></my-nocontent> <my-nocontent v-else></my-nocontent>
</view> </view>
</skeleton>
</view> </view>
</template> </template>
@ -37,7 +39,8 @@
loadingText: '正在加载中', loadingText: '正在加载中',
page: 1, page: 1,
isPage: true, isPage: true,
pageSize: 20
pageSize: 20,
skeletonLoading: true
} }
}, },
onLoad(){ onLoad(){
@ -46,6 +49,7 @@
methods: { methods: {
getCollectList(){ getCollectList(){
this.$http(this.API.API_COLLECT_LIST).then(res => { this.$http(this.API.API_COLLECT_LIST).then(res => {
this.skeletonLoading = false;
this.isPage = res.data.has_more_page; this.isPage = res.data.has_more_page;
let list = res.data.items.map(item => { let list = res.data.items.map(item => {
item.is_collect = true; // item.is_collect = true; //
@ -60,6 +64,8 @@
}else{ }else{
this.list.push(...list); this.list.push(...list);
} }
}).catch(err => {
this.skeletonLoading = false;
}) })
}, },
// //

11
pages/goodsDetail/index.vue

@ -1,5 +1,6 @@
<template> <template>
<view> <view>
<skeleton :loading="skeletonLoading" :row="12" :showAvatar="false" :showTitle="true">
<block v-if="isRight(goods_detail)"> <block v-if="isRight(goods_detail)">
<!-- 商品图片轮播 --> <!-- 商品图片轮播 -->
<swiper :current="current" :indicator-dots="true" :circular="true" class="swiper-box" indicator-active-color="#FE9903"> <swiper :current="current" :indicator-dots="true" :circular="true" class="swiper-box" indicator-active-color="#FE9903">
@ -81,19 +82,19 @@
<button class="btn" @click="toAddOrder">立即抢购</button> <button class="btn" @click="toAddOrder">立即抢购</button>
</view> </view>
</block> </block>
</skeleton>
</view> </view>
</template> </template>
<script> <script>
let time = null;
export default { export default {
data(){ data(){
return { return {
current: 0, // current: 0, //
goods_id: 0, goods_id: 0,
goods_detail: {}, goods_detail: {},
is_collect: 0 // 10
is_collect: 0, // 10
skeletonLoading: true
} }
}, },
computed: { computed: {
@ -112,11 +113,13 @@
let that = this; let that = this;
this.$http(this.API.API_GOODS_DETAIL, {goods_id: this.goods_id}).then(res => { this.$http(this.API.API_GOODS_DETAIL, {goods_id: this.goods_id}).then(res => {
console.log("res", res); console.log("res", res);
this.skeletonLoading = false;
this.goods_detail = res.data; this.goods_detail = res.data;
this.is_collect = Boolean(res.data.user.is_collect); this.is_collect = Boolean(res.data.user.is_collect);
}).catch(err => { }).catch(err => {
this.skeletonLoading = false;
that.$msg(err.msg); that.$msg(err.msg);
time = setTimeout(() => {
setTimeout(() => {
that.$toBack(); that.$toBack();
}, 1000); }, 1000);
}) })

Loading…
Cancel
Save