<!--
 * @Author: euzhi
 * @Description: 我的挪车码
-->
<template>
<view class="appCotent">
<div class="myMoveCar">
    <div class="my__search">
        <u-search placeholder="请输入车牌号" :showAction='false' bgColor='#ffffff' v-model="keyword"></u-search>
    </div>
    <div class="my__list">
        <div class="list__item" v-for="(vo,inx) in items" :key="inx">
            <div class="item__top">
                <div class="top__img">
                    <image src="@/static/move-car/my-move-car4.png" />
                </div>
                <div class="top__car__phone">
                    <div>
                        {{vo.carNo}}
                    </div>
                    <div>
                        {{vo.userMobile}}
                    </div>
                </div>
                <div class="top__car__name">
                    {{vo.brand}}
                </div>
            </div>
            <div class="item__bottom">
                <span @click="openUnbindModal(vo.id)">解除绑定</span>
                <span @click="goView(vo.id)">查看详情</span>
            </div>
			<div>
				<u-modal :show="unbindShow" :title="unbindTitle" :content='unbindContent'
					@confirm="unbind" @cancel="cancelModal" showCancelButton="true"></u-modal>
			</div>
        </div>
    </div>
</div>
</view>
</template>

<script>
export default {
    data() {
        return {
            keyword: '',
			//挪车码列表
            items: [],
			//解除绑定对话框
			unbindShow: false,
			//解除绑定对话框标题
			unbindTitle: '解除绑定',
			//解除绑定对话框内容
			unbindContent: '确定解除绑定吗？',
			//解除绑定的挪车牌
			id: '',
        };
    },
    methods: {
        goView(id){
            uni.navigateTo({
                url: '/pagesB/pages/move-car/moveCarDetail?id=' + id
            })
        },
		getMyMoveCodeList(){
			let opts = { url: '/app/moveCode/list', method: 'get' };
			this.http.httpTokenRequest(opts, {}).then(res => {
				if (res.data.code == 200) {
					this.items = res.data.rows
				}
			})
		},
		openUnbindModal(id){
			this.id = id
			this.unbindShow = true
		},
		unbind(){
			let opts = { url: '/app/moveCode/edit/' + this.id, method: 'put' };
			this.http.httpTokenRequest(opts, {}).then(res => {
				if (res.data.code == 200) {
					uni.showToast({
						title: '解绑成功',
						icon: "success",
					});
					this.getMyMoveCodeList()
				}
			})
			this.unbindShow = false
		},
		cancelModal(){
			this.unbindShow = false
		},
    },
	created() {
		this.getMyMoveCodeList()
	}
	
}
</script>

<style lang="scss" scoped>
.myMoveCar {
    padding: 40rpx 30rpx;

    .my__list {
        margin-top: 30rpx;

        .list__item {
            position: relative;
            margin-bottom: 20rpx;
            padding: 30rpx;
            background: #FFFFFF;
            box-shadow: 0rpx 0rpx 28rpx 1rpx rgba(232, 232, 232, 0.2);
            border-radius: 20rpx;

            .item__top {
                display: flex;
                justify-content: space-between;
                margin-bottom: 44rpx;
                align-items: center;
                .top__img {
                    width: 100rpx;
                    height: 100rpx;

                    image {
                        width: 100%;
                        height: 100%;
                    }
                }

                .top__car__phone {
                    width: 60%;

                    .top__car {
                        font-size: 36rpx;
                        font-family: PingFang SC;
                        font-weight: bold;
                        color: #333333;
                    }

                    .top__phone {
                        font-size: 30rpx;
                        font-family: DIN;
                        font-weight: 500;
                        color: #666666;
                    }
                }

                .top__car__name {
                    font-size: 28rpx;
                    font-family: PingFang SC;
                    font-weight: 500;
                    color: #666666;
                }
            }

            .item__bottom {
                display: flex;
                justify-content: flex-end;
                span {
                    display: inline-block;
                    width: 180rpx;
                    height: 56rpx;
                    text-align: center;
                    line-height: 56rpx;
                }

                span:nth-of-type(1) {
                    font-size: 30rpx;
                    font-family: PingFang SC;
                    font-weight: 500;
                    color: #999999;
                    background: url(@/static/move-car/my-move-car3.png) no-repeat;
                    background-size: contain;
                    margin-right: 20rpx;
                }

                span:nth-of-type(2) {
                    font-size: 30rpx;
                    font-family: PingFang SC;
                    font-weight: 500;
                    color: #F1251B;
                    background: url(@/static/move-car/my-move-car2.png) no-repeat;
                    background-size: contain;
                }
            }
        }
    }
}
</style>
