Showing
5 changed files
with
42 additions
and
18 deletions
| @@ -9,7 +9,7 @@ import font from '@ohos.font'; | @@ -9,7 +9,7 @@ import font from '@ohos.font'; | ||
| 9 | import { ENewspaperPageDialog } from '../dialog/ENewspaperPageDialog'; | 9 | import { ENewspaperPageDialog } from '../dialog/ENewspaperPageDialog'; |
| 10 | import { RMCalendarBean } from './calendar/RMCalendarBean'; | 10 | import { RMCalendarBean } from './calendar/RMCalendarBean'; |
| 11 | import { newsSkeleton } from './skeleton/newsSkeleton'; | 11 | import { newsSkeleton } from './skeleton/newsSkeleton'; |
| 12 | -import { Logger, ToastUtils } from 'wdKit/Index'; | 12 | +import { Logger, ToastUtils, NetworkUtil } from 'wdKit/Index'; |
| 13 | 13 | ||
| 14 | @Component | 14 | @Component |
| 15 | export struct ENewspaperPageComponent { | 15 | export struct ENewspaperPageComponent { |
| @@ -82,6 +82,12 @@ export struct ENewspaperPageComponent { | @@ -82,6 +82,12 @@ export struct ENewspaperPageComponent { | ||
| 82 | this.screenWidth = this.displayTool.width | 82 | this.screenWidth = this.displayTool.width |
| 83 | this.picWidth = this.screenWidth - vp2px(52) | 83 | this.picWidth = this.screenWidth - vp2px(52) |
| 84 | this.picHeight = this.picWidth * 566 / 378 | 84 | this.picHeight = this.picWidth * 566 / 378 |
| 85 | + // 默认日期 | ||
| 86 | + const date = new Date() | ||
| 87 | + const month = date.getMonth() + 1 | ||
| 88 | + const day = date.getDate() | ||
| 89 | + this.calendarDate = | ||
| 90 | + `${date.getFullYear()}-${month > 9 ? month : '0' + month}-${day > 9 ? day : '0' + day}` | ||
| 85 | //注册字体 | 91 | //注册字体 |
| 86 | font.registerFont({ | 92 | font.registerFont({ |
| 87 | familyName: 'BebasNeueBold', | 93 | familyName: 'BebasNeueBold', |
| @@ -135,12 +141,12 @@ export struct ENewspaperPageComponent { | @@ -135,12 +141,12 @@ export struct ENewspaperPageComponent { | ||
| 135 | }) | 141 | }) |
| 136 | .id('e_newspaper_date') | 142 | .id('e_newspaper_date') |
| 137 | .onClick(() => { | 143 | .onClick(() => { |
| 138 | - this.calendarDialogShow = !this.calendarDialogShow | ||
| 139 | - if (this.calendarDialogShow) { | ||
| 140 | - this.calendarDialogController.open() | ||
| 141 | - } else { | ||
| 142 | - this.calendarDialogController.close() | ||
| 143 | - } | 144 | + this.calendarDialogShow = !this.calendarDialogShow |
| 145 | + if (this.calendarDialogShow) { | ||
| 146 | + this.calendarDialogController.open() | ||
| 147 | + } else { | ||
| 148 | + this.calendarDialogController.close() | ||
| 149 | + } | ||
| 144 | }) | 150 | }) |
| 145 | 151 | ||
| 146 | Image($r('app.media.icon_share')) | 152 | Image($r('app.media.icon_share')) |
| @@ -260,11 +266,15 @@ export struct ENewspaperPageComponent { | @@ -260,11 +266,15 @@ export struct ENewspaperPageComponent { | ||
| 260 | }) | 266 | }) |
| 261 | .id('e_newspaper_page_num') | 267 | .id('e_newspaper_page_num') |
| 262 | .onClick((event: ClickEvent) => { | 268 | .onClick((event: ClickEvent) => { |
| 263 | - this.pageDialogShow = !this.pageDialogShow | ||
| 264 | - if (this.pageDialogShow) { | ||
| 265 | - this.pageDialogController.open() | ||
| 266 | - } else { | ||
| 267 | - this.pageDialogController.close() | 269 | + if (this.newspaperListBean.list && this.newspaperListBean.list.length > 0) { |
| 270 | + this.pageDialogShow = !this.pageDialogShow | ||
| 271 | + if (this.pageDialogShow) { | ||
| 272 | + this.pageDialogController.open() | ||
| 273 | + } else { | ||
| 274 | + this.pageDialogController.close() | ||
| 275 | + } | ||
| 276 | + }else { | ||
| 277 | + ToastUtils.showToast('暂无数据', 1000) | ||
| 268 | } | 278 | } |
| 269 | }) | 279 | }) |
| 270 | 280 | ||
| @@ -291,7 +301,11 @@ export struct ENewspaperPageComponent { | @@ -291,7 +301,11 @@ export struct ENewspaperPageComponent { | ||
| 291 | }) | 301 | }) |
| 292 | .id('e_newspaper_read') | 302 | .id('e_newspaper_read') |
| 293 | .onClick((event: ClickEvent) => { | 303 | .onClick((event: ClickEvent) => { |
| 294 | - this.isOpenListDialog = true | 304 | + if (this.newspaperListBean.list && this.newspaperListBean.list.length > 0) { |
| 305 | + this.isOpenListDialog = true | ||
| 306 | + }else { | ||
| 307 | + ToastUtils.showToast('暂无数据', 1000) | ||
| 308 | + } | ||
| 295 | }) | 309 | }) |
| 296 | } | 310 | } |
| 297 | .width('100%') | 311 | .width('100%') |
| @@ -322,8 +336,12 @@ export struct ENewspaperPageComponent { | @@ -322,8 +336,12 @@ export struct ENewspaperPageComponent { | ||
| 322 | 336 | ||
| 323 | private async getNewspaperList() { | 337 | private async getNewspaperList() { |
| 324 | try { | 338 | try { |
| 325 | - let listBean = await NewspaperViewModel.getNewspaperList(this.calendarDate, this.picWidth + 'x' + this.picHeight) | ||
| 326 | - this.newspaperListBean = listBean; | 339 | + if (NetworkUtil.isNetConnected()) { |
| 340 | + let listBean = await NewspaperViewModel.getNewspaperList(this.calendarDate, this.picWidth + 'x' + this.picHeight) | ||
| 341 | + this.newspaperListBean = listBean; | ||
| 342 | + } else { | ||
| 343 | + ToastUtils.showToast('网络出小差了,请检查网络后重试', 1000) | ||
| 344 | + } | ||
| 327 | } catch (exception) { | 345 | } catch (exception) { |
| 328 | 346 | ||
| 329 | } | 347 | } |
| @@ -114,7 +114,7 @@ export struct SingleColumn999Component { | @@ -114,7 +114,7 @@ export struct SingleColumn999Component { | ||
| 114 | build() { | 114 | build() { |
| 115 | // if (this.compDTO && this.compDTO?.operDataList?.length > 0) { | 115 | // if (this.compDTO && this.compDTO?.operDataList?.length > 0) { |
| 116 | if (this.compListItem && this.compListItem?.operDataList?.length > 0) { | 116 | if (this.compListItem && this.compListItem?.operDataList?.length > 0) { |
| 117 | - List({ space: 2, initialIndex: 0 }) { | 117 | + List({ initialIndex: 0 }) { |
| 118 | // ListItemGroup({ | 118 | // ListItemGroup({ |
| 119 | // // footer: this.itemFooter("") | 119 | // // footer: this.itemFooter("") |
| 120 | // }) { | 120 | // }) { |
| 1 | import { RMCalendarBean } from './RMCalendarBean' | 1 | import { RMCalendarBean } from './RMCalendarBean' |
| 2 | import { RMCalenderCell } from './RMCalendarCell' | 2 | import { RMCalenderCell } from './RMCalendarCell' |
| 3 | +import { ToastUtils, NetworkUtil } from 'wdKit/Index'; | ||
| 3 | 4 | ||
| 4 | @Component | 5 | @Component |
| 5 | export struct RMCalendar { | 6 | export struct RMCalendar { |
| @@ -166,6 +167,9 @@ export struct RMCalendar { | @@ -166,6 +167,9 @@ export struct RMCalendar { | ||
| 166 | * 下一个月 | 167 | * 下一个月 |
| 167 | */ | 168 | */ |
| 168 | private nextMonth() { | 169 | private nextMonth() { |
| 170 | + if (!NetworkUtil.isNetConnected()) { | ||
| 171 | + ToastUtils.showToast('网络出小差了,请检查网络后重试', 1000) | ||
| 172 | + } | ||
| 169 | // this.dates.slice(0, this.dates.length) | 173 | // this.dates.slice(0, this.dates.length) |
| 170 | this.dates = [] | 174 | this.dates = [] |
| 171 | const beforDate = new Date(this.selectDay.getFullYear(), this.selectDay.getMonth()) | 175 | const beforDate = new Date(this.selectDay.getFullYear(), this.selectDay.getMonth()) |
| @@ -180,6 +184,9 @@ export struct RMCalendar { | @@ -180,6 +184,9 @@ export struct RMCalendar { | ||
| 180 | * 上一个月 | 184 | * 上一个月 |
| 181 | */ | 185 | */ |
| 182 | private preMonth() { | 186 | private preMonth() { |
| 187 | + if (!NetworkUtil.isNetConnected()) { | ||
| 188 | + ToastUtils.showToast('网络出小差了,请检查网络后重试', 1000) | ||
| 189 | + } | ||
| 183 | // this.dates.slice(0, this.dates.length) | 190 | // this.dates.slice(0, this.dates.length) |
| 184 | this.dates = [] | 191 | this.dates = [] |
| 185 | const beforDate = new Date(this.selectDay.getFullYear(), this.selectDay.getMonth()) | 192 | const beforDate = new Date(this.selectDay.getFullYear(), this.selectDay.getMonth()) |
| @@ -517,7 +517,7 @@ export struct PaperSingleColumn999CardView { | @@ -517,7 +517,7 @@ export struct PaperSingleColumn999CardView { | ||
| 517 | } | 517 | } |
| 518 | } | 518 | } |
| 519 | .backgroundColor(Color.White) | 519 | .backgroundColor(Color.White) |
| 520 | - .margin({ bottom: 14, left: 12, right: 12 }) | 520 | + .margin({ bottom: 10, left: 12, right: 12 }) |
| 521 | .borderRadius(4) | 521 | .borderRadius(4) |
| 522 | .onClick(() => { | 522 | .onClick(() => { |
| 523 | ProcessUtils.processPage(this.item) | 523 | ProcessUtils.processPage(this.item) |
| @@ -8,7 +8,6 @@ export struct ENewspaperCalendarDialog { | @@ -8,7 +8,6 @@ export struct ENewspaperCalendarDialog { | ||
| 8 | onDateChange?: (date: RMCalendarBean) => void | 8 | onDateChange?: (date: RMCalendarBean) => void |
| 9 | //当前选择的日期标记 | 9 | //当前选择的日期标记 |
| 10 | @Prop selectDate: Date = new Date() | 10 | @Prop selectDate: Date = new Date() |
| 11 | - | ||
| 12 | build() { | 11 | build() { |
| 13 | RMCalendar({ | 12 | RMCalendar({ |
| 14 | // 开始日期 | 13 | // 开始日期 |
-
Please register or login to post a comment