修改
This commit is contained in:
@@ -0,0 +1,184 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<!-- 列表 -->
|
||||
<z-paging ref="paging" v-model="list" @query="queryList" empty-view-text="暂无发布信息!">
|
||||
<uni-nav-bar
|
||||
leftText=" "
|
||||
leftIcon="back"
|
||||
@clickLeft="goBack"
|
||||
:fixed="true"
|
||||
:border="false"
|
||||
color="#000000"
|
||||
backgroundColor="#fff"
|
||||
:statusBar="true"
|
||||
title="我的发布"
|
||||
></uni-nav-bar>
|
||||
|
||||
<!-- 顶部:搜索 -->
|
||||
<view class="page-head">
|
||||
<view class="head-search">
|
||||
<u-search
|
||||
v-model="keyword"
|
||||
placeholder="请输入关键词"
|
||||
:show-action="false"
|
||||
shape="round"
|
||||
@change="onKeywordChange"
|
||||
@search="onSearch"
|
||||
@clear="onSearch"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="list-wrap">
|
||||
<uni-swipe-action-item
|
||||
v-for="item in list"
|
||||
:key="item.id"
|
||||
:right-options="options1"
|
||||
@click="swipeClick($event, item)"
|
||||
>
|
||||
<CarCard
|
||||
:item="item"
|
||||
/>
|
||||
</uni-swipe-action-item>
|
||||
</view>
|
||||
</z-paging>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { request } from '@/api/apiT.js'
|
||||
import CarCard from '@/components/CarCard/CarCard.vue'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
CarCard
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
options1: [{
|
||||
text: '编辑',
|
||||
style: {
|
||||
backgroundColor: '#007aff'
|
||||
}
|
||||
},
|
||||
{
|
||||
text: '删除',
|
||||
style: {
|
||||
backgroundColor: '#F56C6C'
|
||||
}
|
||||
}],
|
||||
keyword: '',
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
loading: false,
|
||||
finished: false,
|
||||
list: []
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
},
|
||||
methods: {
|
||||
onKeywordChange(val) {
|
||||
// val 是输入值(uView 通常会传)
|
||||
this.keyword = val
|
||||
|
||||
// 防抖:300ms 内持续输入只触发一次
|
||||
if (this._kwTimer) clearTimeout(this._kwTimer)
|
||||
this._kwTimer = setTimeout(() => {
|
||||
this.onSearch()
|
||||
}, 300)
|
||||
},
|
||||
onSearch() {
|
||||
this.queryList(this.page, this.pageSize)
|
||||
},
|
||||
queryList(pageNo, pageSize, from) {
|
||||
this.loading = true;
|
||||
var that = this;
|
||||
const params = {
|
||||
current: pageNo,
|
||||
status: 1,
|
||||
size: 10,
|
||||
scene: 'self' // 只获取自己的发布
|
||||
};
|
||||
params.keyword = this.keyword;
|
||||
request({
|
||||
url: 'common/usedcar/list',
|
||||
method: 'get',
|
||||
data: params
|
||||
}).then(res => {
|
||||
if (res.data.code == 200) {
|
||||
var datas = res.data.data.records;
|
||||
this.$refs.paging.complete(datas);
|
||||
} else {
|
||||
}
|
||||
uni.stopPullDownRefresh();
|
||||
})
|
||||
},
|
||||
goBack() {
|
||||
uni.navigateBack()
|
||||
},
|
||||
swipeClick(e, item) {
|
||||
let {
|
||||
content
|
||||
} = e;
|
||||
if (content.text === '删除') {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '是否删除',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
request({
|
||||
url: 'common/usedcar/destroy',
|
||||
method: 'post',
|
||||
data: { id: item.id }
|
||||
}).then(res => {
|
||||
uni.showToast({
|
||||
title: res.data.message,
|
||||
icon: 'none'
|
||||
});
|
||||
this.queryList()
|
||||
})
|
||||
} else if (res.cancel) {
|
||||
console.log('用户点击取消');
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
const id = item.id
|
||||
uni.navigateTo({
|
||||
url: `/pages/index/publishedit?id=${id}`
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.page {
|
||||
min-height: 100vh;
|
||||
background: #f4f6f8;
|
||||
}
|
||||
|
||||
.page-head {
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
bottom: 0px;
|
||||
z-index: 99;
|
||||
}
|
||||
|
||||
.head-search {
|
||||
background: rgba(255, 255, 255, 1);
|
||||
border-radius: 18rpx;
|
||||
padding: 20rpx 10px;
|
||||
box-shadow: 0 10rpx 28rpx rgba(0, 0, 0, 0.06);
|
||||
}
|
||||
|
||||
.list-wrap {
|
||||
padding: 18rpx 24rpx 40rpx;
|
||||
}
|
||||
|
||||
.loadmore {
|
||||
padding: 18rpx 0 6rpx;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user