<!--
 * @Author: euzhi
 * @Description: 我的挪车码
-->
<template>
<view class="appCotent">
<div class="myMoveCar">
    <div class="my__search">
        <u-search placeholder="请输入车牌号" :showAction='false' bgColor='#ffffff' v-model="keyword" @change="getMyMoveCodeList"></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 class="top__car">
                        {{vo.carNo}}
                    </div>
                    <div class="top__phone">
                        {{vo.userMobile}}
                    </div>
                </div>
                <div class="top__car__name">
                    {{vo.brand?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 {
            option: {
              size: 10,
              auto: true
            },
            keyword: '',
			      //挪车码列表
            items: [],
            //解除绑定对话框
            unbindShow: false,
            //解除绑定对话框标题
            unbindTitle: '解除绑定',
            //解除绑定对话框内容
            unbindContent: '确定解除绑定吗？',
            //解除绑定的挪车牌
            id: '',
        };
    },
    onShow() {
      this.getMyMoveCodeList()
    },
    methods: {
      // 加载数据
      // load(paging) {
      //   setTimeout(() => {
      //     let list = [];
      //     let opts = { url: '/app/moveCode/list?pageSize='+paging.size+'&pageNum='+paging.page, method: 'get' };
      //     this.http.httpTokenRequest(opts, {}).then(res => {
      //       if (res.data.code == 200) {
      //         list = res.data.rows
      //         this.items = [...this.items, ...list]
      //         // 加载成功  参数对象{list: 当前列表,total: 数据总长度(后端查询的total)}
      //         this.$refs.list.loadSuccess({
      //           list: this.items,
      //           total: res.data.total
      //         });
      //         // 加载失败
      //         // this.$refs.list.loadFail()
      //       }
      //     })
      //   }, this.$u.random(100, 1000));
      // },
        goView(id){
            uni.navigateTo({
                url: '/pagesB/pages/move-car/moveCarDetail?id=' + id
            })
        },
		getMyMoveCodeList(){
			this.$http.request({
				url:'/app/moveCode/list?carNo=' + this.keyword,
				method:'get',
				data:{},
				isFactory:false,
			}).then(res => {
				if (res.data.code == 200) {
					this.items = res.data.rows || []
				} else {
					uni.showToast({
						title: res.data.msg,
						icon: "none",
					});
				}
			})
		},
		openUnbindModal(id){
			this.id = id
			this.unbindShow = true
		},
		unbind(){
			this.$http.request({
				url:'/app/moveCode/edit/' + this.id,
				method:'put',
				data:{},
				isFactory:false,
			}).then(res => {
				if (res.data.code == 200) {
					uni.showToast({
						title: '解绑成功',
						icon: "success",
					});
					this.getMyMoveCodeList()
				}else {
					uni.showToast({
						title: res.data.msg,
						icon: "none",
					});
				}
			})
			this.unbindShow = false
		},
		cancelModal(){
			this.unbindShow = false
		},
		searchMoveCode(){
			
		}
    },
}
</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;
                margin-bottom: 44rpx;
                align-items: center;

                .top__img {
                    width: 100rpx;
                    height: 100rpx;
					margin-right:30rpx;

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

                .top__car__phone {
                    width: 340rpx;
                    .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;
                    padding-bottom: 50rpx;
                }
            }

            .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: #1C8CE8;
					box-sizing: border-box;
					line-height: 50rpx;
                    // background: url(@/static/move-car/my-move-car2.png) no-repeat;
                    // background-size: contain;
					border: 2rpx solid #1C8CE8;
					border-radius: 28rpx;
                }
            }
        }
    }
}
</style>
