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
yangsunyue_wd
2024-03-28 13:39:42 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e81803f215cffe6989b68e32be2e5e8853b8ea29
e81803f2
1 parent
01ff96d7
desc:隐私设置、忘记密码、关于,用户登录后的token存储调整
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
72 additions
and
43 deletions
sight_harmony/commons/wdKit/src/main/ets/utils/PermissionUtil.ets
sight_harmony/commons/wdNetwork/src/main/ets/http/HttpUrlUtils.ets
sight_harmony/features/wdComponent/src/main/ets/components/setting/AboutPageUI.ets
sight_harmony/features/wdComponent/src/main/ets/components/setting/PrivacySettingComponents.ets
sight_harmony/features/wdComponent/src/main/ets/model/EditInfoModel.ets
sight_harmony/features/wdComponent/src/main/ets/model/PrivacySettingModel.ets
sight_harmony/features/wdLogin/src/main/ets/pages/login/LoginModel.ets
sight_harmony/features/wdLogin/src/main/ets/pages/login/SettingPasswordLayout.ets
sight_harmony/products/phone/src/main/module.json5
sight_harmony/commons/wdKit/src/main/ets/utils/PermissionUtil.ets
View file @
e81803f
...
...
@@ -5,6 +5,7 @@ import featureAbility from '@ohos.ability.featureAbility';
import wantConstant from '@ohos.ability.wantConstant';
import Want from '@ohos.app.ability.Want';
import { AppUtils } from './AppUtils';
import { Callback } from '@ohos.base';
export class PermissionUtil {
async checkAccessToken(permission: Permissions): Promise<abilityAccessCtrl.GrantStatus> {
...
...
@@ -45,38 +46,34 @@ export class PermissionUtil {
return hasPermissions;
}
static reqPermissionsFromUser(permissions: Array<Permissions>, component: Object): void {
let context = getContext(component) as common.UIAbilityContext;
let atManager = abilityAccessCtrl.createAtManager();
// requestPermissionsFromUser会判断权限的授权状态来决定是否唤起弹窗
atManager.requestPermissionsFromUser(context, permissions).then((data) => {
let grantStatus: Array<number> = data.authResults;
let length: number = grantStatus.length;
for (let i = 0; i < length; i++) {
if (grantStatus[i] === 0) {
// 用户授权,可以继续访问目标操作
static reqPermissionsFromUser(permissions: Array<Permissions>, component: Object): Promise<boolean> {
// let hasPermissions = false;
} else {
PermissionUtil.openPermissionsInSystemSettings(component);
// 用户拒绝授权,提示用户必须授权才能访问当前页面的功能,并引导用户到系统设置中打开相应的权限
// AlertDialog.show({
// title: '权限设置',
// message: '到系统设置中打开相应的权限',
// confirm: {
// value: "OK",
// action: () => {
//
// },
// }
// })
return;
return new Promise((resolve) => {
let context = getContext(component) as common.UIAbilityContext;
let atManager = abilityAccessCtrl.createAtManager();
// requestPermissionsFromUser会判断权限的授权状态来决定是否唤起弹窗
atManager.requestPermissionsFromUser(context, permissions).then((data) => {
let grantStatus: Array<number> = data.authResults;
let length: number = grantStatus.length;
for (let i = 0; i < length; i++) {
if (grantStatus[i] === 0) {
// 用户授权,可以继续访问目标操作
resolve(true);
} else {
PermissionUtil.openPermissionsInSystemSettings(component);
}
}
}
// 授权成功
}).catch((err:Error) => {
// console.error(`requestPermissionsFromUser failed, code is ${err.code}, message is ${err.message}`);
})
// 授权成功
}).catch((err:Error) => {
})
});
// return hasPermissions;
}
...
...
sight_harmony/commons/wdNetwork/src/main/ets/http/HttpUrlUtils.ets
View file @
e81803f
...
...
@@ -150,8 +150,8 @@ export class HttpUrlUtils {
headers.set('timestamp', HttpUrlUtils.getTimestamp())
headers.set('RMRB-X-TOKEN', HttpUrlUtils.getXToken())
headers.set('device_id', HttpUrlUtils.getDeviceId())
if(HttpUrlUtils.token!=''){
headers.set('cookie', 'RMRB-X-TOKEN='+HttpUrlUtils.token)
if(HttpUrlUtils.getXToken()!=''){
headers.set('cookie', 'RMRB-X-TOKEN='+HttpUrlUtils.getXToken())
}
headers.set('build_version', HttpUrlUtils.getVersion())
headers.set('adcode', HttpUrlUtils.getAdCode())
...
...
@@ -232,6 +232,10 @@ export class HttpUrlUtils {
}
private static getXToken() {
let jwttoken = SPHelper.default.getSync(SpConstants.USER_JWT_TOKEN,"")
if(StringUtils.isNotEmpty(jwttoken)) {
return jwttoken as string;
}
return 'eyJhbGciOiJIUzI1NiIsImtpZCI6ImQ4WkI2QkhxSEZrdjJ2U25BNlRwZEdKRjBHcjItVzBvS2FaYzdLOUUycmcifQ.eyJpc3MiOiJwZW9wbGVzLWRhaWx5LWZvdXJhIiwic3ViIjoicGVvcGxlcy1kYWlseS1mb3VyYSIsImV4cCI6MTcwMzY0OTYwNiwidXNlcklkIjo0NTk3NzYyOTc0NzQ5NDksInVzZXJWZXJzaW9uIjoiNDU5Nzc2Mjk3NDc0OTQ5XzIiLCJ1c2VyTmFtZSI6IkJ1bGlraWtpMTgxIiwidXNlclR5cGUiOjIsImNyZWF0b3JJZCI6NDI2NTM5MH0.jhQ9kylcm3FxWf0-lBMZuLkdtIQ6XpFnAi0AFZJNwfc';
}
...
...
@@ -293,14 +297,19 @@ export class HttpUrlUtils {
private static getUserId() {
// TODO 对接登录
// let userid = await SPHelper.default.get(SpConstants.USER_ID,"")
// if(StringUtils.isNotEmpty(userid)) {
// return userid as string;
// }
let userid = SPHelper.default.getSync(SpConstants.USER_ID,"")
if(StringUtils.isNotEmpty(userid)) {
return userid as string;
}
return HttpUrlUtils.userId;
}
private static getUserType() {
let userType = SPHelper.default.getSync(SpConstants.USER_Type,"")
if(StringUtils.isNotEmpty(userType)) {
return userType as string;
}
return HttpUrlUtils.userType;
}
...
...
@@ -331,7 +340,7 @@ export class HttpUrlUtils {
}
static editUserDetail() {
let url = HttpUrlUtils.hostUrl + "/user/zh/c/editUserDetail";
let url = HttpUrlUtils.hostUrl + "/
api/rmrb-user-center/
user/zh/c/editUserDetail";
return url;
}
...
...
sight_harmony/features/wdComponent/src/main/ets/components/setting/AboutPageUI.ets
View file @
e81803f
import { Params } from 'wdBean';
import { WDRouterPage, WDRouterRule } from 'wdRouter';
import featureAbility from '@ohos.ability.featureAbility';
const TAG = 'AboutPageUI';
...
...
@@ -7,7 +8,7 @@ const TAG = 'AboutPageUI';
export struct AboutPageUI {
@State listData: Array<string | Array<string>> = ['隐私授权协议', '软件许可及用户协议'];
@State message: string = '京ICP备16066560号-6A Copyright © 人民日报客户端\nall rights reserved.'
@State version: string = '版本号:v
8.0.1.1
'
@State version: string = '版本号:v'
build() {
...
...
@@ -18,6 +19,11 @@ export struct AboutPageUI {
.title('关于')
}
aboutToAppear(){
let context = getContext();
context.getApplicationContext();
}
@Builder aboutUi() {
Column() {
Image($r('app.media.setting_about_logo'))
...
...
sight_harmony/features/wdComponent/src/main/ets/components/setting/PrivacySettingComponents.ets
View file @
e81803f
...
...
@@ -3,12 +3,14 @@ import { PermissionUtil } from 'wdKit'
import { SPHelper } from 'wdKit'
import hilog from '@ohos.hilog';
import { PrivacySettingModel } from '../../model/PrivacySettingModel'
import { Params } from 'wdBean';
import { WDRouterPage, WDRouterRule } from 'wdRouter';
const TAG = 'PrivacySettingComponents';
@Component
export struct PrivacySettingComponents {
@State listData: Array<PrivacySettingModel> = [new PrivacySettingModel('开启个性推荐', false, 'ohos.permission.READ_MEDIA'), new PrivacySettingModel('相册权限', false, 'ohos.permission.READ_MEDIA'), new PrivacySettingModel('相机权限', false, 'ohos.permission.CAMERA'), new PrivacySettingModel('定位权限', false, 'ohos.permission.LOCATION'), new PrivacySettingModel('麦克风权限', false, 'ohos.permission.MICROPHONE')];
@State listData: Array<PrivacySettingModel> = [new PrivacySettingModel('开启个性推荐', false, 'ohos.permission.READ_MEDIA'), new PrivacySettingModel('相册权限', false, 'ohos.permission.READ_MEDIA'), new PrivacySettingModel('相机权限', false, 'ohos.permission.CAMERA'), new PrivacySettingModel('定位权限', false, 'ohos.permission.
APPROXIMATELY_
LOCATION'), new PrivacySettingModel('麦克风权限', false, 'ohos.permission.MICROPHONE')];
@State tips: string = '设置前可查阅'
@State privacyTips: string = '《隐私政策》'
...
...
@@ -26,6 +28,7 @@ export struct PrivacySettingComponents {
for (const element of this.listData) {
if (element.privacyName == '开启个性推荐') {
element.queryUserDetail();
// element.permission = true;
continue;
}
const result = await permissionUtil.checkPermissions(element.permissionKey);
...
...
@@ -59,7 +62,9 @@ export struct PrivacySettingComponents {
if (!item.permission) {
//跳转权限设置
const permissionUtil = new PermissionUtil();
PermissionUtil.reqPermissionsFromUser([item.permissionKey], this);
PermissionUtil.reqPermissionsFromUser([item.permissionKey], this).then((res)=>{
item.permission = res;
});
}
}
})
...
...
@@ -82,6 +87,8 @@ export struct PrivacySettingComponents {
.margin({ top: '46lpx' })
.onClick(() => {
//跳转隐私政策
let bean={contentId:"2",pageID:""} as Params
WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage,bean)
})
}
...
...
@@ -150,6 +157,7 @@ struct getTuiJianCell {
// .selectedColor(Color.Pink)
.onChange((isOn: boolean) => {
// this.privacySwitch = isOn;
this.item.editUserDetail(isOn?'1':'0');
})
}
...
...
sight_harmony/features/wdComponent/src/main/ets/model/EditInfoModel.ets
View file @
e81803f
...
...
@@ -24,6 +24,8 @@ export interface EditInfoModel{
birthday:string
//性别
sex:string
// 推荐开关 0:关 1:开(默认)
airec:number
}
export interface editModel{
...
...
sight_harmony/features/wdComponent/src/main/ets/model/PrivacySettingModel.ets
View file @
e81803f
...
...
@@ -3,6 +3,8 @@ import HashMap from '@ohos.util.HashMap';
import { HttpUrlUtils, ResponseDTO } from 'wdNetwork';
import { Logger } from 'wdKit';
import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest';
import EditInfoViewModel from '../viewmodel/EditInfoViewModel';
import { editModel } from './EditInfoModel';
@Observed
...
...
@@ -20,10 +22,12 @@ export class PrivacySettingModel{
queryUserDetail() {
// EditInfoViewModel
let bean: Record<string, string> = {};
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return new Promise<string>((success, fail) => {
HttpRequest.get<ResponseDTO<string>>(HttpUrlUtils.queryUserDetail(), headers).then((data: ResponseDTO<string>) => {
return new Promise<editModel>((success, fail) => {
HttpRequest.get<ResponseDTO<editModel>>(HttpUrlUtils.queryUserDetail(), headers).then((data: ResponseDTO<editModel>) => {
if (!data || !data.data) {
fail("数据为空")
return
...
...
@@ -32,7 +36,8 @@ export class PrivacySettingModel{
fail(data.message)
return
}
// this.permission = data.data.userExtend.airec as boolean;
this.permission = Boolean(data.data.userExtend.airec)
console.log('this.permission',this.permission);
success(data.data)
}, (error: Error) => {
fail(error.message)
...
...
sight_harmony/features/wdLogin/src/main/ets/pages/login/LoginModel.ets
View file @
e81803f
...
...
@@ -202,6 +202,7 @@ export class LoginModel {
let JwtToken = SPHelper.default.getSync(SpConstants.USER_JWT_TOKEN, '') as string;
headers.set('JwtToken',(JwtToken));
headers.set('rmrb-x-token',(JwtToken));
return new Promise<string>((success, fail) => {
HttpRequest.post<ResponseDTO<string>>(HttpUrlUtils.getForgetPasswordUrl(), bean, headers).then((data: ResponseDTO<string>) => {
if (!data || !data.data) {
...
...
sight_harmony/features/wdLogin/src/main/ets/pages/login/SettingPasswordLayout.ets
View file @
e81803f
...
...
@@ -188,6 +188,7 @@ export struct SettingPasswordLayout {
Row() {
TextInput({ placeholder: item.inputPlacholder })
.type(InputType.Password)
.showPasswordIcon(false)
.backgroundColor('#00000000')
.onChange((value: string) => {
this.inputTextChange(value, item.inputTag)
...
...
sight_harmony/products/phone/src/main/module.json5
View file @
e81803f
...
...
@@ -66,7 +66,7 @@
}
},
{
"name"
:
"ohos.permission.LOCATION"
,
"name"
:
"ohos.permission.
APPROXIMATELY_
LOCATION"
,
"reason"
:
"$string:EntryAbility_desc"
,
"usedScene"
:
{
"abilities"
:
[
...
...
Please
register
or
login
to post a comment