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-09-04 16:55:18 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
eab0169a943d0e6702d3064a98d170ce70009007
eab0169a
1 parent
b4411a04
feat:增加用户头像上传
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
20 deletions
sight_harmony/features/wdComponent/src/main/ets/components/page/EditUserInfoPage.ets
sight_harmony/features/wdComponent/src/main/ets/model/EditInfoModel.ets
sight_harmony/features/wdComponent/src/main/ets/viewmodel/EditInfoViewModel.ets
sight_harmony/features/wdComponent/src/main/ets/viewmodel/MineUserDetailItem.ets
sight_harmony/features/wdHwAbility/src/main/ets/aliOSS/OSSUploadManager.ets
sight_harmony/features/wdComponent/src/main/ets/components/page/EditUserInfoPage.ets
View file @
eab0169
...
...
@@ -16,6 +16,7 @@ import { SPHelper } from 'wdKit/Index';
import { SpConstants } from 'wdConstant/Index';
import { photoPickerUtils} from '../../utils/PhotoPickerUtils';
import { cameraPickerUtils } from '../../utils/CameraPickerUtils';
import { OSSConfigSceneType, OSSFileType, OSSUploadManager, UploadResourceParams } from 'wdHwAbility';
@Entry
@Component
...
...
@@ -102,18 +103,37 @@ struct EditUserInfoPage {
photoPickerUtils.getPhotoPicker(1).then(value => {
if (value['photoUris'].length > 0) {
this.headerImg = value['photoUris'][0]
this.photoCommit()
}
})
}else {
cameraPickerUtils.getCamera().then(value => {
if (value.length > 0) {
this.headerImg = value
this.photoCommit()
}
})
}
}
async photoCommit(){
if (this.headerImg.length > 0) {
try {
let results = await OSSUploadManager.sharedManager().uploadFile(this.headerImg,OSSConfigSceneType.userPhone,OSSFileType.image)
let photoUrl = results.ossFile??''
if (photoUrl.length > 0) {
this.currentUserInfo.headPhotoUrl = photoUrl
this.currentUserInfo.editDataType = WDEditDataModelType.WDEditDataModelType_head
this.updateEditModel()
}
} catch (exception) {
console.log('请求失败',JSON.stringify(exception))
}
}
}
aboutToAppear() {
let userType = SPHelper.default.getSync(SpConstants.USER_Type,"") as string
if (userType && userType.length > 0) {
...
...
@@ -145,30 +165,30 @@ struct EditUserInfoPage {
.height(84)
.borderRadius(42)
// if (this.headerImg.length === 0){
// Image('')
// .width('84')
// .height('84')
// .backgroundColor(Color.Gray)
// .opacity(0.7)
// .borderRadius(5)
// .borderRadius(42)
//
// Image($r('app.media.seletct_photo'))
// .width('30')
// .height('30')
// }
if (this.headerImg.length === 0){
Image('')
.width('84')
.height('84')
.backgroundColor(Color.Gray)
.opacity(0.7)
.borderRadius(5)
.borderRadius(42)
Image($r('app.media.seletct_photo'))
.width('30')
.height('30')
}
}.margin({top:20})
.onClick(()=>{
//
this.photoDialogController.open()
this.photoDialogController.open()
})
///目前不支持头像上传,暂时屏蔽
// Button('点击更换头像')
// .fontColor(Color.Gray)
// .fontSize(15)
// .backgroundColor(Color.White)
// .margin({top:10,bottom:20})
Button('点击更换头像')
.fontColor(Color.Gray)
.fontSize(15)
.backgroundColor(Color.White)
.margin({top:10,bottom:20})
List({}){
ForEach(this.listData,(item:EditListInfo,index:number) =>{
...
...
@@ -283,8 +303,10 @@ struct EditUserInfoPage {
EditInfoViewModel.queryAccountOwnerInfo(getContext(this)).then((editModel) => {
this.listData = []
if (editModel.userExtend?.headPhotoUrl) {
if (this.headerImg.length === 0) {
this.headerImg = editModel.userExtend.headPhotoUrl
}
}
this.currentUserInfo = editModel as editModel;
this.listData.push(...EditInfoViewModel.getEditListInfo(editModel))
});
...
...
@@ -295,7 +317,9 @@ struct EditUserInfoPage {
this.currentUserInfo.userExtend.introduction = peopleItem.introduction
this.currentUserInfo.userExtend.creatorId = peopleItem.creatorId
this.currentUserInfo.userName = peopleItem.userName
if (this.headerImg.length === 0) {
this.headerImg = peopleItem.headPhotoUrl
}
this.currentUserInfo.userType = Number(this.userType)
this.currentUserInfo.userExtend.districtCode = peopleItem.district
this.currentUserInfo.userExtend.cityCode = peopleItem.city
...
...
@@ -307,6 +331,7 @@ struct EditUserInfoPage {
}
getAreaList(){
if (this.dataSource.length > 0) return
EditInfoViewModel.getAreaList(getContext(this)).then((value) =>{
this.dataSource.push(...value)
this.getAreaIndex()
...
...
sight_harmony/features/wdComponent/src/main/ets/model/EditInfoModel.ets
View file @
eab0169
...
...
@@ -74,6 +74,8 @@ export class editModel{
}
export interface editModelParams {
headPhotoUrl?: string;
editContent?: string;
userName?: string;
...
...
sight_harmony/features/wdComponent/src/main/ets/viewmodel/EditInfoViewModel.ets
View file @
eab0169
...
...
@@ -142,6 +142,7 @@ class EditInfoViewModel {
if (item.userType === 1){
if (item.editDataType == WDEditDataModelType.WDEditDataModelType_head) {
this.params = { headPhotoUrl: item.headPhotoUrl }
} else if (item.editDataType == WDEditDataModelType.WDEditDataModelType_nickname) {
this.params = { userName: item.userName }
}
...
...
@@ -176,6 +177,7 @@ class EditInfoViewModel {
}else {
let url = ''
if (item.editDataType == WDEditDataModelType.WDEditDataModelType_head) {
this.params = { headPhotoUrl: item.headPhotoUrl}
url = '/api/rmrb-creator-user/c/rmrb-creator-user/creator/updateIcon'
} else if (item.editDataType == WDEditDataModelType.WDEditDataModelType_nickname) {
this.params = { name: item.userName}
...
...
sight_harmony/features/wdComponent/src/main/ets/viewmodel/MineUserDetailItem.ets
View file @
eab0169
...
...
@@ -13,6 +13,8 @@ export class MineUserDetailItem{
honoraryIcon = ""//荣誉称号 (优先)
avatarFrame:string = ""//最佳评论员头像框地址
province:string = ""
region:string = ""
}
\ No newline at end of file
...
...
sight_harmony/features/wdHwAbility/src/main/ets/aliOSS/OSSUploadManager.ets
View file @
eab0169
...
...
@@ -11,7 +11,7 @@ import { putObject } from './upload'
export enum OSSConfigSceneType {
feedback = "feedback",
userPhone = 'userPhone'
}
export enum OSSFileType {
...
...
Please
register
or
login
to post a comment