ref |> 新增设备信息上报接口逻辑
1、启动和登录后都会调用 Signed-off-by: xugenyuan <xugenyuan@wondertek.com.cn>
Showing
7 changed files
with
70 additions
and
2 deletions
| @@ -742,4 +742,8 @@ export class HttpUrlUtils { | @@ -742,4 +742,8 @@ export class HttpUrlUtils { | ||
| 742 | return url | 742 | return url |
| 743 | } | 743 | } |
| 744 | 744 | ||
| 745 | -} | ||
| 745 | + static reportDeviceInfo() { | ||
| 746 | + let url = HttpUrlUtils.getHost() + "/api/rmrb-user-center/common/user/c/device/push"; | ||
| 747 | + return url; | ||
| 748 | + } | ||
| 749 | +} |
| @@ -2,7 +2,10 @@ import HuaweiAuth from './utils/HuaweiAuth' | @@ -2,7 +2,10 @@ import HuaweiAuth from './utils/HuaweiAuth' | ||
| 2 | import { JumpInterceptorAction, RouterJumpInterceptor, WDRouterPage } from 'wdRouter' | 2 | import { JumpInterceptorAction, RouterJumpInterceptor, WDRouterPage } from 'wdRouter' |
| 3 | import { BusinessError } from '@kit.BasicServicesKit' | 3 | import { BusinessError } from '@kit.BasicServicesKit' |
| 4 | import { router } from '@kit.ArkUI' | 4 | import { router } from '@kit.ArkUI' |
| 5 | -import { AccountManagerUtils } from 'wdKit/Index' | 5 | +import { AccountManagerUtils, SPHelper } from 'wdKit/Index' |
| 6 | +import { LoginViewModel } from './pages/login/LoginViewModel' | ||
| 7 | +import { SpConstants } from 'wdConstant/Index' | ||
| 8 | +import { ReportDeviceInfo } from './reportDeviceInfo/ReportDeviceInfo' | ||
| 6 | 9 | ||
| 7 | class LoginJumpHandler implements JumpInterceptorAction { | 10 | class LoginJumpHandler implements JumpInterceptorAction { |
| 8 | 11 | ||
| @@ -37,4 +40,14 @@ export class LoginModule { | @@ -37,4 +40,14 @@ export class LoginModule { | ||
| 37 | } | 40 | } |
| 38 | 41 | ||
| 39 | } | 42 | } |
| 43 | + | ||
| 44 | + // 启动进入主页 和 每次登录成功调用 | ||
| 45 | + static reportDeviceInfo() { | ||
| 46 | + ReportDeviceInfo.reportDeviceInfo().then((res) => { | ||
| 47 | + let nickName = res.touristNickName | ||
| 48 | + if (res.touristNickName) { | ||
| 49 | + SPHelper.default.save(SpConstants.TOURIST_NICK_NAME, res.touristNickName) | ||
| 50 | + } | ||
| 51 | + }) | ||
| 52 | + } | ||
| 40 | } | 53 | } |
| @@ -10,6 +10,7 @@ import { encryptMessage } from '../../utils/cryptoUtil' | @@ -10,6 +10,7 @@ import { encryptMessage } from '../../utils/cryptoUtil' | ||
| 10 | import { SpConstants } from 'wdConstant/Index' | 10 | import { SpConstants } from 'wdConstant/Index' |
| 11 | import { UserDetail } from 'wdBean/Index'; | 11 | import { UserDetail } from 'wdBean/Index'; |
| 12 | import { HttpUtils } from 'wdNetwork/Index' | 12 | import { HttpUtils } from 'wdNetwork/Index' |
| 13 | +import { LoginModule } from '../../LoginModule' | ||
| 13 | 14 | ||
| 14 | const TAG = "LoginViewModel" | 15 | const TAG = "LoginViewModel" |
| 15 | 16 | ||
| @@ -77,6 +78,8 @@ export class LoginViewModel { | @@ -77,6 +78,8 @@ export class LoginViewModel { | ||
| 77 | SPHelper.default.saveSync(SpConstants.USER_Type, data.userType) | 78 | SPHelper.default.saveSync(SpConstants.USER_Type, data.userType) |
| 78 | SPHelper.default.saveSync(SpConstants.USER_NAME, data.userName) | 79 | SPHelper.default.saveSync(SpConstants.USER_NAME, data.userName) |
| 79 | EmitterUtils.sendEmptyEvent(EmitterEventId.LOGIN_SUCCESS) | 80 | EmitterUtils.sendEmptyEvent(EmitterEventId.LOGIN_SUCCESS) |
| 81 | + | ||
| 82 | + LoginModule.reportDeviceInfo() | ||
| 80 | } | 83 | } |
| 81 | 84 | ||
| 82 | async appLoginByPassword(phone: string, loginType: number, password: string, oldPassword: string) { | 85 | async appLoginByPassword(phone: string, loginType: number, password: string, oldPassword: string) { |
| 1 | +import { AppUtils, DeviceUtil, Logger, UserDataLocal } from 'wdKit/Index'; | ||
| 2 | +import { HttpBizUtil, HttpUrlUtils, ResponseDTO } from 'wdNetwork/Index'; | ||
| 3 | + | ||
| 4 | +export class ReportDeviceInfo { | ||
| 5 | + static reportDeviceInfo() { | ||
| 6 | + const userId = UserDataLocal.getUserId() || "" | ||
| 7 | + const url = HttpUrlUtils.reportDeviceInfo() | ||
| 8 | + | ||
| 9 | + let bean: Record<string, string | number> = {}; | ||
| 10 | + bean['deviceId'] = DeviceUtil.clientId() | ||
| 11 | + bean['appVersion'] = AppUtils.getAppVersionCode() | ||
| 12 | + bean['platform'] = 3 /// 1Android 2iOS | ||
| 13 | + bean['userId'] = userId | ||
| 14 | + bean['brand'] = DeviceUtil.getMarketName() | ||
| 15 | + bean['modelSystemVersion'] = DeviceUtil.getDisplayVersion() | ||
| 16 | + bean['tenancy'] = 3 ///1-视界 2-英文版 3-中文版 | ||
| 17 | + | ||
| 18 | + return new Promise<ReportDeviceInfoRes>((success, fail) => { | ||
| 19 | + HttpBizUtil.post<ResponseDTO<ReportDeviceInfoRes>>(url,bean).then((data: ResponseDTO<ReportDeviceInfoRes>) => { | ||
| 20 | + if (!data) { | ||
| 21 | + fail("数据为空") | ||
| 22 | + return | ||
| 23 | + } | ||
| 24 | + if (data.code != 0) { | ||
| 25 | + fail(data.message) | ||
| 26 | + return | ||
| 27 | + } | ||
| 28 | + success(data.data!) | ||
| 29 | + }, (error: Error) => { | ||
| 30 | + fail(error.message) | ||
| 31 | + Logger.debug("ReportDeviceInfo", error.toString()) | ||
| 32 | + }) | ||
| 33 | + }) | ||
| 34 | + | ||
| 35 | + } | ||
| 36 | +} | ||
| 37 | + | ||
| 38 | +export class ReportDeviceInfoRes { | ||
| 39 | + clean : number = 0 | ||
| 40 | + touristNickName : string = "" | ||
| 41 | +} |
| @@ -8,6 +8,7 @@ import router from '@ohos.router'; | @@ -8,6 +8,7 @@ import router from '@ohos.router'; | ||
| 8 | import { promptAction } from '@kit.ArkUI'; | 8 | import { promptAction } from '@kit.ArkUI'; |
| 9 | import { UpgradeTipDialog } from "./upgradePage/UpgradeTipDialog" | 9 | import { UpgradeTipDialog } from "./upgradePage/UpgradeTipDialog" |
| 10 | import { ProcessUtils } from 'wdRouter/Index'; | 10 | import { ProcessUtils } from 'wdRouter/Index'; |
| 11 | +import { StartupManager } from '../startupmanager/StartupManager'; | ||
| 11 | 12 | ||
| 12 | const TAG = 'MainPage'; | 13 | const TAG = 'MainPage'; |
| 13 | 14 | ||
| @@ -27,6 +28,8 @@ struct MainPage { | @@ -27,6 +28,8 @@ struct MainPage { | ||
| 27 | 28 | ||
| 28 | aboutToAppear() { | 29 | aboutToAppear() { |
| 29 | 30 | ||
| 31 | + StartupManager.sharedInstance().appReachMainPage() | ||
| 32 | + | ||
| 30 | this.breakpointSystem.register() | 33 | this.breakpointSystem.register() |
| 31 | 34 | ||
| 32 | let context = getContext(this) as common.UIAbilityContext | 35 | let context = getContext(this) as common.UIAbilityContext |
| @@ -90,6 +90,9 @@ export class StartupManager { | @@ -90,6 +90,9 @@ export class StartupManager { | ||
| 90 | appReachMainPage() : Promise<void> { | 90 | appReachMainPage() : Promise<void> { |
| 91 | return new Promise((resolve) => { | 91 | return new Promise((resolve) => { |
| 92 | Logger.debug(TAG, "App 进入首页,开始其他任务初始化") | 92 | Logger.debug(TAG, "App 进入首页,开始其他任务初始化") |
| 93 | + | ||
| 94 | + LoginModule.reportDeviceInfo() | ||
| 95 | + | ||
| 93 | //TODO: | 96 | //TODO: |
| 94 | 97 | ||
| 95 | resolve() | 98 | resolve() |
-
Please register or login to post a comment