Showing
6 changed files
with
56 additions
and
4 deletions
| @@ -24,4 +24,6 @@ export class SpConstants{ | @@ -24,4 +24,6 @@ export class SpConstants{ | ||
| 24 | static SETTING_SUSPENSION_SWITCH = "setting_suspension_switch" //悬浮窗 开关 | 24 | static SETTING_SUSPENSION_SWITCH = "setting_suspension_switch" //悬浮窗 开关 |
| 25 | static SETTING_PUSH_SWITCH = "setting_push_switch" //推送 开关 | 25 | static SETTING_PUSH_SWITCH = "setting_push_switch" //推送 开关 |
| 26 | 26 | ||
| 27 | + //未登录保存兴趣标签 | ||
| 28 | + static PUBLICVISUTORMODE_INTERESTTAGS = 'PublicVisitorMode_InterestTags' | ||
| 27 | } | 29 | } |
| @@ -258,6 +258,10 @@ export class HttpUrlUtils { | @@ -258,6 +258,10 @@ export class HttpUrlUtils { | ||
| 258 | * app启动页 兴趣偏好 | 258 | * app启动页 兴趣偏好 |
| 259 | */ | 259 | */ |
| 260 | static readonly INTERESTS_HOTS_DATA_PATH: string = "/api/rmrb-user-center/user/zh/c/tag/queryTags"; | 260 | static readonly INTERESTS_HOTS_DATA_PATH: string = "/api/rmrb-user-center/user/zh/c/tag/queryTags"; |
| 261 | + /** | ||
| 262 | + * 更新 兴趣偏好 | ||
| 263 | + */ | ||
| 264 | + static readonly INTERESTS_UPDATETAG_PATH: string = "/api/rmrb-user-center/user/zh/c/tag/updateUserTag"; | ||
| 261 | 265 | ||
| 262 | 266 | ||
| 263 | private static _hostUrl: string = HttpUrlUtils.HOST_PRODUCT; | 267 | private static _hostUrl: string = HttpUrlUtils.HOST_PRODUCT; |
| @@ -663,6 +667,11 @@ export class HttpUrlUtils { | @@ -663,6 +667,11 @@ export class HttpUrlUtils { | ||
| 663 | 667 | ||
| 664 | } | 668 | } |
| 665 | 669 | ||
| 670 | + static getUpdateInterestsUrl() { | ||
| 671 | + let url = HttpUrlUtils._hostUrl + HttpUrlUtils.INTERESTS_UPDATETAG_PATH; | ||
| 672 | + return url; | ||
| 673 | + } | ||
| 674 | + | ||
| 666 | static getLiveDetailsUrl() { | 675 | static getLiveDetailsUrl() { |
| 667 | let url = HttpUrlUtils._hostUrl + HttpUrlUtils.LIVE_DETAILS_PATH | 676 | let url = HttpUrlUtils._hostUrl + HttpUrlUtils.LIVE_DETAILS_PATH |
| 668 | return url | 677 | return url |
| @@ -129,10 +129,13 @@ class EditInfoViewModel { | @@ -129,10 +129,13 @@ class EditInfoViewModel { | ||
| 129 | .then((navResDTO: ResponseDTO) => { | 129 | .then((navResDTO: ResponseDTO) => { |
| 130 | if (navResDTO.code == 0) { | 130 | if (navResDTO.code == 0) { |
| 131 | promptAction.showToast({ message: '修改成功' }) | 131 | promptAction.showToast({ message: '修改成功' }) |
| 132 | + }else { | ||
| 133 | + promptAction.showToast({ message: navResDTO.message }) | ||
| 132 | } | 134 | } |
| 133 | }) | 135 | }) |
| 134 | .catch((error: Error) => { | 136 | .catch((error: Error) => { |
| 135 | Logger.info(TAG,'updateUserInfo','EditInfoViewModel') | 137 | Logger.info(TAG,'updateUserInfo','EditInfoViewModel') |
| 138 | + promptAction.showToast({ message: error.message }) | ||
| 136 | }) | 139 | }) |
| 137 | }) | 140 | }) |
| 138 | } | 141 | } |
| @@ -8,7 +8,7 @@ import { ErrorToastUtils, SPHelper } from 'wdKit' | @@ -8,7 +8,7 @@ import { ErrorToastUtils, SPHelper } from 'wdKit' | ||
| 8 | import { WDRouterPage } from 'wdRouter/src/main/ets/router/WDRouterPage'; | 8 | import { WDRouterPage } from 'wdRouter/src/main/ets/router/WDRouterPage'; |
| 9 | import { WDRouterRule } from 'wdRouter/src/main/ets/router/WDRouterRule'; | 9 | import { WDRouterRule } from 'wdRouter/src/main/ets/router/WDRouterRule'; |
| 10 | import { Params } from '../../../../../../../commons/wdRouter/oh_modules/wdBean/src/main/ets/bean/content/Params' | 10 | import { Params } from '../../../../../../../commons/wdRouter/oh_modules/wdBean/src/main/ets/bean/content/Params' |
| 11 | - | 11 | +import {InterestsHobbiesModel} from '../../../../../../../products/phone/src/main/ets/pages/viewModel/InterestsHobbiesModel' |
| 12 | @Extend(Row) | 12 | @Extend(Row) |
| 13 | function otherStyle() { | 13 | function otherStyle() { |
| 14 | .backgroundImageSize(ImageSize.Cover) | 14 | .backgroundImageSize(ImageSize.Cover) |
| @@ -306,6 +306,10 @@ struct LoginPage { | @@ -306,6 +306,10 @@ struct LoginPage { | ||
| 306 | if (this.checkCodePage) { | 306 | if (this.checkCodePage) { |
| 307 | this.loginViewModel.appLogin(this.phoneContent, 2, this.codeContent).then((data) => { | 307 | this.loginViewModel.appLogin(this.phoneContent, 2, this.codeContent).then((data) => { |
| 308 | Logger.debug(TAG, "requestLogin: " + data.jwtToken) | 308 | Logger.debug(TAG, "requestLogin: " + data.jwtToken) |
| 309 | + ///同步兴趣tag | ||
| 310 | + let interestsModel = new InterestsHobbiesModel() | ||
| 311 | + interestsModel.updateInterests() | ||
| 312 | + | ||
| 309 | router.back({ | 313 | router.back({ |
| 310 | params: { userName: data.userName, | 314 | params: { userName: data.userName, |
| 311 | userId:data.id}, | 315 | userId:data.id}, |
| @@ -319,6 +323,11 @@ struct LoginPage { | @@ -319,6 +323,11 @@ struct LoginPage { | ||
| 319 | this.loginViewModel.appLoginByPassword(this.accountContent, 0, this.passwordContent, "").then((data) => { | 323 | this.loginViewModel.appLoginByPassword(this.accountContent, 0, this.passwordContent, "").then((data) => { |
| 320 | Logger.debug(TAG, "requestLogin: " + data.jwtToken) | 324 | Logger.debug(TAG, "requestLogin: " + data.jwtToken) |
| 321 | promptAction.showToast({ message: '登录成功' }) | 325 | promptAction.showToast({ message: '登录成功' }) |
| 326 | + | ||
| 327 | + ///同步兴趣tag | ||
| 328 | + let interestsModel = new InterestsHobbiesModel() | ||
| 329 | + interestsModel.updateInterests() | ||
| 330 | + | ||
| 322 | router.back({ | 331 | router.back({ |
| 323 | params: { userName: data.userName, | 332 | params: { userName: data.userName, |
| 324 | userId:data.id}, | 333 | userId:data.id}, |
| 1 | import {InterestsHobbiesModel, InterestsList} from '../viewModel/InterestsHobbiesModel' | 1 | import {InterestsHobbiesModel, InterestsList} from '../viewModel/InterestsHobbiesModel' |
| 2 | import { WDRouterRule } from 'wdRouter'; | 2 | import { WDRouterRule } from 'wdRouter'; |
| 3 | import { WDRouterPage } from 'wdRouter'; | 3 | import { WDRouterPage } from 'wdRouter'; |
| 4 | +import { SPHelper } from 'wdKit/Index'; | ||
| 5 | +import { SpConstants } from 'wdConstant/Index'; | ||
| 4 | 6 | ||
| 5 | @Entry | 7 | @Entry |
| 6 | @Component | 8 | @Component |
| @@ -121,6 +123,7 @@ struct LaunchInterestsHobbiesPage { | @@ -121,6 +123,7 @@ struct LaunchInterestsHobbiesPage { | ||
| 121 | .width('662lpx') | 123 | .width('662lpx') |
| 122 | .height('84lpx') | 124 | .height('84lpx') |
| 123 | .onClick(()=>{ | 125 | .onClick(()=>{ |
| 126 | + this.saveTagIds() | ||
| 124 | //跳转首页 | 127 | //跳转首页 |
| 125 | WDRouterRule.jumpWithReplacePage(WDRouterPage.mainPage) | 128 | WDRouterRule.jumpWithReplacePage(WDRouterPage.mainPage) |
| 126 | }) | 129 | }) |
| @@ -149,4 +152,15 @@ struct LaunchInterestsHobbiesPage { | @@ -149,4 +152,15 @@ struct LaunchInterestsHobbiesPage { | ||
| 149 | }) | 152 | }) |
| 150 | } | 153 | } |
| 151 | 154 | ||
| 155 | + saveTagIds(){ | ||
| 156 | + let tags: string = '' | ||
| 157 | + if (this.interestsArray.filter(item => item.choose).length > 0) { | ||
| 158 | + let array = this.interestsArray.filter(item => item.choose) | ||
| 159 | + for (let index = 0; index < array.length; index++) { | ||
| 160 | + const element = array[index]; | ||
| 161 | + tags = tags.length === 0 ? element.id.toString() : tags + ',' + element.id.toString() | ||
| 162 | + } | ||
| 163 | + } | ||
| 164 | + SPHelper.default.saveSync(SpConstants.PUBLICVISUTORMODE_INTERESTTAGS,tags) | ||
| 165 | + } | ||
| 152 | } | 166 | } |
| @@ -3,6 +3,7 @@ import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest'; | @@ -3,6 +3,7 @@ import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest'; | ||
| 3 | import { HttpUrlUtils, ResponseDTO } from 'wdNetwork/Index'; | 3 | import { HttpUrlUtils, ResponseDTO } from 'wdNetwork/Index'; |
| 4 | import { Logger, SPHelper } from 'wdKit/Index'; | 4 | import { Logger, SPHelper } from 'wdKit/Index'; |
| 5 | import data from '@ohos.telephony.data'; | 5 | import data from '@ohos.telephony.data'; |
| 6 | +import { SpConstants } from 'wdConstant/Index'; | ||
| 6 | 7 | ||
| 7 | 8 | ||
| 8 | export interface InterestsBean { | 9 | export interface InterestsBean { |
| @@ -60,9 +61,23 @@ export class InterestsHobbiesModel { | @@ -60,9 +61,23 @@ export class InterestsHobbiesModel { | ||
| 60 | fail(error.message) | 61 | fail(error.message) |
| 61 | }) | 62 | }) |
| 62 | }) | 63 | }) |
| 63 | - | ||
| 64 | - | ||
| 65 | } | 64 | } |
| 66 | 65 | ||
| 67 | - | 66 | + updateInterests(){ |
| 67 | + let tags = SPHelper.default.getSync(SpConstants.PUBLICVISUTORMODE_INTERESTTAGS,'') as string | ||
| 68 | + if (tags.length === 0) return | ||
| 69 | + let bean: Record<string, string> = {}; | ||
| 70 | + bean['tagIds'] = tags | ||
| 71 | + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | ||
| 72 | + return new Promise<ResponseDTO>((success, fail) => { | ||
| 73 | + HttpRequest.post<ResponseDTO>(HttpUrlUtils.getUpdateInterestsUrl(),bean,headers).then((data: ResponseDTO) => { | ||
| 74 | + if (data.code == 0) { | ||
| 75 | + Logger.info('InterestsHobbiesModel','updateInterests','更新兴趣成功') | ||
| 76 | + SPHelper.default.deleteSync(SpConstants.PUBLICVISUTORMODE_INTERESTTAGS) | ||
| 77 | + } | ||
| 78 | + }, (error: Error) => { | ||
| 79 | + fail(error.message) | ||
| 80 | + }) | ||
| 81 | + }) | ||
| 82 | + } | ||
| 68 | } | 83 | } |
-
Please register or login to post a comment