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
liyubing
2024-04-26 18:20:42 +0800
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
8e01a6fe0bc0f905ff9c7e79a4aafe6a1db319a8
8e01a6fe
2 parents
58326afc
4c55851e
Merge remote-tracking branch 'origin/main'
Hide whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
696 additions
and
183 deletions
sight_harmony/commons/wdKit/src/main/ets/utils/EmitterEventId.ts
sight_harmony/commons/wdKit/src/main/ets/utils/LazyDataSource.ets
sight_harmony/commons/wdRouter/Index.ets
sight_harmony/commons/wdRouter/src/main/ets/router/RouterJumpInterceptor.ets
sight_harmony/commons/wdRouter/src/main/ets/router/WDRouterPage.ets
sight_harmony/commons/wdRouter/src/main/ets/router/WDRouterRule.ets
sight_harmony/features/wdBean/src/main/ets/bean/content/commentInfo.ets
sight_harmony/features/wdComponent/src/main/ets/components/MultiPictureDetailItemComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/MultiPictureDetailPageComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/comment/model/PublishCommentModel.ets
sight_harmony/features/wdComponent/src/main/ets/components/comment/view/CommentComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/comment/view/CommentCustomDialog.ets
sight_harmony/features/wdComponent/src/main/ets/components/comment/view/CommentTabComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/comment/view/QualityCommentsComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/comment/viewmodel/CommentViewModel.ets
sight_harmony/features/wdComponent/src/main/ets/components/view/OperRowListView.ets
sight_harmony/features/wdComponent/src/main/resources/base/media/comment_icon_number.png → sight_harmony/features/wdComponent/src/main/resources/base/media/comment_icon_number_bg.png
sight_harmony/features/wdDetailPlayLive/src/main/ets/pages/DetailPlayVLivePage.ets
sight_harmony/features/wdDetailPlayShortVideo/src/main/ets/pages/DetailVideoListPage.ets
sight_harmony/features/wdDetailPlayShortVideo/src/main/ets/pages/VideoChannelDetail.ets
sight_harmony/features/wdLogin/Index.ets
sight_harmony/features/wdLogin/src/main/ets/LoginModule.ets
sight_harmony/features/wdLogin/src/main/ets/pages/login/LoginPage.ets
sight_harmony/features/wdLogin/src/main/ets/pages/login/LoginProtocolWebview.ets
sight_harmony/features/wdLogin/src/main/ets/pages/login/OneKeyLoginPage.ets
sight_harmony/features/wdLogin/src/main/ets/utils/HuaweiAuth.ets
sight_harmony/features/wdLogin/src/main/resources/base/media/login_hw.png
sight_harmony/features/wdLogin/src/main/resources/base/profile/main_pages.json
sight_harmony/products/phone/oh-package.json5
sight_harmony/products/phone/src/main/ets/entryability/EntryAbility.ets
sight_harmony/products/phone/src/main/module.json5
sight_harmony/commons/wdKit/src/main/ets/utils/EmitterEventId.ts
View file @
8e01a6f
...
...
@@ -11,6 +11,15 @@ export enum EmitterEventId {
// 跳转首页指定频道,事件id
JUMP_HOME_CHANNEL
=
4
,
LOCATION
=
5
LOCATION
=
5
,
/*发布评论*/
COMMENT_PUBLISH
=
6
,
// App回到前台
APP_ENTER_FOREGROUD
=
100
,
// App进入后台
APP_ENTER_BACKGROUD
=
101
,
}
...
...
sight_harmony/commons/wdKit/src/main/ets/utils/LazyDataSource.ets
View file @
8e01a6f
...
...
@@ -289,4 +289,8 @@ export class LazyDataSource<T> extends BasicDataSource<T> {
this.dataArray.splice(start, this.dataArray.length, ...data);
this.notifyDataReload()
}
public reloadData(): void {
this.notifyDataReload();
}
}
\ No newline at end of file
...
...
sight_harmony/commons/wdRouter/Index.ets
View file @
8e01a6f
...
...
@@ -5,3 +5,5 @@ export { WDRouterPage } from './src/main/ets/router/WDRouterPage'
export { registerRouter } from './src/main/ets/router/Action2Page'
export { ProcessUtils } from './src/main/ets/utils/ProcessUtils'
export { RouterJumpInterceptor, JumpInterceptorAction } from './src/main/ets/router/RouterJumpInterceptor'
\ No newline at end of file
...
...
sight_harmony/commons/wdRouter/src/main/ets/router/RouterJumpInterceptor.ets
0 → 100644
View file @
8e01a6f
import { WDRouterPage } from './WDRouterPage';
export interface JumpInterceptorAction {
on(params?: object, singleMode?: boolean): boolean
}
// TODO:待优化
// 临时解决跳转页面之前方法拦截,比如登录先走一键登录,直播请求接口等
//
export class RouterJumpInterceptor {
private static actions: Record<string, JumpInterceptorAction> = {}
static getInterceptorAction(jumpPage: WDRouterPage): JumpInterceptorAction | undefined {
return RouterJumpInterceptor.actions[jumpPage.url()]
}
static register(jumpPage: WDRouterPage, interceptorAction: JumpInterceptorAction) {
RouterJumpInterceptor.actions[jumpPage.url()] = interceptorAction
}
}
...
...
sight_harmony/commons/wdRouter/src/main/ets/router/WDRouterPage.ets
View file @
8e01a6f
...
...
@@ -66,6 +66,7 @@ export class WDRouterPage {
// 动态详情页
static dynamicDetailPage = new WDRouterPage("phone", "ets/pages/detail/DynamicDetailPage");
static loginPage = new WDRouterPage("wdLogin", "ets/pages/login/LoginPage");
static oneKeyLoginPage = new WDRouterPage("wdLogin", "ets/pages/login/OneKeyLoginPage");
static forgetPasswordPage = new WDRouterPage("wdLogin", "ets/pages/login/ForgetPasswordPage");
//我的 预约
static appointmentListPage = new WDRouterPage("wdComponent", "ets/components/page/AppointmentListPage");
...
...
sight_harmony/commons/wdRouter/src/main/ets/router/WDRouterRule.ets
View file @
8e01a6f
...
...
@@ -3,6 +3,7 @@ import { Action } from 'wdBean'
import { ToastUtils } from 'wdKit'
import { Action2Page } from './Action2Page'
import { WDRouterPage } from './WDRouterPage'
import { RouterJumpInterceptor } from './RouterJumpInterceptor'
export class WDRouterRule {
static jumpWithAction(action?: Action) {
...
...
@@ -16,6 +17,11 @@ export class WDRouterRule {
static jumpWithPage(page?: WDRouterPage, params?: object, singleMode?: boolean) {
if (page) {
let action = RouterJumpInterceptor.getInterceptorAction(page)
if (action && action.on(params, singleMode)) {
return
}
let mode = router.RouterMode.Standard
if (singleMode) {
mode = router.RouterMode.Single
...
...
@@ -36,6 +42,10 @@ export class WDRouterRule {
static jumpWithReplacePage(page?: WDRouterPage, params?: object) {
if (page) {
let action = RouterJumpInterceptor.getInterceptorAction(page)
if (action && action.on(params)) {
return
}
if (params) {
// router.pushUrl({ url: 'pages/routerpage2', , params: params })
router.replaceUrl({ url: page.url(), params: params })
...
...
sight_harmony/features/wdBean/src/main/ets/bean/content/commentInfo.ets
View file @
8e01a6f
...
...
@@ -8,4 +8,5 @@ export interface commentInfo {
newsId: string,
relId: string;
relType: string;
userId: string;
}
\ No newline at end of file
...
...
sight_harmony/features/wdComponent/src/main/ets/components/MultiPictureDetailItemComponent.ets
View file @
8e01a6f
...
...
@@ -21,7 +21,7 @@ export struct MultiPictureDetailItemComponent {
.alt($r('app.media.picture_loading'))
.width(this.imageWidth)
.aspectRatio(this.ratio)
.objectFit(ImageFit.
Fill
)
.objectFit(ImageFit.
Contain
)
.interpolation(ImageInterpolation.High)
.onComplete(event => {
this.imageWidth = '100%'
...
...
sight_harmony/features/wdComponent/src/main/ets/components/MultiPictureDetailPageComponent.ets
View file @
8e01a6f
...
...
@@ -12,6 +12,7 @@ import display from '@ohos.display';
import font from '@ohos.font';
import { OperRowListView } from './view/OperRowListView';
import { MultiPictureDetailItemComponent } from './MultiPictureDetailItemComponent';
import { ImageDownloadComponent } from '../components/ImageDownloadComponent';
import { EmptyComponent } from './view/EmptyComponent';
import { DateTimeUtils } from 'wdKit/Index';
import { HttpUrlUtils } from 'wdNetwork/Index';
...
...
@@ -37,9 +38,10 @@ export struct MultiPictureDetailPageComponent {
private swiperController: SwiperController = new SwiperController()
private swiperControllerItem: SwiperController = new SwiperController()
@State swiperIndex: number = 0;
@Provide followStatus: string
= '0'
// 关注状态
@Provide followStatus: string
| undefined = undefined
// 关注状态
private scroller: Scroller = new Scroller()
@State netStatus: number | undefined = undefined // 存储网络状态用来展示缺省图
@State showDownload: Boolean = false // 控制是否显示下载默认隐藏
//watch监听页码回调
onCurrentPageNumUpdated(): void {
...
...
@@ -146,8 +148,8 @@ export struct MultiPictureDetailPageComponent {
right: 0
})
if (this.followStatus == '0') {
Row() {
Row() {
if (this.followStatus == '0') {
Button({ type: ButtonType.Normal, stateEffect: true }) {
Row() {
Text('+关注').fontSize(12).fontColor(0xffffff)
...
...
@@ -160,15 +162,27 @@ export struct MultiPictureDetailPageComponent {
.onClick(() => {
this.handleAccention()
})
} else {
Button({ type: ButtonType.Normal, stateEffect: true }) {
Row() {
Text('已关注').fontSize(12).fontColor(0xffffff)
}.alignItems(VerticalAlign.Center)
}
.borderRadius(4)
.backgroundColor('#B0B0B0')
.width(48)
.height(24)
}
.justifyContent(FlexAlign.Center)
.alignItems(VerticalAlign.Center)
.width('21.6%')
.height('100%')
}
.justifyContent(FlexAlign.Center)
.alignItems(VerticalAlign.Center)
.width('21.6%')
.height('100%')
}
.width('100%')
.height(44)
.zIndex(10)
.alignRules({
top: { anchor: "__container__", align: VerticalAlign.Top },
middle: { anchor: "__container__", align: HorizontalAlign.Center }
...
...
@@ -195,7 +209,7 @@ export struct MultiPictureDetailPageComponent {
}
.index(this.swiperIndex)
.width('100%')
.height(
px2vp(this.picHeight) + 32
)
.height(
'100%'
)
.vertical(false)
.autoPlay(false)
.cachedCount(3)
...
...
@@ -207,77 +221,13 @@ export struct MultiPictureDetailPageComponent {
center: { anchor: "__container__", align: VerticalAlign.Center },
middle: { anchor: "__container__", align: HorizontalAlign.Center }
})
.zIndex(1)
.onChange((index: number) => {
this.swiperIndex = index
})
Row() {
Scroll(this.scroller) {
Row() {
Flex({
direction: FlexDirection.Column,
justifyContent: FlexAlign.Start
}) {
Text() {
Span(`${this.swiperIndex + 1}`)
.fontSize(24)
.fontFamily('PingFang SC-Medium')
.fontWeight(500)
.lineHeight(28)
Span(`/${this.contentDetailData.photoList.length}`)
.fontSize(14)
.fontFamily('PingFang SC-Medium')
.fontWeight(500)
.lineHeight(19)
}.fontColor(Color.White).margin(4)
Text(`${this.contentDetailData.newsTitle}`)
.fontColor(Color.White)
.fontSize(16)
.fontFamily('PingFang SC-Semibold')
.fontWeight(600)
.lineHeight(24)
.margin({
top: 4,
left: 0,
bottom: 4,
right: 0
})
Text(`${this.contentDetailData.photoList?.[this.swiperIndex].picDesc}`)
.fontColor(Color.White)
.fontSize(14)
.fontFamily('PingFang SC-Regular')
.fontWeight(400)
.lineHeight(22)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.margin({
top: 4,
left: 0,
bottom: 4,
right: 18
})
.maxLines(16)
}
}
.width('100%')
.margin({
top: 8,
left: 18,
bottom: 24,
right: 18
})
}
.scrollable(ScrollDirection.Vertical)
.scrollBarWidth(0)
.height(px2vp(this.titleHeight))
}
.id('e_swiper_titles')
.alignRules({
bottom: { anchor: "__container__", align: VerticalAlign.Bottom },
middle: { anchor: "__container__", align: HorizontalAlign.Center }
.onClick(() => {
this.showDownload = !this.showDownload
})
.height(px2vp(this.titleHeight) + 64)
}
if (this.netStatus !== undefined) {
EmptyComponent({
...
...
@@ -291,23 +241,113 @@ export struct MultiPictureDetailPageComponent {
middle: { anchor: "__container__", align: HorizontalAlign.Center }
})
}
OperRowListView({
contentDetailData: this.contentDetailData,
Column(){
Column(){
Row() {
Scroll(this.scroller) {
Row() {
Flex({
direction: FlexDirection.Column,
justifyContent: FlexAlign.Start
}) {
Text() {
Span(`${this.swiperIndex + 1}`)
.fontSize(24)
.fontFamily('PingFang SC-Medium')
.fontWeight(500)
.lineHeight(28)
Span(`/${this.contentDetailData?.photoList?.length}`)
.fontSize(14)
.fontFamily('PingFang SC-Medium')
.fontWeight(500)
.lineHeight(19)
}
.fontColor(Color.White)
.margin(4)
Text(`${this.contentDetailData.newsTitle}`)
.fontColor(Color.White)
.fontSize(16)
.fontFamily('PingFang SC-Semibold')
.fontWeight(600)
.lineHeight(24)
.margin({
top: 4,
left: 0,
bottom: 4,
right: 0
})
Text(`${this.contentDetailData.photoList?.[this.swiperIndex].picDesc}`)
.fontColor(Color.White)
.fontSize(14)
.fontFamily('PingFang SC-Regular')
.fontWeight(400)
.lineHeight(22)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.margin({
top: 4,
left: 0,
bottom: 4,
right: 18
})
.maxLines(16)
}
}
.width('100%')
}
.scrollable(ScrollDirection.Vertical)
.scrollBarWidth(0)
.height(px2vp(this.titleHeight))
.align(Alignment.Bottom)
}
OperRowListView({
contentDetailData: this.contentDetailData,
})
.width('100%')
.height(56)
.border({ width: { top: 0.5 }, color: '#FFFFFF' })
}
.visibility(!this.showDownload ? Visibility.Visible : Visibility.None)
Column(){
Row() {
Flex({
direction: FlexDirection.Row,
justifyContent: FlexAlign.SpaceBetween
}) {
Text() {
Span(`${this.swiperIndex + 1}`)
.fontSize(24)
.fontFamily('PingFang SC-Medium')
.fontWeight(500)
.lineHeight(28)
Span(`/${this.contentDetailData?.photoList?.length}`)
.fontSize(14)
.fontFamily('PingFang SC-Medium')
.fontWeight(500)
.lineHeight(19)
}
.fontColor(Color.White)
.margin(4)
ImageDownloadComponent({ url: this.contentDetailData.photoList?.[this.swiperIndex].picPath })
.margin({
top: 8,
left: 18,
bottom: 24,
right: 18
})
}
}
.width('100%')
}
.visibility(this.showDownload ? Visibility.Visible : Visibility.None)
}
.zIndex(10)
.id('e_swiper_bottom')
.alignRules({
bottom: { anchor: "__container__", align: VerticalAlign.Bottom },
middle: { anchor: "__container__", align: HorizontalAlign.Center }
})
.alignRules({
bottom: { anchor: "__container__", align: VerticalAlign.Bottom },
middle: { anchor: "__container__", align: HorizontalAlign.Center }
})
.width('100%')
.height(56)
.margin({
top: 16,
left: 16,
right: 16,
bottom: 0
})
.border({ width: { top: 0.5 }, color: '#FFFFFF' })
.id('e_oper_row')
}
getContentDetailData() {
...
...
sight_harmony/features/wdComponent/src/main/ets/components/comment/model/PublishCommentModel.ets
View file @
8e01a6f
import { commentItemModel } from './CommentModel'
@Observed
export class publishCommentModel {
...
...
@@ -25,7 +27,7 @@ export class publishCommentModel {
/*评论内容*/
commentContent: string = ""
/*1.文字 2.文字+表情 3.定制表情(客户端写死) 4.图片*/
commentType: string = '
1
'
commentType: string = '
2
'
/*根评论id,如果是一级评论,传-1;否则,传当前评论所属的根评论id*/
rootCommentId: string = "-1"
/*父评论id,如果是其它评论的回复,该字段必填*/
...
...
@@ -35,6 +37,10 @@ export class publishCommentModel {
//可选
placeHolderText: string = "优质评论会获得最佳评论人的称号"
//最新发布的评论
lastCommentModel: commentItemModel = new commentItemModel()
}
...
...
sight_harmony/features/wdComponent/src/main/ets/components/comment/view/CommentComponent.ets
View file @
8e01a6f
import ArrayList from '@ohos.util.ArrayList'
import { ViewType } from 'wdConstant/Index';
import { DateTimeUtils, LazyDataSource } from 'wdKit/Index';
import { DateTimeUtils,
EmitterEventId, EmitterUtils,
LazyDataSource } from 'wdKit/Index';
import PageModel from '../../../viewmodel/PageModel';
import { commentItemModel, commentListModel, WDPublicUserType } from '../model/CommentModel';
import commentViewModel from '../viewmodel/CommentViewModel'
...
...
@@ -9,6 +9,7 @@ import measure from '@ohos.measure'
import { CommentCustomDialog } from './CommentCustomDialog'
import { publishCommentModel } from '../model/PublishCommentModel';
import { ifaa } from '@kit.OnlineAuthenticationKit';
import { HttpUrlUtils } from 'wdNetwork/Index';
const TAG = 'CommentComponent';
...
...
@@ -18,18 +19,13 @@ const testString = '因为读书的人\n是低着头向上看的人\n身处一
@Preview
@Component
export struct CommentComponent {
// @State private browSingModel: commentListModel = new commentListModel()
/*必传*/
@ObjectLink publishCommentModel: publishCommentModel
isloading: boolean = false
@State allDatas: LazyDataSource<commentItemModel> = new LazyDataSource();
@State dialogController: CustomDialogController | null = null;
// 在自定义组件即将析构销毁时将dialogControlle置空
aboutToDisappear() {
this.dialogController = null // 将dialogController置空
...
...
@@ -37,12 +33,23 @@ export struct CommentComponent {
aboutToAppear() {
//注册通知,来自别的组件的评论成功通知
EmitterUtils.receiveEvent(EmitterEventId.COMMENT_PUBLISH, (targetId?: string) => {
if (targetId) {
if (targetId == this.publishCommentModel.targetId) {
//新增评论
this.addCommentLocal()
}
}
})
this.dialogController = new CustomDialogController({
builder: CommentCustomDialog({
confirm: (value: Record<string, string>) => {
this.addCommentLocal()
},
publishCommentModel:this.publishCommentModel
publishCommentModel:
this.publishCommentModel
}),
autoCancel: true,
alignment: DialogAlignment.Bottom,
...
...
@@ -57,6 +64,24 @@ export struct CommentComponent {
}
//
addCommentLocal() {
let model = commentViewModel.deepCopyCommentItemModel(this.publishCommentModel.lastCommentModel)
/*一级评论*/
if (this.publishCommentModel.lastCommentModel.parentId == '-1') {
this.allDatas.addFirstItem(model)
//TODO 跳转顶部
}else{
//二级评论
this.allDatas.getDataArray().forEach(element => {
if (element.id == this.publishCommentModel.lastCommentModel.rootCommentId) {
element.childCommentsLazyDataSource.addFirstItem(model)
}
});
}
}
/*标题:全部评论*/
@Builder
titleHeader() {
...
...
@@ -73,6 +98,11 @@ export struct CommentComponent {
}
.margin({ left: 16 })
.onClick(()=>{
// this.allDatas.push(new commentItemModel())
// this.allDatas.addFirstItem(new commentItemModel())
// this.allDatas.reloadData();
})
}.height(44)
.width('100%')
...
...
@@ -92,7 +122,11 @@ export struct CommentComponent {
/*查看更多和收起*/
@Builder
GroupFooterView(item: commentItemModel, index: number) {
footerExpandedView({ item: item, contentId: this.publishCommentModel.targetId, contentType: this.publishCommentModel.targetType })
footerExpandedView({
item: item,
contentId: this.publishCommentModel.targetId,
contentType: this.publishCommentModel.targetType
})
}
build() {
...
...
@@ -114,7 +148,7 @@ export struct CommentComponent {
.onClick(() => {
console.log(TAG)
})
})
}
,(childItem: commentItemModel, subIndex: number) => JSON.stringify(childItem) + subIndex.toString()
)
}
} else {
ListItemGroup({ header: this.CommentHeaderItem(item, index) }) {
...
...
@@ -129,29 +163,31 @@ export struct CommentComponent {
.onClick(() => {
console.log(TAG)
})
})
}
,(childItem: commentItemModel, subIndex: number) => JSON.stringify(childItem) + subIndex.toString()
)
}
}
})
}
,(item: commentItemModel, index: number) => JSON.stringify(item) + index.toString()
)
}.layoutWeight(1)
}
}
//获取数据
async getData() {
commentViewModel.fetchContentCommentList('1', this.publishCommentModel.targetId, this.publishCommentModel.targetType).then(commentListModel => {
if (commentListModel && commentListModel.list && commentListModel.list.length > 0) {
commentListModel.list.forEach(element => {
element.hasMore = Number.parseInt(element.childCommentNum) ? true : false
let newModel = commentViewModel.deepCopyCommentItemModel(element)
// newModel.targetId = this.publishCommentModel.targetId
// newModel.targetType = this.publishCommentModel.targetType
this.allDatas.push(newModel)
});
commentViewModel.fetchContentCommentList('1', this.publishCommentModel.targetId, this.publishCommentModel.targetType)
.then(commentListModel => {
if (commentListModel && commentListModel.list && commentListModel.list.length > 0) {
commentListModel.list.forEach(element => {
element.hasMore = Number.parseInt(element.childCommentNum) ? true : false
let newModel = commentViewModel.deepCopyCommentItemModel(element)
// 点赞用
newModel.targetId = this.publishCommentModel.targetId
newModel.targetType = this.publishCommentModel.targetType
this.allDatas.push(newModel)
});
}
})
}
})
}
}
...
...
@@ -243,6 +279,8 @@ struct ChildCommentItem {
})
.margin({ left: 95, right: 16, top: -5 })
.onClick(() => {
this.publishCommentModel.rootCommentId = this.item.rootCommentId
this.publishCommentModel.parentId = this.item.id
this.publishCommentModel.placeHolderText = '回复' + this.item.fromUserName + ':'
...
...
sight_harmony/features/wdComponent/src/main/ets/components/comment/view/CommentCustomDialog.ets
View file @
8e01a6f
import { inputMethodEngine } from '@kit.IMEKit'
import { commentInfo } from 'wdBean/Index'
import { commentItemModel } from '../model/CommentModel'
import { publishCommentModel } from '../model/PublishCommentModel'
import commentViewModel from '../viewmodel/CommentViewModel'
...
...
@@ -22,9 +24,10 @@ export struct CommentCustomDialog {
let bean: Record<string, string> = {};
// this.publishCommentModel.commentContent = this.commentText
//TODO 判断类型
this.publishCommentModel.commentType = '1'
commentViewModel.publishComment(this.publishCommentModel).then(() => {
this.publishCommentModel.commentType = '2'
commentViewModel.publishComment(this.publishCommentModel).then((model:commentItemModel) => {
this.publishCommentModel.commentContent = ''
this.publishCommentModel.lastCommentModel = model
// this.commentText = ''
if (this.controller != null) {
this.controller.close()
...
...
sight_harmony/features/wdComponent/src/main/ets/components/comment/view/CommentTabComponent.ets
View file @
8e01a6f
import { EmitterEventId, EmitterUtils } from 'wdKit/Index'
import { publishCommentModel } from '../model/PublishCommentModel'
import { CommentCustomDialog } from './CommentCustomDialog'
@Preview
@Component
...
...
@@ -8,6 +11,34 @@ export struct CommentTabComponent {
@State type:number = 1
@State placeHolder: string = '说两句...'
@State dialogController: CustomDialogController | null = null;
/*回调方法*/
dialogControllerConfirm: () => void = () => {}
aboutToAppear() {
this.dialogController = new CustomDialogController({
builder: CommentCustomDialog({
confirm: (value: Record<string, string>) => {
this.dialogControllerConfirm();
EmitterUtils.sendEvent(EmitterEventId.COMMENT_PUBLISH,this.publishCommentModel.targetId)
},
publishCommentModel:this.publishCommentModel
}),
autoCancel: true,
alignment: DialogAlignment.Bottom,
customStyle: true,
offset: {
dx: 0,
dy: -20
},
})
}
build() {
Row(){
Stack({alignContent:Alignment.Start}){
...
...
@@ -15,6 +46,10 @@ export struct CommentTabComponent {
Text(this.placeHolder).fontSize(12).fontColor('#999999').margin({left:10})
}
}.width(151).height(30)
.onClick(()=>{
this.publishCommentModel.parentId = '-1';
this.dialogController?.open();
})
}
}
...
...
@@ -25,25 +60,52 @@ export struct CommentIconComponent {
/*展示类型*/
@State type:number = 1
/*回调方法*/
onClickItem: () => void = () => {}
build() {
Row(){
Stack({alignContent:Alignment.TopEnd}){
Image($r('app.media.comment_icon')).width(24).height(24)
// Stack({alignContent:Alignment.Start}) {
// Image($r('app.media.comment_icon_number')).objectFit(ImageFit.Fill).width(12).height(12)
Text(this.publishCommentModel.totalCommentNumer + '12345' +' ')
.fontSize(8)
.fontColor('#ffffff')
// .backgroundColor('#ED2800')
.height(12)
.margin({ left: 6 })
.backgroundImage($r('app.media.comment_icon_number'))
// }.width(25)
RelativeContainer() {
Image($r('app.media.comment_icon_number_bg'))
.objectFit(ImageFit.Fill)
.resizable({ slice: {top:1, left: 20 , right:1, bottom:1} })
.alignRules({
top: {anchor: "Text", align: VerticalAlign.Top},
left: {anchor: "Text", align: HorizontalAlign.Start},
right: {anchor: "Text", align: HorizontalAlign.End},
bottom : {anchor: "Text", align: VerticalAlign.Bottom},
})
// .offset({
// x:-6
// })
.id("Image")
Text('123213123123123')
.fontSize(8)
.fontColor('#ffffff')// .backgroundColor('#ED2800')
.height(12)
.alignRules({
top: {anchor: "__container__", align: VerticalAlign.Top},
left: {anchor: "__container__", align: HorizontalAlign.Start}
})
// .margin({left: 4,right:4
// })
/*动态计算文字宽度*/
.width(50)
// .backgroundColor(Color.Green)
.id("Text")
}
// }
.offset({
x:12
})
}
}.width(24).height(24)
// .backgroundColor(Color.Blue)
}
}
\ No newline at end of file
...
...
sight_harmony/features/wdComponent/src/main/ets/components/comment/view/QualityCommentsComponent.ets
View file @
8e01a6f
...
...
@@ -184,37 +184,14 @@ export struct QualityCommentsComponent {
Column() {
Stack() {
this.titleHeader()
this.listLayout()
// if(this.viewType == ViewType.ERROR){
// ErrorComponent()
// }else if(this.viewType == ViewType.EMPTY){
// EmptyComponent({emptyType:WDViewDefaultType.WDViewDefaultType_NoComment})
// }else {
// CustomPullToRefresh({
// alldata:[],
// scroller:this.scroller,
// customList:()=>{
// this.listLayout()
// // this.testLayout()
// },
// onRefresh:(resolve)=>{
// this.currentPage = 1
// this.getData(resolve)
// },
// onLoadMore:(resolve)=> {
// if (this.hasMore === false) {
// if(resolve) resolve('')
// return
// }
// this.currentPage++
// this.getData(resolve)
// }
// })
// }
if(this.viewType == ViewType.ERROR){
ErrorComponent()
}else if(this.viewType == ViewType.EMPTY){
EmptyComponent({emptyType:WDViewDefaultType.WDViewDefaultType_NoComment})
}else {
this.listLayout()
}
}.alignContent(Alignment.Top)
}.backgroundColor(this.currentWindowColor).width('100%')
...
...
@@ -250,12 +227,15 @@ export struct QualityCommentsComponent {
ListItem() {
}.height(this.bottomSafeHeight)
}
}.onReachEnd(()=>{
this.currentPage++
this.getData()
})
.margin({ top: 196 })
.height("100%")
.width("100%")
.edgeEffect(EdgeEffect.None) // 必须设置列表为滑动到边缘无效果
// .edgeEffect(EdgeEffect.Spring)
// .edgeEffect(EdgeEffect.None) // 必须设置列表为滑动到边缘无效果
.edgeEffect(EdgeEffect.Spring)
.nestedScroll({
scrollForward: NestedScrollMode.PARENT_FIRST,
scrollBackward: NestedScrollMode.SELF_FIRST
...
...
sight_harmony/features/wdComponent/src/main/ets/components/comment/viewmodel/CommentViewModel.ets
View file @
8e01a6f
...
...
@@ -148,7 +148,7 @@ class CommentViewModel {
bean['userName'] = UserDataLocal.getUserId();
bean['userHeaderUrl'] = UserDataLocal.getUserHeaderUrl();
Http
Request
.post<ResponseDTO<commentStatusModel[]>>(url, bean, headers).then((data: ResponseDTO<commentStatusModel[]>) => {
Http
BizUtil
.post<ResponseDTO<commentStatusModel[]>>(url, bean, headers).then((data: ResponseDTO<commentStatusModel[]>) => {
if (data.code != 0) {
fail()
return
...
...
@@ -164,7 +164,7 @@ class CommentViewModel {
/*发布评论*/
publishComment(model: publishCommentModel) {
return new Promise<
void
>((success, fail) => {
return new Promise<
commentItemModel
>((success, fail) => {
let url = HttpUrlUtils.getPublishCommentUrl()
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
let bean: Record<string, string> = {};
...
...
@@ -182,14 +182,15 @@ class CommentViewModel {
bean['targetType'] = model.targetType
bean['parentId'] = model.parentId
HttpRequest.post<ResponseDTO<comment
StatusModel[]>>(url, bean, headers).then((data: ResponseDTO<commentStatusModel[]
>) => {
HttpRequest.post<ResponseDTO<comment
ItemModel>>(url, bean, headers).then((data: ResponseDTO<commentItemModel
>) => {
if (data.code != 0) {
ToastUtils.showToast(data.message, 1000);
fail()
return
}
ToastUtils.showToast(data.message, 1000);
success()
let model = data.data as commentItemModel
success(model)
}, (error: Error) => {
ToastUtils.showToast('评论失败', 1000);
fail()
...
...
@@ -240,7 +241,7 @@ class CommentViewModel {
let promiseArray: Promise<commentStatusListModel | void>[] = [];
//未登录不用批查
if (HttpUrlUtils.getUserId()){
if (HttpUrlUtils.getUserId())
{
if (commentIDs.length > 0) {
let promise1 = new Promise<void>((success) => {
// HttpRequest HttpBizUtil
...
...
@@ -285,7 +286,7 @@ class CommentViewModel {
})
promiseArray.push(promise1);
}
}
}
if (fromUserIDs.length > 0) {
let promise2 = new Promise<void>((success) => {
let url = HttpUrlUtils.getBatchUserUrl();
...
...
@@ -386,8 +387,6 @@ class CommentViewModel {
}
deepCopyCommentItemModel(model: commentItemModel) {
let newModel = new commentItemModel()
...
...
@@ -411,10 +410,13 @@ class CommentViewModel {
newModel.fromUserHeader = model.fromUserHeader
newModel.fromUserId = model.fromUserId
newModel.fromUserName = model.fromUserName
newModel.fromUserType = model.fromUserType
if (model.toUserType != null) {
newModel.fromUserType = model.fromUserType
}
newModel.id = model.id
newModel.likeNum = model.likeNum.toString()
if (model.likeNum) {
newModel.likeNum = model.likeNum.toString()
}
if (Number.parseInt(newModel.likeNum) <= 0) {
newModel.likeNum = ''
}
...
...
sight_harmony/features/wdComponent/src/main/ets/components/view/OperRowListView.ets
View file @
8e01a6f
...
...
@@ -13,7 +13,10 @@ import router from '@ohos.router';
import inputMethod from '@ohos.inputMethod';
import { MultiPictureDetailViewModel } from '../../viewmodel/MultiPictureDetailViewModel';
import { LikeComponent } from './LikeComponent';
import { CommentCustomDialog } from '../comment/view/CommentCustomDialog';
import { CommentTabComponent, CommentIconComponent, } from '../comment/view/CommentTabComponent';
import { publishCommentModel } from '../comment/model/PublishCommentModel'
// import { CommentCustomDialog } from '../comment/view/CommentCustomDialog';
import { HttpUrlUtils } from 'wdNetwork/Index';
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
import { PageRepository } from '../../repository/PageRepository';
...
...
@@ -38,6 +41,7 @@ export struct OperRowListView {
@State interactData: InteractDataDTO = {} as InteractDataDTO
@State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态
@State likeBean: Record<string, string> = {}
@State publishCommentModel: publishCommentModel = new publishCommentModel()
@State operationList: OperationItem[] = [
{
...
...
@@ -81,13 +85,23 @@ export struct OperRowListView {
this.likeBean['channelId'] = this.contentDetailData.reLInfo?.channelId + ''
console.info(TAG, 'contentDetailData----', JSON.stringify(this.contentDetailData))
console.info(TAG, 'likeBean----', JSON.stringify(this.likeBean))
// 评论需要数据
this.publishCommentModel.targetId = this.contentDetailData.newsId + ''
this.publishCommentModel.targetRelId = this.contentDetailData.reLInfo?.relId + ''
this.publishCommentModel.targetTitle = this.contentDetailData.newsTitle + ''
this.publishCommentModel.targetRelType = this.contentDetailData.reLInfo?.relType + ''
this.publishCommentModel.targetRelObjectId = this.contentDetailData.reLInfo?.relObjectId + ''
this.publishCommentModel.keyArticle = this.contentDetailData.keyArticle + ''
this.publishCommentModel.targetType = this.contentDetailData.newsType + ''
this.publishCommentModel.totalCommentNumer = '10'
}
build() {
Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems:ItemAlign.Center }){
Row() {
Column() {
Image($r('app.media.icon_arrow_left_white'))
// Image($r('app.media.icon_arrow_left_white'))
Image($r('app.media.icon_arrow_left'))
.width(24)
.height(24)
.aspectRatio(1)
...
...
@@ -109,6 +123,10 @@ export struct OperRowListView {
/* CommentCustomDialog({
placeHolderText: '说两句'
})*/
if (this.publishCommentModel?.targetId) {
CommentTabComponent({publishCommentModel: this.publishCommentModel})
CommentIconComponent({publishCommentModel: this.publishCommentModel})
}
}
/*TextInput({placeholder:'说两句...'})
.placeholderColor('#999999')
...
...
@@ -140,7 +158,8 @@ export struct OperRowListView {
}
.width('100%')
.height(50)
.backgroundColor(Color.Black)
// .backgroundColor(Color.Black)
.backgroundColor(Color.White)
.margin({
bottom: 20
})
...
...
sight_harmony/features/wdComponent/src/main/resources/base/media/comment_icon_number.png → sight_harmony/features/wdComponent/src/main/resources/base/media/comment_icon_number
_bg
.png
View file @
8e01a6f
934 Bytes
sight_harmony/features/wdDetailPlayLive/src/main/ets/pages/DetailPlayVLivePage.ets
View file @
8e01a6f
...
...
@@ -107,7 +107,7 @@ export struct DetailPlayVLivePage {
(data) => {
if (data.length > 0) {
this.liveDetailsBean = data[0]
this.liveState =
'end' //
this.liveDetailsBean.liveInfo?.liveState //直播新闻-直播状态 wait待开播running直播中end已结束cancel已取消paused暂停
this.liveState = this.liveDetailsBean.liveInfo?.liveState //直播新闻-直播状态 wait待开播running直播中end已结束cancel已取消paused暂停
if (this.liveDetailsBean.fullColumnImgUrls && this.liveDetailsBean.fullColumnImgUrls.length > 0) {
this.imgUrl = this.liveDetailsBean.fullColumnImgUrls[0].url
}
...
...
sight_harmony/features/wdDetailPlayShortVideo/src/main/ets/pages/DetailVideoListPage.ets
View file @
8e01a6f
...
...
@@ -22,7 +22,7 @@ export struct DetailVideoListPage {
@Provide showComment: boolean = true
@Provide pageShow: number = -1
@Provide pageHide: number = -1
@Provide switchVideoStatus: boolean =
fals
e
@Provide switchVideoStatus: boolean =
tru
e
@State data: ContentDetailDTO[] = []
@State currentIndex: number = 0
@State interactDataList: InteractDataDTO[] = []
...
...
sight_harmony/features/wdDetailPlayShortVideo/src/main/ets/pages/VideoChannelDetail.ets
View file @
8e01a6f
...
...
@@ -44,7 +44,7 @@ export struct VideoChannelDetail {
@Provide windowWidth: number = AppStorage.get<number>('windowWidth') || 0
@Consume @Watch('pageShowChange') pageShow: number
@Consume @Watch('pageHideChange') pageHide: number
@Provide switchVideoStatus: boolean =
fals
e
@Provide switchVideoStatus: boolean =
tru
e
@State data: ContentDetailDTO[] = []
@State currentIndex: number = 0
@State interactDataList: InteractDataDTO[] = []
...
...
sight_harmony/features/wdLogin/Index.ets
View file @
8e01a6f
export { add } from "./src/main/ets/utils/Calc"
export { SettingPasswordParams } from "./src/main/ets/pages/login/SettingPasswordLayout"
\ No newline at end of file
export { SettingPasswordParams } from "./src/main/ets/pages/login/SettingPasswordLayout"
export { LoginModule } from './src/main/ets/LoginModule'
\ No newline at end of file
...
...
sight_harmony/features/wdLogin/src/main/ets/LoginModule.ets
0 → 100644
View file @
8e01a6f
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'
class LoginJumpHandler implements JumpInterceptorAction {
/// 说明是调用了跳转 WDRouterPage.loginPage 页面的行为
on(params?: object | undefined, singleMode?: boolean | undefined): boolean {
HuaweiAuth.sharedInstance().fetchAnonymousPhone().then((anonymousPhone) => {
router.pushUrl({url: WDRouterPage.oneKeyLoginPage.url()})
}).catch((error: string) => {
router.pushUrl({url: WDRouterPage.loginPage.url()})
})
return true
}
}
export class LoginModule {
static startup() {
/// 初始化华为一键登录相关
if (HuaweiAuth.enable) {
HuaweiAuth.sharedInstance().registerEvents()
AccountManagerUtils.isLogin().then((login) => {
if (!login) {
HuaweiAuth.sharedInstance().rePrefetchAnonymousPhone()
}
})
RouterJumpInterceptor.register(WDRouterPage.loginPage, new LoginJumpHandler())
}
}
}
\ No newline at end of file
...
...
sight_harmony/features/wdLogin/src/main/ets/pages/login/LoginPage.ets
View file @
8e01a6f
...
...
@@ -9,6 +9,10 @@ import { WDRouterPage } from 'wdRouter/src/main/ets/router/WDRouterPage';
import { WDRouterRule } from 'wdRouter/src/main/ets/router/WDRouterRule';
import { Params } from '../../../../../../../commons/wdRouter/oh_modules/wdBean/src/main/ets/bean/content/Params'
import {InterestsHobbiesModel} from '../../../../../../../products/phone/src/main/ets/pages/viewModel/InterestsHobbiesModel'
import HuaweiAuth from '../../utils/HuaweiAuth'
import { loginComponentManager, LoginWithHuaweiIDButton } from '@hms.core.account.LoginComponent'
import { BusinessError } from '@ohos.base'
@Extend(Row)
function otherStyle() {
.backgroundImageSize(ImageSize.Cover)
...
...
@@ -56,7 +60,6 @@ struct LoginPage {
})
loginViewModel = new LoginViewModel()
@State isProtocol:boolean=false
onCodeSend() {
Logger.debug(TAG, "isCodeSend:" + this.isCodeSend + "")
if (this.isCodeSend) {
...
...
sight_harmony/features/wdLogin/src/main/ets/pages/login/LoginProtocolWebview.ets
View file @
8e01a6f
...
...
@@ -15,6 +15,7 @@ struct LoginProtocolWebview {
userProtocol = "https://cdnpeoplefrontuat.aikan.pdnews.cn/rmrb/rmrb-protocol-zh-web/0.0.1/app/protocol-1005.html"
privateProtocol = 'https://cdnpeoplefrontuat.aikan.pdnews.cn/rmrb/rmrb-protocol-zh-web/0.0.1/app/protocol-1001.html'
logoutProtocol = 'https://cdnpeoplefrontuat.aikan.pdnews.cn/rmrb/rmrb-protocol-zh-web/0.0.1/app/protocol-1003.html'
huaweiAuthProtocol = 'https://privacy.consumer.huawei.com/legal/id/authentication-terms.htm?code=CN&language=zh-CN'
async aboutToAppear() {
if (router.getParams()) {
...
...
@@ -30,6 +31,9 @@ struct LoginProtocolWebview {
}else if(params.contentID == "3"){ //注销协议
this.webUrl = await SPHelper.default.get(SpConstants.LOGOUT_PROTOCOL, this.logoutProtocol) as string
this.webviewController.loadUrl(this.webUrl)
} else if(params.contentID == "4"){ //华为用户认证协议
this.webUrl = this.huaweiAuthProtocol
this.webviewController.loadUrl(this.webUrl)
}
}
...
...
sight_harmony/features/wdLogin/src/main/ets/pages/login/OneKeyLoginPage.ets
0 → 100644
View file @
8e01a6f
import { router } from '@kit.ArkUI'
import { Params } from 'wdBean/Index'
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'
import HuaweiAuth from '../../utils/HuaweiAuth'
import { BusinessError } from '@kit.BasicServicesKit'
@Entry
@Component
struct OneKeyLoginPage {
anonymousPhone: string = ''
@State agreeProtocol: boolean = false
aboutToAppear(): void {
this.anonymousPhone = HuaweiAuth.sharedInstance().anonymousPhone||""
}
build() {
Column() {
this.CloseRow()
Image($r("app.media.login_logo"))
.width(120)
.height(66)
.margin({ top: 78, bottom: 74})
.align(Alignment.Center)
Text(this.anonymousPhone)
.fontSize(30)
.fontWeight(600)
.fontColor("#222222")
.margin({bottom: 10})
.align(Alignment.Center)
this.ProtocolRow()
Row() {
Button("华为账号一键登录")
.type(ButtonType.Normal)
.height(48)
.backgroundColor(!this.agreeProtocol ? Color.Grey : Color.Red)
.width("100%")
.onClick((event) => {
if (!this.agreeProtocol) {
return
}
HuaweiAuth.sharedInstance().oneKeyLogin().then((authorizeCode) => {
//TODO: 调用服务端接口登录
}).catch((error: BusinessError) => {
})
})
}
.padding({ left: 25, right: 25 })
.margin({top: 15})
Button("其他手机号登录")
.type(ButtonType.Normal)
.align(Alignment.Center)
.foregroundColor("#666666")
.backgroundColor(Color.White)
.onClick((event) => {
router.replaceUrl({url: WDRouterPage.loginPage.url()})
})
}
}
@Builder ProtocolRow() {
Row({space: 4}) {
Image(this.agreeProtocol ? $r('app.media.login_checkbox_select') : $r('app.media.login_checkbox_unselected'))
.width(15)
.height(15)
.onClick(() => {
this.agreeProtocol = !this.agreeProtocol
})
Text() {
Span("我已阅读并同意").fontColor("#999999").fontSize(12)
Span("《用户协议》").fontColor("#ED2800").fontSize(12).onClick(() => {
let bean = { contentID: "1", pageID: "" } as Params
WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage, bean)
})
Span("、").fontColor("#999999").fontSize(12)
Span("《隐私政策》").fontColor("#ED2800").fontSize(12).onClick(() => {
let bean = { contentID: "2", pageID: "" } as Params
WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage, bean)
})
Span("和").fontColor("#999999").fontSize(12)
Span("《华为账号用户认证协议》").fontColor("#ED2800").fontSize(12).onClick(() => {
let bean = { contentID: "4", pageID: "" } as Params
WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage, bean)
})
}
.layoutWeight(1)
}
.margin({top: 15})
.padding({ left: 25, right: 25 })
.width('100%')
}
@Builder CloseRow() {
Row() {
Blank()
Image($r('app.media.login_closed'))
.width(24)
.height(24)
.onClick(() => router.back())
}.margin({ top: 15, right: 15 })
.width("100%")
}
}
\ No newline at end of file
...
...
sight_harmony/features/wdLogin/src/main/ets/utils/HuaweiAuth.ets
0 → 100644
View file @
8e01a6f
import { authentication, extendService } from '@kit.AccountKit';
import { AccountManagerUtils, EmitterEventId, EmitterUtils, Logger } from 'wdKit/Index';
import { util } from '@kit.ArkTS';
import { DEFAULT } from '@ohos/hypium';
import { BusinessError } from '@kit.BasicServicesKit';
const TAG = "HuaweiOneKeyAuth"
export default class HuaweiAuth {
// 是否开启
static enable = false
// 匿名手机号
private _anonymousPhone?: string
get anonymousPhone() {
return this._anonymousPhone
}
private static instance: HuaweiAuth
static sharedInstance(): HuaweiAuth {
if (!HuaweiAuth.instance) {
HuaweiAuth.instance = new HuaweiAuth()
}
return HuaweiAuth.instance
}
registerEvents() {
// 注册用户退出登录,取一次用来下次使用
EmitterUtils.receiveEvent(EmitterEventId.FORCE_USER_LOGIN_OUT, ((str?: string) => {
HuaweiAuth.sharedInstance().rePrefetchAnonymousPhone()
}))
EmitterUtils.receiveEvent(EmitterEventId.APP_ENTER_FOREGROUD, ((str?: string) => {
AccountManagerUtils.isLogin().then((login) => {
if (!login) {
HuaweiAuth.sharedInstance().rePrefetchAnonymousPhone()
}
})
}))
}
// 重新预取手机号(App启动未登录、回前台未登录、和退出登录 时调用提前取号)
rePrefetchAnonymousPhone() {
this._anonymousPhone = undefined
this.fetchAnonymousPhone()
}
// 要登录时,先调用。如果获取到手机号了 则弹起一键登录页面
fetchAnonymousPhone() : Promise<string> {
return new Promise((resolve, fail) => {
if (this.anonymousPhone) {
resolve(this.anonymousPhone)
return
}
let authRequest = new authentication.HuaweiIDProvider().createAuthorizationWithHuaweiIDRequest();
// 权限有 phone 、email、realTimePhone、quickLoginMobilePhone,这里用获取匿名手机号
authRequest.scopes = ['quickLoginAnonymousPhone'];
authRequest.state = util.generateRandomUUID();
authRequest.forceAuthorization = false;
let controller = new authentication.AuthenticationController(getContext(this));
try {
controller.executeRequest(authRequest).then((response: authentication.AuthorizationWithHuaweiIDResponse) => {
let anonymousPhone = response.data?.extraInfo?.quickLoginAnonymousPhone;
if (anonymousPhone) {
Logger.info(TAG, 'get anonymousPhone, ' + JSON.stringify(response));
this._anonymousPhone = anonymousPhone as string
resolve(this._anonymousPhone)
return;
}
Logger.info(TAG, 'get anonymousPhone is empty. ' + JSON.stringify(response));
fail("获取匿名手机号为空")
}).catch((err: BusinessError) => {
Logger.error(TAG, 'get anonymousPhone failed. ' + JSON.stringify(err));
fail("获取匿名手机号失败")
})
} catch (err) {
Logger.error(TAG, 'get anonymousPhone fail. ' + JSON.stringify(err));
fail("获取匿名手机号失败")
}
})
}
// 华为账号一键登录授权
// 返回结果为 Authorization Code
oneKeyLogin() : Promise<string> {
let loginRequest = new authentication.HuaweiIDProvider().createLoginWithHuaweiIDRequest();
// 当用户未登录华为帐号时,是否强制拉起华为帐号登录界面
loginRequest.forceLogin = true;
loginRequest.state = util.generateRandomUUID();
return new Promise((resolve, fail) => {
try {
let controller = new authentication.AuthenticationController(getContext(this));
controller.executeRequest(loginRequest, (err, data) => {
if (err) {
Logger.error(TAG, 'login fail, ' + JSON.stringify(err))
fail(err)
return;
}
let loginWithHuaweiIDResponse = data as authentication.LoginWithHuaweiIDResponse;
let state = loginWithHuaweiIDResponse.state;
if (state != undefined && loginRequest.state != state) {
Logger.error(TAG, 'login fail, The state is different' + JSON.stringify(loginWithHuaweiIDResponse))
fail({
code: 99999,
name: "一键登录",
message:"状态错误:" + `请求状态 ${loginRequest.state}, 结果状态 ${state}`
} as BusinessError)
return;
}
Logger.info(TAG, 'login success, ' + JSON.stringify(loginWithHuaweiIDResponse));
let loginWithHuaweiIDCredential = loginWithHuaweiIDResponse.data!;
let authorizationCode = loginWithHuaweiIDCredential.authorizationCode;
resolve(authorizationCode!)
});
} catch (error) {
Logger.error(TAG, 'login fail, ' + JSON.stringify(error))
fail(error)
}
});
}
// 打开账户中心
openAccountCenter() {
try {
extendService.startAccountCenter(getContext(this), (err, data) => {
if (err) {
Logger.info(TAG, 'startAccountCenterWithCallback fail,error: ' + JSON.stringify(err));
return;
}
Logger.info(TAG, 'startAccountCenterWithCallback success');
});
} catch (error) {
Logger.error(TAG, 'startAccountCenterWithCallback fail,error: ' + JSON.stringify(error));
}
}
}
...
...
sight_harmony/features/wdLogin/src/main/resources/base/media/login_hw.png
0 → 100644
View file @
8e01a6f
1.31 KB
sight_harmony/features/wdLogin/src/main/resources/base/profile/main_pages.json
View file @
8e01a6f
...
...
@@ -6,6 +6,7 @@
"pages/login/LoginProtocolWebview"
,
"pages/login/SettingPasswordPage"
,
"pages/login/SettingPasswordLayout"
,
"pages/guide/GuidePages"
"pages/guide/GuidePages"
,
"pages/login/OneKeyLoginPage"
]
}
...
...
sight_harmony/products/phone/oh-package.json5
View file @
8e01a6f
...
...
@@ -16,6 +16,7 @@
"wdRouter"
:
"file:../../commons/wdRouter"
,
"wdNetwork"
:
"file:../../commons/wdNetwork"
,
"wdHwAbility"
:
"file:../../features/wdHwAbility"
,
"wdJsBridge"
:
"file:../../commons/wdJsBridge"
"wdJsBridge"
:
"file:../../commons/wdJsBridge"
,
"wdLogin"
:
"file:../../features/wdLogin"
}
}
...
...
sight_harmony/products/phone/src/main/ets/entryability/EntryAbility.ets
View file @
8e01a6f
...
...
@@ -15,12 +15,14 @@ import {
WindowModel
} from 'wdKit';
import { HostEnum, HostManager, WDHttp } from 'wdNetwork';
import { LoginModule } from 'wdLogin/src/main/ets/LoginModule';
export default class EntryAbility extends UIAbility {
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
SPHelper.init(this.context);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
registerRouter();
LoginModule.startup()
NetworkManager.getInstance().init()
WDHttp.initHttpHeader()
const spHostUrl = SPHelper.default.getSync('hostUrl', '') as string
...
...
@@ -94,10 +96,14 @@ export default class EntryAbility extends UIAbility {
onForeground(): void {
// Ability has brought to foreground
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
EmitterUtils.sendEmptyEvent(EmitterEventId.APP_ENTER_FOREGROUD)
}
onBackground(): void {
// Ability has back to background
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
EmitterUtils.sendEmptyEvent(EmitterEventId.APP_ENTER_BACKGROUD)
}
}
...
...
sight_harmony/products/phone/src/main/module.json5
View file @
8e01a6f
...
...
@@ -34,6 +34,10 @@
]
}
],
"metadata"
:
[{
"name"
:
"client_id"
,
"value"
:
"220837707901830144"
}],
"requestPermissions"
:
[
{
"name"
:
"ohos.permission.CAMERA"
,
...
...
@@ -88,6 +92,6 @@
{
"name"
:
"ohos.permission.INTERNET"
}
]
,
]
}
}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment