zoukankan      html  css  js  c++  java
  • 在线教育项目-day13【讲师整合前端】

    1.在api创建js文件

    import request from '@/utils/request'
    
    export default {
      //讲师分页查询
      getTeacherFrontList(page,limit){
          return request({
              url: `/eduservice/teacherfront/getTeacherFrontList/${page}/${limit}`,
              method: 'get'
          })
      },
      //讲师详情
      getById(id){
          return request({
            url: `/eduservice/teacherfront/${id}`,
            method: 'get'
          })
      }
    }

    2.讲师列表前端方法

    <script>
    import teacher from "@/api/teacher"
    export default {
      asyncData({ params, error }) {
        return teacher.getTeacherFrontList(1, 8)
        .then(response => {
          console.log(response.data.data);
          return { data: response.data.data }
        });
      },
    };
    </script>

    3.讲师列表页面

    <section class="c-sort-box unBr">
            <div>
              <!-- /无数据提示 开始-->
              <section class="no-data-wrap" v-if="data.total==0">
                <em class="icon30 no-data-ico">&nbsp;</em>
                <span class="c-666 fsize14 ml10 vam">没有相关数据,小编正在努力整理中...</span>
              </section>
              <!-- /无数据提示 结束-->
              <article v-if="data.total>0" class="i-teacher-list">
        <ul class="of">
            <li v-for="item in data.items" :key="item.id">
                <section class="i-teach-wrap">
                    <div class="i-teach-pic">
                        <a :href="'/teacher/'+item.id" :title="item.name">
                            <img :src="item.avatar" :alt="item.name" height="142" hright="142">
                        </a>
                    </div>
                    <div class="mt10 hLh30 txtOf tac">
                        <a :href="'/teacher/'+item.id" :title="item.name" class="fsize18 c-666">{{ item.name }}</a>
                    </div>
                    <div class="hLh30 txtOf tac">
                        <span class="fsize14 c-999" >{{ item.career }}</span>
                    </div>
                    <div class="mt15 i-q-txt">
                        <p class="c-999 f-fA">{{ item.intro }}</p>
                    </div>
                </section>
            </li>
        </ul>
        <div class="clear"/>
    </article>

    测试:

    4.讲师分页方法

    methods: {
        gotoPage(page){
            teacher.getTeacherFrontList(page, 4).then(response => {
                this.data = response.data.data
            })
        }
      }

    5.讲师分页页面代码

    <!-- 公共分页 开始 -->
            <div>
              <div class="paging">
                <!-- undisable这个class是否存在,取决于数据属性hasPrevious -->
                <a
                  :class="{undisable: !data.hasPrevious}"
                  href="#"
                  title="首页"
                  @click.prevent="gotoPage(1)"
                >首</a>
                <a
                  :class="{undisable: !data.hasPrevious}"
                  href="#"
                  title="前一页"
                  @click.prevent="gotoPage(data.current-1)"
                >&lt;</a>
                <a
                  v-for="page in data.pages"
                  :key="page"
                  :class="{current: data.current == page, undisable: data.current == page}"
                  :title="'第'+page+'页'"
                  href="#"
                  @click.prevent="gotoPage(page)"
                >{{ page }}</a>
                <a
                  :class="{undisable: !data.hasNext}"
                  href="#"
                  title="后一页"
                  @click.prevent="gotoPage(data.current+1)"
                >&gt;</a>
                <a
                  :class="{undisable: !data.hasNext}"
                  href="#"
                  title="末页"
                  @click.prevent="gotoPage(data.pages)"
                >末</a>
                <div class="clear" />
              </div>
            </div>
            <!-- 公共分页 结束 -->

    6.讲师详情前端方法

    <script>
    import teacher from "@/api/teacher";
    export default {
      asyncData({ params, error }) {
        return teacher.getById(params.id).then(response => {
          console.log(response);
          return {
            teacher: response.data.data.teacher,
            courseList: response.data.data.courseList
          };
        });
      }
    };
    </script>

    7.讲师详情前端页面

    <template>
      <div id="aCoursesList" class="bg-fa of">
        <!-- 讲师介绍 开始 -->
        <section class="container">
          <header class="comm-title">
            <h2 class="fl tac">
              <span class="c-333">讲师介绍</span>
            </h2>
          </header>
          <div class="t-infor-wrap">
            <!-- 讲师基本信息 开始 -->
            <section class="fl t-infor-box c-desc-content">
              <div class="mt20 ml20">
                <section class="t-infor-pic">
                  <img :src="teacher.avatar" :alt="teacher.name" />
                </section>
                <h3 class="hLh30">
                  <span class="fsize24 c-333">
                    {{ teacher.name }}
                    &nbsp;
                    {{ teacher.level===1?'高级讲师':'首席讲师' }}
                  </span>
                </h3>
                <section class="mt10">
                  <span class="t-tag-bg">{{ teacher.intro }}</span>
                </section>
                <section class="t-infor-txt">
                  <p class="mt20">{{ teacher.career }}</p>
                </section>
                <div class="clear" />
              </div>
            </section>
            <!-- /讲师基本信息 结束 -->
            <div class="clear"></div>
          </div>
          <section class="mt30">
            <div>
              <header class="comm-title all-teacher-title c-course-content">
                <h2 class="fl tac">
                  <span class="c-333">主讲课程</span>
                </h2>
                <section class="c-tab-title">
                  <a href="javascript: void(0)">&nbsp;</a>
                </section>
              </header>
              <!-- /无数据提示 开始-->
              <!-- 无数据提示 开始-->
    <section class="no-data-wrap" v-if="courseList.length==0">
        <em class="icon30 no-data-ico">&nbsp;</em>
        <span class="c-666 fsize14 ml10 vam">没有相关数据,小编正在努力整理中...</span>
    </section>
    <!-- /无数据提示 结束-->
              <!-- 课程列表 开始-->
    <article class="comm-course-list">
      <ul class="of">
        <li v-for="course in courseList" :key="course.id">
          <div class="cc-l-wrap">
            <section class="course-img">
              <img :src="course.cover" class="img-responsive">
              <div class="cc-mask">
                <a :href="'/course/'+course.id" title="开始学习" target="_blank" class="comm-btn c-btn-1">开始学习</a>
              </div>
            </section>
            <h3 class="hLh30 txtOf mt10">
              <a
                :href="'/course/'+course.id"
                :title="course.title"
                target="_blank"
                class="course-title fsize18 c-333">{{ course.title }}</a>
            </h3>
          </div>
        </li>
      </ul>
      <div class="clear"/>
    </article>
    <!-- /课程列表 结束-->
            </div>
          </section>
        </section>
        <!-- /讲师介绍 结束 -->
      </div>
    </template>

  • 相关阅读:
    Discuz X 2.5 点点(伪静态)
    jq 、xml 省市级联动
    php memcache 初级使用(2)
    关于windows虚拟内存管理的页目录自映射
    SharePoint 2010 网络上的开发经验和资源
    SharePoint 2010 Reporting Services 报表服务器正在内置 NT AUTHORITY\SYSTEM 账户下运行 解决方法
    SharePoint 2010 Reporting Services 报表服务器无法解密用于访问报表服务器数据库中的敏感数据或加密数据的对称密钥 解决方法
    Active Directory Rights Management Services (AD RMS)无法检索证书层次结构。 解决方法
    SharePoint 2010 Reporting Services 报表服务器实例没有正确配置 解决方法
    SharePoint 2010 页面引用 Reporting Services 展现 List 报表
  • 原文地址:https://www.cnblogs.com/dmzna/p/12862996.html
Copyright © 2011-2022 走看看