<template>
  <view class="main">
    <view class="header">
      <!--  占位  -->
      <view :style="{height: menu.bottom + 6 + 'px',marginBottom:'8px'}"></view>
      <view class="selectTimeBox" :style="{height: menu.bottom + 6 + 'px'}">
        <view class="selectTime" :style="{height: menu.height + 'px'}">
          <image class="backIcon" src="https://eshangtech.com/ShopICO/ahyd-BID/commercial/navigation-left.svg" @click="handleBack"/>
            <picker mode="date" fields="month" :value="single" :start="startDate" :end="endData" @change="bindDateChange">
              <view class="timeBox">
                <image class="timeIcon" src="https://eshangtech.com/ShopICO/ahyd-BID/merchantAccount/selectIcon.svg"/>
                <text class="timeText">{{single}}</text>
                <image class="downIcon" src="https://eshangtech.com/ShopICO/ahyd-BID/merchantAccount/downIcon.svg"/>
              </view>
            </picker>
        </view>
      </view>

      <view class="detailBox">
        <view class="detailTitle">商家营收金额</view>
        <view class="entryBox">
          <view class="entryItem">
            <view class="itemLeft">
              <image class="itemIcon" src="https://eshangtech.com/ShopICO/ahyd-BID/merchantAccount/accountIcon.svg"/>
              <text class="itemTitle">商家到账<text class="itemUnit">/元</text></text>
              <image class="noticeIcon" src="https://eshangtech.com/ShopICO/ahyd-BID/newIndex3/noticeIcon.svg"/>
            </view>
            <text class="itemRight">1,005,164.28</text>
          </view>

          <view class="entryItem">
            <view class="itemLeft">
              <image class="itemIcon" src="https://eshangtech.com/ShopICO/ahyd-BID/merchantAccount/entryIcon.svg"/>
              <text class="itemTitle">商家入账<text class="itemUnit">/元</text></text>
              <image class="noticeIcon" src="https://eshangtech.com/ShopICO/ahyd-BID/newIndex3/noticeIcon.svg"/>
            </view>
            <text class="itemRight">1,005,164.28</text>
          </view>

          <view class="entryItem">
            <view class="itemLeft">
              <image class="itemIcon" src="https://eshangtech.com/ShopICO/ahyd-BID/merchantAccount/payIcon.svg"/>
              <text class="itemTitle">商家应缴<text class="itemUnit">/元</text></text>
              <image class="noticeIcon" src="https://eshangtech.com/ShopICO/ahyd-BID/newIndex3/noticeIcon.svg"/>
            </view>
            <text class="itemRight">1,005,164.28</text>
          </view>
        </view>
      </view>
    </view>
    <div class="merchantData">
      <view class="titleBox">
        <text class="title">商家数据</text>
        <view class="sortBox">
          <view class="sortItem" style="margin-right: 48rpx" @click="handleChangeSortName(1)">
            <text class="sortText">到账</text>
            <view class="sortIconBox">
              <image class="upIcon" :style="{transform: sortName===1?sortType===1?``:`rotate(180deg)`:``}" :src="sortType===1?'https://eshangtech.com/ShopICO/ahyd-BID/car/upDesc.svg':sortName===1?'https://eshangtech.com/ShopICO/ahyd-BID/car/downDesc.svg':'https://eshangtech.com/ShopICO/ahyd-BID/car/upDesc.svg'"/>
              <image class="bottomIcon" :style="{transform: sortName===1?sortType===1?``:`rotate(180deg)`:'rotate(-180deg)'}":src="sortType===1 && sortName===1?'https://eshangtech.com/ShopICO/ahyd-BID/car/downDesc.svg':'https://eshangtech.com/ShopICO/ahyd-BID/car/upDesc.svg'"/>
            </view>
          </view>

          <view class="sortItem" style="margin-right: 48rpx" @click="handleChangeSortName(2)">
            <text class="sortText">入账</text>
            <view class="sortIconBox">
              <image class="upIcon" :style="{transform: sortName===2?sortType===1?``:`rotate(180deg)`:``}" :src="sortType===1?'https://eshangtech.com/ShopICO/ahyd-BID/car/upDesc.svg':sortName===2?'https://eshangtech.com/ShopICO/ahyd-BID/car/downDesc.svg':'https://eshangtech.com/ShopICO/ahyd-BID/car/upDesc.svg'"/>
              <image class="bottomIcon" :style="{transform: sortName===2?sortType===1?``:`rotate(180deg)`:'rotate(-180deg)'}":src="sortType===1 && sortName===2?'https://eshangtech.com/ShopICO/ahyd-BID/car/downDesc.svg':'https://eshangtech.com/ShopICO/ahyd-BID/car/upDesc.svg'"/>
            </view>
          </view>

          <view class="sortItem" @click="handleChangeSortName(3)">
            <text class="sortText">应缴</text>
            <view class="sortIconBox">
              <image class="upIcon" :style="{transform: sortName===3?sortType===1?``:`rotate(180deg)`:``}" :src="sortType===1?'https://eshangtech.com/ShopICO/ahyd-BID/car/upDesc.svg':sortName===3?'https://eshangtech.com/ShopICO/ahyd-BID/car/downDesc.svg':'https://eshangtech.com/ShopICO/ahyd-BID/car/upDesc.svg'"/>
              <image class="bottomIcon" :style="{transform: sortName===3?sortType===1?``:`rotate(180deg)`:'rotate(-180deg)'}":src="sortType===1 && sortName===3?'https://eshangtech.com/ShopICO/ahyd-BID/car/downDesc.svg':'https://eshangtech.com/ShopICO/ahyd-BID/car/upDesc.svg'"/>
            </view>
          </view>
        </view>
      </view>

      <view class="listBox">
        <view class="listItem" v-for="(item,index) in 8">
          <view class="typeBox">商家</view>
          <view class="itemTop">
            <view class="itemLeft">
              <image class="listItemIcon" src="https://eshangtech.com/ShopICO/ahyd-BID/merchantAccount/shopIcon.svg"/>
            </view>

            <view class="itemRight">
              <view class="rightTitleBox" @click="handleGoDetail(item)">
                <text class="title">合肥好顺坊餐饮管理有限公司</text>
                <image class="goMore" src="https://eshangtech.com/ShopICO/ahyd-BID/merchantAccount/goMore.svg"/>
              </view>
              <view style="display: inline-block">
                <view class="numberProject">6 个项目</view>
              </view>
            </view>
          </view>


          <view class="moneyBox">
              <view class="moneyItem">
                <text class="itemLabel">到账 /元</text>
                <text class="itemValue">79.435,54</text>
              </view>

              <view class="moneyItem">
                <text class="itemLabel">入账 /元</text>
                <text class="itemValue">79.435,54</text>
              </view>

              <view class="moneyItem">
                <text class="itemLabel">应缴 /元</text>
                <text class="itemValue">79.435,54</text>
              </view>
            </view>
        </view>
      </view>
    </div>
  </view>
</template>
<script>
export default {
  name: "index",
  data(){
    return {
      menu:{},
      single:'',
      startDate:'2023-01',
      endData:'',
      sortName:3, // 排序字段 1到账 2入账 3应缴
      sortType:1, // 正序降序 0正序  1降序
    }
  },
  onLoad(){
    this.menu = uni.getMenuButtonBoundingClientRect()
    let lastDay = uni.getStorageSync('lastDay')
    const date = new Date(lastDay)
    let y = date.getFullYear()
    let m = date.getMonth() + 1
    this.single = `${y}-${m<10?'0'+m :m}`
    this.endData = lastDay
  },
  methods:{
    // 修改时间
    bindDateChange(e){
      this.single = e.detail.value
    },
    // 返回
    handleBack(){
      uni.navigateBack({
        delta: 1
      });
    },
    // 改变排序的方法
    handleChangeSortName(value){
      if (value===this.sortName){
        if (this.sortType===1){
          this.sortType=0
        }else{
          this.sortType=1
        }
      }else{
        this.sortName = value
        this.sortType=1
      }
    },
    // 跳转到详情的方法
    handleGoDetail(obj){
      uni.navigateTo({
        url: '/pages/merchantAccount/detail'
      })
    }
  }
}
</script>
<style scoped lang="scss">
.main{
  width: 100%;
  height: 100%;
  background: #F3F4F9;
  .header{
    width: 100%;
    height: 536rpx;
    background: linear-gradient(180deg, #D8E3FF 0%, #F3F3F3 100%);
    .selectTimeBox{
      position: fixed;
      top: 0;left: 0;
      z-index: 99;
      width: 100%;
      background: linear-gradient(180deg, #D8E3FF 0%, #E2EBFC 100%);
      box-sizing: border-box;
      padding-bottom: 6px;
      display: flex;
      align-items: flex-end;
      .selectTime{
        display: flex;
        align-items: center;
        width: 100%;
        box-sizing: border-box;
        padding: 0 32rpx;
        .backIcon{
          width: 48rpx;
          height: 48rpx;
        }
        .timeBox{
          margin-left: 18rpx;
          display: flex;
          align-items: center;
          .timeIcon{
            width: 40rpx;
            height: 40rpx;
          }
          .timeText{
            font-size: 32rpx;
            font-family: AlimamaShuHeiTi, AlimamaShuHeiTi;
            font-weight: bold;
            color: #000000;
            line-height: 40rpx;
            margin: 0 12rpx;
          }
          .downIcon{
            width: 32rpx;
            height: 32rpx;
          }
        }
      }
    }

    .detailBox{
      width: calc(100% - 64rpx);
      margin-left: 32rpx;
      background: #F5F6FF;
      border-radius: 16rpx;
      .detailTitle{
        font-size: 28rpx;
        font-family: PingFangSC, PingFang SC;
        font-weight: 600;
        color: #212226;
        line-height: 40rpx;
        background: #F5F6FF;
        padding: 24rpx;
        box-sizing: border-box;
        border-top-left-radius: 16rpx;
        border-top-right-radius: 16rpx;
      }
      .entryBox{
        width:100%;
        background: #FFFFFF;
        border-radius: 16rpx;
        padding: 20rpx 24rpx;
        box-sizing: border-box;
        .entryItem{
          width: 100%;
          display: flex;
          justify-content: space-between;
          align-items: center;
          padding: 12rpx 0;
          .itemLeft{
            display: flex;
            align-items: center;
            .itemIcon{
              width: 48rpx;
              height: 48rpx;
              margin-right: 8rpx;
            }
            .itemTitle{
              font-size: 28rpx;
              font-family: PingFangSC, PingFang SC;
              font-weight: 400;
              color: #160002;
              line-height: 40rpx;
              .itemUnit{
                margin-left: 4rpx;
                font-size: 28rpx;
                font-family: PingFangSC, PingFang SC;
                font-weight: 400;
                color: #A69E9F;
                line-height: 40rpx;
              }
            }
            .noticeIcon{
              width: 34rpx;
              height: 34rpx;
              margin-left: 6rpx;
            }
          }
          .itemRight{
            font-size: 36rpx;
            font-family: DINAlternate, DINAlternate;
            font-weight: bold;
            color: #160002;
            line-height: 42rpx;
          }
        }
      }
    }
  }
  .merchantData{
    width: calc(100% - 64rpx);
    margin-left: 32rpx;
    box-sizing: border-box;
    padding: 24rpx;
    background: #fff;
    margin-top: 24rpx;
    border-radius: 16rpx;
    .titleBox{
      width: 100%;
      display: flex;
      align-items: center;
      justify-content: space-between;
      .title{
        font-size: 28rpx;
        font-family: PingFangSC, PingFang SC;
        font-weight: 600;
        color: #160002;
        line-height: 40rpx;
      }
      .sortBox{
        display: flex;
        align-items: center;
        .sortItem{
          display: flex;
          align-items: center;
          .sortText{
            font-size: 28rpx;
            font-family: PingFangSC, PingFang SC;
            font-weight: 400;
            color: #9A9A9A;
            line-height: 40rpx;
          }
          .sortIconBox{
            display: flex;
            flex-direction: column;
            margin-left: 16rpx;
            .upIcon{
              width: 16rpx;
              height: 12rpx;
              margin-bottom: 4rpx;
            }
            .bottomIcon{
              width: 16rpx;
              height: 12rpx;
            }
          }
        }
      }
    }

    .listBox{
      width: 100%;
      margin-top: 24rpx;
      .listItem{
        width: 100%;
        padding: 24rpx;
        background: linear-gradient(314deg, #F4F8FF 0%, #F3F5FF 20%, #F5FAFF 75%, #F2F6FF 100%);
        border-radius: 16rpx;
        box-sizing: border-box;
        position: relative;
        margin-bottom: 24rpx;
        .typeBox{
          position: absolute;
          right: 0;top: 0;
          background: linear-gradient(135deg, #D6E8FF 0%, #D5DFFE 100%);
          border-radius: 0rpx 16rpx 0rpx 16rpx;
          width: 80rpx;
          height: 40rpx;
          font-size: 24rpx;
          font-family: PingFangSC, PingFang SC;
          font-weight: 400;
          color: #166BF7;
          line-height: 36rpx;
          text-align: center;
        }

        .itemTop{
          display: flex;
          margin-bottom: 32rpx;
          .itemLeft{
            width: 90rpx;
            height: 90rpx;
            border-radius: 12rpx;
            overflow: hidden;
            margin-right: 16rpx;
            .listItemIcon{
              width: 100%;
              height: 100%;
            }
          }
          .itemRight{
            width: calc(100% - 84rpx);
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            .rightTitleBox{
              display: flex;
              align-items: center;
              .title{
                font-size: 28rpx;
                font-family: PingFangSC, PingFang SC;
                font-weight: 600;
                color: #160002;
                display: inline-block;
                width: 360rpx;
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              }
              .goMore{
                width: 32rpx;
                height: 32rpx;
                margin-left: 16rpx;
              }
            }
            .numberProject{
              background: #DAF1FF;
              border-radius: 4rpx;
              font-size: 24rpx;
              font-family: PingFangSC, PingFang SC;
              font-weight: 400;
              color: #0092EB;
              line-height: 36rpx;
              padding: 0 8rpx;
              display: inline-block;
            }
          }
        }
        .moneyBox{
          width: 100%;
          box-sizing: border-box;
          padding-left: 106rpx;
          display: flex;
          .moneyItem{
            width: calc(100% / 3);
            display: flex;
            flex-direction: column;
            .itemLabel{
              font-size: 24rpx;
              font-family: PingFangSC, PingFang SC;
              font-weight: 400;
              color: #9A9A9A;
              line-height: 36rpx;
              margin-bottom: 4rpx;
            }
            .itemValue{
              font-size: 28rpx;
              font-family: DINAlternate, DINAlternate;
              font-weight: bold;
              color: #160002;
              line-height: 32rpx;
            }
          }
        }
      }
    }
  }
}
</style>
