<!-- 创业指引 -->
<template>
  <view class="entrepreneurship">
    <u-navbar
      back-text=""
      title=""
      back-icon-color="#FFFFFF"
      :background="{ background: '#3D5D4C' }"
      :border-bottom="false"
    ></u-navbar>
    <z-paging ref="paging" v-model="list" @query="queryList">
      <view class="entrepreneurship-list">
        <view
          class="entrepreneurship-list-item"
          v-for="(item, index) in list"
          :key="index"
          @click="jumpPage('pages/entrepreneurshipGuidelines/planDetails/planDetails', { id: item.id })"
        >
          <view class="entrepreneurship-list-item-title">{{ item.title }}</view>
          <view class="entrepreneurship-list-item-content">
            <u-parse :html="item.description" @imgtap="imageTap"></u-parse>
          </view>
          <view class="entrepreneurship-list-item-bottom">
            <view
              class="left"
              :class="item.replyStatus === 0 ? 'waiting' : 'had'"
            >{{ item.replyStatus === 0 ? '待专家回复' : '专家已回复' }}</view>
            <view class="right">{{ item.createTime | date('yyyy-mm-dd hh:MM:ss') }} 提交</view>
          </view>
        </view>
      </view>
    </z-paging>
    <view class="bottom-btn">
      <view
        class="bottom-btn-box"
        @click="jumpPageAuth('pages/entrepreneurshipGuidelines/addPlan/addPlan')"
      >提交创业计划</view>
    </view>
    <u-toast ref="uToast" />
    <judge-auth ref="judgeAuth" @adoptAuth="adoptAuth"/>
  </view>
</template>

<script>
export default {
  data() {
    return {
      list: []
    };
  },
  onBackPress(e) {
    // 返回主页面tabBar
    uni.switchTab({
      url: '../index/index'
    });
    // 此处一定要return为true，否则页面不会返回到指定路径
    return true;
  },
  methods: {
    /**
     * 获取列表
     * @param { Number } pageNum
     */
    getList(pageNum) {
      this.$u.api.entrepreneurship
        .getEntrepreneurshipListApi({
          pageNum: pageNum || 1
        })
        .then((res) => {
          if (res.code === 200) {
            this.$refs.paging.complete(res.rows);
          } else {
            this.$refs.uToast.show({
              title: res.msg,
              type: 'error'
            });
          }
        });
    },
    /**
     * 下拉加载组件触发
     * @param { Number } pageNo
     * @param { Number } pageSize
     */
    queryList(pageNo, pageSize) {
      this.getList(pageNo);
    },
    jumpPage(url, params) {
      this.$u.route({
        url,
        params
      });
    },
    jumpPageAuth(url) {
      this.$refs['judgeAuth'].modalShow(url);
    },
    adoptAuth(url) {
      this.jumpPage(url);
    },
    imageTap(e) {
      e.ignore();
    }
  }
};
</script>

<style lang="scss" scoped>
@import './entrepreneurshipGuidelines.scss';
</style>
