zhenghy

Merge remote-tracking branch 'origin/main'

@@ -47,8 +47,10 @@ export struct MultiPictureDetailPageComponent { @@ -47,8 +47,10 @@ export struct MultiPictureDetailPageComponent {
47 @State publishCommentModel: publishCommentModel = new publishCommentModel() 47 @State publishCommentModel: publishCommentModel = new publishCommentModel()
48 @State operationButtonList: string[] = ['comment', 'like', 'collect', 'share'] 48 @State operationButtonList: string[] = ['comment', 'like', 'collect', 'share']
49 @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') as number; 49 @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') as number;
  50 + @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') as number;
50 @State windowHeight: number = AppStorage.get<number>('windowHeight') as number; 51 @State windowHeight: number = AppStorage.get<number>('windowHeight') as number;
51 @State currentOffset:number = 0 52 @State currentOffset:number = 0
  53 + @State duration:number = 0
52 54
53 //watch监听页码回调 55 //watch监听页码回调
54 onCurrentPageNumUpdated(): void { 56 onCurrentPageNumUpdated(): void {
@@ -81,6 +83,7 @@ export struct MultiPictureDetailPageComponent { @@ -81,6 +83,7 @@ export struct MultiPictureDetailPageComponent {
81 } 83 }
82 } 84 }
83 85
  86 +
84 aboutToDisappear() { 87 aboutToDisappear() {
85 88
86 } 89 }
@@ -98,6 +101,7 @@ export struct MultiPictureDetailPageComponent { @@ -98,6 +101,7 @@ export struct MultiPictureDetailPageComponent {
98 @Builder 101 @Builder
99 init() { 102 init() {
100 if (this.contentDetailData.rmhPlatform == 1) { 103 if (this.contentDetailData.rmhPlatform == 1) {
  104 + if(!this.showDownload) {
101 Row() { 105 Row() {
102 Row({ space: 8 }) { 106 Row({ space: 8 }) {
103 if (this.getImgUrl()){ 107 if (this.getImgUrl()){
@@ -221,7 +225,11 @@ export struct MultiPictureDetailPageComponent { @@ -221,7 +225,11 @@ export struct MultiPictureDetailPageComponent {
221 middle: { anchor: "__container__", align: HorizontalAlign.Center } 225 middle: { anchor: "__container__", align: HorizontalAlign.Center }
222 }) 226 })
223 .id('e_attention') 227 .id('e_attention')
224 - .visibility(!this.showDownload ? Visibility.Visible : Visibility.None) 228 + .transition(TransitionEffect.OPACITY.animation({ duration: this.duration, curve: Curve.Ease }).combine(
  229 + TransitionEffect.translate({ x: 0, y: `-${this.topSafeHeight + 12}px` })
  230 + ))
  231 + }
  232 +
225 } 233 }
226 if (this.contentDetailData?.photoList && this.contentDetailData?.photoList?.length > 0) { 234 if (this.contentDetailData?.photoList && this.contentDetailData?.photoList?.length > 0) {
227 Swiper(this.swiperController) { 235 Swiper(this.swiperController) {
@@ -241,6 +249,9 @@ export struct MultiPictureDetailPageComponent { @@ -241,6 +249,9 @@ export struct MultiPictureDetailPageComponent {
241 this.currentOffset = Math.abs(extraInfo.currentOffset) 249 this.currentOffset = Math.abs(extraInfo.currentOffset)
242 }) 250 })
243 .onTouch((event: TouchEvent) => { 251 .onTouch((event: TouchEvent) => {
  252 + if(this.duration === 0) {
  253 + this.duration = 500
  254 + }
244 if(event.type === 1) { 255 if(event.type === 1) {
245 // if(this.currentOffset > px2vp((this.windowHeight - item.height)/2 - 100)) { 256 // if(this.currentOffset > px2vp((this.windowHeight - item.height)/2 - 100)) {
246 if(this.currentOffset > 160) { 257 if(this.currentOffset > 160) {
@@ -285,6 +296,7 @@ export struct MultiPictureDetailPageComponent { @@ -285,6 +296,7 @@ export struct MultiPictureDetailPageComponent {
285 }) 296 })
286 } 297 }
287 Column(){ 298 Column(){
  299 + if(!this.showDownload) {
288 Column(){ 300 Column(){
289 Row() { 301 Row() {
290 Scroll(this.scroller) { 302 Scroll(this.scroller) {
@@ -354,7 +366,11 @@ export struct MultiPictureDetailPageComponent { @@ -354,7 +366,11 @@ export struct MultiPictureDetailPageComponent {
354 operationButtonList: this.operationButtonList, 366 operationButtonList: this.operationButtonList,
355 }) 367 })
356 } 368 }
357 - .visibility(!this.showDownload ? Visibility.Visible : Visibility.None) 369 + .transition(TransitionEffect.OPACITY.animation({ duration: this.duration, curve: Curve.Ease }).combine(
  370 + TransitionEffect.translate({ x: 0, y: `-${this.bottomSafeHeight}px` })
  371 + ))
  372 + }
  373 + if(this.showDownload) {
358 Column(){ 374 Column(){
359 Row() { 375 Row() {
360 Flex({ 376 Flex({
@@ -391,7 +407,10 @@ export struct MultiPictureDetailPageComponent { @@ -391,7 +407,10 @@ export struct MultiPictureDetailPageComponent {
391 } 407 }
392 .width('100%') 408 .width('100%')
393 } 409 }
394 - .visibility(this.showDownload ? Visibility.Visible : Visibility.None) 410 + .transition(TransitionEffect.OPACITY.animation({ duration: this.duration, curve: Curve.Ease }).combine(
  411 + TransitionEffect.translate({ x: 0, y: `${this.bottomSafeHeight}px` })
  412 + ))
  413 + }
395 } 414 }
396 .zIndex(10) 415 .zIndex(10)
397 .id('e_swiper_bottom') 416 .id('e_swiper_bottom')
@@ -5,6 +5,8 @@ import { PageRepository } from '../../repository/PageRepository'; @@ -5,6 +5,8 @@ import { PageRepository } from '../../repository/PageRepository';
5 import { ProcessUtils } from 'wdRouter'; 5 import { ProcessUtils } from 'wdRouter';
6 import { HttpUtils } from 'wdNetwork/Index'; 6 import { HttpUtils } from 'wdNetwork/Index';
7 import { DateTimeUtils } from 'wdKit'; 7 import { DateTimeUtils } from 'wdKit';
  8 +import { LiveModel } from '../../viewmodel/LiveModel'
  9 +import { Logger, ToastUtils } from 'wdKit';
8 10
9 /** 11 /**
10 * 直播预约卡 12 * 直播预约卡
@@ -12,13 +14,62 @@ import { DateTimeUtils } from 'wdKit'; @@ -12,13 +14,62 @@ import { DateTimeUtils } from 'wdKit';
12 */ 14 */
13 const TAG = 'Zh_Single_Row-03' 15 const TAG = 'Zh_Single_Row-03'
14 16
  17 +interface reserveItem {
  18 + liveId: number,
  19 + relationId: string,
  20 + subscribe: boolean
  21 +}
  22 +
  23 +interface reserveReqItem {
  24 + liveId: string,
  25 + relationId: string,
  26 +}
  27 +
15 @Entry 28 @Entry
16 @Component 29 @Component
17 export struct ZhSingleRow03 { 30 export struct ZhSingleRow03 {
18 @State compDTO: CompDTO = {} as CompDTO 31 @State compDTO: CompDTO = {} as CompDTO
19 @State isEndEdge: boolean = false; 32 @State isEndEdge: boolean = false;
  33 + // @State reserveStatus: reserveItem[] = []
  34 + @State reservedIds: number[] = [];
20 scroller: Scroller = new Scroller() 35 scroller: Scroller = new Scroller()
21 36
  37 + aboutToAppear(): void {
  38 + this.getReserveState();
  39 + }
  40 +
  41 + // 请求所有预约状态
  42 + async getReserveState() {
  43 + const reserveBean: reserveReqItem[] = this.compDTO.operDataList.map((item: ContentDTO) => {
  44 + const reqItem: reserveReqItem = {
  45 + liveId: item.objectId,
  46 + relationId: item.relId
  47 + }
  48 + return reqItem;
  49 + })
  50 + const res = await LiveModel.getAppointmentStatus(reserveBean);
  51 + // this.reserveStatus = res;
  52 + res.map((item: reserveItem) => {
  53 + if (item.subscribe) {
  54 + this.reservedIds.push(item.liveId)
  55 + }
  56 + })
  57 + }
  58 +
  59 + // 判断是否预约
  60 + isReserved(liveId: number) {
  61 + return this.reservedIds.includes(liveId)
  62 + }
  63 +
  64 + // 预约/取消预约
  65 + async bookAndCancel(relationId: string, liveId: string, isSubscribe: boolean) {
  66 + const res = await LiveModel.liveAppointment(relationId, liveId, isSubscribe);
  67 + if (res.code == 0) {
  68 + ToastUtils.shortToast(isSubscribe ? '预约成功' : '取消预约成功')
  69 + this.getReserveState();
  70 + }
  71 + }
  72 +
22 format(timeNum: number) { 73 format(timeNum: number) {
23 const todayDate = new Date().setHours(0,0,0,0) 74 const todayDate = new Date().setHours(0,0,0,0)
24 const parseDate = new Date(timeNum).setHours(0,0,0,0); 75 const parseDate = new Date(timeNum).setHours(0,0,0,0);
@@ -44,6 +95,37 @@ export struct ZhSingleRow03 { @@ -44,6 +95,37 @@ export struct ZhSingleRow03 {
44 Scroll(this.scroller){ 95 Scroll(this.scroller){
45 Row() { 96 Row() {
46 ForEach(this.compDTO.operDataList, (item: ContentDTO) => { 97 ForEach(this.compDTO.operDataList, (item: ContentDTO) => {
  98 + this.ItemCard(item)
  99 + })
  100 + }
  101 + }
  102 + .scrollable(ScrollDirection.Horizontal)
  103 + .scrollBar(BarState.Off)
  104 + .onScrollEdge((side: Edge) => {
  105 + if (side === Edge.End) {
  106 + this.isEndEdge = true;
  107 + }
  108 + })
  109 + .onScrollStop(() => {
  110 + if (this.isEndEdge) {
  111 + this.jumpToMore();
  112 + }
  113 + })
  114 + .onScroll((xOffset: number, yOffset: number) => {
  115 + this.isEndEdge = false;
  116 + })
  117 + }
  118 + .padding({
  119 + left: $r('app.float.card_comp_pagePadding_lf'),
  120 + right: $r('app.float.card_comp_pagePadding_lf'),
  121 + top: $r('app.float.card_comp_pagePadding_tb'),
  122 + bottom: $r('app.float.card_comp_pagePadding_tb')
  123 + })
  124 + .backgroundColor($r('app.color.white'))
  125 + }
  126 +
  127 + @Builder
  128 + ItemCard(item: ContentDTO) {
47 Column() { 129 Column() {
48 Row() { 130 Row() {
49 Image(item.coverUrl) 131 Image(item.coverUrl)
@@ -80,14 +162,18 @@ export struct ZhSingleRow03 { @@ -80,14 +162,18 @@ export struct ZhSingleRow03 {
80 } 162 }
81 163
82 Row() { 164 Row() {
83 - Text('预约') 165 + Text(this.isReserved(Number(item.objectId)) ? '已预约' : '预约')
84 .width(48) 166 .width(48)
85 .height(24) 167 .height(24)
86 - .backgroundColor(0xED2800)  
87 - .fontColor(0xffffff) 168 + .backgroundColor(this.isReserved(Number(item.objectId)) ? 0xffffff : 0xED2800)
  169 + .fontColor(this.isReserved(Number(item.objectId)) ? 0xC8C8C8 : 0xffffff)
88 .fontSize(12) 170 .fontSize(12)
89 .textAlign(TextAlign.Center) 171 .textAlign(TextAlign.Center)
90 .borderRadius(3) 172 .borderRadius(3)
  173 + .onClick(() => {
  174 + this.bookAndCancel(item.relId, item.objectId, !this.isReserved(Number(item.objectId)))
  175 + })
  176 +
91 } 177 }
92 .margin({top: -5}) 178 .margin({top: -5})
93 } 179 }
@@ -102,34 +188,9 @@ export struct ZhSingleRow03 { @@ -102,34 +188,9 @@ export struct ZhSingleRow03 {
102 .onClick(() => { 188 .onClick(() => {
103 ProcessUtils.processPage(item) 189 ProcessUtils.processPage(item)
104 }) 190 })
105 - })  
106 - }  
107 - }  
108 - .scrollable(ScrollDirection.Horizontal)  
109 - .scrollBar(BarState.Off)  
110 - .onScrollEdge((side: Edge) => {  
111 - if (side === Edge.End) {  
112 - this.isEndEdge = true;  
113 - }  
114 - })  
115 - .onScrollStop(() => {  
116 - if (this.isEndEdge) {  
117 - this.jumpToMore();  
118 - }  
119 - })  
120 - .onScroll((xOffset: number, yOffset: number) => {  
121 - this.isEndEdge = false;  
122 - })  
123 - }  
124 - .padding({  
125 - left: $r('app.float.card_comp_pagePadding_lf'),  
126 - right: $r('app.float.card_comp_pagePadding_lf'),  
127 - top: $r('app.float.card_comp_pagePadding_tb'),  
128 - bottom: $r('app.float.card_comp_pagePadding_tb')  
129 - })  
130 - .backgroundColor($r('app.color.white'))  
131 } 191 }
132 192
  193 +
133 @Builder 194 @Builder
134 CompHeader(item: CompDTO) { 195 CompHeader(item: CompDTO) {
135 Row() { 196 Row() {
@@ -115,15 +115,6 @@ export struct BottomNavigationComponent { @@ -115,15 +115,6 @@ export struct BottomNavigationComponent {
115 .height(CommonConstants.FULL_PARENT) 115 .height(CommonConstants.FULL_PARENT)
116 .padding({ bottom: 15, left: 10, right: 10, top: 2 }) 116 .padding({ bottom: 15, left: 10, right: 10, top: 2 })
117 .aspectRatio(this.ASPECT_RATIO_1_1) 117 .aspectRatio(this.ASPECT_RATIO_1_1)
118 - .gesture(  
119 - TapGesture({ count: 2 })  
120 - .onAction((event: GestureEvent) => {  
121 - if (this.currentNavIndex === index) {  
122 - // 当前tab,双击事件  
123 - this.autoRefresh++  
124 - }  
125 - })  
126 - )  
127 118
128 Text(navItem.name) 119 Text(navItem.name)
129 .margin({ bottom: $r('app.float.bottom_navigation_margin_bottom') }) 120 .margin({ bottom: $r('app.float.bottom_navigation_margin_bottom') })
@@ -140,8 +131,14 @@ export struct BottomNavigationComponent { @@ -140,8 +131,14 @@ export struct BottomNavigationComponent {
140 this.barBackgroundColor = Color.White 131 this.barBackgroundColor = Color.White
141 this.currentBottomNavInfo = {} as BottomNavDTO 132 this.currentBottomNavInfo = {} as BottomNavDTO
142 } else { 133 } else {
  134 + if (this.currentNavIndex === index) {
  135 + // 当前tab,单击事件
  136 + this.autoRefresh++
  137 + } else {
  138 + // 切换tab
143 this.currentBottomNavInfo = navItem 139 this.currentBottomNavInfo = navItem
144 } 140 }
  141 + }
145 142
146 this.currentNavIndex = index; 143 this.currentNavIndex = index;
147 Logger.info(TAG, `onChange, index: ${index}`); 144 Logger.info(TAG, `onChange, index: ${index}`);
@@ -186,21 +183,4 @@ export struct BottomNavigationComponent { @@ -186,21 +183,4 @@ export struct BottomNavigationComponent {
186 this.assignChannel.bottomNavId = assignChannel.bottomNavId 183 this.assignChannel.bottomNavId = assignChannel.bottomNavId
187 }, 20) 184 }, 20)
188 } 185 }
189 -  
190 - /**  
191 - * 双击实现  
192 - */  
193 - // doubleClickTime: number = 0  
194 -  
195 - /**  
196 - * 双击实现  
197 - */  
198 - // private doubleClick(fun: () => void) {  
199 - // let now = DateTimeUtils.getTimeStamp()  
200 - // if (now - this.doubleClickTime < 200) {  
201 - // fun()  
202 - // } else {  
203 - // this.doubleClickTime = now  
204 - // }  
205 - // }  
206 } 186 }
@@ -83,7 +83,7 @@ struct ReserveMorePage { @@ -83,7 +83,7 @@ struct ReserveMorePage {
83 this.reserveBean = this.transformToLiveDetailsBeans(liveReviewDTO.list) 83 this.reserveBean = this.transformToLiveDetailsBeans(liveReviewDTO.list)
84 84
85 const apointMentStatus = await LiveModel.getAppointmentStatus(this.reserveBean) 85 const apointMentStatus = await LiveModel.getAppointmentStatus(this.reserveBean)
86 - console.info(`cj2024 ${apointMentStatus.code}`) 86 + // console.info(`cj2024 ${apointMentStatus.code}`)
87 }) 87 })
88 88
89 89
@@ -5,6 +5,17 @@ import { LiveDetailsBean, ReserveBean } from 'wdBean/Index'; @@ -5,6 +5,17 @@ import { LiveDetailsBean, ReserveBean } from 'wdBean/Index';
5 5
6 const TAG = 'LiveModel' 6 const TAG = 'LiveModel'
7 7
  8 +interface ReserveRes {
  9 + code: string | number,
  10 + data: ReserveItem[]
  11 +}
  12 +
  13 +interface ReserveItem {
  14 + liveId: number,
  15 + relationId: string,
  16 + subscribe: boolean
  17 +}
  18 +
8 export class LiveModel { 19 export class LiveModel {
9 /** 20 /**
10 * 直播内容详情 21 * 直播内容详情
@@ -74,17 +85,21 @@ export class LiveModel { @@ -74,17 +85,21 @@ export class LiveModel {
74 static getAppointmentStatus(reserveBean: ReserveBean[]) { 85 static getAppointmentStatus(reserveBean: ReserveBean[]) {
75 // let params: Record<string, ArrayList<ReserveBean>> = {}; 86 // let params: Record<string, ArrayList<ReserveBean>> = {};
76 // params = reserveBean 87 // params = reserveBean
77 - return new Promise<ResponseDTO<string>>((success, fail) => {  
78 - HttpRequest.post<ResponseDTO<string>>( 88 + return new Promise<Array<ReserveItem>>((success, fail) => {
  89 + HttpRequest.post<ResponseDTO<Array<ReserveItem>>>(
79 HttpUrlUtils.getAppointmentStatusUrl(), 90 HttpUrlUtils.getAppointmentStatusUrl(),
80 reserveBean, 91 reserveBean,
81 - ).then((data: ResponseDTO<string>) => { 92 + ).then((data: ResponseDTO<Array<ReserveItem>>) => {
  93 + if (!data || !data.data) {
  94 + fail("数据为空")
  95 + return
  96 + }
82 if (data.code != 0) { 97 if (data.code != 0) {
83 fail(data.message) 98 fail(data.message)
84 ToastUtils.shortToast(data.message) 99 ToastUtils.shortToast(data.message)
85 return 100 return
86 } 101 }
87 - success(data) 102 + success(data.data)
88 }, (error: Error) => { 103 }, (error: Error) => {
89 fail(error.message) 104 fail(error.message)
90 Logger.debug(TAG + ":error ", error.toString()) 105 Logger.debug(TAG + ":error ", error.toString())
@@ -21,7 +21,7 @@ struct MainPage { @@ -21,7 +21,7 @@ struct MainPage {
21 } 21 }
22 22
23 aboutToAppear() { 23 aboutToAppear() {
24 - HWLocationUtils.startLocationService() 24 +
25 this.breakpointSystem.register() 25 this.breakpointSystem.register()
26 26
27 let context = getContext(this) as common.UIAbilityContext 27 let context = getContext(this) as common.UIAbilityContext
@@ -31,6 +31,7 @@ struct MainPage { @@ -31,6 +31,7 @@ struct MainPage {
31 31
32 // WDPushNotificationManager.getInstance().sendLocalNotification() 32 // WDPushNotificationManager.getInstance().sendLocalNotification()
33 } 33 }
  34 + HWLocationUtils.startLocationService()
34 }) 35 })
35 36
36 Logger.info(TAG, `aboutToAppear `); 37 Logger.info(TAG, `aboutToAppear `);