myStars.vue
3.0 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
<template>
<view style="background-color: #f7f8faff;;">
<view style="display: flex; justify-content: center; margin: 12rpx;" class="">
<u-tabs :list="list1" @click="click"></u-tabs>
</view>
<view class="tips">
<view>
<image src="../../static/hand.png" style="width: 48rpx; height: 48rpx;" mode=""></image>
</view>
<p style=" color: #3375d8ff;font-size: 28rpx;font-weight: 400;">左滑取消收藏</p>
</view>
<view class="" style="padding: 24rpx;" v-if="list && list.length > 0">
<u-swipe-action v-for="item in list" >
<u-swipe-action-item
@click="(e) => cancelStar(e,item)"
:options="options1"
>
<view class="swipe-action " >
<view class="swipe-action__content " v-if="item.equip">
<item v-if="item.equip.type == 3 || item.equip.type == 4" :info="item.equip"></item>
<item-sell v-else :info="item.equip"></item-sell>
</view>
</view>
</u-swipe-action-item>
</u-swipe-action>
</view>
<view class="" v-else style="margin-top: 40%;">
</view>
</view>
</template>
<script>
import item from '@/component/listItem/listItem.vue'
import ItemSell from '@/component/sellItem/sellItem.vue'
export default {
components:{
item,ItemSell
},
data() {
return {
isSell:false,
options1: [{
text: '取消收藏'
}],
list:[],
type:3,
list1: [{
name: '设备出租',
}, {
name: '设备出售',
}, {
name: '设备求租'
}, {
name: '设备求购'
}]
}
},
methods: {
click(e){
console.log(e);
if(e.name == '设备出租'){
this.type = 3
this.isSell = false
}else if(e.name == '设备出售'){
this.type = 4
this.isSell = false
}else if(e.name == '设备求租'){
this.type = 1
this.isSell = true
}else{
this.type = 2
this.isSell = true
}
this.getList()
},
cancelStar(e,item){
console.log(item);
uni.$u.http.post('/api/common/favorite',{
equip_id: item.equip.id
}).then(res => {
console.log(res);
uni.showToast({
title:res.msg
})
this.getList()
}).catch(err => {
console.log(err);
})
},
getList(){
uni.$u.http.post('/api/user/my_favorite',{
page: 1,
pagenum: 10,
type: this.type
}).then(res => {
console.log(res);
this.list = res.data.data
}).catch(err => {
console.log(err);
})
}
},
onLoad() {
this.getList()
}
}
</script>
<style scoped lang="scss">
.tips{
height: 60rpx;
background: #e8effaff;
padding: 20rpx 0;
display: flex;
align-items: center;
justify-content: center;
}
.item{
margin: 24rpx;
}
/deep/.u-swipe-action{
margin-bottom: 24rpx
}
.u-page {
padding: 0;
}
.swipe-action {
&__content {
&__text {
font-size: 15px;
color: $u-main-color;
padding-left: 30rpx;
}
}
}
</style>