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
wangliang_wd
2024-07-17 16:02:31 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6af8cc7f869ecf9d75c8b577a5621980a2df8409
6af8cc7f
1 parent
27d11b95
feat:优化编辑资料
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
226 additions
and
28 deletions
sight_harmony/features/wdComponent/src/main/ets/components/MorningEveningPaper/MorningEveningPaperComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/comment/viewmodel/CommentViewModel.ets
sight_harmony/features/wdComponent/src/main/ets/components/page/EditUserInfoPage.ets
sight_harmony/features/wdComponent/src/main/ets/components/page/PeopleShipHomePage.ets
sight_harmony/features/wdComponent/src/main/ets/components/view/areaPickerDialog/CustomDialogUI.ets
sight_harmony/features/wdComponent/src/main/ets/model/EditInfoModel.ets
sight_harmony/features/wdComponent/src/main/ets/utils/ImageUtils.ets
sight_harmony/features/wdComponent/src/main/ets/viewmodel/EditInfoViewModel.ets
sight_harmony/features/wdComponent/src/main/ets/components/MorningEveningPaper/MorningEveningPaperComponent.ets
View file @
6af8cc7
...
...
@@ -245,11 +245,11 @@ export struct MorningEveningPaperComponent {
// rgb = ColorUtils.hsv2rgb(hsv);
// this.mixedBgColor = "#" + rgb.red.toString(16) + rgb.green.toString(16) + rgb.blue.toString(16);
effectKit.createColorPicker(pixelMap, (err, colorPicker) => {
let color = colorPicker.get
MainColorSync
();
let color = colorPicker.get
LargestProportionColor
();
console.log(TAG, "compInfoBean compStyle = " + color)
// color = ColorUtils.getMorningEveningPaperRgb({red:color.red,green:color.green,blue:color.blue,alpha:color.alpha})
// 将取色器选取的color示例转换为十六进制颜色代码
this.mixedBgColor = "#" + color.alpha.toString(16) + color.red.toString(16)
+ color.green.toString(16) + color.blue.toString(16
);
this.mixedBgColor = "#" + color.alpha.toString(16) + color.red.toString(16)
.padStart(2,'0') + color.green.toString(16).padStart(2,'0') + color.blue.toString(16).padStart(2,'0'
);
console.log(TAG, "compInfoBean compStyle = " + this.mixedBgColor)
});
}
...
...
sight_harmony/features/wdComponent/src/main/ets/components/comment/viewmodel/CommentViewModel.ets
View file @
6af8cc7
...
...
@@ -484,7 +484,8 @@ class CommentViewModel {
return false
}
jumpToAccountPage(commentItem: commentItemModel, beforeJump: () => void = () => {}) {
async jumpToAccountPage(commentItem: commentItemModel, beforeJump: () => void = () => {}) {
let userid = await SPHelper.default.get(SpConstants.USER_ID,"")
let url = HttpUrlUtils.getOtherUserDetailDataUrl()
let item : Record<string, string >= {}
...
...
@@ -510,7 +511,11 @@ class CommentViewModel {
beforeJump()
if (result.data.userType === "1") { // 普通用户
let params: Record<string, string> = {'userId': result.data.userId};
if (userid && userid == result.data.userId) {
WDRouterRule.jumpWithPage(WDRouterPage.mineHomePage,params)
}else {
WDRouterRule.jumpWithPage(WDRouterPage.otherNormalUserHomePagePage,params)
}
} else { // 非普通用户
ProcessUtils.gotoPeopleShipHomePage(result.data.creatorId)
}
...
...
sight_harmony/features/wdComponent/src/main/ets/components/page/EditUserInfoPage.ets
View file @
6af8cc7
...
...
@@ -6,22 +6,38 @@ import { WDRouterPage, WDRouterRule } from 'wdRouter';
import {AreaPickerDialog} from '../view/areaPickerDialog/AreaPickerDialog'
import {EditUserInfoCustomDialog} from '../view/areaPickerDialog/EditUserInfoCustomDialog'
import {EditUserSexCustomDialog} from '../view/areaPickerDialog/EditUserSexCustomDialog'
import { AreaListManageModel, AreaListModel } from '../../model/AreaListModel';
import {CustomDialogUI} from '../view/areaPickerDialog/CustomDialogUI'
import {AreaListModel } from '../../model/AreaListModel';
import router from '@ohos.router';
import TrackingPageBrowseUtils from '../../utils/TrackingPageBrowseUtils'
import { TrackConstants } from 'wdTracking/Index';
import { window } from '@kit.ArkUI';
import { SPHelper } from 'wdKit/Index';
import { SpConstants } from 'wdConstant/Index';
import { abilityAccessCtrl, common, Permissions } from '@kit.AbilityKit';
import { picker } from '@kit.CoreFileKit';
import { camera, cameraPicker } from '@kit.CameraKit';
import { BusinessError } from '@kit.BasicServicesKit';
let mContext = getContext(this) as common.Context;
const PERMISSIONS: Array<Permissions> = [
'ohos.permission.READ_IMAGEVIDEO',
'ohos.permission.WRITE_IMAGEVIDEO'
];
@Entry
@Component
struct EditUserInfoPage {
@State listData: EditListInfo[] = []
@State headerImg: string = ''
@State dataSource: AreaListModel[] = []
@State currentUserInfo: editModel =
new editModel()
@State currentUserInfo: editModel =
{} as editModel
@State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0
@State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0
userType:string = "1"
@State firstSelect:number = 0
@State secondSelect:number = 0
@State thirdSelect:number = 0
...
...
@@ -47,8 +63,8 @@ struct EditUserInfoPage {
builder: EditUserInfoCustomDialog({
confirmCallback:(selectDate:Date)=>{
let mon = selectDate.getUTCMonth() as number + 1
let monStr = mon < 10? '0'+mon.toString():mon.toString();
let dayStr = selectDate.getUTCDate() as number < 10? '0'+selectDate.getUTCDate():selectDate.getUTCDate();
let monStr = mon.toString().padStart(2,'0')
let dayStr = selectDate.getUTCDate().toString().padStart(2,'0')
this.currentUserInfo.userExtend.birthday = selectDate.getUTCFullYear()+'-'+monStr+'-'+dayStr;
this.currentUserInfo.editDataType = WDEditDataModelType.WDEditDataModelType_birthday
this.updateEditModel()
...
...
@@ -73,7 +89,64 @@ struct EditUserInfoPage {
closeAnimation:{duration:0}
})
photoDialogController: CustomDialogController = new CustomDialogController({
builder: CustomDialogUI({
itemData:['相册','拍照'],
confirmCallback:(index)=>{
if (index === 0) {
this.getPhotoPicker()
}else {
this.getCamera()
}
}
}),
alignment: DialogAlignment.Bottom,
customStyle: true,
closeAnimation:{duration:0}
})
async getPhotoPicker(){
///权限查询
const context = getContext(this) as common.UIAbilityContext;
const atManager = abilityAccessCtrl.createAtManager();
await atManager.requestPermissionsFromUser(context, PERMISSIONS);
let PhotoSelectOptions = new picker.PhotoSelectOptions();
PhotoSelectOptions.MIMEType = picker.PhotoViewMIMETypes.IMAGE_TYPE; // 过滤选择媒体文件类型
PhotoSelectOptions.maxSelectNumber = 1; // 选择媒体文件的最大数目
let photoPicker = new picker.PhotoViewPicker(); // 使用图库选择器对象前,需要先创建PhotoViewPicker实例
photoPicker.select(PhotoSelectOptions).then((PhotoSelectResult) => {
if (PhotoSelectResult !== null && PhotoSelectResult !==
undefined) {
// 接口采用callback异步返回形式,返回PhotoSelectResult对象,故进行下一步操作前要先判断是否已经成功返回PhotoSelectResult对象了
this.headerImg = PhotoSelectResult['photoUris'][0]
}
})
}
async getCamera(){
try {
let pickerProfile: cameraPicker.PickerProfile = {
cameraPosition: camera.CameraPosition.CAMERA_POSITION_BACK
};
let pickerResult: cameraPicker.PickerResult = await cameraPicker.pick(mContext,
[cameraPicker.PickerMediaType.PHOTO, cameraPicker.PickerMediaType.VIDEO], pickerProfile);
if (pickerResult['resultCode'] === 0) {
this.headerImg = pickerResult['resultUri']
}
console.log("the pick pickerResult is:" + JSON.stringify(pickerResult));
} catch (error) {
let err = error as BusinessError;
console.error(`the pick call failed. error code: ${err.code}`);
}
}
aboutToAppear() {
let userType = SPHelper.default.getSync(SpConstants.USER_Type,"") as string
if (userType && userType.length > 0) {
this.userType = userType
}
this.getAccountOwnerInfo()
this.getAreaList()
}
...
...
@@ -100,7 +173,6 @@ struct EditUserInfoPage {
.height(84)
.borderRadius(42)
if (this.headerImg.length === 0){
Image('')
.width('84')
...
...
@@ -114,14 +186,17 @@ struct EditUserInfoPage {
.width('30')
.height('30')
}
}.margin({top:20,bottom:40})
}.margin({top:20})
.onClick(()=>{
this.photoDialogController.open()
})
///目前不支持头像上传,暂时屏蔽
// Button('点击更换头像')
// .fontColor(Color.Gray)
// .fontSize(15)
// .backgroundColor(Color.White)
// .margin(20)
Button('点击更换头像')
.fontColor(Color.Gray)
.fontSize(15)
.backgroundColor(Color.White)
.margin({top:10,bottom:20})
List({}){
ForEach(this.listData,(item:EditListInfo,index:number) =>{
...
...
@@ -226,16 +301,32 @@ struct EditUserInfoPage {
this.getAccountOwnerInfo()
})
}
getAccountOwnerInfo(){
EditInfoViewModel.queryAccountOwnerInfo(1,getContext(this)).then((editModel) => {
async getAccountOwnerInfo(){
if (this.userType === '1') {
EditInfoViewModel.queryAccountOwnerInfo(getContext(this)).then((editModel) => {
this.listData = []
if (editModel.userExtend
.headPhotoUrl) {
if (editModel.userExtend?
.headPhotoUrl) {
this.headerImg = editModel.userExtend.headPhotoUrl
}
this.currentUserInfo = editModel as editModel;
this.listData.push(...EditInfoViewModel.getEditListInfo(editModel))
});
}else {
EditInfoViewModel.queryPeopleAccountOwnerInfo(getContext(this)).then((peopleItem) => {
EditInfoViewModel.queryAccountOwnerInfo(getContext(this)).then((editM) => {
this.listData = []
editM.userExtend.introduction = peopleItem.introduction
editM.userName = peopleItem.userName
this.headerImg = peopleItem.headPhotoUrl
this.currentUserInfo = editM as editModel;
this.listData.push(...EditInfoViewModel.getEditListInfo(editM))
});
});
}
}
getAreaList(){
EditInfoViewModel.getAreaList(getContext(this)).then((value) =>{
this.dataSource.push(...value)
...
...
sight_harmony/features/wdComponent/src/main/ets/components/page/PeopleShipHomePage.ets
View file @
6af8cc7
...
...
@@ -68,7 +68,7 @@ struct PeopleShipHomePage {
Image($r('app.media.home_page_bg'))
.width('100%')
.height('120vp')
.objectFit(ImageFit.
Auto
)
.objectFit(ImageFit.
Fill
)
.objectRepeat(ImageRepeat.NoRepeat)
.backgroundColor(Color.White)
.visibility(this.isLoading ? Visibility.None : Visibility.Visible)
...
...
sight_harmony/features/wdComponent/src/main/ets/components/view/areaPickerDialog/CustomDialogUI.ets
0 → 100644
View file @
6af8cc7
@CustomDialog
export struct CustomDialogUI {
itemData:string[] = []
controller: CustomDialogController
confirmCallback: (selectIndex:number) => void = () => {
}
build() {
Column(){
List({}){
ForEach(this.itemData,(item:string,index:number) =>{
ListItem(){
Column(){
Button(item,{type:ButtonType.Normal}).height(45).width('100%').fontSize(14).fontColor('#222222').backgroundColor(0xffffff)
.onClick(()=>{
this.confirmCallback(index)
this.controller.close()
})
Divider()
.color('#f5f5f5')
.width('100%')
.strokeWidth(1)
}
}
}
)
}
Divider()
.color('#f5f5f5')
.width('100%')
.strokeWidth(4)
Button('取消',{type:ButtonType.Normal}).height(80).width('100%').fontSize(14).fontColor('#222222').backgroundColor(0xffffff)
.onClick(()=>{
this.controller.close()
})
}.height(176).width('100%').backgroundColor(Color.White)
}
}
\ No newline at end of file
...
...
sight_harmony/features/wdComponent/src/main/ets/model/EditInfoModel.ets
View file @
6af8cc7
...
...
@@ -44,8 +44,6 @@ export class EditInfoModel{
airec:number = 0
constructor(headPhotoUrl?:string , introduction?:string,city?:string , county?:string,birthday?:string , sex?:number,airec?:number) {
}
}
export class editModel{
...
...
@@ -53,16 +51,20 @@ export class editModel{
userNameStatus:string = ''
userType:number = 1
phone:string = ''
introduction:string = ''
headPhotoUrl:string = ''
headPhotoStatus:string = ''
userExtend:EditInfoModel = new EditInfoModel()
editDataType:number = WDEditDataModelType.WDEditDataModelType_default
constructor(userName?:string , userNameStatus?:string,phone?:string , headPhotoStatus?:string,userExtend?:EditInfoModel,editDataType?:number) {
}
}
export interface editModelParams {
...
...
@@ -97,3 +99,28 @@ export interface editItem{
timestamp:number
}
export interface peopleItem{
code:number
data:peopleItemModel
message:string
success:boolean
timestamp:number
}
export class peopleItemModel{
userName:string = ''
introduction:string = ''
headPhotoUrl:string = ''
userType:number = 1
}
\ No newline at end of file
...
...
sight_harmony/features/wdComponent/src/main/ets/utils/ImageUtils.ets
View file @
6af8cc7
...
...
@@ -21,8 +21,8 @@ import { BusinessError } from '@kit.BasicServicesKit';
import ResponseCode from '@ohos.net.http';
// const resourceMgs: resourceManager.ResourceManager = getContext(this).resourceManager;
const PIXEL_MAP_SIZE_WIDTH: number = 40;
const PIXEL_MAP_SIZE_HEIGHT: number = 40;
const PIXEL_MAP_SIZE_WIDTH: number = 80;
const PIXEL_MAP_SIZE_HEIGHT: number = 80;
/**
* 图片转换为PixelMap对象
...
...
sight_harmony/features/wdComponent/src/main/ets/viewmodel/EditInfoViewModel.ets
View file @
6af8cc7
import {
editItem,
EditListInfo, editModel, editModelParams, WDEditDataModelType } from '../model/EditInfoModel';
EditListInfo, editModel, editModelParams,
peopleItem,
peopleItemModel,
WDEditDataModelType } from '../model/EditInfoModel';
import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork';
import { Logger, ResourcesUtils } from 'wdKit';
import { AreaListManageModel, AreaListModel,AreaListData } from '../model/AreaListModel';
...
...
@@ -36,19 +39,46 @@ class EditInfoViewModel {
getEditListInfo(item?:editModel):EditListInfo[]{
if (item?.userType === 1) {
this.editListData = [
new EditListInfo('昵称',item&&item.userName.length > 0?item.userName:'待完善'),
new EditListInfo('简介',item&&item.userExtend.introduction?item.userExtend.introduction:'待完善'),
new EditListInfo('地区',item&&item.userExtend.address?item.userExtend.address:'待完善'),
new EditListInfo('生日',item&&item.userExtend.birthday?item.userExtend.birthday:'待完善'),
new EditListInfo('性别',item?(item.userExtend.sex === 0?'待完善':(item.userExtend.sex === 1?'男':'女')):'待完善'),]
}else {
this.editListData = [
new EditListInfo('昵称',item&&item.userName.length > 0?item.userName:'待完善'),
new EditListInfo('简介',item&&item.userExtend.introduction?item.userExtend.introduction:'待完善'),
new EditListInfo('地区',item&&item.userExtend.address?item.userExtend.address:'待完善')]
}
return this.editListData
}
///1普通用户
queryAccountOwnerInfo(userType:number, context: Context):PromiseLike<editModel>{
queryAccountOwnerInfo(context: Context):PromiseLike<editModel>{
return new Promise(((success, error) => {
this.BaseGetRequest(HttpUrlUtils.APPOINTMENT_QueryUserDetail_PATH).then((editDTO:editItem) =>{
if (editDTO.code == 0) {
success(editDTO.data)
}else {
// success(this.GetqueryAccountOwnerLocal(context))
}
}).catch((error: Error) => {
Logger.info(TAG,'queryAccountOwnerInfo','EditInfoViewModel')
// success(this.GetqueryAccountOwnerLocal(context))
})
}))
}
BasePeopleGetRequest(requestUrl:string){
requestUrl = HttpUrlUtils.getHost() + requestUrl
return WDHttp.get<peopleItem>(requestUrl)
}
queryPeopleAccountOwnerInfo(context: Context):PromiseLike<peopleItemModel>{
return new Promise(((success, error) => {
this.Base
GetRequest(userType == 1?HttpUrlUtils.APPOINTMENT_QueryUserDetail_PATH:HttpUrlUtils.APPOINTMENT_AccountOwner_PATH).then((editDTO:edit
Item) =>{
this.Base
PeopleGetRequest(HttpUrlUtils.APPOINTMENT_AccountOwner_PATH).then((editDTO:people
Item) =>{
if (editDTO.code == 0) {
success(editDTO.data)
}else {
...
...
@@ -87,6 +117,12 @@ class EditInfoViewModel {
})
}
getLocalAreaList(context: Context):PromiseLike<AreaListModel[]>{
return new Promise((success, error) => {
success(this.getAreaListLocal(context))
})
}
async getAreaListLocal(context: Context): Promise<AreaListModel[]> {
Logger.info(TAG, `getBottomNavDataMock start`);
let compRes: ResponseDTO<AreaListModel[]> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<AreaListModel[]>>(context,'areaList_data.json');
...
...
Please
register
or
login
to post a comment