Showing
5 changed files
with
51 additions
and
20 deletions
| @@ -16,6 +16,7 @@ import { SPHelper } from 'wdKit/Index'; | @@ -16,6 +16,7 @@ import { SPHelper } from 'wdKit/Index'; | ||
| 16 | import { SpConstants } from 'wdConstant/Index'; | 16 | import { SpConstants } from 'wdConstant/Index'; |
| 17 | import { photoPickerUtils} from '../../utils/PhotoPickerUtils'; | 17 | import { photoPickerUtils} from '../../utils/PhotoPickerUtils'; |
| 18 | import { cameraPickerUtils } from '../../utils/CameraPickerUtils'; | 18 | import { cameraPickerUtils } from '../../utils/CameraPickerUtils'; |
| 19 | +import { OSSConfigSceneType, OSSFileType, OSSUploadManager, UploadResourceParams } from 'wdHwAbility'; | ||
| 19 | 20 | ||
| 20 | @Entry | 21 | @Entry |
| 21 | @Component | 22 | @Component |
| @@ -102,18 +103,37 @@ struct EditUserInfoPage { | @@ -102,18 +103,37 @@ struct EditUserInfoPage { | ||
| 102 | photoPickerUtils.getPhotoPicker(1).then(value => { | 103 | photoPickerUtils.getPhotoPicker(1).then(value => { |
| 103 | if (value['photoUris'].length > 0) { | 104 | if (value['photoUris'].length > 0) { |
| 104 | this.headerImg = value['photoUris'][0] | 105 | this.headerImg = value['photoUris'][0] |
| 106 | + this.photoCommit() | ||
| 105 | } | 107 | } |
| 106 | }) | 108 | }) |
| 107 | }else { | 109 | }else { |
| 108 | cameraPickerUtils.getCamera().then(value => { | 110 | cameraPickerUtils.getCamera().then(value => { |
| 109 | if (value.length > 0) { | 111 | if (value.length > 0) { |
| 110 | this.headerImg = value | 112 | this.headerImg = value |
| 113 | + this.photoCommit() | ||
| 111 | } | 114 | } |
| 112 | }) | 115 | }) |
| 113 | } | 116 | } |
| 114 | } | 117 | } |
| 115 | 118 | ||
| 116 | 119 | ||
| 120 | + async photoCommit(){ | ||
| 121 | + if (this.headerImg.length > 0) { | ||
| 122 | + try { | ||
| 123 | + let results = await OSSUploadManager.sharedManager().uploadFile(this.headerImg,OSSConfigSceneType.userPhone,OSSFileType.image) | ||
| 124 | + let photoUrl = results.ossFile??'' | ||
| 125 | + if (photoUrl.length > 0) { | ||
| 126 | + this.currentUserInfo.headPhotoUrl = photoUrl | ||
| 127 | + this.currentUserInfo.editDataType = WDEditDataModelType.WDEditDataModelType_head | ||
| 128 | + this.updateEditModel() | ||
| 129 | + } | ||
| 130 | + } catch (exception) { | ||
| 131 | + console.log('请求失败',JSON.stringify(exception)) | ||
| 132 | + } | ||
| 133 | + } | ||
| 134 | + } | ||
| 135 | + | ||
| 136 | + | ||
| 117 | aboutToAppear() { | 137 | aboutToAppear() { |
| 118 | let userType = SPHelper.default.getSync(SpConstants.USER_Type,"") as string | 138 | let userType = SPHelper.default.getSync(SpConstants.USER_Type,"") as string |
| 119 | if (userType && userType.length > 0) { | 139 | if (userType && userType.length > 0) { |
| @@ -145,30 +165,30 @@ struct EditUserInfoPage { | @@ -145,30 +165,30 @@ struct EditUserInfoPage { | ||
| 145 | .height(84) | 165 | .height(84) |
| 146 | .borderRadius(42) | 166 | .borderRadius(42) |
| 147 | 167 | ||
| 148 | - // if (this.headerImg.length === 0){ | ||
| 149 | - // Image('') | ||
| 150 | - // .width('84') | ||
| 151 | - // .height('84') | ||
| 152 | - // .backgroundColor(Color.Gray) | ||
| 153 | - // .opacity(0.7) | ||
| 154 | - // .borderRadius(5) | ||
| 155 | - // .borderRadius(42) | ||
| 156 | - // | ||
| 157 | - // Image($r('app.media.seletct_photo')) | ||
| 158 | - // .width('30') | ||
| 159 | - // .height('30') | ||
| 160 | - // } | 168 | + if (this.headerImg.length === 0){ |
| 169 | + Image('') | ||
| 170 | + .width('84') | ||
| 171 | + .height('84') | ||
| 172 | + .backgroundColor(Color.Gray) | ||
| 173 | + .opacity(0.7) | ||
| 174 | + .borderRadius(5) | ||
| 175 | + .borderRadius(42) | ||
| 176 | + | ||
| 177 | + Image($r('app.media.seletct_photo')) | ||
| 178 | + .width('30') | ||
| 179 | + .height('30') | ||
| 180 | + } | ||
| 161 | }.margin({top:20}) | 181 | }.margin({top:20}) |
| 162 | .onClick(()=>{ | 182 | .onClick(()=>{ |
| 163 | - // this.photoDialogController.open() | 183 | + this.photoDialogController.open() |
| 164 | }) | 184 | }) |
| 165 | 185 | ||
| 166 | ///目前不支持头像上传,暂时屏蔽 | 186 | ///目前不支持头像上传,暂时屏蔽 |
| 167 | - // Button('点击更换头像') | ||
| 168 | - // .fontColor(Color.Gray) | ||
| 169 | - // .fontSize(15) | ||
| 170 | - // .backgroundColor(Color.White) | ||
| 171 | - // .margin({top:10,bottom:20}) | 187 | + Button('点击更换头像') |
| 188 | + .fontColor(Color.Gray) | ||
| 189 | + .fontSize(15) | ||
| 190 | + .backgroundColor(Color.White) | ||
| 191 | + .margin({top:10,bottom:20}) | ||
| 172 | 192 | ||
| 173 | List({}){ | 193 | List({}){ |
| 174 | ForEach(this.listData,(item:EditListInfo,index:number) =>{ | 194 | ForEach(this.listData,(item:EditListInfo,index:number) =>{ |
| @@ -283,8 +303,10 @@ struct EditUserInfoPage { | @@ -283,8 +303,10 @@ struct EditUserInfoPage { | ||
| 283 | EditInfoViewModel.queryAccountOwnerInfo(getContext(this)).then((editModel) => { | 303 | EditInfoViewModel.queryAccountOwnerInfo(getContext(this)).then((editModel) => { |
| 284 | this.listData = [] | 304 | this.listData = [] |
| 285 | if (editModel.userExtend?.headPhotoUrl) { | 305 | if (editModel.userExtend?.headPhotoUrl) { |
| 306 | + if (this.headerImg.length === 0) { | ||
| 286 | this.headerImg = editModel.userExtend.headPhotoUrl | 307 | this.headerImg = editModel.userExtend.headPhotoUrl |
| 287 | } | 308 | } |
| 309 | + } | ||
| 288 | this.currentUserInfo = editModel as editModel; | 310 | this.currentUserInfo = editModel as editModel; |
| 289 | this.listData.push(...EditInfoViewModel.getEditListInfo(editModel)) | 311 | this.listData.push(...EditInfoViewModel.getEditListInfo(editModel)) |
| 290 | }); | 312 | }); |
| @@ -295,7 +317,9 @@ struct EditUserInfoPage { | @@ -295,7 +317,9 @@ struct EditUserInfoPage { | ||
| 295 | this.currentUserInfo.userExtend.introduction = peopleItem.introduction | 317 | this.currentUserInfo.userExtend.introduction = peopleItem.introduction |
| 296 | this.currentUserInfo.userExtend.creatorId = peopleItem.creatorId | 318 | this.currentUserInfo.userExtend.creatorId = peopleItem.creatorId |
| 297 | this.currentUserInfo.userName = peopleItem.userName | 319 | this.currentUserInfo.userName = peopleItem.userName |
| 320 | + if (this.headerImg.length === 0) { | ||
| 298 | this.headerImg = peopleItem.headPhotoUrl | 321 | this.headerImg = peopleItem.headPhotoUrl |
| 322 | + } | ||
| 299 | this.currentUserInfo.userType = Number(this.userType) | 323 | this.currentUserInfo.userType = Number(this.userType) |
| 300 | this.currentUserInfo.userExtend.districtCode = peopleItem.district | 324 | this.currentUserInfo.userExtend.districtCode = peopleItem.district |
| 301 | this.currentUserInfo.userExtend.cityCode = peopleItem.city | 325 | this.currentUserInfo.userExtend.cityCode = peopleItem.city |
| @@ -307,6 +331,7 @@ struct EditUserInfoPage { | @@ -307,6 +331,7 @@ struct EditUserInfoPage { | ||
| 307 | } | 331 | } |
| 308 | 332 | ||
| 309 | getAreaList(){ | 333 | getAreaList(){ |
| 334 | + if (this.dataSource.length > 0) return | ||
| 310 | EditInfoViewModel.getAreaList(getContext(this)).then((value) =>{ | 335 | EditInfoViewModel.getAreaList(getContext(this)).then((value) =>{ |
| 311 | this.dataSource.push(...value) | 336 | this.dataSource.push(...value) |
| 312 | this.getAreaIndex() | 337 | this.getAreaIndex() |
| @@ -74,6 +74,8 @@ export class editModel{ | @@ -74,6 +74,8 @@ export class editModel{ | ||
| 74 | } | 74 | } |
| 75 | 75 | ||
| 76 | export interface editModelParams { | 76 | export interface editModelParams { |
| 77 | + headPhotoUrl?: string; | ||
| 78 | + | ||
| 77 | editContent?: string; | 79 | editContent?: string; |
| 78 | 80 | ||
| 79 | userName?: string; | 81 | userName?: string; |
| @@ -142,6 +142,7 @@ class EditInfoViewModel { | @@ -142,6 +142,7 @@ class EditInfoViewModel { | ||
| 142 | 142 | ||
| 143 | if (item.userType === 1){ | 143 | if (item.userType === 1){ |
| 144 | if (item.editDataType == WDEditDataModelType.WDEditDataModelType_head) { | 144 | if (item.editDataType == WDEditDataModelType.WDEditDataModelType_head) { |
| 145 | + this.params = { headPhotoUrl: item.headPhotoUrl } | ||
| 145 | } else if (item.editDataType == WDEditDataModelType.WDEditDataModelType_nickname) { | 146 | } else if (item.editDataType == WDEditDataModelType.WDEditDataModelType_nickname) { |
| 146 | this.params = { userName: item.userName } | 147 | this.params = { userName: item.userName } |
| 147 | } | 148 | } |
| @@ -176,6 +177,7 @@ class EditInfoViewModel { | @@ -176,6 +177,7 @@ class EditInfoViewModel { | ||
| 176 | }else { | 177 | }else { |
| 177 | let url = '' | 178 | let url = '' |
| 178 | if (item.editDataType == WDEditDataModelType.WDEditDataModelType_head) { | 179 | if (item.editDataType == WDEditDataModelType.WDEditDataModelType_head) { |
| 180 | + this.params = { headPhotoUrl: item.headPhotoUrl} | ||
| 179 | url = '/api/rmrb-creator-user/c/rmrb-creator-user/creator/updateIcon' | 181 | url = '/api/rmrb-creator-user/c/rmrb-creator-user/creator/updateIcon' |
| 180 | } else if (item.editDataType == WDEditDataModelType.WDEditDataModelType_nickname) { | 182 | } else if (item.editDataType == WDEditDataModelType.WDEditDataModelType_nickname) { |
| 181 | this.params = { name: item.userName} | 183 | this.params = { name: item.userName} |
| @@ -13,6 +13,8 @@ export class MineUserDetailItem{ | @@ -13,6 +13,8 @@ export class MineUserDetailItem{ | ||
| 13 | honoraryIcon = ""//荣誉称号 (优先) | 13 | honoraryIcon = ""//荣誉称号 (优先) |
| 14 | avatarFrame:string = ""//最佳评论员头像框地址 | 14 | avatarFrame:string = ""//最佳评论员头像框地址 |
| 15 | 15 | ||
| 16 | + province:string = "" | ||
| 17 | + region:string = "" | ||
| 16 | 18 | ||
| 17 | 19 | ||
| 18 | } | 20 | } |
| @@ -11,7 +11,7 @@ import { putObject } from './upload' | @@ -11,7 +11,7 @@ import { putObject } from './upload' | ||
| 11 | 11 | ||
| 12 | export enum OSSConfigSceneType { | 12 | export enum OSSConfigSceneType { |
| 13 | feedback = "feedback", | 13 | feedback = "feedback", |
| 14 | - | 14 | + userPhone = 'userPhone' |
| 15 | } | 15 | } |
| 16 | 16 | ||
| 17 | export enum OSSFileType { | 17 | export enum OSSFileType { |
-
Please register or login to post a comment