Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
wangyujian_wd
2024-03-22 14:15:00 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
22e9873975dfb61ad79ab5f2c0decf73ec8528ec
22e98739
1 parent
99b1d863
feat:
1)电子版-日历和期刊弹窗和联动优化; 2)电子版-数据加载初始化调整优化;
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
79 additions
and
63 deletions
sight_harmony/features/wdComponent/src/main/ets/components/ENewspaperPageComponent.ets
sight_harmony/features/wdComponent/src/main/ets/dialog/ENewspaperListDialog.ets
sight_harmony/features/wdComponent/src/main/ets/dialog/ENewspaperPageDialog.ets
sight_harmony/features/wdComponent/src/main/ets/components/ENewspaperPageComponent.ets
View file @
22e9873
...
...
@@ -16,31 +16,33 @@ export struct ENewspaperPageComponent {
private picWidth: number = 0
@State picHeight: number = 0
@State newspaperListBean: NewspaperListBean = {} as NewspaperListBean
@
State
currentPageNum: string = '01'
@
Provide @Watch('onCurrentPageNumUpdated')
currentPageNum: string = '01'
@State pageDialogShow: boolean = false
@State calendarDialogShow: boolean = false
@State calendarDate: string = ''
private swiperController: SwiperController = new SwiperController()
@State swiperIndex: number = 0;
//watch监听报纸页码回调
// onCurrentPageNumUpdated(): void {
// console.log("ENewspaperPageComponent-onCurrentPageNumUpdated", "date:", this.currentPageNum)
// let _swiperIndex = Number.parseInt(this.currentPageNum)
// console.log("ENewspaperPageComponent-onCurrentPageNumUpdated", "_swiperIndex:", _swiperIndex)
// this.swiperIndex = _swiperIndex > 0 ? _swiperIndex - 1 : _swiperIndex
// }
onCurrentPageNumUpdated(): void {
console.log("ENewspaperPageComponent-onCurrentPageNumUpdated", "currentPageNum:", this.currentPageNum)
let _swiperIndex = Number.parseInt(this.currentPageNum)
console.log("ENewspaperPageComponent-onCurrentPageNumUpdated", "_swiperIndex:", _swiperIndex)
this.swiperIndex = _swiperIndex > 0 ? _swiperIndex - 1 : _swiperIndex
}
//日历选择弹框
calendarDialogController: CustomDialogController = new CustomDialogController({
builder: ENewspaperCalendarDialog({ onDateChange: (date: RMCalendarBean) => {
console.log("onDateChange-日历选择弹框", "date:", JSON.stringify(date))
if (date.fullYear && date.month && date.date) {
this.calendarDate = `${date.fullYear}-${date.month > 9 ? date.month + 1 : '0' + (date.month + 1)}-${date.date > 9 ? date.date : '0' + date.date}`
this.currentPageNum = '01'
this.getNewspaperTime()
this.getNewspaperList()
builder: ENewspaperCalendarDialog({
onDateChange: (date: RMCalendarBean) => {
console.log("onDateChange-日历选择弹框", "date:", JSON.stringify(date))
if (date.fullYear && date.month && date.date) {
this.calendarDate = `${date.fullYear}-${date.month > 9 ? date.month + 1 : '0' + (date.month + 1)}-${date.date > 9 ? date.date : '0' + date.date}`
this.getNewspaperTime()
this.getNewspaperList()
}
}
}
}
),
}),
alignment: DialogAlignment.Top,
offset: { dx: 0, dy: 80 },
customStyle: true,
...
...
@@ -48,16 +50,8 @@ export struct ENewspaperPageComponent {
//图片版选择弹框
pageDialogController: CustomDialogController = new CustomDialogController({
builder: ENewspaperPageDialog({
currentPageNum: this.currentPageNum,
dialogType: 0,
newspaperListBean: this.newspaperListBean,
onDateChange: (date: string, dialogType: number) => {
if (dialogType == 0) {
let _swiperIndex = Number.parseInt(this.currentPageNum)
console.log("ENewspaperPageComponent-onCurrentPageNumUpdated", "_swiperIndex:", _swiperIndex)
this.swiperIndex = _swiperIndex > 0 ? _swiperIndex - 1 : _swiperIndex
}
}
}),
alignment: DialogAlignment.BottomStart,
offset: { dx: 0, dy: -90 },
...
...
@@ -66,8 +60,8 @@ export struct ENewspaperPageComponent {
//文字报纸弹框
listDialogController: CustomDialogController = new CustomDialogController({
builder: ENewspaperListDialog({
currentPageNum: this.currentPageNum,
newspaperListBean: this.newspaperListBean }),
newspaperListBean: this.newspaperListBean
}),
alignment: DialogAlignment.Bottom,
offset: { dx: 0, dy: 0 }
})
...
...
@@ -78,8 +72,10 @@ export struct ENewspaperPageComponent {
Image($r('app.media.icon_arrow_down'))
.height($r('app.float.top_arrow_size'))
.width($r('app.float.top_arrow_size'))
.alignRules({ left: { anchor: "__container__", align: HorizontalAlign.Start },
center: { anchor: "__container__", align: VerticalAlign.Center } })
.alignRules({
left: { anchor: "__container__", align: HorizontalAlign.Start },
center: { anchor: "__container__", align: VerticalAlign.Center }
})
.id('e_newspaper_back')
.onClick((event: ClickEvent) => {
router.back()
...
...
@@ -98,8 +94,10 @@ export struct ENewspaperPageComponent {
.margin({ left: 2, bottom: 5 })
}
.alignItems(VerticalAlign.Bottom)
.alignRules({ middle: { anchor: "__container__", align: HorizontalAlign.Center },
center: { anchor: "__container__", align: VerticalAlign.Center } })
.alignRules({
middle: { anchor: "__container__", align: HorizontalAlign.Center },
center: { anchor: "__container__", align: VerticalAlign.Center }
})
.id('e_newspaper_date')
.onClick(() => {
this.calendarDialogShow = !this.calendarDialogShow
...
...
@@ -113,15 +111,19 @@ export struct ENewspaperPageComponent {
Image($r('app.media.icon_share'))
.height($r('app.float.top_arrow_size'))
.width($r('app.float.top_arrow_size'))
.alignRules({ right: { anchor: "__container__", align: HorizontalAlign.End },
center: { anchor: "__container__", align: VerticalAlign.Center } })
.alignRules({
right: { anchor: "__container__", align: HorizontalAlign.End },
center: { anchor: "__container__", align: VerticalAlign.Center }
})
.id('e_newspaper_share')
}
.margin({ left: $r('app.float.margin_16'), right: $r('app.float.margin_16') })
.height($r('app.float.top_bar_height'))
.alignRules({ top: { anchor: '__container__', align: VerticalAlign.Top },
.alignRules({
top: { anchor: '__container__', align: VerticalAlign.Top },
left: { anchor: '__container__', align: HorizontalAlign.Start },
right: { anchor: '__container__', align: HorizontalAlign.End } })
right: { anchor: '__container__', align: HorizontalAlign.End }
})
.id('e_newspaper_top')
if (this.newspaperListBean && this.newspaperListBean.list && this.newspaperListBean.list.length > 0) {
...
...
@@ -140,19 +142,24 @@ export struct ENewspaperPageComponent {
.displayCount(1)
.margin({ top: 35, left: 10, right: 10 })
.id('e_newspaper_content')
.alignRules({ top: { anchor: "e_newspaper_top", align: VerticalAlign.Bottom },
middle: { anchor: "__container__", align: HorizontalAlign.Center } })
.alignRules({
top: { anchor: "e_newspaper_top", align: VerticalAlign.Bottom },
middle: { anchor: "__container__", align: HorizontalAlign.Center }
})
.onChange((index: number) => {
this.currentPageNum = this.newspaperListBean?.list[index]?.pageNum
this.swiperIndex = index
})
Image($r('app.media.newspaper_shadow'))
.height($r('app.float.vp_12'))
.margin({ left: 20, right: 20, top: -1 })
.objectFit(ImageFit.Contain)
.alignRules({ top: { anchor: "e_newspaper_content", align: VerticalAlign.Bottom },
.alignRules({
top: { anchor: "e_newspaper_content", align: VerticalAlign.Bottom },
left: { anchor: 'e_newspaper_content', align: HorizontalAlign.Start },
right: { anchor: 'e_newspaper_content', align: HorizontalAlign.End } })
right: { anchor: 'e_newspaper_content', align: HorizontalAlign.End }
})
.id('e_newspaper_shadow')
Row() {
...
...
@@ -165,8 +172,10 @@ export struct ENewspaperPageComponent {
}
.justifyContent(FlexAlign.Center)
.margin({ top: $r('app.float.margin_16') })
.alignRules({ top: { anchor: "e_newspaper_shadow", align: VerticalAlign.Bottom },
middle: { anchor: "__container__", align: HorizontalAlign.Center } })
.alignRules({
top: { anchor: "e_newspaper_shadow", align: VerticalAlign.Bottom },
middle: { anchor: "__container__", align: HorizontalAlign.Center }
})
.id('e_newspaper_next')
.onClick((event: ClickEvent) => {
this.swiperController.showNext()
...
...
@@ -190,8 +199,10 @@ export struct ENewspaperPageComponent {
}
.alignItems(VerticalAlign.Bottom)
.margin({ left: $r('app.float.margin_16'), bottom: $r('app.float.top_tab_bar_height') })
.alignRules({ bottom: { anchor: '__container__', align: VerticalAlign.Bottom },
left: { anchor: '__container__', align: HorizontalAlign.Start } })
.alignRules({
bottom: { anchor: '__container__', align: VerticalAlign.Bottom },
left: { anchor: '__container__', align: HorizontalAlign.Start }
})
.id('e_newspaper_page_num')
.onClick((event: ClickEvent) => {
this.pageDialogShow = !this.pageDialogShow
...
...
@@ -219,8 +230,10 @@ export struct ENewspaperPageComponent {
}
.alignItems(VerticalAlign.Center)
.margin({ right: $r('app.float.margin_16'), bottom: $r('app.float.top_tab_bar_height') })
.alignRules({ bottom: { anchor: '__container__', align: VerticalAlign.Bottom },
right: { anchor: '__container__', align: HorizontalAlign.End } })
.alignRules({
bottom: { anchor: '__container__', align: VerticalAlign.Bottom },
right: { anchor: '__container__', align: HorizontalAlign.End }
})
.id('e_newspaper_read')
.onClick((event: ClickEvent) => {
this.listDialogController.open()
...
...
@@ -250,6 +263,8 @@ export struct ENewspaperPageComponent {
let newspaperTimes = await NewspaperViewModel.getNewspaperTime(this.calendarDate)
if (newspaperTimes && newspaperTimes.length > 0) {
this.calendarDate = newspaperTimes[0].date
this.currentPageNum = '01'
this.swiperIndex = 0
}
}
...
...
sight_harmony/features/wdComponent/src/main/ets/dialog/ENewspaperListDialog.ets
View file @
22e9873
...
...
@@ -7,26 +7,26 @@ import { ENewspaperPageDialog } from '../dialog/ENewspaperPageDialog'
*/
@CustomDialog
export struct ENewspaperListDialog {
@
Link
currentPageNum: string
@
Consume @Watch('onCurrentPageNumUpdated')
currentPageNum: string
@State pageDialogShow: boolean = false
@State scrollIndex: number = 0
newspaperListBean: NewspaperListBean = {} as NewspaperListBean
private listScroller: Scroller = new Scroller();
//watch监听报纸页码回调
onCurrentPageNumUpdated(): void {
console.log("ENewspaperListDialog-onCurrentPageNumUpdated", "currentPageNum:", this.currentPageNum)
let _scrollIndex = Number.parseInt(this.currentPageNum)
console.log("ENewspaperListDialog-onCurrentPageNumUpdated", "_swiperIndex:", _scrollIndex)
this.scrollIndex = _scrollIndex > 0 ? _scrollIndex - 1 : _scrollIndex
this.listScroller.scrollToIndex(this.scrollIndex)
}
//文字版选择弹框
pageListDialogController: CustomDialogController = new CustomDialogController({
builder: ENewspaperPageDialog({
currentPageNum: this.currentPageNum,
dialogType: 1,
newspaperListBean: this.newspaperListBean,
onDateChange: (date: string, dialogType: number) => {
if (dialogType == 1) {
console.log("ENewspaperListDialog-pageListDialogController", "date:", this.currentPageNum)
let _scrollIndex = Number.parseInt(this.currentPageNum)
console.log("ENewspaperListDialog-pageListDialogController", "_swiperIndex:", _scrollIndex)
this.scrollIndex = _scrollIndex > 0 ? _scrollIndex - 1 : _scrollIndex
this.listScroller.scrollToIndex(this.scrollIndex)
}
}
}),
alignment: DialogAlignment.TopStart,
offset: { dx: 0, dy: 214 },
...
...
@@ -43,8 +43,10 @@ export struct ENewspaperListDialog {
.width(43)
.height(4)
.backgroundColor('#EDEDED')
.margin({ top: 10,
bottom: 10 })
.margin({
top: 10,
bottom: 10
})
Row() {
Text(this.currentPageNum)
.fontSize($r('app.float.font_size_36'))
...
...
@@ -155,7 +157,7 @@ export struct ENewspaperListDialog {
for (let item of itemBean.items) {
index++
if (index == firstIndex) {
this.currentPageNum = itemBean.pageNum
//
this.currentPageNum = itemBean.pageNum
return
}
}
...
...
sight_harmony/features/wdComponent/src/main/ets/dialog/ENewspaperPageDialog.ets
View file @
22e9873
...
...
@@ -7,10 +7,12 @@ import { NewspaperListBean, NewspaperListItemBean } from 'wdBean/Index'
export struct ENewspaperPageDialog {
dialogType: number = 0 //0:图片版,1:文字版
pageDialogController?: CustomDialogController
@
Link
currentPageNum: string
@
Consume @Watch('onCurrentPageNumUpdated')
currentPageNum: string
@Prop newspaperListBean: NewspaperListBean = {} as NewspaperListBean
// 选择变化监听,
onDateChange?: (date: string, dialogType: number) => void
onCurrentPageNumUpdated(): void {
console.log("ENewspaperListDialog-onCurrentPageNumUpdated", "currentPageNum:", this.currentPageNum)
}
build() {
Column() {
...
...
@@ -36,9 +38,6 @@ export struct ENewspaperPageDialog {
.backgroundColor(this.currentPageNum != item.pageNum ? Color.White : $r('app.color.color_ED2800'))
.onClick((event: ClickEvent) => {
this.currentPageNum = item.pageNum
if (this.onDateChange) {
this.onDateChange(item.pageNum, this.dialogType)
}
if (this.pageDialogController) {
this.pageDialogController.close()
}
...
...
Please
register
or
login
to post a comment