MyCollection.vue
3.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<template>
<div class="myCillection">
<van-nav-bar title="我的收藏" left-arrow :fixed="true" @click-left="onClickLeft" />
<van-list v-model="loading" :finished="Finished" finished-text="没有更多了" @load="onLoad">
<ul class="list">
<li v-for="(n, i) in list" :key="i">
<van-swipe-cell>
<div class="box">
<img :src="n.coverUrl ? n.coverUrl : require('@/assets/def.png')" alt="" />
<h3>{{ n.baseName }}</h3>
<div>
<van-icon name="location" />
{{ n.province + n.city + n.address }}
</div>
<p>{{ n.baseInfo }}</p>
</div>
<template #right>
<van-button square text="删除" type="danger" class="delete-button" @click="DeleteMyCollect(n.id)" />
</template>
</van-swipe-cell>
</li>
</ul>
<van-empty
class="custom-image"
image="https://img.yzcdn.cn/vant/custom-empty-image.png"
description="暂无收藏"
v-if="list.length == 0"
/>
</van-list>
</div>
</template>
<script>
export default {
data() {
return {
list: [],
page: 1,
loading: false,
Finished: false,
userInfo: '',
}
},
created() {
var userInfo = sessionStorage.getItem('userInfo')
if (userInfo) {
this.userInfo = JSON.parse(userInfo)
}
this.GetMycollectList(1)
},
methods: {
onClickLeft() {
history.back()
},
onLoad() {
var that = this
setTimeout(() => {
that.page++
that.GetMycollectList(that.page)
}, 1000)
},
GetMycollectList(page) {
var that = this
this.http
.GetMycollectList({
pageIndex: page,
pageSize: 6,
userId: this.userInfo ? this.userInfo.centerNo : 0,
cs: this.projectCity,
})
.then(function(res) {
if (res.status == 1) {
if (res.data.items.length > 0) {
that.list = that.list.concat(res.data.items)
}
that.loading = false
if (res.data.items.length < 10) {
that.Finished = true
}
}
})
},
DeleteMyCollect(id) {
var that = this
this.$dialog
.confirm({
title: '提示',
message: '是否删除该基地?',
})
.then(() => {
this.$toast.loading({
message: '请求中...',
})
this.DeleteMyCollect({
id: id,
}).then(function(res) {
that.$toast.clear()
if (res.status == 1) {
that.$toast.success('删除成功')
that.GetMycollectList()
}
})
})
.catch(() => {
// on cancel
})
},
},
}
</script>
<style lang="stylus" scoped>
.myCillection{
position fixed
top 0
left 0
right 0
bottom 0
background-color #F7F7F7
}
.list{
margin-top 100px
li{
padding 40px
box-sizing border-box
.box{
background-color white
position relative
box-sizing border-box
padding 20px 20px 20px 240px
min-height 220px
border-radius 10px
img{
position absolute
left 40px
top 20px
width 180px
height 180px
border-radius px
}
h3{
word-break: break-all;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 1;
overflow: hidden;
font-size 1.6rem
margin 0px
}
p{
color #BE9A80
font-size 1.4rem
margin 0
}
div{
padding-left 40px
position relative
box-sizing border-box
color #B4B4B4
font-size 1.2rem
margin 10px 0
i{
position absolute
left 0
top 0
font-size 1.4rem
}
}
}
}
}
.delete-button {
height: 100%;
}
</style>