<template><page-meta :root-font-size="fontSize+'px'"></page-meta>
    <seller-base :show="false"><view style="position: absolute;top:0;right:0;left:0;bottom:0" class="scroll-view-wrapper div container">
    <view class="div common-header-wrap">
        <view class="status-holder"></view>
        <view :style="'height:'+navHeight+'px'"></view>
        <view class="common-header-holder"></view>
        <view class="common-header-fixed">
        <title-header />
        <uni-nav-bar title="账号日志" class="common-header" left-icon="back" @clickLeft="goBack()">
        </uni-nav-bar>
    </view>
    </view>
<view class="scroll-view div" style="position:relative">
        <scroll-view style="position: absolute;top:0;right:0;left:0;bottom:0" class="div mt-5" @scrolltolower="loadMore" scroll-y="true">
            <view class="div item mb-5" v-for="item in logList" :key="item.log_id">
                <view class="div mt">
                    <text class="h2">{{item.sellerlog_seller_name}}</text><text class="em time"> {{ $moment.unix(item.sellerlog_time).format('YYYY-MM-DD h:mm:ss') }}</text>
                </view>
                <view class="div mc">
                    {{item.sellerlog_content}}
                </view>
            </view>
        </scroll-view>
    </view>
</view>
</seller-base>
</template>

<script>
import {getFontSize} from '@/util/common'
import TitleHeader from '../../TitleHeader'
import SellerBase from '../SellerBase'

import EmptyRecord from '../../EmptyRecord'
import { getSellerLogList } from '../../../api/seller'
export default {
  name: 'LogList',
  components:{
    TitleHeader,
    SellerBase,
    EmptyRecord
  },
  computed:{
  fontSize(){
    return getFontSize()
  },
  },
  data(){
    return {
      navHeight: 0,
      params: { 'page': 0, 'per_page': 10 },
      loading: false, // 是否加载更多
      isMore: true, // 是否有更多
      logList: false // 记录列表
    }
  },
  created () {
  	this.loadMore()
  },
  mounted(){
  // #ifdef  MP-WEIXIN
  this.navHeight = uni.getMenuButtonBoundingClientRect().height
  // #endif
  },
  methods:{
    goBack(){uni.navigateBack({delta:1})},
    getLogList (ispush) {
      uni.showLoading({ title: '加载中' })
      let params = this.params
      getSellerLogList(params).then(res => {
        uni.hideLoading()

        if (ispush && this.logList) {
          this.logList = this.logList.concat(res.result.log_list)
        } else {
          this.logList = res.result.log_list
        }
        if (res.result.hasmore) {
          this.isMore = true
        } else {
          this.isMore = false
        }
      }).catch(error=>{
          uni.hideLoading()
          uni.showToast({icon:'none',title: error.message})
      })
    },
    loadMore () {
      this.loading = true
      this.params.page = ++this.params.page
      if (this.isMore) {
        this.loading = false
        this.getLogList(true)
      }
    }
  }
}
</script>

<style scoped lang="scss">
.scroll-view-wrapper{display: flex;flex-direction: column;}
.scroll-view{flex:1}
.item{padding:.5rem;background:#fff;}
.item .mt{height:1rem;line-height:1rem;}
.item .mt .h2{float:left;font-size:$subFontSize;font-weight:600;}
.item .mt .em{float:right;font-size:$fontSize;color: #999;}
.item .mc{padding-top:.5rem;line-height:1rem;font-size:$h6;color:#999}
</style>
