提交 684f35e4 authored 作者: pengxiaohui's avatar pengxiaohui

修复list重复两次请求bug

上级 262828af
......@@ -9,7 +9,7 @@
<p class="surplus">剩余 {{surplus}}</p>
</div>
</div>
<van-field label="规格" class="tag-item">
<van-field :label="spec_title" class="tag-item">
<template #input>
<tag-selection v-model="spec" :data="specList" :options="{ label: 'spec_values', value: 'sku_id'}" @currentSelected="handleTagSelected"/>
</template>
......@@ -60,6 +60,7 @@ export default {
thumb: '',
price: '',
surplus: 0,
spec_title: '规格',
spec: '',
specList: [],
form: {
......@@ -202,6 +203,7 @@ export default {
getGoodsSpecs(params).then(res => {
this.specList = res.data
const [first = {}] = res.data
this.spec_title = first.spec_names
this.spec = first.sku_id
this.price = first.price
this.surplus = first.stock
......
......@@ -225,6 +225,9 @@ export default {
}
</script>
<style scoped lang="scss">
.buy-container{
padding-bottom:1.04rem;
}
.van-swipe-item{
.van-icon{
position:absolute !important;
......@@ -332,7 +335,7 @@ export default {
}
.bottom-bar{
position:fixed;
bottom:0;
bottom:-1px;
width:100%;
box-sizing:border-box;
padding:0.2rem 0.8rem;
......
......@@ -43,29 +43,16 @@
<p class="title van-ellipsis">{{item.spu_name}}</p>
</div>
</div>
<template slot="finished">{{goodsList.length > 0 ? '没有更多了': ''}}</template>
</van-list>
</van-pull-refresh>
<ul class="goods-list" v-if="false">
<li class="goods-item" v-for="item in goodsList" :key="item.id" @click="handleClick(item)">
<div class="thumb">
<img :src="imgJsonParse(item.chart_oss)">
</div>
<div class="content">
<div class="top">
<div class="price"><span>{{item.price_zone}}</span></div>
<div class="right-tag">{{item.sales_volume}}人付款</div>
</div>
<p class="title van-ellipsis">{{item.spu_name}}</p>
</div>
</li>
</ul>
<van-empty description="暂无商品" v-if="goodsList.length === 0"/>
<van-empty description="暂无商品" v-if="goodsList.length === 0 && finished"/>
</div>
</template>
<script>
import AppSearchBar from '@/components/AppSearchBar.vue'
import { getGoodsList } from '@/api/common.js'
// import _ from 'lodash'
import _ from 'lodash'
export default {
name: 'Index',
components: { AppSearchBar },
......@@ -76,7 +63,7 @@ export default {
loading: false,
finished: false,
refreshing: false,
page_size: '10',
page_size: '5',
page: '0',
total: 0
}
......@@ -105,19 +92,18 @@ export default {
}
},
initParams() {
console.log(this.loading)
this.goodsList = []
this.loading = false
this.loading = true
this.finished = false
// this.refreshing = false
this.page_size = '10'
this.page_size = '5'
this.page = '0'
this.total = 0
},
initFetchList() {
initFetchList: _.debounce(function() {
this.initParams()
this.fetchGoodsList()
},
}, 200),
onRefresh() {
this.initParams()
this.finished = true // 防止下拉刷新时触发上拉加载
......@@ -138,19 +124,18 @@ export default {
this.finished = false
this.refreshing = false;
}
if (res.code === 0 && res.msg === '成功') {
console.log(this.goodsList)
console.log(res.data)
if (res.code === 0 && Array.isArray(res.data)) {
this.goodsList = this.goodsList.concat(res.data)
} else {
this.goodsList = []
}
this.total = parseInt(res.page_info.total_number)
if (((parseInt(this.page) + 1) * parseInt(this.page_size)) > this.total) {
if (((parseInt(this.page) + 1) * parseInt(this.page_size)) >= this.total) {
this.finished = true
} else {
this.page = parseInt(this.page) + 1 + ''
}
} else {
this.goodsList = []
this.finished = true
}
this.loading = false
})
}
......
......@@ -92,6 +92,7 @@ import { getOrderList, createOrder } from '@/api/common'
import { getOpenId } from '@/api/account.js'
import { mapGetters } from 'vuex'
import { Toast } from 'vant'
import _ from 'lodash'
const statusMap = {
1: '等待买家付款',
2: '等待卖家发货',
......@@ -192,17 +193,17 @@ export default {
},
initParams() {
this.list = []
this.loading = false
this.loading = true
this.finished = false
// this.refreshing = false
this.page_size = '10'
this.page = '0'
this.total = 0
},
initFetchList() {
initFetchList: _.throttle(function() {
this.initParams()
this.fetchOrderList()
},
}, 200),
onRefresh() {
this.initParams()
this.finished = true // 防止下拉刷新时触发上拉加载
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论