<!--
 * @Author: euzhi
 * @Description: 我的呼叫记录
-->
<template>
<view class="appCotent">
<div class="myRecord">
  <scroll-list ref="list" :option="option" @load="load" @refresh="refresh">
    <div class="record__item" v-for="(vo,inx) in items" :key="inx">
        <div class="item__top">
            <div class="top__time">
                时间:{{vo.applyDate}}
            </div>
            <div class="top__state" :class="vo.state==='微信'?'':'phone__state'">
                {{vo.confirmType=="1"?'电话':'微信'}}
            </div>
        </div>
        <div class="item__content">
            <div>
                车牌号:{{vo.carNo}}
            </div>
            <div>
                通知类型:{{type}}
            </div>
            <div>
                车主手机号:{{vo.applyUserMobile?vo.applyUserMobile:""}}
            </div>
        </div>
        <div class="item__btn" @click="goDetail(vo.id)">
            <view>
                查看详情
            </view>
        </div>
    </div>
  </scroll-list>
</div>
</view>
</template>

<script>
export default {
    data() {
        return {
          option: {
            size: 10,
            auto: true
          },
          items: [],
			    type: '请求他人挪车'
        };
    },
    methods: {
      // 加载数据
      load(paging) {
        setTimeout(() => {
          let list = [];
          let opts = { url: '/app/moveLog/apply/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
              });
            } else {
              // 加载失败
              this.$refs.list.loadFail()
            }
          })
        }, this.$u.random(100, 1000));
      },
      // 刷新
      refresh(paging) {
        setTimeout(() => {
          let list = [];
          let opts = { url: '/app/moveLog/apply/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 = list

              // 加载成功  参数对象{list: 当前列表,total: 数据总长度(后端查询的total)}
              this.$refs.list.refreshSuccess({
                list: this.items,
                total: res.data.total
              });
            } else {
              // 加载失败
              this.$refs.list.refreshFail()
            }
          })
        }, this.$u.random(100, 1000));
      },
      goDetail(id){
          uni.navigateTo({
            url: '/pagesB/pages/move-car/callDetail?id=' + id
          })
      },
		getApplyMoveLogList(){
			let opts = { url: '/app/moveLog/apply/list', method: 'get' };
			this.http.httpTokenRequest(opts, {}).then(res => {
				if (res.data.code == 200) {
					this.items = res.data.rows
				}
			})
		},
    },
	created() {
		//this.getApplyMoveLogList()
	},
}
</script>

<style lang="scss" scoped>
.myRecord {
    padding: 40rpx 0rpx;

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

        .item__top {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0 40rpx;
            border-bottom: 1rpx solid rgba(0, 0, 0, .1);
            padding-bottom: 30rpx;
            margin-bottom: 30rpx;

            .top__state {
                background: #cfffe2;
                width: 70rpx;
                height: 34rpx;
                font-size: 26rpx;
                font-family: PingFang SC;
                font-weight: 500;
                color: #00AD42;
                line-height: 34rpx;
                text-align: center;
                border-radius: 4rpx;
            }

            .phone__state {
                background: #ffebd8;
                color: rgba(248, 141, 40, 1);
            }

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

        .item__content {
            padding: 0 40rpx;
            display: flex;
            align-items: center;
            flex-wrap: wrap;
            justify-content: space-between;

            >div {
                width: 50%;
                margin-bottom: 30rpx;

                font-size: 30rpx;
                font-family: PingFang SC;
                font-weight: 500;
                color: #333333;
            }

            >div:nth-of-type(3) {
                width: 100%;
            }
        }

        .item__btn {
            display: flex;
            justify-content: flex-end;
            padding-right: 40rpx;
            font-size: 30rpx;
            font-family: PingFang SC;
            font-weight: 500;
            color: #999999;

            >view {
                width: 180rpx;
                height: 56rpx;
                text-align: center;
                line-height: 56rpx;
                border: 1rpx solid #DDDDDD;
                border-radius: 50rpx;
                font-size: 30rpx;
                font-family: PingFang SC;
                font-weight: 500;
                color: #999999;

            }
        }
    }
}
</style>
