<template><page-meta :root-font-size="fontSize+'px'"></page-meta>
    <member-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" @scrolltolower="loadMore" scroll-y="true">
            <view class="div"  v-if="evaluateList && evaluateList.length">
                <view class="div item-wrapper mt-5"  v-for="evaluate in evaluateList" :key="evaluate.ob_no" @click="goDetail(evaluate.geval_goodsid)">
                    <view class="div item">
                        <view class="div p-img">
                            <image mode="aspectFit" class="img" :src="evaluate.geval_goodsimage"/>
                        </view>
                        <view class="div p-info">
                            <view class="div p-name">{{evaluate.geval_goodsname}}</view>
                            <uni-rate :size="18" :readonly="true" :value="evaluate.geval_scores"/>

                        </view>
                    </view>
                    <view class="div p-content">评价：{{evaluate.geval_content}}</view>
                    <view class="div p-time">{{$moment.unix(evaluate.geval_addtime).format('YYYY年MM月DD日')}}</view>
                </view>
            </view>
            <empty-record v-if="evaluateList && !evaluateList.length"></empty-record>
        </scroll-view>
</view>
    </view></member-base>
</template>

<script>
import {getFontSize} from '@/util/common'
import TitleHeader from '../../TitleHeader'
import MemberBase from '../MemberBase'
import EmptyRecord from '../../EmptyRecord'
import { urlencode } from '@/util/common'
import { getMemberevaluateList } from '../../../api/memberEvaluate'
export default {
  name: 'EvaluateList',
  components:{
    TitleHeader,
    MemberBase,
    EmptyRecord
  },
  mounted(){
  // #ifdef  MP-WEIXIN
  this.navHeight = uni.getMenuButtonBoundingClientRect().top
  // #endif
  },
  computed:{
  fontSize(){
    return getFontSize()
  },
  },
  data(){
    return {
      navHeight: 0,
      params: { 'page': 0, 'per_page': 10 },
      loading: false, // 是否加载更多
      isMore: true, // 是否有更多
      evaluateList: false // 商品列表
    }
  },
  created () {
  this.loadMore()
  },
  methods:{
    goBack(){uni.navigateBack({delta:1})},
    getEvaluateList (ispush) {
      uni.showLoading({ title: '加载中' })
      let params = this.params
      getMemberevaluateList(params).then(res => {
        uni.hideLoading()

        if (ispush && this.evaluateList) {
          this.evaluateList = this.evaluateList.concat(res.result.goodsevallist)
        } else {
          this.evaluateList = res.result.goodsevallist
        }
        if (res.result.hasmore) {
          this.isMore = true
        } else {
          this.isMore = false
        }
      })
    },
    loadMore () {
      this.loading = true
      this.params.page = ++this.params.page
      if (this.isMore) {
        this.loading = false
        this.getEvaluateList(true)
      }
    },
	goDetail (goods_id) {
	  uni.navigateTo({url:'/pages/home/goodsdetail/Goodsdetail'+'?'+urlencode({ 'goods_id': goods_id } )})
	}
  }
}
</script>

<style scoped lang="scss">
.scroll-view-wrapper{display: flex;flex-direction: column;}
.scroll-view{flex:1}
.item{display: flex;display:-webkit-flex;}
.item-wrapper{background:#fff;padding:.5rem;}
.item .p-img{}
.item .p-img .img{width:3rem;border-radius:.2rem;}
.item .p-info{margin-left:.4rem;}
.item .p-info .p-name{
    height:2rem;
    line-height:1rem;
    display:-moz-box;
    display:-webkit-box;
    -webkit-line-clamp: 2;
    -moz-line-clamp: 2;
    -moz-box-orient:vertical;
    -webkit-box-orient:vertical;
    box-orient:vertical;
    overflow: hidden;
    font-size:$subFontSize;}
.item .p-info .p-score{}
.p-content{font-size:$subFontSize;line-height:.8rem;color:#666666;margin-top:.5rem}
    .p-time{text-align: right;font-size:$fontSize;color:$descTextColor}
</style>
