<template>
  <page-theme :theme="theme">
    <template>
      <view class="f-30 p-t-20 p-b-20">
        <view class="col-info-d t-c m-b-30">搜索框</view>
        <u-list @scrolltolower="scrolltolower">
          <u-list-item v-for="(item, index) in list" :key="index">
            <u-cell :title="item.name" @click="toDetail(item.id)">
              <u-avatar slot="icon" shape="square" size="35" :src="item.cover"
                customStyle="margin: -3px 5px -3px 0"></u-avatar>
            </u-cell>
          </u-list-item>
        </u-list>
      </view>
    </template>
  </page-theme>
</template>

<script>
  import themeMixins from '@/pages/yuecai/mixins/themeMixins.js';
  export default {
    mixins: [themeMixins],
    data() {
      return {
        page: {
          current: 1,
          size: 10,
          total: 0
        },
        searchKey: '',
        list: []
      }
    },
    methods: {
      doSearch() {
        this.page.current = 1;
        this.list = [];
        this.getLocationList();
      },
      scrolltolower() {
        this.loadmore()
      },
      loadmore() {
        this.page.current++;
        this.getLocationList();
      },
      getLocationList() {
        this.$u.api.getLocationList().then(res => {
          if (res.data.records && res.data.records.length > 0) {
            this.list.push(...res.data.records)
          }
          this.page.total = res.data.total || 0;
        })
      },
      toDetail(id) {
        uni.navigateTo({
          url: "/pages/yuecai/location/detail/index?id=" + id
        })
      }
    },
    onLoad(options) {
      this.getLocationList()
    },
  }
</script>

<style scoped lang="scss">
</style>