zhaojunkai
Showing 17 changed files with 381 additions and 71 deletions
... ... @@ -28,5 +28,6 @@ export interface CompDTO {
sortValue: number;
subType: string;
imageScale: number; // 封面图比例 1-4:3, 2-16:9, 3-3:2
audioDataList: AudioDTO[]
audioDataList: AudioDTO[];
isSelect: boolean;
}
\ No newline at end of file
... ...
import { CustomTitleUI } from '../reusable/CustomTitleUI'
import { CustomTitleAndEditUI } from '../reusable/CustomTitleAndEditUI'
import MyCollectionViewModel from '../../viewmodel/MyCollectionViewModel';
import PageModel from '../../viewmodel/PageModel';
import { CommonConstants, ViewType } from 'wdConstant'
... ... @@ -11,20 +11,31 @@ import LoadMoreLayout from './LoadMoreLayout'
import NoMoreLayout from './NoMoreLayout'
import { CompParser } from '../CompParser'
import CustomRefreshLoadLayout from './CustomRefreshLoadLayout';
import { listTouchEvent } from '../../utils/PullDownRefresh';
import { CustomSelectUI } from '../view/CustomSelectUI';
import { CustomBottomFuctionUI } from '../view/CustomBottomFuctionUI';
@Entry
@Component
struct BrowsingHistoryPage {
@State private browSingModel: PageModel = new PageModel()
isloading : boolean = false
@Provide isEditState:boolean = false
@State allDatas :CompDTO[] = [];
@State selectDatas :CompDTO[] = [];
@Provide deleteNum :number = 0;
@Provide isAllSelect:boolean = false
aboutToAppear(){
this.getData()
}
build() {
Column(){
CustomTitleUI({titleName:'浏览历史'})
CustomTitleAndEditUI({titleName:'浏览历史',isDisplayButton:true,editCallback:()=>{
this.allSelectDatas(false)
this.isAllSelect = false
this.selectDatas = []
this.deleteNum = 0
}})
if (this.browSingModel.viewType == ViewType.LOADING){
this.LoadingLayout()
}else if(this.browSingModel.viewType == ViewType.ERROR){
... ... @@ -34,16 +45,21 @@ struct BrowsingHistoryPage {
}else {
this.ListLayout()
}
if (this.isEditState){
CustomBottomFuctionUI({
selectAllCallback:(isAllSelect)=>{
this.allSelectDatas(isAllSelect)
},
confirmCallback:()=>{
this.deleteDatas()
}
})
.position({y:'92%'})
}
}
.width(CommonConstants.FULL_WIDTH)
.height(CommonConstants.FULL_HEIGHT)
.onTouch((event: TouchEvent | undefined) => {
if (event) {
if (this.browSingModel.viewType === ViewType.LOADED) {
listTouchEvent(this.browSingModel, event);
}
}
})
}
@Builder ListLayout() {
... ... @@ -56,11 +72,9 @@ struct BrowsingHistoryPage {
})
}
LazyForEach(this.browSingModel.compList, (compDTO: CompDTO, compIndex: number) => {
ForEach(this.allDatas, (compDTO: CompDTO, compIndex: number) => {
ListItem() {
Column() {
CompParser({ compDTO: compDTO, compIndex: compIndex });
}
this.newCompParser(compDTO,compIndex)
}
})
... ... @@ -79,6 +93,24 @@ struct BrowsingHistoryPage {
.height(CommonConstants.FULL_PARENT)
}
@Builder
newCompParser(compDTO: CompDTO, compIndex: number){
Row(){
if (this.isEditState){
CustomSelectUI({
isOn:compDTO.isSelect,
selectCallback:(isOn)=>{
this.addCompDTO(isOn,compDTO)
}
})
.margin({left:16})
}
Column() {
CompParser({ compDTO: compDTO, compIndex: compIndex })
}
}
}
@Builder LoadingLayout() {
CustomRefreshLoadLayout({ refreshBean: new RefreshLayoutBean(true,
$r('app.media.ic_pull_up_load'), $r('app.string.pull_up_load_text'), this.browSingModel.pullDownRefreshHeight) })
... ... @@ -89,7 +121,7 @@ struct BrowsingHistoryPage {
MyCollectionViewModel.newFetchMyCollectList(2,'1',this.browSingModel.currentPage,getContext(this)).then(pageDto => {
if (pageDto && pageDto.compList && pageDto.compList.length > 0) {
this.browSingModel.viewType = ViewType.LOADED;
this.browSingModel.compList.push(...pageDto.compList)
this.allDatas.push(...pageDto.compList)
if (pageDto.compList.length === this.browSingModel.pageSize) {
this.browSingModel.currentPage++;
this.browSingModel.hasMore = true;
... ... @@ -101,4 +133,49 @@ struct BrowsingHistoryPage {
}
})
}
}
\ No newline at end of file
//数据处理
//单个选择
addCompDTO(isOn:boolean , compDTO: CompDTO){
compDTO.isSelect = isOn;
if (isOn === true){
this.selectDatas.push(compDTO)
}else {
this.selectDatas.splice(this.selectDatas.indexOf(compDTO),1)
}
this.deleteNum = this.selectDatas.length
this.isAllSelect = this.deleteNum === this.allDatas.length?true:false;
}
//全选
allSelectDatas(isOn:boolean){
let datas: CompDTO[] = [];
for (let index = 0; index < this.allDatas.length; index++) {
const compDTO = this.allDatas[index];
compDTO.isSelect = isOn
datas.push(compDTO)
}
this.selectDatas = []
this.allDatas = []
if (isOn === true) {
this.selectDatas.push(...datas)
}else {
this.selectDatas.splice(0,this.deleteNum)
}
this.allDatas.push(...datas)
this.deleteNum = this.selectDatas.length
}
//删除
deleteDatas(){
for (let index = 0; index < this.selectDatas.length; index++) {
const compDTO = this.allDatas[index];
this.allDatas.splice(this.selectDatas.indexOf(compDTO),1)
}
//重置删除状态
this.isEditState = false
this.isAllSelect = false
}
}
... ...
import { CustomTitleUI } from '../reusable/CustomTitleUI';
import { EditListInfo } from '../../model/EditInfoModel';
import { EditListInfo, editModel } from '../../model/EditInfoModel';
import EditInfoViewModel from '../../viewmodel/EditInfoViewModel';
import { WDRouterPage, WDRouterRule } from 'wdRouter';
import {AreaPickerDialog} from '../view/areaPickerDialog/AreaPickerDialog'
import { AreaListModel } from '../../model/AreaListModel';
import router from '@ohos.router';
@Entry
@Component
... ... @@ -14,9 +12,15 @@ struct EditUserInfoPage {
@State listData: EditListInfo[] = []
@State headerImg: string = ''
@State dataSource: AreaListModel[] = []
@State currentUserInfo: editModel = new editModel()
dialogController: CustomDialogController = new CustomDialogController({
builder: AreaPickerDialog({dataSource:this.dataSource}),
builder: AreaPickerDialog({dataSource:this.dataSource,
confirmCallback:(area:string)=>{
this.currentUserInfo.userExtend.city = area;
this.updateEditModel()
}
}),
alignment: DialogAlignment.Bottom,
offset:{dx:0,dy:-20}
})
... ... @@ -109,25 +113,33 @@ struct EditUserInfoPage {
end:new Date(),
selected:new Date,
lunar:false,
// onAccept:(value:DatePickerResult) => {
//
// }
onAccept:(value:DatePickerResult) => {
let mon = value.month as number + 1
this.currentUserInfo.userExtend.birthday = value.year+'-'+mon.toString()+'-'+value.day;
this.updateEditModel()
}
})
}else if(i === 5){
TextPickerDialog.show({
range:['男','女'],
range:['女','男'],
selected:0,
// onAccept:(value:TextPickerResult) => {
//
// }
onAccept:(value:TextPickerResult) => {
this.currentUserInfo.userExtend.sex = value.index.toString();
this.updateEditModel()
}
})
}
})
}
updateEditModel(){
this.listData = []
this.listData.push(...EditInfoViewModel.getEditListInfo(this.currentUserInfo))
}
getAccountOwnerInfo(){
EditInfoViewModel.queryAccountOwnerInfo(1,getContext(this)).then((editModel) => {
this.headerImg = editModel.userExtend.headPhotoUrl
this.currentUserInfo = editModel;
this.listData.push(...EditInfoViewModel.getEditListInfo(editModel))
});
}
... ...
import { CustomTitleUI } from '../reusable/CustomTitleUI'
import { CustomTitleAndEditUI } from '../reusable/CustomTitleAndEditUI'
import MyCollectionViewModel from '../../viewmodel/MyCollectionViewModel';
import PageModel from '../../viewmodel/PageModel';
import { CommonConstants, ViewType } from 'wdConstant'
... ... @@ -11,20 +11,31 @@ import LoadMoreLayout from './LoadMoreLayout'
import NoMoreLayout from './NoMoreLayout'
import { CompParser } from '../CompParser'
import CustomRefreshLoadLayout from './CustomRefreshLoadLayout';
import { CustomSelectUI } from '../view/CustomSelectUI';
import { CustomBottomFuctionUI } from '../view/CustomBottomFuctionUI';
@Entry
@Component
struct MyCollectionListPage {
@State private browSingModel: PageModel = new PageModel()
isloading : boolean = false
@Provide isEditState:boolean = false
@State allDatas :CompDTO[] = [];
@State selectDatas :CompDTO[] = [];
@Provide deleteNum :number = 0;
@Provide isAllSelect:boolean = false
aboutToAppear(){
this.getData()
}
build() {
Column(){
CustomTitleUI({titleName:'我的收藏'})
CustomTitleAndEditUI({titleName:'我的收藏',isDisplayButton:true,editCallback:()=>{
this.allSelectDatas(false)
this.isAllSelect = false
this.selectDatas = []
this.deleteNum = 0
}})
if (this.browSingModel.viewType == ViewType.LOADING){
this.LoadingLayout()
}else if(this.browSingModel.viewType == ViewType.ERROR){
... ... @@ -34,6 +45,18 @@ struct MyCollectionListPage {
}else {
this.ListLayout()
}
if (this.isEditState){
CustomBottomFuctionUI({
selectAllCallback:(isAllSelect)=>{
this.allSelectDatas(isAllSelect)
},
confirmCallback:()=>{
this.deleteDatas()
}
})
.position({y:'92%'})
}
}
.width(CommonConstants.FULL_WIDTH)
.height(CommonConstants.FULL_HEIGHT)
... ... @@ -49,7 +72,7 @@ struct MyCollectionListPage {
})
}
LazyForEach(this.browSingModel.compList, (compDTO: CompDTO, compIndex: number) => {
ForEach(this.allDatas, (compDTO: CompDTO, compIndex: number) => {
ListItem() {
this.newCompParser(compDTO,compIndex)
}
... ... @@ -73,16 +96,17 @@ struct MyCollectionListPage {
@Builder
newCompParser(compDTO: CompDTO, compIndex: number){
Row(){
Button()
.type(ButtonType.Normal)
.width('20')
.height('20')
.backgroundColor('#ED2800')
.borderRadius(5)
.margin({left:16})
if (this.isEditState){
CustomSelectUI({
isOn:compDTO.isSelect,
selectCallback:(isOn)=>{
this.addCompDTO(isOn,compDTO)
}
})
.margin({left:16})
}
Column() {
CompParser({ compDTO: compDTO, compIndex: compIndex });
CompParser({ compDTO: compDTO, compIndex: compIndex })
}
}
}
... ... @@ -97,7 +121,7 @@ struct MyCollectionListPage {
MyCollectionViewModel.newFetchMyCollectList(1,'1',this.browSingModel.currentPage,getContext(this)).then(pageDto => {
if (pageDto && pageDto.compList && pageDto.compList.length > 0) {
this.browSingModel.viewType = ViewType.LOADED;
this.browSingModel.compList.push(...pageDto.compList)
this.allDatas.push(...pageDto.compList)
if (pageDto.compList.length === this.browSingModel.pageSize) {
this.browSingModel.currentPage++;
this.browSingModel.hasMore = true;
... ... @@ -109,4 +133,49 @@ struct MyCollectionListPage {
}
})
}
//数据处理
//单个选择
addCompDTO(isOn:boolean , compDTO: CompDTO){
compDTO.isSelect = isOn;
if (isOn === true){
this.selectDatas.push(compDTO)
}else {
this.selectDatas.splice(this.selectDatas.indexOf(compDTO),1)
}
this.deleteNum = this.selectDatas.length
this.isAllSelect = this.deleteNum === this.allDatas.length?true:false;
}
//全选
allSelectDatas(isOn:boolean){
let datas: CompDTO[] = [];
for (let index = 0; index < this.allDatas.length; index++) {
const compDTO = this.allDatas[index];
compDTO.isSelect = isOn
datas.push(compDTO)
}
this.selectDatas = []
this.allDatas = []
if (isOn === true) {
this.selectDatas.push(...datas)
}else {
this.selectDatas.splice(0,this.deleteNum)
}
this.allDatas.push(...datas)
this.deleteNum = this.selectDatas.length
}
//删除
deleteDatas(){
for (let index = 0; index < this.selectDatas.length; index++) {
const compDTO = this.allDatas[index];
this.allDatas.splice(this.selectDatas.indexOf(compDTO),1)
}
//重置删除状态
this.isEditState = false
this.isAllSelect = false
}
}
\ No newline at end of file
... ...
import router from '@ohos.router'
@Component
export struct CustomTitleAndEditUI {
imgBack:boolean = true
titleName:string = "默认标题"
isDisplayButton:boolean = false
@Consume isEditState:boolean
editCallback: () => void = () => {
}
build() {
RelativeContainer() {
//标题栏目
if(this.imgBack){
Image($r('app.media.back_icon'))
.width('46lpx')
.height('46lpx')
.objectFit(ImageFit.Auto)
.interpolation(ImageInterpolation.High)
.id("back_icon")
.alignRules({
center: {anchor: "__container__", align: VerticalAlign.Center},
left: {anchor: "__container__", align: HorizontalAlign.Start}
})
.margin({left:'31lpx'})
.onClick(()=>{
router.back()
})
}
Text(this.titleName)
.height('42lpx')
.maxLines(1)
.id("title")
.fontSize('35lpx')
.fontWeight(400)
.fontColor($r('app.color.color_222222'))
.lineHeight('42lpx')
.alignRules({
center: {anchor: "__container__", align: VerticalAlign.Center},
middle: {anchor: "__container__", align: HorizontalAlign.Center}
})
if (this.isDisplayButton){
Button(this.isEditState === true?'取消':'编辑')
.type(ButtonType.Normal)
.fontColor($r('app.color.color_222222'))
.backgroundColor(Color.White)
.id("edit_Button")
.alignRules({
center: {anchor: "__container__", align: VerticalAlign.Center},
right: {anchor: "__container__", align: HorizontalAlign.End}
})
.margin({right:'31lpx'})
.onClick(()=>{
this.isEditState = !this.isEditState
this.editCallback()
})
}
}
.height('84lpx')
.width('100%')
.backgroundColor($r('app.color.white'))
}
}
\ No newline at end of file
... ...
... ... @@ -37,10 +37,10 @@ export struct CustomTitleUI {
center: {anchor: "__container__", align: VerticalAlign.Center},
middle: {anchor: "__container__", align: HorizontalAlign.Center}
})
}
.height('84lpx')
.width('100%')
.backgroundColor($r('app.color.white'))
}
}
\ No newline at end of file
... ...
... ... @@ -24,6 +24,7 @@ export struct CompStyle_09 {
// 大图
Image(this.compDTO.operDataList[0].coverUrl)
.width('100%')
.borderRadius({topLeft: $r('app.float.image_border_radius'), topRight: $r('app.float.image_border_radius')})
// 时间线--后端返回三个,
Column(){
ForEach(this.compDTO.operDataList[0].slideShows, (item:slideShows, index:number) => {
... ... @@ -44,7 +45,7 @@ export struct CompStyle_09 {
.backgroundColor($r('app.color.color_F5F5F5'))
.width(CommonConstants.FULL_WIDTH)
.height(40)
.borderRadius(3)
.borderRadius($r('app.float.button_border_radius'))
.justifyContent(FlexAlign.Center)
.margin({top: 5})
}
... ... @@ -103,7 +104,7 @@ export struct CompStyle_09 {
Image(item.fullColumnImgUrls[0].url)
.width(90)
.height(60)
.borderRadius(4)
.borderRadius($r('app.float.image_border_radius'))
}
}
}
... ...
... ... @@ -26,6 +26,7 @@ export struct CompStyle_10 {
// 大图
Image(this.compDTO.operDataList[0] && this.compDTO.operDataList[0].coverUrl)
.width('100%')
.borderRadius({topLeft: $r('app.float.image_border_radius'), topRight: $r('app.float.image_border_radius')})
.onClick((event: ClickEvent) => {
ProcessUtils.processPage(this.compDTO?.operDataList[0])
})
... ... @@ -49,7 +50,7 @@ export struct CompStyle_10 {
.backgroundColor($r('app.color.color_F5F5F5'))
.width(CommonConstants.FULL_WIDTH)
.height(40)
.borderRadius(3)
.borderRadius($r('app.float.button_border_radius'))
.justifyContent(FlexAlign.Center)
.margin({top: 5})
.onClick((event: ClickEvent) => {
... ... @@ -105,7 +106,7 @@ export struct CompStyle_10 {
.width(117)
.height(78)
.objectFit(ImageFit.Cover)
.borderRadius(4)
.borderRadius($r('app.float.image_border_radius'))
.margin({left: 12})
}
}
... ...
@Component
export struct CustomBottomFuctionUI {
@Consume deleteNum: number
@Consume isAllSelect: boolean
selectAllCallback: (isOn: boolean) => void = () => {
}
confirmCallback: () => void = () => {
}
build() {
RelativeContainer(){
Row(){
Image(this.isAllSelect?$r("app.media.MyCollection_selected_icon"):$r("app.media.MyCollection_unselected_icon"))
.width('20')
.height('20')
.margin({right:'31lpx' })
Text(this.isAllSelect?'取消':'全选')
.fontColor($r('app.color.color_222222'))
.backgroundColor(Color.White)
}
.id("allSelect_Button")
.margin({left:'31lpx'})
.alignRules({
center: {anchor: "__container__", align: VerticalAlign.Center},
left: {anchor: "__container__", align: HorizontalAlign.Start}
})
.onClick(()=>{
this.isAllSelect = !this.isAllSelect;
this.selectAllCallback(this.isAllSelect)
})
Button('删除'+ (this.deleteNum === 0 ? '':'('+this.deleteNum.toString()+')'))
.type(ButtonType.Normal)
.fontColor(this.deleteNum === 0?$r('app.color.color_222222'):$r('app.color.color_ED2800'))
.backgroundColor(Color.White)
.id("delete_Button")
.alignRules({
center: {anchor: "__container__", align: VerticalAlign.Center},
right: {anchor: "__container__", align: HorizontalAlign.End}
})
.margin({right:'31lpx'})
.onClick(()=>{
this.confirmCallback()
})
}
.height('8%')
.width('100%')
.backgroundColor(Color.White)
}
}
\ No newline at end of file
... ...
@Component
export struct CustomSelectUI {
@State isOn: boolean = false
selectCallback: (isOn: boolean) => void = () => {
}
build() {
Button(){
Image(this.isOn?$r("app.media.MyCollection_selected_icon"):$r("app.media.MyCollection_unselected_icon"))
}
.backgroundColor(Color.White)
.type(ButtonType.Normal)
.width('20')
.height('20')
.onClick(() => {
this.isOn = !this.isOn;
this.selectCallback(this.isOn)
})
}
}
\ No newline at end of file
... ...
... ... @@ -47,7 +47,7 @@ export struct ZhGridLayoutComponent {
buildItemCard(item: ContentDTO) {
Column() {
Image(item.coverUrl)
.borderRadius(5)
.width(44)
.aspectRatio(1 / 1)
.margin(16)
Text(item.newsTitle)
... ...
... ... @@ -13,6 +13,8 @@ export struct AreaPickerDialog {
title: string = '地区选择'
@Provide dataSource: AreaListModel[] = []
result: JSON[] = [];
confirmCallback: (area:string) => void = () => {
}
build() {
Column(){
... ... @@ -35,7 +37,7 @@ export struct AreaPickerDialog {
Button('确定',{type:ButtonType.Normal})
.onClick(()=> {
this.controller.close()
Logger.info('area',this.currentFirst.label+this.currentSecondBean.label+this.currentThirdBean.label);
this.confirmCallback(this.currentFirst.label+this.currentSecondBean.label+this.currentThirdBean.label);
})
.backgroundColor(0xffffff)
.fontColor(Color.Blue)
... ...
... ... @@ -11,32 +11,37 @@ export class EditListInfo{
}
}
export interface EditInfoModel{
export class EditInfoModel{
//头像
headPhotoUrl:string
headPhotoUrl:string = ''
//简介
introduction:string
introduction:string = ''
//城市
city:string
city:string = ''
//地区
county:string
county:string = ''
//生日
birthday:string
birthday:string = ''
//性别
sex:number
sex:string = ''
airec:number
airec:number = 0
constructor(headPhotoUrl?:string , introduction?:string,city?:string , county?:string,birthday?:string , sex?:string,airec?:number) {
}
}
export interface editModel{
userName:string
export class editModel{
userName:string = ''
userNameStatus:string = ''
userNameStatus:string
phone:string = ''
phone:string
headPhotoStatus:string = ''
headPhotoStatus:string
userExtend:EditInfoModel = new EditInfoModel()
userExtend:EditInfoModel
constructor(userName?:string , userNameStatus?:string,phone?:string , headPhotoStatus?:string,userExtend?:EditInfoModel) {
}
}
\ No newline at end of file
... ...
... ... @@ -30,11 +30,11 @@ class EditInfoViewModel {
getEditListInfo(item?:editModel):EditListInfo[]{
this.editListData = [
new EditListInfo('昵称',item&&item.userName?item.userName:'待完善'),
new EditListInfo('简介',item&&item.userExtend.introduction?item.userExtend.introduction:'待完善'),
new EditListInfo('地区',item&&item.userExtend.city?item.userExtend.city:'待完善'),
new EditListInfo('生日',item&&item.userExtend.birthday?item.userExtend.birthday:'待完善'),
new EditListInfo('性别',item&&item.userExtend.sex?item.userExtend.sex===1?'男':'女':'待完善'),
new EditListInfo('昵称',item&&item.userName.length > 0?item.userName:'待完善'),
new EditListInfo('简介',item&&item.userExtend.introduction.length > 0?item.userExtend.introduction:'待完善'),
new EditListInfo('地区',item&&item.userExtend.city.length > 0?item.userExtend.city:'待完善'),
new EditListInfo('生日',item&&item.userExtend.birthday.length > 0?item.userExtend.birthday:'待完善'),
new EditListInfo('性别',item&&item.userExtend.sex.length > 0?(item.userExtend.sex=== '1'?'男':'女'):'待完善'),
]
return this.editListData
}
... ... @@ -61,7 +61,7 @@ class EditInfoViewModel {
let compRes: ResponseDTO<editModel> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<editModel>>(context,'userInfo.json');
if (!compRes || !compRes.data) {
Logger.info(TAG, `getAppointmentListDataLocal compRes is empty`);
return {} as editModel
return new editModel()
}
Logger.info(TAG, `getAppointmentListDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`);
return compRes.data
... ...
... ... @@ -82,7 +82,11 @@
},
{
"name": "image_border_radius",
"value": "8vp"
"value": "5vp"
},
{
"name": "button_border_radius",
"value": "3vp"
},
{
"name": "border_radius_6",
... ...