Showing
13 changed files
with
356 additions
and
61 deletions
| @@ -28,5 +28,6 @@ export interface CompDTO { | @@ -28,5 +28,6 @@ export interface CompDTO { | ||
| 28 | sortValue: number; | 28 | sortValue: number; |
| 29 | subType: string; | 29 | subType: string; |
| 30 | imageScale: number; // 封面图比例 1-4:3, 2-16:9, 3-3:2 | 30 | imageScale: number; // 封面图比例 1-4:3, 2-16:9, 3-3:2 |
| 31 | - audioDataList: AudioDTO[] | 31 | + audioDataList: AudioDTO[]; |
| 32 | + isSelect: boolean; | ||
| 32 | } | 33 | } |
| 1 | -import { CustomTitleUI } from '../reusable/CustomTitleUI' | 1 | +import { CustomTitleAndEditUI } from '../reusable/CustomTitleAndEditUI' |
| 2 | import MyCollectionViewModel from '../../viewmodel/MyCollectionViewModel'; | 2 | import MyCollectionViewModel from '../../viewmodel/MyCollectionViewModel'; |
| 3 | import PageModel from '../../viewmodel/PageModel'; | 3 | import PageModel from '../../viewmodel/PageModel'; |
| 4 | import { CommonConstants, ViewType } from 'wdConstant' | 4 | import { CommonConstants, ViewType } from 'wdConstant' |
| @@ -11,12 +11,18 @@ import LoadMoreLayout from './LoadMoreLayout' | @@ -11,12 +11,18 @@ import LoadMoreLayout from './LoadMoreLayout' | ||
| 11 | import NoMoreLayout from './NoMoreLayout' | 11 | import NoMoreLayout from './NoMoreLayout' |
| 12 | import { CompParser } from '../CompParser' | 12 | import { CompParser } from '../CompParser' |
| 13 | import CustomRefreshLoadLayout from './CustomRefreshLoadLayout'; | 13 | import CustomRefreshLoadLayout from './CustomRefreshLoadLayout'; |
| 14 | -import { listTouchEvent } from '../../utils/PullDownRefresh'; | 14 | +import { CustomSelectUI } from '../view/CustomSelectUI'; |
| 15 | +import { CustomBottomFuctionUI } from '../view/CustomBottomFuctionUI'; | ||
| 15 | 16 | ||
| 16 | @Entry | 17 | @Entry |
| 17 | @Component | 18 | @Component |
| 18 | struct BrowsingHistoryPage { | 19 | struct BrowsingHistoryPage { |
| 19 | @State private browSingModel: PageModel = new PageModel() | 20 | @State private browSingModel: PageModel = new PageModel() |
| 21 | + isloading : boolean = false | ||
| 22 | + @Provide isEditState:boolean = false | ||
| 23 | + @State allDatas :CompDTO[] = []; | ||
| 24 | + @State selectDatas :CompDTO[] = []; | ||
| 25 | + @Provide deleteNum :number = 0; | ||
| 20 | 26 | ||
| 21 | aboutToAppear(){ | 27 | aboutToAppear(){ |
| 22 | this.getData() | 28 | this.getData() |
| @@ -24,7 +30,10 @@ struct BrowsingHistoryPage { | @@ -24,7 +30,10 @@ struct BrowsingHistoryPage { | ||
| 24 | 30 | ||
| 25 | build() { | 31 | build() { |
| 26 | Column(){ | 32 | Column(){ |
| 27 | - CustomTitleUI({titleName:'浏览历史'}) | 33 | + CustomTitleAndEditUI({titleName:'浏览历史',isDisplayButton:true,editCallback:()=>{ |
| 34 | + this.selectDatas = [] | ||
| 35 | + this.deleteNum = 0 | ||
| 36 | + }}) | ||
| 28 | if (this.browSingModel.viewType == ViewType.LOADING){ | 37 | if (this.browSingModel.viewType == ViewType.LOADING){ |
| 29 | this.LoadingLayout() | 38 | this.LoadingLayout() |
| 30 | }else if(this.browSingModel.viewType == ViewType.ERROR){ | 39 | }else if(this.browSingModel.viewType == ViewType.ERROR){ |
| @@ -34,16 +43,21 @@ struct BrowsingHistoryPage { | @@ -34,16 +43,21 @@ struct BrowsingHistoryPage { | ||
| 34 | }else { | 43 | }else { |
| 35 | this.ListLayout() | 44 | this.ListLayout() |
| 36 | } | 45 | } |
| 46 | + | ||
| 47 | + if (this.isEditState){ | ||
| 48 | + CustomBottomFuctionUI({ | ||
| 49 | + selectAllCallback:(isOn)=>{ | ||
| 50 | + this.allSelectDatas(isOn) | ||
| 51 | + }, | ||
| 52 | + confirmCallback:()=>{ | ||
| 53 | + this.deleteDatas() | ||
| 37 | } | 54 | } |
| 38 | - .width(CommonConstants.FULL_WIDTH) | ||
| 39 | - .height(CommonConstants.FULL_HEIGHT) | ||
| 40 | - .onTouch((event: TouchEvent | undefined) => { | ||
| 41 | - if (event) { | ||
| 42 | - if (this.browSingModel.viewType === ViewType.LOADED) { | ||
| 43 | - listTouchEvent(this.browSingModel, event); | 55 | + }) |
| 56 | + .position({y:'92%'}) | ||
| 44 | } | 57 | } |
| 45 | } | 58 | } |
| 46 | - }) | 59 | + .width(CommonConstants.FULL_WIDTH) |
| 60 | + .height(CommonConstants.FULL_HEIGHT) | ||
| 47 | } | 61 | } |
| 48 | 62 | ||
| 49 | @Builder ListLayout() { | 63 | @Builder ListLayout() { |
| @@ -56,11 +70,9 @@ struct BrowsingHistoryPage { | @@ -56,11 +70,9 @@ struct BrowsingHistoryPage { | ||
| 56 | }) | 70 | }) |
| 57 | } | 71 | } |
| 58 | 72 | ||
| 59 | - LazyForEach(this.browSingModel.compList, (compDTO: CompDTO, compIndex: number) => { | 73 | + ForEach(this.allDatas, (compDTO: CompDTO, compIndex: number) => { |
| 60 | ListItem() { | 74 | ListItem() { |
| 61 | - Column() { | ||
| 62 | - CompParser({ compDTO: compDTO, compIndex: compIndex }); | ||
| 63 | - } | 75 | + this.newCompParser(compDTO,compIndex) |
| 64 | } | 76 | } |
| 65 | }) | 77 | }) |
| 66 | 78 | ||
| @@ -79,6 +91,24 @@ struct BrowsingHistoryPage { | @@ -79,6 +91,24 @@ struct BrowsingHistoryPage { | ||
| 79 | .height(CommonConstants.FULL_PARENT) | 91 | .height(CommonConstants.FULL_PARENT) |
| 80 | } | 92 | } |
| 81 | 93 | ||
| 94 | + @Builder | ||
| 95 | + newCompParser(compDTO: CompDTO, compIndex: number){ | ||
| 96 | + Row(){ | ||
| 97 | + if (this.isEditState){ | ||
| 98 | + CustomSelectUI({ | ||
| 99 | + isOn:compDTO.isSelect, | ||
| 100 | + selectCallback:(isOn)=>{ | ||
| 101 | + this.addCompDTO(isOn,compDTO) | ||
| 102 | + } | ||
| 103 | + }) | ||
| 104 | + .margin({left:16}) | ||
| 105 | + } | ||
| 106 | + Column() { | ||
| 107 | + CompParser({ compDTO: compDTO, compIndex: compIndex }) | ||
| 108 | + } | ||
| 109 | + } | ||
| 110 | + } | ||
| 111 | + | ||
| 82 | @Builder LoadingLayout() { | 112 | @Builder LoadingLayout() { |
| 83 | CustomRefreshLoadLayout({ refreshBean: new RefreshLayoutBean(true, | 113 | CustomRefreshLoadLayout({ refreshBean: new RefreshLayoutBean(true, |
| 84 | $r('app.media.ic_pull_up_load'), $r('app.string.pull_up_load_text'), this.browSingModel.pullDownRefreshHeight) }) | 114 | $r('app.media.ic_pull_up_load'), $r('app.string.pull_up_load_text'), this.browSingModel.pullDownRefreshHeight) }) |
| @@ -89,7 +119,7 @@ struct BrowsingHistoryPage { | @@ -89,7 +119,7 @@ struct BrowsingHistoryPage { | ||
| 89 | MyCollectionViewModel.newFetchMyCollectList(2,'1',this.browSingModel.currentPage,getContext(this)).then(pageDto => { | 119 | MyCollectionViewModel.newFetchMyCollectList(2,'1',this.browSingModel.currentPage,getContext(this)).then(pageDto => { |
| 90 | if (pageDto && pageDto.compList && pageDto.compList.length > 0) { | 120 | if (pageDto && pageDto.compList && pageDto.compList.length > 0) { |
| 91 | this.browSingModel.viewType = ViewType.LOADED; | 121 | this.browSingModel.viewType = ViewType.LOADED; |
| 92 | - this.browSingModel.compList.push(...pageDto.compList) | 122 | + this.allDatas.push(...pageDto.compList) |
| 93 | if (pageDto.compList.length === this.browSingModel.pageSize) { | 123 | if (pageDto.compList.length === this.browSingModel.pageSize) { |
| 94 | this.browSingModel.currentPage++; | 124 | this.browSingModel.currentPage++; |
| 95 | this.browSingModel.hasMore = true; | 125 | this.browSingModel.hasMore = true; |
| @@ -101,4 +131,47 @@ struct BrowsingHistoryPage { | @@ -101,4 +131,47 @@ struct BrowsingHistoryPage { | ||
| 101 | } | 131 | } |
| 102 | }) | 132 | }) |
| 103 | } | 133 | } |
| 134 | + | ||
| 135 | + //数据处理 | ||
| 136 | + //单个选择 | ||
| 137 | + addCompDTO(isOn:boolean , compDTO: CompDTO){ | ||
| 138 | + compDTO.isSelect = isOn; | ||
| 139 | + if (isOn === true){ | ||
| 140 | + this.selectDatas.push(compDTO) | ||
| 141 | + }else { | ||
| 142 | + this.selectDatas.splice(this.selectDatas.indexOf(compDTO),1) | ||
| 143 | + } | ||
| 144 | + this.deleteNum = this.selectDatas.length | ||
| 145 | + } | ||
| 146 | + | ||
| 147 | + //全选 | ||
| 148 | + allSelectDatas(isOn:boolean){ | ||
| 149 | + let datas: CompDTO[] = []; | ||
| 150 | + for (let index = 0; index < this.allDatas.length; index++) { | ||
| 151 | + const compDTO = this.allDatas[index]; | ||
| 152 | + compDTO.isSelect = isOn | ||
| 153 | + datas.push(compDTO) | ||
| 154 | + } | ||
| 155 | + this.selectDatas = [] | ||
| 156 | + this.allDatas = [] | ||
| 157 | + if (isOn === true) { | ||
| 158 | + this.selectDatas.push(...datas) | ||
| 159 | + }else { | ||
| 160 | + this.selectDatas.splice(0,this.deleteNum) | ||
| 161 | + } | ||
| 162 | + this.allDatas.push(...datas) | ||
| 163 | + this.deleteNum = this.selectDatas.length | ||
| 164 | + } | ||
| 165 | + | ||
| 166 | + //删除 | ||
| 167 | + deleteDatas(){ | ||
| 168 | + for (let index = 0; index < this.selectDatas.length; index++) { | ||
| 169 | + const compDTO = this.allDatas[index]; | ||
| 170 | + this.allDatas.splice(this.selectDatas.indexOf(compDTO),1) | ||
| 171 | + } | ||
| 172 | + | ||
| 173 | + //重置删除状态 | ||
| 174 | + this.isEditState = false | ||
| 175 | + } | ||
| 104 | } | 176 | } |
| 177 | + |
| 1 | 1 | ||
| 2 | import { CustomTitleUI } from '../reusable/CustomTitleUI'; | 2 | import { CustomTitleUI } from '../reusable/CustomTitleUI'; |
| 3 | -import { EditListInfo } from '../../model/EditInfoModel'; | 3 | +import { EditListInfo, editModel } from '../../model/EditInfoModel'; |
| 4 | import EditInfoViewModel from '../../viewmodel/EditInfoViewModel'; | 4 | import EditInfoViewModel from '../../viewmodel/EditInfoViewModel'; |
| 5 | import { WDRouterPage, WDRouterRule } from 'wdRouter'; | 5 | import { WDRouterPage, WDRouterRule } from 'wdRouter'; |
| 6 | import {AreaPickerDialog} from '../view/areaPickerDialog/AreaPickerDialog' | 6 | import {AreaPickerDialog} from '../view/areaPickerDialog/AreaPickerDialog' |
| 7 | import { AreaListModel } from '../../model/AreaListModel'; | 7 | import { AreaListModel } from '../../model/AreaListModel'; |
| 8 | -import router from '@ohos.router'; | ||
| 9 | - | ||
| 10 | 8 | ||
| 11 | @Entry | 9 | @Entry |
| 12 | @Component | 10 | @Component |
| @@ -14,9 +12,15 @@ struct EditUserInfoPage { | @@ -14,9 +12,15 @@ struct EditUserInfoPage { | ||
| 14 | @State listData: EditListInfo[] = [] | 12 | @State listData: EditListInfo[] = [] |
| 15 | @State headerImg: string = '' | 13 | @State headerImg: string = '' |
| 16 | @State dataSource: AreaListModel[] = [] | 14 | @State dataSource: AreaListModel[] = [] |
| 15 | + @State currentUserInfo: editModel = new editModel() | ||
| 17 | 16 | ||
| 18 | dialogController: CustomDialogController = new CustomDialogController({ | 17 | dialogController: CustomDialogController = new CustomDialogController({ |
| 19 | - builder: AreaPickerDialog({dataSource:this.dataSource}), | 18 | + builder: AreaPickerDialog({dataSource:this.dataSource, |
| 19 | + confirmCallback:(area:string)=>{ | ||
| 20 | + this.currentUserInfo.userExtend.city = area; | ||
| 21 | + this.updateEditModel() | ||
| 22 | + } | ||
| 23 | + }), | ||
| 20 | alignment: DialogAlignment.Bottom, | 24 | alignment: DialogAlignment.Bottom, |
| 21 | offset:{dx:0,dy:-20} | 25 | offset:{dx:0,dy:-20} |
| 22 | }) | 26 | }) |
| @@ -109,25 +113,33 @@ struct EditUserInfoPage { | @@ -109,25 +113,33 @@ struct EditUserInfoPage { | ||
| 109 | end:new Date(), | 113 | end:new Date(), |
| 110 | selected:new Date, | 114 | selected:new Date, |
| 111 | lunar:false, | 115 | lunar:false, |
| 112 | - // onAccept:(value:DatePickerResult) => { | ||
| 113 | - // | ||
| 114 | - // } | 116 | + onAccept:(value:DatePickerResult) => { |
| 117 | + let mon = value.month as number + 1 | ||
| 118 | + this.currentUserInfo.userExtend.birthday = value.year+'-'+mon.toString()+'-'+value.day; | ||
| 119 | + this.updateEditModel() | ||
| 120 | + } | ||
| 115 | }) | 121 | }) |
| 116 | }else if(i === 5){ | 122 | }else if(i === 5){ |
| 117 | TextPickerDialog.show({ | 123 | TextPickerDialog.show({ |
| 118 | - range:['男','女'], | 124 | + range:['女','男'], |
| 119 | selected:0, | 125 | selected:0, |
| 120 | - // onAccept:(value:TextPickerResult) => { | ||
| 121 | - // | ||
| 122 | - // } | 126 | + onAccept:(value:TextPickerResult) => { |
| 127 | + this.currentUserInfo.userExtend.sex = value.index.toString(); | ||
| 128 | + this.updateEditModel() | ||
| 129 | + } | ||
| 123 | }) | 130 | }) |
| 124 | } | 131 | } |
| 125 | }) | 132 | }) |
| 126 | } | 133 | } |
| 127 | 134 | ||
| 135 | + updateEditModel(){ | ||
| 136 | + this.listData = [] | ||
| 137 | + this.listData.push(...EditInfoViewModel.getEditListInfo(this.currentUserInfo)) | ||
| 138 | + } | ||
| 128 | getAccountOwnerInfo(){ | 139 | getAccountOwnerInfo(){ |
| 129 | EditInfoViewModel.queryAccountOwnerInfo(1,getContext(this)).then((editModel) => { | 140 | EditInfoViewModel.queryAccountOwnerInfo(1,getContext(this)).then((editModel) => { |
| 130 | this.headerImg = editModel.userExtend.headPhotoUrl | 141 | this.headerImg = editModel.userExtend.headPhotoUrl |
| 142 | + this.currentUserInfo = editModel; | ||
| 131 | this.listData.push(...EditInfoViewModel.getEditListInfo(editModel)) | 143 | this.listData.push(...EditInfoViewModel.getEditListInfo(editModel)) |
| 132 | }); | 144 | }); |
| 133 | } | 145 | } |
| 1 | -import { CustomTitleUI } from '../reusable/CustomTitleUI' | 1 | +import { CustomTitleAndEditUI } from '../reusable/CustomTitleAndEditUI' |
| 2 | import MyCollectionViewModel from '../../viewmodel/MyCollectionViewModel'; | 2 | import MyCollectionViewModel from '../../viewmodel/MyCollectionViewModel'; |
| 3 | import PageModel from '../../viewmodel/PageModel'; | 3 | import PageModel from '../../viewmodel/PageModel'; |
| 4 | import { CommonConstants, ViewType } from 'wdConstant' | 4 | import { CommonConstants, ViewType } from 'wdConstant' |
| @@ -11,12 +11,18 @@ import LoadMoreLayout from './LoadMoreLayout' | @@ -11,12 +11,18 @@ import LoadMoreLayout from './LoadMoreLayout' | ||
| 11 | import NoMoreLayout from './NoMoreLayout' | 11 | import NoMoreLayout from './NoMoreLayout' |
| 12 | import { CompParser } from '../CompParser' | 12 | import { CompParser } from '../CompParser' |
| 13 | import CustomRefreshLoadLayout from './CustomRefreshLoadLayout'; | 13 | import CustomRefreshLoadLayout from './CustomRefreshLoadLayout'; |
| 14 | +import { CustomSelectUI } from '../view/CustomSelectUI'; | ||
| 15 | +import { CustomBottomFuctionUI } from '../view/CustomBottomFuctionUI'; | ||
| 14 | 16 | ||
| 15 | @Entry | 17 | @Entry |
| 16 | @Component | 18 | @Component |
| 17 | struct MyCollectionListPage { | 19 | struct MyCollectionListPage { |
| 18 | @State private browSingModel: PageModel = new PageModel() | 20 | @State private browSingModel: PageModel = new PageModel() |
| 19 | isloading : boolean = false | 21 | isloading : boolean = false |
| 22 | + @Provide isEditState:boolean = false | ||
| 23 | + @State allDatas :CompDTO[] = []; | ||
| 24 | + @State selectDatas :CompDTO[] = []; | ||
| 25 | + @Provide deleteNum :number = 0; | ||
| 20 | 26 | ||
| 21 | aboutToAppear(){ | 27 | aboutToAppear(){ |
| 22 | this.getData() | 28 | this.getData() |
| @@ -24,7 +30,10 @@ struct MyCollectionListPage { | @@ -24,7 +30,10 @@ struct MyCollectionListPage { | ||
| 24 | 30 | ||
| 25 | build() { | 31 | build() { |
| 26 | Column(){ | 32 | Column(){ |
| 27 | - CustomTitleUI({titleName:'我的收藏'}) | 33 | + CustomTitleAndEditUI({titleName:'我的收藏',isDisplayButton:true,editCallback:()=>{ |
| 34 | + this.selectDatas = [] | ||
| 35 | + this.deleteNum = 0 | ||
| 36 | + }}) | ||
| 28 | if (this.browSingModel.viewType == ViewType.LOADING){ | 37 | if (this.browSingModel.viewType == ViewType.LOADING){ |
| 29 | this.LoadingLayout() | 38 | this.LoadingLayout() |
| 30 | }else if(this.browSingModel.viewType == ViewType.ERROR){ | 39 | }else if(this.browSingModel.viewType == ViewType.ERROR){ |
| @@ -34,6 +43,18 @@ struct MyCollectionListPage { | @@ -34,6 +43,18 @@ struct MyCollectionListPage { | ||
| 34 | }else { | 43 | }else { |
| 35 | this.ListLayout() | 44 | this.ListLayout() |
| 36 | } | 45 | } |
| 46 | + | ||
| 47 | + if (this.isEditState){ | ||
| 48 | + CustomBottomFuctionUI({ | ||
| 49 | + selectAllCallback:(isOn)=>{ | ||
| 50 | + this.allSelectDatas(isOn) | ||
| 51 | + }, | ||
| 52 | + confirmCallback:()=>{ | ||
| 53 | + this.deleteDatas() | ||
| 54 | + } | ||
| 55 | + }) | ||
| 56 | + .position({y:'92%'}) | ||
| 57 | + } | ||
| 37 | } | 58 | } |
| 38 | .width(CommonConstants.FULL_WIDTH) | 59 | .width(CommonConstants.FULL_WIDTH) |
| 39 | .height(CommonConstants.FULL_HEIGHT) | 60 | .height(CommonConstants.FULL_HEIGHT) |
| @@ -49,7 +70,7 @@ struct MyCollectionListPage { | @@ -49,7 +70,7 @@ struct MyCollectionListPage { | ||
| 49 | }) | 70 | }) |
| 50 | } | 71 | } |
| 51 | 72 | ||
| 52 | - LazyForEach(this.browSingModel.compList, (compDTO: CompDTO, compIndex: number) => { | 73 | + ForEach(this.allDatas, (compDTO: CompDTO, compIndex: number) => { |
| 53 | ListItem() { | 74 | ListItem() { |
| 54 | this.newCompParser(compDTO,compIndex) | 75 | this.newCompParser(compDTO,compIndex) |
| 55 | } | 76 | } |
| @@ -73,16 +94,17 @@ struct MyCollectionListPage { | @@ -73,16 +94,17 @@ struct MyCollectionListPage { | ||
| 73 | @Builder | 94 | @Builder |
| 74 | newCompParser(compDTO: CompDTO, compIndex: number){ | 95 | newCompParser(compDTO: CompDTO, compIndex: number){ |
| 75 | Row(){ | 96 | Row(){ |
| 76 | - Button() | ||
| 77 | - .type(ButtonType.Normal) | ||
| 78 | - .width('20') | ||
| 79 | - .height('20') | ||
| 80 | - .backgroundColor('#ED2800') | ||
| 81 | - .borderRadius(5) | 97 | + if (this.isEditState){ |
| 98 | + CustomSelectUI({ | ||
| 99 | + isOn:compDTO.isSelect, | ||
| 100 | + selectCallback:(isOn)=>{ | ||
| 101 | + this.addCompDTO(isOn,compDTO) | ||
| 102 | + } | ||
| 103 | + }) | ||
| 82 | .margin({left:16}) | 104 | .margin({left:16}) |
| 83 | - | 105 | + } |
| 84 | Column() { | 106 | Column() { |
| 85 | - CompParser({ compDTO: compDTO, compIndex: compIndex }); | 107 | + CompParser({ compDTO: compDTO, compIndex: compIndex }) |
| 86 | } | 108 | } |
| 87 | } | 109 | } |
| 88 | } | 110 | } |
| @@ -97,7 +119,7 @@ struct MyCollectionListPage { | @@ -97,7 +119,7 @@ struct MyCollectionListPage { | ||
| 97 | MyCollectionViewModel.newFetchMyCollectList(1,'1',this.browSingModel.currentPage,getContext(this)).then(pageDto => { | 119 | MyCollectionViewModel.newFetchMyCollectList(1,'1',this.browSingModel.currentPage,getContext(this)).then(pageDto => { |
| 98 | if (pageDto && pageDto.compList && pageDto.compList.length > 0) { | 120 | if (pageDto && pageDto.compList && pageDto.compList.length > 0) { |
| 99 | this.browSingModel.viewType = ViewType.LOADED; | 121 | this.browSingModel.viewType = ViewType.LOADED; |
| 100 | - this.browSingModel.compList.push(...pageDto.compList) | 122 | + this.allDatas.push(...pageDto.compList) |
| 101 | if (pageDto.compList.length === this.browSingModel.pageSize) { | 123 | if (pageDto.compList.length === this.browSingModel.pageSize) { |
| 102 | this.browSingModel.currentPage++; | 124 | this.browSingModel.currentPage++; |
| 103 | this.browSingModel.hasMore = true; | 125 | this.browSingModel.hasMore = true; |
| @@ -109,4 +131,46 @@ struct MyCollectionListPage { | @@ -109,4 +131,46 @@ struct MyCollectionListPage { | ||
| 109 | } | 131 | } |
| 110 | }) | 132 | }) |
| 111 | } | 133 | } |
| 134 | + | ||
| 135 | + //数据处理 | ||
| 136 | + //单个选择 | ||
| 137 | + addCompDTO(isOn:boolean , compDTO: CompDTO){ | ||
| 138 | + compDTO.isSelect = isOn; | ||
| 139 | + if (isOn === true){ | ||
| 140 | + this.selectDatas.push(compDTO) | ||
| 141 | + }else { | ||
| 142 | + this.selectDatas.splice(this.selectDatas.indexOf(compDTO),1) | ||
| 143 | + } | ||
| 144 | + this.deleteNum = this.selectDatas.length | ||
| 145 | + } | ||
| 146 | + | ||
| 147 | + //全选 | ||
| 148 | + allSelectDatas(isOn:boolean){ | ||
| 149 | + let datas: CompDTO[] = []; | ||
| 150 | + for (let index = 0; index < this.allDatas.length; index++) { | ||
| 151 | + const compDTO = this.allDatas[index]; | ||
| 152 | + compDTO.isSelect = isOn | ||
| 153 | + datas.push(compDTO) | ||
| 154 | + } | ||
| 155 | + this.selectDatas = [] | ||
| 156 | + this.allDatas = [] | ||
| 157 | + if (isOn === true) { | ||
| 158 | + this.selectDatas.push(...datas) | ||
| 159 | + }else { | ||
| 160 | + this.selectDatas.splice(0,this.deleteNum) | ||
| 161 | + } | ||
| 162 | + this.allDatas.push(...datas) | ||
| 163 | + this.deleteNum = this.selectDatas.length | ||
| 164 | + } | ||
| 165 | + | ||
| 166 | + //删除 | ||
| 167 | + deleteDatas(){ | ||
| 168 | + for (let index = 0; index < this.selectDatas.length; index++) { | ||
| 169 | + const compDTO = this.allDatas[index]; | ||
| 170 | + this.allDatas.splice(this.selectDatas.indexOf(compDTO),1) | ||
| 171 | + } | ||
| 172 | + | ||
| 173 | + //重置删除状态 | ||
| 174 | + this.isEditState = false | ||
| 175 | + } | ||
| 112 | } | 176 | } |
sight_harmony/features/wdComponent/src/main/ets/components/reusable/CustomTitleAndEditUI.ets
0 → 100644
| 1 | +import router from '@ohos.router' | ||
| 2 | + | ||
| 3 | +@Component | ||
| 4 | +export struct CustomTitleAndEditUI { | ||
| 5 | + imgBack:boolean = true | ||
| 6 | + titleName:string = "默认标题" | ||
| 7 | + isDisplayButton:boolean = false | ||
| 8 | + @Consume isEditState:boolean | ||
| 9 | + editCallback: () => void = () => { | ||
| 10 | + } | ||
| 11 | + build() { | ||
| 12 | + RelativeContainer() { | ||
| 13 | + //标题栏目 | ||
| 14 | + if(this.imgBack){ | ||
| 15 | + Image($r('app.media.back_icon')) | ||
| 16 | + .width('46lpx') | ||
| 17 | + .height('46lpx') | ||
| 18 | + .objectFit(ImageFit.Auto) | ||
| 19 | + .interpolation(ImageInterpolation.High) | ||
| 20 | + .id("back_icon") | ||
| 21 | + .alignRules({ | ||
| 22 | + center: {anchor: "__container__", align: VerticalAlign.Center}, | ||
| 23 | + left: {anchor: "__container__", align: HorizontalAlign.Start} | ||
| 24 | + }) | ||
| 25 | + .margin({left:'31lpx'}) | ||
| 26 | + .onClick(()=>{ | ||
| 27 | + router.back() | ||
| 28 | + }) | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + Text(this.titleName) | ||
| 32 | + .height('42lpx') | ||
| 33 | + .maxLines(1) | ||
| 34 | + .id("title") | ||
| 35 | + .fontSize('35lpx') | ||
| 36 | + .fontWeight(400) | ||
| 37 | + .fontColor($r('app.color.color_222222')) | ||
| 38 | + .lineHeight('42lpx') | ||
| 39 | + .alignRules({ | ||
| 40 | + center: {anchor: "__container__", align: VerticalAlign.Center}, | ||
| 41 | + middle: {anchor: "__container__", align: HorizontalAlign.Center} | ||
| 42 | + }) | ||
| 43 | + | ||
| 44 | + if (this.isDisplayButton){ | ||
| 45 | + Button(this.isEditState === true?'取消':'编辑') | ||
| 46 | + .type(ButtonType.Normal) | ||
| 47 | + .fontColor($r('app.color.color_222222')) | ||
| 48 | + .backgroundColor(Color.White) | ||
| 49 | + .id("edit_Button") | ||
| 50 | + .alignRules({ | ||
| 51 | + center: {anchor: "__container__", align: VerticalAlign.Center}, | ||
| 52 | + right: {anchor: "__container__", align: HorizontalAlign.End} | ||
| 53 | + }) | ||
| 54 | + .margin({right:'31lpx'}) | ||
| 55 | + .onClick(()=>{ | ||
| 56 | + this.isEditState = !this.isEditState | ||
| 57 | + this.editCallback() | ||
| 58 | + }) | ||
| 59 | + } | ||
| 60 | + } | ||
| 61 | + .height('84lpx') | ||
| 62 | + .width('100%') | ||
| 63 | + .backgroundColor($r('app.color.white')) | ||
| 64 | + | ||
| 65 | + } | ||
| 66 | +} |
| @@ -37,10 +37,10 @@ export struct CustomTitleUI { | @@ -37,10 +37,10 @@ export struct CustomTitleUI { | ||
| 37 | center: {anchor: "__container__", align: VerticalAlign.Center}, | 37 | center: {anchor: "__container__", align: VerticalAlign.Center}, |
| 38 | middle: {anchor: "__container__", align: HorizontalAlign.Center} | 38 | middle: {anchor: "__container__", align: HorizontalAlign.Center} |
| 39 | }) | 39 | }) |
| 40 | + | ||
| 40 | } | 41 | } |
| 41 | .height('84lpx') | 42 | .height('84lpx') |
| 42 | .width('100%') | 43 | .width('100%') |
| 43 | .backgroundColor($r('app.color.white')) | 44 | .backgroundColor($r('app.color.white')) |
| 44 | - | ||
| 45 | } | 45 | } |
| 46 | } | 46 | } |
sight_harmony/features/wdComponent/src/main/ets/components/view/CustomBottomFuctionUI.ets
0 → 100644
| 1 | + | ||
| 2 | +@Component | ||
| 3 | +export struct CustomBottomFuctionUI { | ||
| 4 | + @Consume deleteNum: number | ||
| 5 | + @State isOn: boolean = false | ||
| 6 | + selectAllCallback: (isOn: boolean) => void = () => { | ||
| 7 | + } | ||
| 8 | + confirmCallback: () => void = () => { | ||
| 9 | + } | ||
| 10 | + build() { | ||
| 11 | + RelativeContainer(){ | ||
| 12 | + Row(){ | ||
| 13 | + Image(this.isOn?$r("app.media.MyCollection_selected_icon"):$r("app.media.MyCollection_unselected_icon")) | ||
| 14 | + .width('20') | ||
| 15 | + .height('20') | ||
| 16 | + .margin({right:'31lpx' }) | ||
| 17 | + | ||
| 18 | + Text(this.isOn?'取消':'全选') | ||
| 19 | + .fontColor($r('app.color.color_222222')) | ||
| 20 | + .backgroundColor(Color.White) | ||
| 21 | + } | ||
| 22 | + .id("allSelect_Button") | ||
| 23 | + .margin({left:'31lpx'}) | ||
| 24 | + .alignRules({ | ||
| 25 | + center: {anchor: "__container__", align: VerticalAlign.Center}, | ||
| 26 | + left: {anchor: "__container__", align: HorizontalAlign.Start} | ||
| 27 | + }) | ||
| 28 | + .onClick(()=>{ | ||
| 29 | + this.isOn = !this.isOn; | ||
| 30 | + this.selectAllCallback(this.isOn) | ||
| 31 | + }) | ||
| 32 | + | ||
| 33 | + | ||
| 34 | + Button('删除'+ (this.deleteNum === 0 ? '':'('+this.deleteNum.toString()+')')) | ||
| 35 | + .type(ButtonType.Normal) | ||
| 36 | + .fontColor(this.deleteNum === 0?$r('app.color.color_222222'):$r('app.color.color_ED2800')) | ||
| 37 | + .backgroundColor(Color.White) | ||
| 38 | + .id("delete_Button") | ||
| 39 | + .alignRules({ | ||
| 40 | + center: {anchor: "__container__", align: VerticalAlign.Center}, | ||
| 41 | + right: {anchor: "__container__", align: HorizontalAlign.End} | ||
| 42 | + }) | ||
| 43 | + .margin({right:'31lpx'}) | ||
| 44 | + .onClick(()=>{ | ||
| 45 | + this.confirmCallback() | ||
| 46 | + }) | ||
| 47 | + } | ||
| 48 | + .height('8%') | ||
| 49 | + .width('100%') | ||
| 50 | + .backgroundColor(Color.White) | ||
| 51 | + } | ||
| 52 | +} |
| 1 | + | ||
| 2 | +@Component | ||
| 3 | +export struct CustomSelectUI { | ||
| 4 | + @State isOn: boolean = false | ||
| 5 | + selectCallback: (isOn: boolean) => void = () => { | ||
| 6 | + } | ||
| 7 | + build() { | ||
| 8 | + Button(){ | ||
| 9 | + Image(this.isOn?$r("app.media.MyCollection_selected_icon"):$r("app.media.MyCollection_unselected_icon")) | ||
| 10 | + } | ||
| 11 | + .backgroundColor(Color.White) | ||
| 12 | + .type(ButtonType.Normal) | ||
| 13 | + .width('20') | ||
| 14 | + .height('20') | ||
| 15 | + .onClick(() => { | ||
| 16 | + this.isOn = !this.isOn; | ||
| 17 | + this.selectCallback(this.isOn) | ||
| 18 | + }) | ||
| 19 | + } | ||
| 20 | +} |
| @@ -13,6 +13,8 @@ export struct AreaPickerDialog { | @@ -13,6 +13,8 @@ export struct AreaPickerDialog { | ||
| 13 | title: string = '地区选择' | 13 | title: string = '地区选择' |
| 14 | @Provide dataSource: AreaListModel[] = [] | 14 | @Provide dataSource: AreaListModel[] = [] |
| 15 | result: JSON[] = []; | 15 | result: JSON[] = []; |
| 16 | + confirmCallback: (area:string) => void = () => { | ||
| 17 | + } | ||
| 16 | 18 | ||
| 17 | build() { | 19 | build() { |
| 18 | Column(){ | 20 | Column(){ |
| @@ -35,7 +37,7 @@ export struct AreaPickerDialog { | @@ -35,7 +37,7 @@ export struct AreaPickerDialog { | ||
| 35 | Button('确定',{type:ButtonType.Normal}) | 37 | Button('确定',{type:ButtonType.Normal}) |
| 36 | .onClick(()=> { | 38 | .onClick(()=> { |
| 37 | this.controller.close() | 39 | this.controller.close() |
| 38 | - Logger.info('area',this.currentFirst.label+this.currentSecondBean.label+this.currentThirdBean.label); | 40 | + this.confirmCallback(this.currentFirst.label+this.currentSecondBean.label+this.currentThirdBean.label); |
| 39 | }) | 41 | }) |
| 40 | .backgroundColor(0xffffff) | 42 | .backgroundColor(0xffffff) |
| 41 | .fontColor(Color.Blue) | 43 | .fontColor(Color.Blue) |
| @@ -11,32 +11,37 @@ export class EditListInfo{ | @@ -11,32 +11,37 @@ export class EditListInfo{ | ||
| 11 | } | 11 | } |
| 12 | } | 12 | } |
| 13 | 13 | ||
| 14 | -export interface EditInfoModel{ | 14 | +export class EditInfoModel{ |
| 15 | //头像 | 15 | //头像 |
| 16 | - headPhotoUrl:string | 16 | + headPhotoUrl:string = '' |
| 17 | //简介 | 17 | //简介 |
| 18 | - introduction:string | 18 | + introduction:string = '' |
| 19 | //城市 | 19 | //城市 |
| 20 | - city:string | 20 | + city:string = '' |
| 21 | //地区 | 21 | //地区 |
| 22 | - county:string | 22 | + county:string = '' |
| 23 | //生日 | 23 | //生日 |
| 24 | - birthday:string | 24 | + birthday:string = '' |
| 25 | //性别 | 25 | //性别 |
| 26 | - sex:number | 26 | + sex:string = '' |
| 27 | 27 | ||
| 28 | - airec:number | 28 | + airec:number = 0 |
| 29 | 29 | ||
| 30 | + constructor(headPhotoUrl?:string , introduction?:string,city?:string , county?:string,birthday?:string , sex?:string,airec?:number) { | ||
| 31 | + } | ||
| 30 | } | 32 | } |
| 31 | 33 | ||
| 32 | -export interface editModel{ | ||
| 33 | - userName:string | 34 | +export class editModel{ |
| 35 | + userName:string = '' | ||
| 36 | + | ||
| 37 | + userNameStatus:string = '' | ||
| 34 | 38 | ||
| 35 | - userNameStatus:string | 39 | + phone:string = '' |
| 36 | 40 | ||
| 37 | - phone:string | 41 | + headPhotoStatus:string = '' |
| 38 | 42 | ||
| 39 | - headPhotoStatus:string | 43 | + userExtend:EditInfoModel = new EditInfoModel() |
| 40 | 44 | ||
| 41 | - userExtend:EditInfoModel | 45 | + constructor(userName?:string , userNameStatus?:string,phone?:string , headPhotoStatus?:string,userExtend?:EditInfoModel) { |
| 46 | + } | ||
| 42 | } | 47 | } |
| @@ -30,11 +30,11 @@ class EditInfoViewModel { | @@ -30,11 +30,11 @@ class EditInfoViewModel { | ||
| 30 | 30 | ||
| 31 | getEditListInfo(item?:editModel):EditListInfo[]{ | 31 | getEditListInfo(item?:editModel):EditListInfo[]{ |
| 32 | this.editListData = [ | 32 | this.editListData = [ |
| 33 | - new EditListInfo('昵称',item&&item.userName?item.userName:'待完善'), | ||
| 34 | - new EditListInfo('简介',item&&item.userExtend.introduction?item.userExtend.introduction:'待完善'), | ||
| 35 | - new EditListInfo('地区',item&&item.userExtend.city?item.userExtend.city:'待完善'), | ||
| 36 | - new EditListInfo('生日',item&&item.userExtend.birthday?item.userExtend.birthday:'待完善'), | ||
| 37 | - new EditListInfo('性别',item&&item.userExtend.sex?item.userExtend.sex===1?'男':'女':'待完善'), | 33 | + new EditListInfo('昵称',item&&item.userName.length > 0?item.userName:'待完善'), |
| 34 | + new EditListInfo('简介',item&&item.userExtend.introduction.length > 0?item.userExtend.introduction:'待完善'), | ||
| 35 | + new EditListInfo('地区',item&&item.userExtend.city.length > 0?item.userExtend.city:'待完善'), | ||
| 36 | + new EditListInfo('生日',item&&item.userExtend.birthday.length > 0?item.userExtend.birthday:'待完善'), | ||
| 37 | + new EditListInfo('性别',item&&item.userExtend.sex.length > 0?(item.userExtend.sex=== '1'?'男':'女'):'待完善'), | ||
| 38 | ] | 38 | ] |
| 39 | return this.editListData | 39 | return this.editListData |
| 40 | } | 40 | } |
| @@ -61,7 +61,7 @@ class EditInfoViewModel { | @@ -61,7 +61,7 @@ class EditInfoViewModel { | ||
| 61 | let compRes: ResponseDTO<editModel> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<editModel>>(context,'userInfo.json'); | 61 | let compRes: ResponseDTO<editModel> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<editModel>>(context,'userInfo.json'); |
| 62 | if (!compRes || !compRes.data) { | 62 | if (!compRes || !compRes.data) { |
| 63 | Logger.info(TAG, `getAppointmentListDataLocal compRes is empty`); | 63 | Logger.info(TAG, `getAppointmentListDataLocal compRes is empty`); |
| 64 | - return {} as editModel | 64 | + return new editModel() |
| 65 | } | 65 | } |
| 66 | Logger.info(TAG, `getAppointmentListDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`); | 66 | Logger.info(TAG, `getAppointmentListDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`); |
| 67 | return compRes.data | 67 | return compRes.data |
-
Please register or login to post a comment