xugenyuan

ref |> 新增设备信息上报接口逻辑

1、启动和登录后都会调用

Signed-off-by: xugenyuan <xugenyuan@wondertek.com.cn>
... ... @@ -47,4 +47,5 @@ export class SpConstants{
//游客状态下首次评论时间
static FIRSTCOMMENTTIME = 'firstCommentTime'
static TOURIST_NICK_NAME = 'touristNickName'
}
\ No newline at end of file
... ...
... ... @@ -742,4 +742,8 @@ export class HttpUrlUtils {
return url
}
}
\ No newline at end of file
static reportDeviceInfo() {
let url = HttpUrlUtils.getHost() + "/api/rmrb-user-center/common/user/c/device/push";
return url;
}
}
... ...
... ... @@ -2,7 +2,10 @@ import HuaweiAuth from './utils/HuaweiAuth'
import { JumpInterceptorAction, RouterJumpInterceptor, WDRouterPage } from 'wdRouter'
import { BusinessError } from '@kit.BasicServicesKit'
import { router } from '@kit.ArkUI'
import { AccountManagerUtils } from 'wdKit/Index'
import { AccountManagerUtils, SPHelper } from 'wdKit/Index'
import { LoginViewModel } from './pages/login/LoginViewModel'
import { SpConstants } from 'wdConstant/Index'
import { ReportDeviceInfo } from './reportDeviceInfo/ReportDeviceInfo'
class LoginJumpHandler implements JumpInterceptorAction {
... ... @@ -37,4 +40,14 @@ export class LoginModule {
}
}
// 启动进入主页 和 每次登录成功调用
static reportDeviceInfo() {
ReportDeviceInfo.reportDeviceInfo().then((res) => {
let nickName = res.touristNickName
if (res.touristNickName) {
SPHelper.default.save(SpConstants.TOURIST_NICK_NAME, res.touristNickName)
}
})
}
}
\ No newline at end of file
... ...
... ... @@ -10,6 +10,7 @@ import { encryptMessage } from '../../utils/cryptoUtil'
import { SpConstants } from 'wdConstant/Index'
import { UserDetail } from 'wdBean/Index';
import { HttpUtils } from 'wdNetwork/Index'
import { LoginModule } from '../../LoginModule'
const TAG = "LoginViewModel"
... ... @@ -77,6 +78,8 @@ export class LoginViewModel {
SPHelper.default.saveSync(SpConstants.USER_Type, data.userType)
SPHelper.default.saveSync(SpConstants.USER_NAME, data.userName)
EmitterUtils.sendEmptyEvent(EmitterEventId.LOGIN_SUCCESS)
LoginModule.reportDeviceInfo()
}
async appLoginByPassword(phone: string, loginType: number, password: string, oldPassword: string) {
... ...
import { AppUtils, DeviceUtil, Logger, UserDataLocal } from 'wdKit/Index';
import { HttpBizUtil, HttpUrlUtils, ResponseDTO } from 'wdNetwork/Index';
export class ReportDeviceInfo {
static reportDeviceInfo() {
const userId = UserDataLocal.getUserId() || ""
const url = HttpUrlUtils.reportDeviceInfo()
let bean: Record<string, string | number> = {};
bean['deviceId'] = DeviceUtil.clientId()
bean['appVersion'] = AppUtils.getAppVersionCode()
bean['platform'] = 3 /// 1Android 2iOS
bean['userId'] = userId
bean['brand'] = DeviceUtil.getMarketName()
bean['modelSystemVersion'] = DeviceUtil.getDisplayVersion()
bean['tenancy'] = 3 ///1-视界 2-英文版 3-中文版
return new Promise<ReportDeviceInfoRes>((success, fail) => {
HttpBizUtil.post<ResponseDTO<ReportDeviceInfoRes>>(url,bean).then((data: ResponseDTO<ReportDeviceInfoRes>) => {
if (!data) {
fail("数据为空")
return
}
if (data.code != 0) {
fail(data.message)
return
}
success(data.data!)
}, (error: Error) => {
fail(error.message)
Logger.debug("ReportDeviceInfo", error.toString())
})
})
}
}
export class ReportDeviceInfoRes {
clean : number = 0
touristNickName : string = ""
}
\ No newline at end of file
... ...
... ... @@ -8,6 +8,7 @@ import router from '@ohos.router';
import { promptAction } from '@kit.ArkUI';
import { UpgradeTipDialog } from "./upgradePage/UpgradeTipDialog"
import { ProcessUtils } from 'wdRouter/Index';
import { StartupManager } from '../startupmanager/StartupManager';
const TAG = 'MainPage';
... ... @@ -27,6 +28,8 @@ struct MainPage {
aboutToAppear() {
StartupManager.sharedInstance().appReachMainPage()
this.breakpointSystem.register()
let context = getContext(this) as common.UIAbilityContext
... ...
... ... @@ -90,6 +90,9 @@ export class StartupManager {
appReachMainPage() : Promise<void> {
return new Promise((resolve) => {
Logger.debug(TAG, "App 进入首页,开始其他任务初始化")
LoginModule.reportDeviceInfo()
//TODO:
resolve()
... ...