wwf
2 天以前 791a96ae03cf92478244127b294c1fe520d31e89
entry/src/main/ets/pages/home/Home.ets
@@ -2,6 +2,7 @@
import http from '@ohos.net.http';
import { HttpResponseResult } from "../../data/HttpResponse";
import { JSON } from "@kit.ArkTS";
import { DOMAIN } from "../../utils/config";
class TabBarBase {
  title: string = ''
@@ -61,25 +62,9 @@
    { title: '更多', value: '', icon: $r('app.media.classification_more') },
  ]
  @State activityList: Activity[] = []
  @State courseList: Course[] = [
    // { title: '零基础到企业级项目实战', 'desc': '针对零基础小白或想升级技术栈的前端从业者,从核心语法入手,逐步深入Vue3组件开发打件开发件开发', count: '800', time: '01:30:23', difficult: '简单' },
    // { title: '零基础到企业级项目实战', 'desc': '针对零基础小白或想升级技术栈的前端从业者,从核心语法入手,逐步深入Vue3组件开发打件开发件开发', count: '800', time: '01:30:23', difficult: '简单' },
    // { title: 'Java高级:JVM深度调优与JVM深度调优', 'desc': '针对零基础小白或想升级技术栈的前端从业者,从核心语法入手,逐步深入Vue3组件开发打件开发件开发', count: '800', time: '01:30:23', difficult: '简单' },
    // { title: '零基础到企业级项目实战', 'desc': '针对零基础小白或想升级技术栈的前端从业者,从核心语法入手,逐步深入Vue3组件开发打件开发件开发', count: '800', time: '01:30:23', difficult: '简单' },
    // { title: '零基础到企业级项目实战', 'desc': '针对零基础小白或想升级技术栈的前端从业者,从核心语法入手,逐步深入Vue3组件开发打件开发件开发', count: '800', time: '01:30:23', difficult: '简单' },
    // { title: '零基础到企业级项目实战', 'desc': '针对零基础小白或想升级技术栈的前端从业者,从核心语法入手,逐步深入Vue3组件开发打件开发件开发', count: '800', time: '01:30:23', difficult: '简单' },
    // { title: '零基础到企业级项目实战', 'desc': '针对零基础小白或想升级技术栈的前端从业者,从核心语法入手,逐步深入Vue3组件开发打件开发件开发', count: '800', time: '01:30:23', difficult: '简单' },
    // { title: '零基础到企业级项目实战', 'desc': '针对零基础小白或想升级技术栈的前端从业者,从核心语法入手,逐步深入Vue3组件开发打件开发件开发', count: '800', time: '01:30:23', difficult: '简单' },
    // { title: '零基础到企业级项目实战', 'desc': '针对零基础小白或想升级技术栈的前端从业者,从核心语法入手,逐步深入Vue3组件开发打件开发件开发', count: '800', time: '01:30:23', difficult: '简单' },
    // { title: '零基础到企业级项目实战', 'desc': '针对零基础小白或想升级技术栈的前端从业者,从核心语法入手,逐步深入Vue3组件开发打件开发件开发', count: '800', time: '01:30:23', difficult: '简单' },
    // { title: '零基础到企业级项目实战', 'desc': '针对零基础小白或想升级技术栈的前端从业者,从核心语法入手,逐步深入Vue3组件开发打件开发件开发', count: '800', time: '01:30:23', difficult: '简单' },
    // { title: '零基础到企业级项目实战', 'desc': '针对零基础小白或想升级技术栈的前端从业者,从核心语法入手,逐步深入Vue3组件开发打件开发件开发', count: '800', time: '01:30:23', difficult: '简单' },
    // { title: '零基础到企业级项目实战', 'desc': '针对零基础小白或想升级技术栈的前端从业者,从核心语法入手,逐步深入Vue3组件开发打件开发件开发', count: '800', time: '01:30:23', difficult: '简单' },
    // { title: '零基础到企业级项目实战', 'desc': '针对零基础小白或想升级技术栈的前端从业者,从核心语法入手,逐步深入Vue3组件开发打件开发件开发', count: '800', time: '01:30:23', difficult: '简单' },
    // { title: '零基础到企业级项目实战', 'desc': '针对零基础小白或想升级技术栈的前端从业者,从核心语法入手,逐步深入Vue3组件开发打件开发件开发', count: '800', time: '01:30:23', difficult: '简单' },
    // { title: '零基础到企业级项目实战', 'desc': '针对零基础小白或想升级技术栈的前端从业者,从核心语法入手,逐步深入Vue3组件开发打件开发件开发', count: '800', time: '01:30:23', difficult: '简单' },
  ]
  @State origCourseList: Course[] = []
  @State courseList: Course[] = []
  @State @Watch('filterCourseList') searchKeyword: string = ''
  @Builder tabBarItem(name:string,index: number){
    Row(){
@@ -128,6 +113,28 @@
    return ''
  }
  getDifficultText(difficult: number) {
    if (difficult == 1) {
      return '简单'
    } else if (difficult == 2) {
      return '中等'
    } else if (difficult == 3) {
      return '困难'
    }
    return ''
  }
  filterCourseList() {
    if (this.searchKeyword) {
      let list = this.origCourseList.filter((ele: Course) => {
        return ele.name.includes(this.searchKeyword) || ele.description.includes(this.searchKeyword)
      })
      this.courseList = list
    } else {
      this.courseList = this.origCourseList
    }
  }
  aboutToAppear(): void {
    this.getBannerList()
    this.getActivityList()
@@ -137,7 +144,7 @@
  getBannerList() {
    let httpRequest = http.createHttp();
    httpRequest.request(
      "http://192.168.20.70:8080/quiz-community/public/v1.0/home/slideshows",
      `${DOMAIN}/quiz-community/public/v1.0/home/slideshows`,
      {
        method: http.RequestMethod.GET,
        header: { 'Content-Type': 'application/json', 'x-jwt-token': `Bearer ${AppStorage.get('x-jwt-token')}` },
@@ -160,7 +167,7 @@
  getActivityList() {
    let httpRequest = http.createHttp();
    httpRequest.request(
      "http://192.168.20.70:8080/quiz-community/public/v1.0/home/hotTraining",
      `${DOMAIN}/quiz-community/public/v1.0/home/hotTraining`,
      {
        method: http.RequestMethod.GET,
        header: { 'Content-Type': 'application/json', 'x-jwt-token': `Bearer ${AppStorage.get('x-jwt-token')}` },
@@ -183,7 +190,7 @@
  getCourseList() {
    let httpRequest = http.createHttp();
    httpRequest.request(
      "http://192.168.20.70:8080/quiz-community/public/v1.0/home/courses",
      `${DOMAIN}/quiz-community/public/v1.0/home/courses`,
      {
        method: http.RequestMethod.GET,
        header: { 'Content-Type': 'application/json', 'x-jwt-token': `Bearer ${AppStorage.get('x-jwt-token')}` },
@@ -194,7 +201,8 @@
        if (data.responseCode == 200) {
          const resData = (typeof data.result == 'string' ? JSON.parse(data.result) : data.result) as HttpResponseResult<Course[]>
          if (resData.code == 200) {
            this.courseList = resData.data || []
            this.origCourseList = resData.data || []
            this.filterCourseList()
          } else {
            promptAction.showToast({ message: resData.msg })
          }
@@ -331,12 +339,12 @@
                        router.pushUrl({
                          url: 'pages/home/ActiveDetail',
                          params: {
                            index: index
                            id: item.id
                          }
                        })
                      })
                    }
                  }, (index: number) => index.toString())
                  })
                }
                .listDirection(Axis.Vertical) // 排列方向
                .scrollBar(BarState.Off)
@@ -360,7 +368,7 @@
                  Image($r('app.media.search_icon'))
                    .width(14)
                    .height(14)
                  TextInput({ placeholder: '搜索想要查找的内容' })
                  TextInput({ placeholder: '搜索想要查找的内容', text: $$this.searchKeyword })
                    .placeholderFont({ size: 14})
                    .placeholderColor('#999999')
                    .backgroundColor('#f3f7fe')
@@ -404,7 +412,7 @@
                            }
                            Text() {
                              Span('课程难度: ')
                              Span(`${item.difficulty}`)
                              Span(this.getDifficultText(item.difficulty))
                            }
                            .fontSize(10)
                            .fontColor('#666666')
@@ -429,15 +437,14 @@
                      .border({ width: 1, style: BorderStyle.Solid, color: '#f2f2f2' })
                      .borderRadius(10)
                    }
                  }, (index: number) => index.toString())
                  })
                }
                .listDirection(Axis.Vertical) // 排列方向
                .scrollBar(BarState.Off)
                .friction(0.6)
                .edgeEffect(EdgeEffect.Spring)
                .width('100%')
                .height(530)
                .height(580)
              }
              .height('100%')
            }.tabBar(this.tabBarItem(item.title, index))