<template>
  <view class="page__view">
    
		<!-- 导航栏 -->
		<navbar :title="title" leftClick @leftClick="$utils.navigateBack" bgColor="#4883F9" color="#FFFFFF" />

    
    <view class="top">
      <!-- 搜索栏 -->
      <view class="search">
				<uv-search v-model="keyword" placeholder="输入关键词搜索" bgColor="#FBFBFB" @custom="search" @search="search">
          <template #prefix>
            <image class="search-icon" src="@/static/image/icon-search.png" mode="widthFix"></image>
          </template>
        </uv-search>
      </view>
    </view>

    <view class="main">
      <template v-if="total">
        <view class="flex card" v-for="item in list" :key="item.id" @click="jumpToDetail(item.id)">
          <view class="left">
            <view class="title-box">
              <view class="title">{{ item.title }}</view>
            </view>
            <view class="content-box" v-if="item.shortTitle">
              <view class="content">
                {{ item.shortTitle || '' }}
              </view>
              <view class="dot bottom-left"></view>
              <view class="dot top-right"></view>
            </view>
          </view>
          <view class="right">
            <image class="img" :src="item.paperImage" mode="aspectFill"></image>
          </view>
        </view>
      </template>
      <template v-else>
        <view class="flex empty">
          <image class="empty-icon" src="@/static/image/icon-empty.png" mode="widthFix"></image>
        </view>
      </template>
    </view>

  </view>
</template>

<script>
	import mixinsList from '@/mixins/list.js'

  export default {
		mixins: [mixinsList],
    data() {
      return {
        title: '搜索',
				keyword: '',
				queryParams: {
					pageNo: 1,
					pageSize: 10,
					title: '',
				},
        mixinsListApi: 'queryThesisList',
      }
    },
    onLoad({ search, categoryOne, categoryTwo, title, api }) {
      if (search) {
        this.keyword = search
				this.queryParams.title = search
			}
      if (categoryTwo) {
				this.queryParams.categoryOne = categoryOne
				this.queryParams.categoryTwo = categoryTwo
			}
      if (title) {
        this.title = title
      }
      if (api) {
        this.mixinsListApi = api
      }
      
      this.getData()
    },
    methods: {
      search() {
        this.queryParams.pageNo = 1
        this.queryParams.pageSize = 10
				this.queryParams.title = this.keyword
        this.getData()
      },
      jumpToDetail(thesisId) {
        let path = this.mixinsListApi == 'queryThesisList' ? '/pages_order/thesis/index' : '/pages_order/thesis/indexTwo'

        uni.navigateTo({
					url: `${path}?thesisId=${thesisId}`
				})
      },
    },
  }
</script>

<style scoped lang="scss">

  .page__view {
    background: $uni-bg-color-grey;
  }

  .top {
    padding: 49rpx 0 17rpx 0;
    box-sizing: border-box;
    background: $uni-color;
  }

	.search {
    margin: 0 19rpx;
    width: calc(100% - 20rpx * 2);
		background-color: #FFFFFF;
		border-radius: 37rpx;
		padding: 13rpx 0 13rpx 18rpx;
    box-sizing: border-box;
		display: flex;
		align-items: center;

		/deep/ .uv-search__action {
			color: $uni-color;
			padding: 10rpx 18rpx;
		}

    &-icon {
      width: 26rpx;
      height: auto;
    }
	}

  .main {
    padding: 17rpx;
    box-sizing: border-box;
  }

  .card {
    align-items: flex-start;
    background: #ffffff;
    border-radius: 20rpx;
    box-shadow: 0rpx 3rpx 6rpx 0rpx rgba(0,0,0,0.16); 

    & + & {
      margin-top: 27rpx;
    }

    .left {
      flex: 1;
      position: relative;
      // padding: 13rpx 32rpx 35rpx 20rpx;
      padding: 13rpx 70rpx 35rpx 20rpx;
      box-sizing: border-box;

      .title {
        font-size: 32rpx;
        font-weight: 700;
        color: $uni-color;
        padding: 4rpx 16rpx;
        background: #FFFFFF;
        border-radius: 12rpx;

        &-box {
          position: absolute;
          top: 0;
          z-index: 1;
          display: inline-block;
          padding: 4rpx;
          background: linear-gradient(to right, $uni-color, #FFFFFF);
          border-radius: 14rpx;
          transform: translateY(50%);
        }
      }

      .content {
        font-size: 24rpx;
        font-weight: 400;
        color: #000000;
        white-space: pre-wrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display:-webkit-box; //作为弹性伸缩盒子模型显示。
        -webkit-box-orient:vertical; //设置伸缩盒子的子元素排列方式--从上到下垂直排列
        -webkit-line-clamp:7; //显示的行

        &-box {
          margin-top: 40rpx;
          position: relative;
          padding: 40rpx 16rpx;
          border: 4rpx solid $uni-color;
          border-radius: 20rpx;

          &:after {
            content: ' ';
            position: absolute;
            bottom: 0;
            right: 0;
            width: 20rpx;
            height: 40rpx;
            background: #FFFFFF;
            transform: translate(4rpx, 4rpx);
          }

          .dot {
            position: absolute;
            z-index: 2;
            width: 8rpx;
            height: 8rpx;
            background: $uni-color;
            border-radius: 50%;

            &.bottom-left {
              bottom: 0;
              right: 16rpx;
              transform: translateY(6rpx);
            }

            &.top-right {
              bottom: 36rpx;
              right: 0;
              transform: translateX(6rpx);
            }
          }
        }
      }
    }

    .right {
      padding: 23rpx 17rpx 23rpx 0;
      box-sizing: border-box;

      .img {
        width: 225rpx;
        height: 325rpx;
      }
    }
  }
  
  .empty {
    margin-top: 165rpx;
  }

</style>