添加商品列表分页功能
This commit is contained in:
@@ -10,4 +10,4 @@ VUE_APP_BASE_API = 'https://admintestpapi.sxczgkj.cn'
|
|||||||
# 如果接口是 http 形式, wss 需要改为 ws
|
# 如果接口是 http 形式, wss 需要改为 ws
|
||||||
VUE_APP_WS_API = 'wss://123.56.110.252'
|
VUE_APP_WS_API = 'wss://123.56.110.252'
|
||||||
|
|
||||||
VUE_APP_PHP_API = 'https://kysh.sxczgkj.cn'
|
VUE_APP_PHP_API = 'https://kysh.sxczgkj.cn/source'
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import Cookies from 'js-cookie'
|
|||||||
|
|
||||||
// 创建axios实例
|
// 创建axios实例
|
||||||
const service = axios.create({
|
const service = axios.create({
|
||||||
baseURL: process.env.NODE_ENV === 'production' ? process.env.VUE_APP_PHP_API : '/source',
|
baseURL: process.env.NODE_ENV === 'production' ? process.env.VUE_APP_PHP_API: '/source',
|
||||||
// baseURL: process.env.VUE_APP_PHP_API, // api 的 base_url
|
// baseURL: process.env.VUE_APP_PHP_API, // api 的 base_url
|
||||||
timeout: Config.timeout // 请求超时时间
|
timeout: Config.timeout // 请求超时时间
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -10,7 +10,8 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
<el-button type="primary" @click="dialogTableVisibles = true">新增类型</el-button>
|
<el-button type="primary" @click="dialogTableVisibles = true">新增类型</el-button>
|
||||||
<el-button type="primary" @click="showUpload = true">新增图片</el-button>
|
<el-button type="primary" @click="showUpload = true">新增图片</el-button>
|
||||||
<imageComponent @onSelectImage="onSelectImage" @getList="getList" :list='dataImages'></imageComponent>
|
<imageComponent @onSelectImage="onSelectImage" @getList="getList" @getlists="getlists" :list='dataImages'>
|
||||||
|
</imageComponent>
|
||||||
<span slot="footer" class="dialog-footer">
|
<span slot="footer" class="dialog-footer">
|
||||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||||
<el-button type="primary" @click="sumbit">确 定</el-button>
|
<el-button type="primary" @click="sumbit">确 定</el-button>
|
||||||
@@ -67,7 +68,7 @@ export default {
|
|||||||
value: '',
|
value: '',
|
||||||
typedata: '',
|
typedata: '',
|
||||||
showUpload: false,
|
showUpload: false,
|
||||||
|
page: 1,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@@ -137,6 +138,10 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
getlists() {
|
||||||
|
this.page++
|
||||||
|
this.getList()
|
||||||
|
},
|
||||||
sumbit() {
|
sumbit() {
|
||||||
this.dialogVisible = false
|
this.dialogVisible = false
|
||||||
this.$emit('successEvent', this.selectImage)
|
this.$emit('successEvent', this.selectImage)
|
||||||
@@ -147,13 +152,17 @@ export default {
|
|||||||
async getList() {
|
async getList() {
|
||||||
let obj = {
|
let obj = {
|
||||||
category: this.value,
|
category: this.value,
|
||||||
page: 1,
|
page: this.page,
|
||||||
size: 10,
|
size: 20,
|
||||||
store_id: localStorage.getItem("shopId"),
|
store_id: localStorage.getItem("shopId"),
|
||||||
|
|
||||||
}
|
}
|
||||||
const res = await getcommonpicture(obj);
|
const res = await getcommonpicture(obj);
|
||||||
this.dataImages = res.data
|
if (this.page == 1) {
|
||||||
|
this.dataImages = res.data
|
||||||
|
} else {
|
||||||
|
this.dataImages.push(...res.data)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
async getType(valueIndex) {
|
async getType(valueIndex) {
|
||||||
const res = await getcommonCategor({
|
const res = await getcommonCategor({
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<ul class="ulStyle">
|
<ul class="ulStyle" v-infinite-scroll="load">
|
||||||
<li v-for="item in list" :key="item.id" class="listyle" :class="[selectList.id == item.id ? 'active' : '']"
|
<li v-for="item in list" :key="item.id" class="listyle" :class="[selectList.id == item.id ? 'active' : '']"
|
||||||
@click="clickEvent(item)">
|
@click="clickEvent(item)">
|
||||||
<img :src="item.url" style="width: 100px;height: 100px;" alt="">
|
<img :src="item.url" style="width: 100px;height: 100px;" alt="">
|
||||||
@@ -20,7 +20,14 @@ export default {
|
|||||||
return {
|
return {
|
||||||
selectList: [],
|
selectList: [],
|
||||||
}
|
}
|
||||||
}, methods: {
|
},
|
||||||
|
mounted() {
|
||||||
|
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
load() {
|
||||||
|
this.$emit('getlists')
|
||||||
|
},
|
||||||
clickEvent(d) {
|
clickEvent(d) {
|
||||||
this.selectList = d
|
this.selectList = d
|
||||||
this.$emit('onSelectImage', d)
|
this.$emit('onSelectImage', d)
|
||||||
@@ -48,6 +55,8 @@ li {
|
|||||||
.ulStyle {
|
.ulStyle {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
overflow: auto;
|
||||||
|
height: 400px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.listyle {
|
.listyle {
|
||||||
|
|||||||
Reference in New Issue
Block a user