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

修复list重复两次请求bug

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