File tree Expand file tree Collapse file tree 2 files changed +42
-34
lines changed Expand file tree Collapse file tree 2 files changed +42
-34
lines changed Original file line number Diff line number Diff line change @@ -35,43 +35,52 @@ async function getCourse() {
3535
3636 let nameRex = / c l a s s = " c o u r s e - n a m e o v e r H i d d e n 2 " t i t l e = " (?< name > .* ?) " / g
3737 let courseIdClassIdRex = / i d = " c o u r s e _ (?< courseId > \d + ) _ (?< classId > \d + ) " / g
38- let imgRex = / < i m g \s * ?s r c = " (?< img > h t t p s \S + \. \w { 3 , 4 } ) " > / g
38+ let imgRex = / < i m g \s * ?s r c = " (?< img > \S + \. \w { 3 , 4 } ) " > / g
3939 let summaryRex = / < p c l a s s = " m a r g i n t 1 0 l i n e 2 " t i t l e = " (?< summary > .* ?) " > / g
4040 let teacherRex = / < p c l a s s = " l i n e 2 " t i t l e = " (?< teacher > .* ?) " > / g
4141 let classNameRex = / < p c l a s s = " o v e r H i d d e n 1 " > (?< className > .* ?) < \/ p > / g
4242 while ( 1 ) {
43- let nameMatch = nameRex . exec ( html ) ?. groups
44- if ( ! nameMatch )
45- break ;
46- let {
47- name
48- } = nameMatch
49- // console.log(name)
50- let {
51- courseId,
52- classId
53- } = courseIdClassIdRex . exec ( html ) . groups
54- let {
55- img
56- } = imgRex . exec ( html ) . groups
57- let {
58- summary
59- } = summaryRex . exec ( html ) . groups
60- let {
61- teacher
62- } = teacherRex . exec ( html ) . groups
63- let {
64- className
65- } = classNameRex . exec ( html ) . groups
66- courseArr . push ( new CourseEntity ( {
67- name,
68- courseId,
69- classId,
70- className,
71- img,
72- summary,
73- teacher
74- } ) )
43+ try {
44+ let nameMatch = nameRex . exec ( html ) ?. groups
45+ if ( ! nameMatch )
46+ break ;
47+ let {
48+ name
49+ } = nameMatch
50+ // console.log(name)
51+ let {
52+ courseId,
53+ classId
54+ } = courseIdClassIdRex . exec ( html ) . groups
55+ let {
56+ img
57+ } = imgRex . exec ( html ) . groups
58+ if ( img . indexOf ( 'http' ) !== 0 ) img = `http://mooc1-1.chaoxing.com/${ img } `
59+ let {
60+ summary
61+ } = summaryRex . exec ( html ) . groups
62+ let {
63+ teacher
64+ } = teacherRex . exec ( html ) . groups
65+ let {
66+ className
67+ } = classNameRex . exec ( html ) . groups
68+ courseArr . push ( new CourseEntity ( {
69+ name,
70+ courseId,
71+ classId,
72+ className,
73+ img,
74+ summary,
75+ teacher
76+ } ) )
77+ } catch ( e ) {
78+ console . error ( e )
79+ uni . showToast ( {
80+ title : '部分课程加载失败' ,
81+ position : 'center'
82+ } )
83+ }
7584 }
7685 return courseArr
7786}
Original file line number Diff line number Diff line change 9898 index,
9999 courseId
100100 } = params
101- index++;
102101 if (params &&
103102 this.tabList[index])
104103 this.currentIndex = index
You can’t perform that action at this time.
0 commit comments