<template>
	<view class="center">
		<view v-for="(item,index) in applyList" class="flex fleet" @click="fleetInfo(item)">
			<view class="fleet_img">
				<u--image class="flex-end" :showLoading="true" :src="item.coverUrl" width="60px" height="60px" shape='circle'>
			</u--image>
			</view>
			<view class="fleet_right">
				<view class="flex">
					<view class="fleet_name">
						{{item.fleetName}}
					</view>
					<view class="fleet_invite" v-if="item.status == '已申请'" @click="refuse(item)">拒绝</view>
					<view class="fleet_invite" v-if="item.status == '已申请'" @click="accept(item)">接受</view>
					<view class="fleet_invite" v-else>{{item.status}}</view>
					
				</view>
			</view>	
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				commonId:"",
				applyList:[]
			}
		},
		onShow(){
			
		},
		onLoad(){
			this.commonId = uni.getStorageSync("firstAuthentication").commonId
			this.getList()
		},
		methods:{
			refuse(item){
				this.$request.baseRequest('post', '/fleetMemberInfo/api/editFleetMemberInfo', {
						examineFlag:2,
						id:item.id
					}).then(res => {
						if (res.code == 200) {
							this.$refs.uToast.show({
								type: 'success',
								message: "拒绝成功！",
								complete() {
									uni.$u.route("pages/riders/myTeam")
								}
							})
						}
					})
					.catch(res => {
						uni.$u.toast(res.message);
					});
			},
			accept(item){
				this.$request.baseRequest('post', '/fleetMemberInfo/api/editFleetMemberInfo', {
						examineFlag:1,
						id:item.id
					}).then(res => {
						if (res.code == 200) {
						this.$refs.uToast.show({
							type: 'success',
							message: "通过成功！",
							complete() {
								uni.$u.route("pages/riders/myTeam")
							}
						})
						}
					})
					.catch(res => {
						uni.$u.toast(res.message);
					});
			},
			getList(){
				this.$request.baseRequest('get', '/fleetMemberInfo/selectFleetMemberInfo', {
						commonId:this.commonId,
						flag:2,
						pageSize: 10,
						currentPage: 1
					}).then(res => {
						if (res.code == 200) {
							this.applyList = res.data.records
						}
					})
					.catch(res => {
						uni.$u.toast(res.message);
					});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.center{
		padding: 30rpx;
	}
	.fleet{
		margin: 30rpx 0;
		.fleet_img{
			width: 20%;
		}
		.fleet_right{
			margin-top: 20rpx;
			width: 80%;
			.fleet_name{
				width: 70%;
			}
			.fleet_invite{
				background-color: #5878e8;
				color: #fff;
				margin-left: 10rpx;
			}
		}
	}
</style>
