myStars.vue 3.0 KB
<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>