<template>
  <div class="m-right-block fr mh576" style="position: relative;">
    <div class="right-block-bd">
      <div class="mb10 tc mt20">
        <span class="p-ico2 worm-ico-o"></span>
        注：未付款的订单设置3小时时限,3小时过后未付的订单就不再显示。
      </div>

      <div  class="ng-scope">

        <el-table v-loading="listLoading" :data="list" border fit highlight-current-row>

          <el-table-column label="交易订单" align="center" >
            <template slot-scope="{row, $index}">
              <span>{{row.payNo}}</span>
            </template>
          </el-table-column>
          <el-table-column label="岗位名称" align="center" >
            <template slot-scope="{row, $index}">
              <span>{{row.courseName}}</span>
            </template>
          </el-table-column>

          <el-table-column label="证书编号" align="left" min-width="100" >
            <template slot-scope="{row, $index}">
              <span>{{row.rzCode}}</span>
            </template>
          </el-table-column>

          <el-table-column label="金额(元)" align="center" >
            <template slot-scope="{row}">
              <span>{{ row.fee|money }} </span>
            </template>
          </el-table-column>

          <el-table-column label="提交结果" align="center" >
            <template slot-scope="{row, $index}">
              <span>{{row.errMarks||'成功'}}</span>
            </template>
          </el-table-column>

          <el-table-column label="提交时间" align="center" >
            <template slot-scope="{row, $index}">
              <span>{{row.createAt}}</span>
            </template>
          </el-table-column>
        </el-table>

        <el-pagination
            @current-change="handleCurrentChange"
            :current-page="page"
           :page-size="size"
           layout="total, prev,pager, next"
           :total="total">
        </el-pagination>

        <el-dialog title="申请开通课程"  :visible.sync="buyCourseDialog" :append-to-body="true"
        width="800px" top="20px" align="center">
          <IBuyCourse :courseId="courseId" @finish="reload"></IBuyCourse>
        </el-dialog>

      </div>
    </div>
  </div>
</template>

<script>
  import {httpServer } from "@/components/httpServer/httpServer.js";
  import {str2time} from '@/utils/date.js'

  import IBuyCourse from '../components/pay/IBuyCourse.vue'


  export default {
    name: "Index",
    components:{IBuyCourse},
    data() {
      return {
        page: 1,
        size: 12,
        total: 1,
        courseId:0,
        list: [],
        buyCourseDialog: false,
        listLoading: false
      };
    },
    beforeMount() {
      this.getData()
    },
    filters:{
      money(val){
        return '￥'+ (val/100);
      },
      payStatus(item){
        if(item.status == 2){
          return '支付完成';
        }
        let nowsec= Date.now()/1000
        if( nowsec - item.create_time > 300 ){
          return "支付超时"
        }
        return "支付中"
      }
    },
    methods: {
      rebuyInfo(row){
        this.courseId = row.courseId||0;
        this.buyCourseDialog = true;
      },
      reload(){
        this.buyCourseDialog = false;
        this.getData();
      },
      getData() {
        let param = {from: (this.page - 1) * this.size,size:this.size}
        httpServer('course.GetSmPayCourseList', param).then(({
          data,
          code
        }) => {
          this.list = data.list || 0;
          this.total = data.total || 0;
        })
      },
      handleCurrentChange: function(page) {
        this.page = page
        this.getData()
      }
    }
  }
</script>

<style>
</style>
