This commit is contained in:
yanran200730
2022-07-02 16:17:55 +08:00
parent 54f0d57b37
commit 58022d5154
7 changed files with 230 additions and 123 deletions

View File

@@ -4,7 +4,16 @@
<u-search placeholder="请输入姓名、手机号、店面" :show-action="false" v-model="keyword" confirm-type="search" @search="current = 1, getList()"/>
</AiTopFixed>
<div class="list">
<div class="item" v-for="item in list" :key="item.id" @click="linkTo('./detail?id=' + item.id)">
<u-swipe-action
class="item"
:show="item.show"
:index="index"
v-for="(item, index) in list"
:key="item.id"
@click="onClick"
@open="onOpen"
@content-click="toDetail(item.id, index)"
:options="options">
<div class="title">
<img :src="$cdn + 'xincheng/icon.png'" alt="">
<p>{{ item.businessName }}</p>
@@ -22,7 +31,7 @@
<img :src="$cdn + 'xincheng/wgz@2x.png'" alt="">
<div>李毅-网格长</div>
</div>
</div>
</u-swipe-action>
<AiEmpty v-if="!list.length"></AiEmpty>
</div>
<div class="btn" @click="linkTo('./add')">新增商户</div>
@@ -40,7 +49,21 @@
keyword: '',
current: 1,
pages: 2,
list: []
list: [],
options: [
{
text: '编辑',
style: {
backgroundColor: '#007aff'
}
},
{
text: '删除',
style: {
backgroundColor: '#dd524d'
}
}
]
}
},
@@ -56,7 +79,7 @@
},
methods: {
getList() {
getList () {
if (this.current > this.pages && this.current !== 1) return
this.$http.post('/app/appcompany/list', null, {
@@ -67,12 +90,54 @@
}
}).then((res) => {
if (res.code == 0) {
this.list = this.current > 1 ? [...this.list, ...res.data.records] : res.data.records
this.list = this.current > 1 ? [...this.list, ...res.data.records.map(v => {
return {
...v,
show: false
}
})] : res.data.records.map(v => {
return {
...v,
show: false
}
})
this.pages = res.data.pages
}
})
},
toDetail (id, index) {
this.list[index].show = false
this.linkTo('./detail?id=' + id)
},
onClick (index, i) {
if (i == 1) {
this.$confirm('确定删除该数据?').then(() => {
this.$http.post('/app/appcompany/delete?id=' + this.list[index].id).then(res => {
if (res.code === 0) {
this.current = 1
this.getList()
}
})
}).catch(() => {
})
} else {
this.list[index].show = false
this.linkTo('./add?id=' + this.list[index].id)
}
},
onOpen (index) {
this.list[index].show = true
this.list.map((val, idx) => {
if(index != idx) {
this.list[idx].show = false
}
})
},
linkTo (url) {
uni.navigateTo({
url