王士厅
... ... @@ -96,6 +96,14 @@ export class HttpUrlUtils {
*/
static readonly APPOINTMENT_QueryUserDetail_PATH: string = "/api/rmrb-user-center/user/zh/c/queryUserDetail";
/**
* 资料编辑 更新普通用户信息
*/
static readonly APPOINTMENT_editUserDetail_PATH: string = "/api/rmrb-user-center/user/zh/c/editUserDetail";
/**
* 资料编辑 更新普通用户名
*/
static readonly APPOINTMENT_editUserDetail1_PATH: string = "/api/rmrb-user-center/user/zh/c/completeUserInfo";
/**
/**
* 个人中心 关注列表详情
*/
... ...
import { TopNavDTO } from 'wdBean';
import curves from '@ohos.curves';
const INDEX_SETTING_TITLE: string = '首页设置'
const INDEX_SETTING_SUBTITLE: string = '将指定频道设置为首页'
const MY_CHANNEL: string = '我的频道'
const EDIT_TEXT: string = '编辑'
const EDIT_DOWN: string = '完成'
const MY_CHANNEL_TIP1: string = '点击进入频道'
const MY_CHANNEL_TIP2: string = '拖动调整频道顺序'
const MORE_CHANNEL: string = '更多频道'
const LOCAL_CHANNEL: string = '地方频道'
@CustomDialog
struct ChannelDialog {
@State dragItem: number = -1
@State item: number = -1
private dragRefOffsetX: number = 0
private dragRefOffsetY: number = 0
@State offsetX: number = 0
@State offsetY: number = 0
private FIX_VP_X: number = 80
private FIX_VP_Y: number = 48
@State indexSettingTabIndex: number = 0
@State isEditIng: boolean = false
@State currentTopNavSelectedItem: TopNavDTO = {} as TopNavDTO
@Link currentTopNavSelectedIndex: number
@Link myChannelList: TopNavDTO[]
@Link moreChannelList: TopNavDTO[]
... ... @@ -20,48 +33,153 @@ struct ChannelDialog {
controller?: CustomDialogController
confirm: (index: number) => void = () => {
}
changeChannelIndex : (index1:number, index2:number) => void = ()=>{}
myChannelItemEditHandle = (index: number): void => {
let item = this.myChannelList.splice(index, 1)[0]
if (item.moreChannel === '1') {
this.moreChannelList.unshift(item)
}
if (item.localChannel === '1') {
this.localChannelList.unshift(item)
changeChannelIndex: (index1: number, index2: number) => void = () => {
}
delChannelItem: (index: number) => void = () => {
}
addChannelItem: (item: TopNavDTO) => void = () => {
}
aboutToAppear() {
this.currentTopNavSelectedItem = this.myChannelList[this.currentTopNavSelectedIndex]
}
itemMove(index: number, newIndex: number): void {
let targetItem = this.myChannelList[newIndex]
if (!(targetItem?.headlinesOn === 1 || targetItem?.movePermitted === 0 || targetItem?.homeChannel === '1')) {
this.changeChannelIndex(index, newIndex)
if (index <= this.currentTopNavSelectedIndex || newIndex <= this.currentTopNavSelectedIndex) {
// this.currentTopNavSelectedIndex = this.myChannelList.findIndex(ele => ele.channelId === currentTopNavSelectedItem.channelId)
}
}
}
@Builder
pixelMapBuilder(item: TopNavDTO, index: number) { //拖拽过程样式
Row() {
Row() {
Text(item.name)
.fontSize(14)
.fontColor(this.currentTopNavSelectedIndex === index ? '#ED2800' : (item.homeChannel === '1' || item.movePermitted === 0 ? '#999999' : '#222222'))
//向下滑
down(index: number): void {
console.info(`向下滑`)
this.offsetY -= this.FIX_VP_Y
this.dragRefOffsetY += this.FIX_VP_Y
this.itemMove(index, index + 4)
}
if (this.isEditIng && item.myChannel !== '1') {
Image($r('app.media.icon_audio_close'))
.width(12)
.margin({ left: 1 })
}
//向下滑(右下角为空)
down2(index: number): void {
this.offsetY -= this.FIX_VP_Y
this.dragRefOffsetY += this.FIX_VP_Y
this.itemMove(index, index + 4)
}
//向上滑
up(index: number): void {
console.info(`向上滑`)
this.offsetY += this.FIX_VP_Y
this.dragRefOffsetY -= this.FIX_VP_Y
this.itemMove(index, index - 4)
}
//向左滑
left(index: number): void {
console.info(`向左滑`)
this.offsetX += this.FIX_VP_X
this.dragRefOffsetX -= this.FIX_VP_X
this.itemMove(index, index - 1)
}
//向右滑
right(index: number): void {
console.info(`向右滑`)
this.offsetX -= this.FIX_VP_X
this.dragRefOffsetX += this.FIX_VP_X
this.itemMove(index, index + 1)
}
//向右下滑
lowerRight(index: number): void {
console.info(`向右下滑`)
this.offsetX -= this.FIX_VP_X
this.dragRefOffsetX += this.FIX_VP_X
this.offsetY -= this.FIX_VP_Y
this.dragRefOffsetY += this.FIX_VP_Y
this.itemMove(index, index + 5)
}
//向右上滑
upperRight(index: number): void {
console.info(`向右上滑`)
this.offsetX -= this.FIX_VP_X
this.dragRefOffsetX += this.FIX_VP_X
this.offsetY += this.FIX_VP_Y
this.dragRefOffsetY -= this.FIX_VP_Y
this.itemMove(index, index - 3)
}
//向左下滑
lowerLeft(index: number): void {
console.info(`向左下滑`)
this.offsetX += this.FIX_VP_X
this.dragRefOffsetX -= this.FIX_VP_X
this.offsetY -= this.FIX_VP_Y
this.dragRefOffsetY += this.FIX_VP_Y
this.itemMove(index, index + 3)
}
//向左上滑
upperLeft(index: number): void {
console.info(`向左上滑`)
this.offsetX += this.FIX_VP_X
this.dragRefOffsetX -= this.FIX_VP_X
this.offsetY += this.FIX_VP_Y
this.dragRefOffsetY -= this.FIX_VP_Y
this.itemMove(index, index - 5)
}
handleAnimationTo(item: TopNavDTO, event: GestureEvent) {
let index = this.myChannelList.findIndex(ele => ele.num === this.dragItem)
if (!(item.headlinesOn === 1 || item.movePermitted === 0 || item.homeChannel === '1') && this.isEditIng) {
this.offsetY = event.offsetY - this.dragRefOffsetY
this.offsetX = event.offsetX - this.dragRefOffsetX
if (this.offsetY >= this.FIX_VP_Y / 2 && (this.offsetX <= 44 && this.offsetX >= -44)
) {
//向下滑
this.down(index)
} else if (this.offsetY <= -this.FIX_VP_Y / 2 && (this.offsetX <= 44 && this.offsetX >= -44)
) {
//向上滑
this.up(index)
} else if (this.offsetX >= this.FIX_VP_X / 2 && (this.offsetY <= 20 && this.offsetY >= -20)
) {
//向右滑
this.right(index)
} else if (this.offsetX <= -this.FIX_VP_X / 2 && (this.offsetY <= 20 && this.offsetY >= -20)
) {
//向左滑
this.left(index)
} else if (this.offsetX >= this.FIX_VP_X / 2 && this.offsetY >= this.FIX_VP_Y / 2
) {
//向右下滑
this.lowerRight(index)
} else if (this.offsetX >= this.FIX_VP_X / 2 && this.offsetY <= -this.FIX_VP_Y / 2
) {
//向右上滑
this.upperRight(index)
} else if (this.offsetX <= -this.FIX_VP_X / 2 && this.offsetY >= this.FIX_VP_Y / 2
) {
//向左下滑
this.lowerLeft(index)
} else if (this.offsetX <= -this.FIX_VP_X / 2 && this.offsetY <= -this.FIX_VP_Y / 2
) {
//向左上滑
this.upperLeft(index)
} else if (this.offsetX >= this.FIX_VP_X / 2 && this.offsetY >= this.FIX_VP_Y / 2
) {
//向右下滑(右下角为空)
this.down2(index)
}
.width('100%')
.height('100%')
.justifyContent(FlexAlign.Center)
.backgroundColor(item.homeChannel === '1' || item.movePermitted === 0 ? '#F5F5F5' : '#ffffff')
}
.width('23%')
.height(40)
.border({
width: item.homeChannel === '1' ? 0 : 1,
color: '#EDEDED',
radius: 3
})
}
build() {
Column() {
Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
Image($r('app.media.icon_ren_min_ri_bao'))
.width(72)
... ... @@ -73,7 +191,7 @@ struct ChannelDialog {
})
}
.width('100%')
.padding({ top: 30, bottom: 10 })
.padding({ bottom: 10 })
List() {
... ... @@ -87,6 +205,7 @@ struct ChannelDialog {
Text(INDEX_SETTING_SUBTITLE)
.fontSize(12)
.fontWeight(400)
.fontColor('#222222')
}
.width('100%')
.margin({ top: 22, bottom: 16 })
... ... @@ -128,9 +247,17 @@ struct ChannelDialog {
ListItem() {
Row() {
Text(MY_CHANNEL)
.fontSize(16)
.fontWeight(600)
Row() {
Text(MY_CHANNEL)
.fontSize(16)
.fontWeight(600)
.margin({ right: 4 })
Text(!this.isEditIng ? MY_CHANNEL_TIP1 : MY_CHANNEL_TIP2)
.fontSize(12)
.fontWeight(400)
.fontColor('#222222')
}
Text(this.isEditIng ? EDIT_DOWN : EDIT_TEXT)
.fontSize(14)
.fontColor('#ED2800')
... ... @@ -151,7 +278,7 @@ struct ChannelDialog {
Row() {
Text(item.name)
.fontSize(14)
.fontColor(this.currentTopNavSelectedIndex === index ? '#ED2800' : (item.homeChannel === '1' || item.movePermitted === 0 ? '#999999' : '#222222'))
.fontColor(this.currentTopNavSelectedItem.channelId === item.channelId ? '#ED2800' : (item.homeChannel === '1' || item.movePermitted === 0 ? '#999999' : '#222222'))
if (this.isEditIng && item.myChannel !== '1') {
Image($r('app.media.icon_audio_close'))
... ... @@ -162,15 +289,14 @@ struct ChannelDialog {
.width('100%')
.height('100%')
.justifyContent(FlexAlign.Center)
.backgroundColor(item.homeChannel === '1' || item.movePermitted === 0 ? '#F5F5F5' : '')
.backgroundColor(item.homeChannel === '1' || item.movePermitted === 0 ? '#F5F5F5' : '#ffffff')
.onClick(() => {
if (this.isEditIng) {
if (item.myChannel !== '1') {
this.myChannelItemEditHandle(index)
this.delChannelItem(index)
}
} else {
this.confirm(index)
this.currentTopNavSelectedIndex = index
this.controller?.close()
}
})
... ... @@ -182,6 +308,33 @@ struct ChannelDialog {
color: '#EDEDED',
radius: 3
})
.zIndex(this.dragItem == item.num ? 1 : 0)
.translate(this.dragItem == item.num ? { x: this.offsetX, y: this.offsetY } : { x: 0, y: 0 })
.gesture(
GestureGroup(GestureMode.Sequence,
PanGesture({ fingers: 1, direction: null, distance: 0 })
.onActionStart((event: GestureEvent) => {
this.dragItem = item.num
this.dragRefOffsetX = 0
this.dragRefOffsetY = 0
})
.onActionUpdate((event: GestureEvent) => {
animateTo({ curve: curves.interpolatingSpring(0, 1, 400, 38) }, () => {
this.handleAnimationTo(item, event)
})
})
.onActionEnd((event: GestureEvent) => {
animateTo({ curve: curves.interpolatingSpring(0, 1, 400, 38) }, () => {
this.dragItem = -1
})
})
)
.onCancel(() => {
animateTo({ curve: curves.interpolatingSpring(0, 1, 400, 38) }, () => {
this.dragItem = -1
})
}))
}, (item: TopNavDTO) => JSON.stringify(item))
}
.width('100%')
... ... @@ -189,22 +342,7 @@ struct ChannelDialog {
.columnsTemplate('1fr 1fr 1fr 1fr')
.columnsGap(8)
.rowsGap(8)
.height(Math.ceil(this.myChannelList.length / 4 ) * 48)
.editMode(this.isEditIng)
.supportAnimation(true) //设置Grid是否开启拖拽补位动画
.onItemDragStart((event: ItemDragInfo, itemIndex: number) => {
if(this.myChannelList[itemIndex].headlinesOn===1 || this.myChannelList[itemIndex].movePermitted===0){
return
}else{
return this.pixelMapBuilder(this.myChannelList[itemIndex], itemIndex) //设置拖拽过程中显示的元素。
}
})
.onItemDrop((event: ItemDragInfo, itemIndex: number, insertIndex: number, isSuccess: boolean) => { //绑定此事件的组件可作为拖拽释放目标,当在本组件范围内停止拖拽行为时,触发回调。
if (!isSuccess || insertIndex >= this.myChannelList.length || this.myChannelList[insertIndex].headlinesOn===1 || this.myChannelList[insertIndex].movePermitted===0) {
return
}
this.changeChannelIndex(itemIndex,insertIndex)
})
.height(Math.ceil(this.myChannelList.length / 4) * 48)
}
//更多频道列表
... ... @@ -233,7 +371,7 @@ struct ChannelDialog {
.width('100%').height('100%')
.justifyContent(FlexAlign.Center)
.onClick(() => {
this.myChannelList.push(this.moreChannelList.splice(index, 1)[0])
this.addChannelItem(this.moreChannelList.splice(index, 1)[0])
})
}
.width(80)
... ... @@ -277,7 +415,7 @@ struct ChannelDialog {
.width('100%').height('100%')
.justifyContent(FlexAlign.Center)
.onClick(() => {
this.myChannelList.push(this.localChannelList.splice(index, 1)[0])
this.addChannelItem(this.localChannelList.splice(index, 1)[0])
})
}
.width(80)
... ... @@ -295,9 +433,8 @@ struct ChannelDialog {
}
}.width('100%').height('100%')
}
.padding(15)
.padding({ top: 40, right: 15, bottom: 20, left: 15 })
.backgroundColor('#ffffff')
}
}
... ... @@ -305,18 +442,42 @@ struct ChannelDialog {
// @Entry
@Component
struct ChannelSubscriptionLayout {
changeTab: (index: number) => void = () => {
}
@State indexSettingArray: string [] = ['推荐', '热点']
//当前选中的频道
@Link currentTopNavSelectedIndex: number;
@Link myChannelList: TopNavDTO []
@Link moreChannelList: TopNavDTO []
@Link localChannelList: TopNavDTO []
@Link @Watch('onChannelIdsUpdate') channelIds: number []
changeTab: (index: number) => void = () => {
}
//频道弹窗点击切换频道
onAccept = (index: number) => {
console.log(`onAccept${index}`)
this.changeTab(index)
}
//交换我的频道数组中的位置
changeChannelIndex = (index1: number, index2: number) => {
let tmp = this.myChannelList.splice(index1, 1)
let channelIdTmp = this.channelIds.splice(index1, 1)
this.myChannelList.splice(index2, 0, tmp[0])
this.channelIds.splice(index2, 0, channelIdTmp[0])
}
//删除频道
delChannelItem = (index: number) => {
let item = this.myChannelList.splice(index, 1)[0]
this.channelIds.splice(index, 1)
if (item.moreChannel === '1') {
this.moreChannelList.unshift(item)
}
if (item.localChannel === '1') {
this.localChannelList.unshift(item)
}
}
// 添加频道
addChannelItem = (item: TopNavDTO) => {
this.channelIds.push(item.channelId)
this.myChannelList.push(item)
}
// @State currentTopNavSelectedIndex: number = 0
// @State topNavList: TopNavDTO [] = [
// {
... ... @@ -1831,22 +1992,14 @@ struct ChannelSubscriptionLayout {
moreChannelList: $moreChannelList,
localChannelList: $localChannelList,
confirm: this.onAccept,
changeChannelIndex: this.changeChannelIndex
changeChannelIndex: this.changeChannelIndex,
delChannelItem: this.delChannelItem,
addChannelItem: this.addChannelItem
}),
alignment: DialogAlignment.TopEnd,
customStyle: true,
})
changeChannelIndex(index1:number, index2:number) { //交换数组中的位置
const temp = this.myChannelList[index1];
if (index1 > index2) {
this.myChannelList.splice(index2, 0, temp);
this.myChannelList.splice(index1 + 1, 1);
} else {
this.myChannelList.splice(index2 + 1, 0, temp);
this.myChannelList.splice(index1, 1);
}
}
// topNavListHandle() {
// let defaultMyChannelList: TopNavDTO[] = []
// let handledTopNavList = [...this.topNavList]
... ... @@ -1896,8 +2049,13 @@ struct ChannelSubscriptionLayout {
// })
// }
onChannelIdsUpdate(){
AppStorage.SetOrCreate('channelIds', this.channelIds.join(','));
console.log(`AppStorage.get('channelIds')${AppStorage.get('channelIds')}`)
}
aboutToAppear() {
console.log(`myChannelListzz${this.channelIds}}`)
// this.topNavListHandle()
}
... ...
import { CustomTitleUI } from '../reusable/CustomTitleUI';
import { EditListInfo, editModel } from '../../model/EditInfoModel';
import { EditListInfo, editModel, editModelParams, WDEditDataModelType } from '../../model/EditInfoModel';
import EditInfoViewModel from '../../viewmodel/EditInfoViewModel';
import { WDRouterPage, WDRouterRule } from 'wdRouter';
import {AreaPickerDialog} from '../view/areaPickerDialog/AreaPickerDialog'
import { AreaListModel } from '../../model/AreaListModel';
import router from '@ohos.router';
@Entry
@Component
... ... @@ -18,6 +19,7 @@ struct EditUserInfoPage {
builder: AreaPickerDialog({dataSource:this.dataSource,
confirmCallback:(area:string)=>{
this.currentUserInfo.userExtend.city = area;
this.currentUserInfo.editDataType = WDEditDataModelType.WDEditDataModelType_region
this.updateEditModel()
}
}),
... ... @@ -31,7 +33,7 @@ struct EditUserInfoPage {
}
onPageShow(){
this.updateUserNameAndIntroduction()
}
build() {
... ... @@ -98,13 +100,15 @@ struct EditUserInfoPage {
.width('100%')
.onClick(()=>{
if (i === 1){
WDRouterRule.jumpWithPage(WDRouterPage.editUserNikeNamePage)
let params: editModelParams = {
editContent: this.currentUserInfo.userName
}
WDRouterRule.jumpWithPage(WDRouterPage.editUserNikeNamePage,params)
}else if (i === 2){
WDRouterRule.jumpWithPage(WDRouterPage.editUserIntroductionPage)
// router.pushUrl({
// url:'pages/EditUserInstoductionPage',
// params:{pageNum:i}
// })
let params: editModelParams = {
editContent: this.currentUserInfo.userExtend.introduction
}
WDRouterRule.jumpWithPage(WDRouterPage.editUserIntroductionPage,params)
}else if (i === 3){
this.dialogController.open()
} else if (i === 4) {
... ... @@ -116,6 +120,7 @@ struct EditUserInfoPage {
onAccept:(value:DatePickerResult) => {
let mon = value.month as number + 1
this.currentUserInfo.userExtend.birthday = value.year+'-'+mon.toString()+'-'+value.day;
this.currentUserInfo.editDataType = WDEditDataModelType.WDEditDataModelType_birthday
this.updateEditModel()
}
})
... ... @@ -125,6 +130,7 @@ struct EditUserInfoPage {
selected:0,
onAccept:(value:TextPickerResult) => {
this.currentUserInfo.userExtend.sex = value.index.toString();
this.currentUserInfo.editDataType = WDEditDataModelType.WDEditDataModelType_sex
this.updateEditModel()
}
})
... ... @@ -132,6 +138,28 @@ struct EditUserInfoPage {
})
}
updateUserNameAndIntroduction(){
let backParams:editModelParams = router.getParams() as editModelParams;
if (backParams) {
let userName = backParams.userName as string ///昵称
let introduction = backParams.introduction as string ///简介
if (userName) {
if (userName != this.currentUserInfo.userName) {
this.currentUserInfo.userName = userName;
this.currentUserInfo.editDataType = WDEditDataModelType.WDEditDataModelType_nickname
this.updateEditModel()
}
} else if (introduction){
if (introduction != this.currentUserInfo.userExtend.introduction ) {
this.currentUserInfo.userExtend.introduction = introduction;
this.currentUserInfo.editDataType = WDEditDataModelType.WDEditDataModelType_intro
this.updateEditModel()
}
}
}
}
updateEditModel(){
this.listData = []
this.listData.push(...EditInfoViewModel.getEditListInfo(this.currentUserInfo))
... ...
import { CustomTitleUI } from '../reusable/CustomTitleUI'
import router from '@ohos.router'
import { editModelParams } from '../../model/EditInfoModel'
@Entry
@Component
... ... @@ -7,13 +8,13 @@ struct EditUserIntroductionPage {
@State numCount: number = 0
@State textColor : string = '#222222'
@State introduction: string = ''
@State params:editModelParams = router.getParams() as editModelParams;
build() {
Column(){
CustomTitleUI({titleName:'修改简介'})
Row(){
TextInput({placeholder:'请输入简介'})
TextInput({placeholder:'请输入简介',text:this.params.editContent})
.maxLength(60)
.width('100%')
.height(80)
... ... @@ -50,9 +51,12 @@ struct EditUserIntroductionPage {
.borderRadius(5)
.margin(30)
.onClick(()=>{
let params: editModelParams = {
introduction: this.introduction
}
router.back({
url:'',
params:{nikeName:this.introduction}
params:params
})
})
}
... ...
import { CustomTitleUI } from '../reusable/CustomTitleUI'
import router from '@ohos.router'
import { editModelParams } from '../../model/EditInfoModel'
@Entry
@Component
... ... @@ -8,13 +9,13 @@ struct EditUserNikeNamePage {
@State numCount: number = 0
@State textColor : string = '#222222'
@State nikeName: string = ''
@State params:editModelParams = router.getParams() as editModelParams;
build() {
Column(){
CustomTitleUI({titleName:'修改昵称'})
Row(){
TextInput({placeholder:'请输入昵称'})
TextInput({placeholder:'请输入昵称',text:this.params.editContent})
.width('100%')
.maxLength(16)
.height(50)
... ... @@ -50,9 +51,12 @@ struct EditUserNikeNamePage {
.borderRadius(5)
.margin(30)
.onClick(()=>{
let params: editModelParams = {
userName: this.nikeName
}
router.back({
url:'',
params:{nikeName:this.nikeName}
params:params
})
})
}
... ...
... ... @@ -68,6 +68,7 @@ export struct TopNavigationComponent {
if (item.myChannel === '1') {
this.myChannelList.push(item)
this.channelIds.push(item.channelId)
}
if (item.moreChannel === '1') {
this.moreChannelList.push(item)
... ... @@ -81,6 +82,7 @@ export struct TopNavigationComponent {
isBroadcast (item: TopNavDTO) {
return item.name === '播报'
}
build() {
Column() {
// 顶部搜索、日报logo、早晚报
... ... @@ -208,15 +210,15 @@ export struct TopNavigationComponent {
})
// 分类列表最右侧频道设置
ChannelSubscriptionLayout({
changeTab: (index) => {
this.tabsController.changeIndex(index)
},
currentTopNavSelectedIndex: $currentTopNavSelectedIndex,
myChannelList: $myChannelList,
moreChannelList: $moreChannelList,
localChannelList: $localChannelList,
currentTopNavSelectedIndex: $currentTopNavSelectedIndex
channelIds: $channelIds,
changeTab: (index) => {
this.tabsController.changeIndex(index)
}
})
// ChannelSubscriptionLayout()
}
}
... ...
/**
* WDEditDataModelType 更新资料类型
*/
export const enum WDEditDataModelType {
WDEditDataModelType_default, //默认不修改
WDEditDataModelType_head, //头像
WDEditDataModelType_nickname, //昵称
WDEditDataModelType_intro, //简介
WDEditDataModelType_sex, //性别
WDEditDataModelType_birthday, //生日
WDEditDataModelType_region, //地址
}
export class EditListInfo{
//标题
title:string
... ... @@ -42,6 +55,26 @@ export class editModel{
userExtend:EditInfoModel = new EditInfoModel()
constructor(userName?:string , userNameStatus?:string,phone?:string , headPhotoStatus?:string,userExtend?:EditInfoModel) {
editDataType:WDEditDataModelType = 0
constructor(userName?:string , userNameStatus?:string,phone?:string , headPhotoStatus?:string,userExtend?:EditInfoModel,editDataType?:WDEditDataModelType) {
}
}
export interface editModelParams {
editContent?: string;
userName?: string;
introduction?: string;
//地区
city?:string;
county?:string;
province?:string;
//生日
birthday?:string;
//性别
sex?:string;
}
\ No newline at end of file
... ...
... ... @@ -105,10 +105,9 @@ export class PageRepository {
}
/**
* 早晚报pageInfo请求 TODO 现网无数据写死测试环境
* 早晚报pageInfo请求
* */
static getMorningEveningPageInfoUrl(pageId: string) {
HttpUrlUtils.hostUrl = HttpUrlUtils.HOST_DEV
let url = HttpUrlUtils.getHost() + HttpUrlUtils.MORNING_EVENING_PAGE_INFO_PATH;
url = url + "?pageId=" + pageId;
Logger.info(TAG, "getMorningEveningPageInfoUrl url = " + url)
... ... @@ -125,11 +124,10 @@ export class PageRepository {
*
* 可选
* channelId:频道id
* channelStrategy:频道策略 TODO 现网无数据写死测试环境
* channelStrategy:频道策略
* topicId:专题id
* */
static getMorningEveningCompInfoUrl(pageId: number, groupId: number, refreshTime: string, topicId: string, pageNum: number, pageSize: number) {
HttpUrlUtils.hostUrl = HttpUrlUtils.HOST_DEV
let url = HttpUrlUtils.getHost() + HttpUrlUtils.MORNING_EVENING_COMP_INFO_PATH;
url = url + "?loadStrategy=first_load&pageNum=" + pageNum + "&refreshTime=" + refreshTime + "&pageId="
+ pageId + "&channelStrategy=2&groupId=" + groupId + "&topicId=" + topicId + "&pageSize=" + pageSize;
... ... @@ -288,7 +286,6 @@ export class PageRepository {
* */
static fetchBroadcastCompInfo(pageId: number, groupId: number, refreshTime: string, topicId:
string, channelId: string) {
HttpUrlUtils.hostUrl = HttpUrlUtils.HOST_DEV
let url = HttpUrlUtils.getHost() + HttpUrlUtils.MORNING_EVENING_COMP_INFO_PATH;
url = `${url}?topicId=${topicId}&channelStrategy=2&groupId=${groupId}&refreshTime=${refreshTime}&pageSize=50&recommend=0&pageId=${pageId}&loadStrategy=first_load&pageNum=1&channelId=${channelId}`
Logger.info(TAG, "getMorningEveningCompInfoUrl url = " + url)
... ...
import { EditInfoModel, EditListInfo, editModel } from '../model/EditInfoModel';
import { EditInfoModel, EditListInfo, editModel, editModelParams, WDEditDataModelType } from '../model/EditInfoModel';
import HashMap from '@ohos.util.HashMap';
import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork';
import { Logger, ResourcesUtils } from 'wdKit';
... ... @@ -27,6 +27,12 @@ class EditInfoViewModel {
return WDHttp.get<ResponseDTO>(requestUrl,headers)
}
BasePOSTRequest(requestUrl:string){
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders()
requestUrl = HttpUrlUtils.HOST_SIT + requestUrl
return WDHttp.post<ResponseDTO>(requestUrl,headers)
}
getEditListInfo(item?:editModel):EditListInfo[]{
this.editListData = [
... ... @@ -34,8 +40,7 @@ class EditInfoViewModel {
new EditListInfo('简介',item&&item.userExtend.introduction.length > 0?item.userExtend.introduction:'待完善'),
new EditListInfo('地区',item&&item.userExtend.city.length > 0?item.userExtend.city:'待完善'),
new EditListInfo('生日',item&&item.userExtend.birthday.length > 0?item.userExtend.birthday:'待完善'),
new EditListInfo('性别',item&&item.userExtend.sex.length > 0?(item.userExtend.sex=== '1'?'男':'女'):'待完善'),
]
new EditListInfo('性别',item&&item.userExtend.sex.length > 0?(item.userExtend.sex=== '1'?'男':'女'):'待完善'),]
return this.editListData
}
... ... @@ -51,7 +56,6 @@ class EditInfoViewModel {
}).catch((error: Error) => {
Logger.info('EditInfoViewModel','EditInfoViewModel','EditInfoViewModel')
success(this.GetqueryAccountOwnerLocal(context))
})
}))
}
... ... @@ -68,7 +72,7 @@ class EditInfoViewModel {
}
getAreaList(context: Context):PromiseLike<AreaListModel[]>{
return new Promise(((success, error) => {
return new Promise((success, error) => {
success(this.getAreaListLocal(context))
// this.BaseGetRequest(HttpUrlUtils.APPOINTMENT_AccountOwner_PATH).then((navResDTO:ResponseDTO) =>{
// if (navResDTO.code == 200) {
... ... @@ -81,7 +85,7 @@ class EditInfoViewModel {
// success(this.GetqueryAccountOwnerLocal(context))
//
// })
}))
})
}
async getAreaListLocal(context: Context): Promise<AreaListModel[]> {
... ... @@ -99,9 +103,33 @@ class EditInfoViewModel {
return new AreaListManageModel(item.code,item.id,item.label,item.children)
}
updateUserInfo(){
}
// updateUserInfo(item?:editModel):Promise<ResponseDTO> {
// let params: editModelParams = {};
// if (item.editDataType === WDEditDataModelType.WDEditDataModelType_head) {
// // params =
// } else if (item.editDataType === WDEditDataModelType.WDEditDataModelType_nickname) {
// params = { userName: item.userName }
// } else if (item.editDataType === WDEditDataModelType.WDEditDataModelType_intro) {
// params = { introduction: item.userExtend.introduction }
// } else if (item.editDataType === WDEditDataModelType.WDEditDataModelType_sex) {
// params = { sex: item.userExtend.sex }
// } else if (item.editDataType === WDEditDataModelType.WDEditDataModelType_birthday) {
// params = { birthday: item.userExtend.birthday }
// } else if (item.editDataType === WDEditDataModelType.WDEditDataModelType_region) {
// params = { county: item.userExtend.county }
// } else {
// }
// return new Promise((success, error) => {
// this.BasePOSTRequest(HttpUrlUtils.APPOINTMENT_editUserDetail_PATH)
// .then((navResDTO: ResponseDTO) => {
// if (navResDTO.code == 200) {
// }
// })
// .catch((error: Error) => {
//
// })
// })
// }
}
... ...
// import router from '@ohos.router';
import mediaquery from '@ohos.mediaquery';
import window from '@ohos.window';
import { ContentDetailDTO, InteractDataDTO, RmhInfoDTO, UserInfoDTO } from 'wdBean';
import { Logger, SPHelper, WindowModel } from 'wdKit';
import { PlayerConstants, WDPlayerController, WDPlayerRenderView } from 'wdPlayer';
import { ContentDetailRequest, devicePLSensorManager } from 'wdDetailPlayApi';
import { PlayControlViewContainer } from '../view/PlayControlViewContainer';
import { PlayerDetailContainer } from '../view/PlayerDetailContainer';
// import { PlayViewModel } from '../viewmodel/PlayViewModel';
import { DetailContainer } from '../view/DetailContainer';
import {
batchLikeAndCollectParams,
batchLikeAndCollectResult,
postBatchAttentionStatusParams
} from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest';
import { HttpUrlUtils } from 'wdNetwork/Index';
const TAG = 'DetailPlayShortVideoPage';
/**
* 详情&短视频播放页面
*/
@Component
export struct DetailPlayShortVideoPage {
// private contentId?: string = undefined
// private relId?: string = undefined
// private relType?: string = undefined
@Provide contentDetailData: ContentDetailDTO | undefined = undefined
@Provide interactData: InteractDataDTO | undefined = undefined
@Prop @Watch('currentIndexChange') currentIndex: number = 0
private index: number = 0
private playerController: WDPlayerController = new WDPlayerController();
// @Watch("urlChanged") @State url?: string = undefined
// @Watch('changeContinue') @Provide nextContId?: string = '';
// @Watch('getPlayHistory') @Provide curContId?: string = undefined;
// @Watch("playVMChanged") @Provide playVM: PlayViewModel = new PlayViewModel();
@Provide isFullScreen: boolean = false;
// @Provide canStart?: boolean = false;
// @Provide status: number = PlayerConstants.STATUS_START;
// @Provide userId: string = '';
// @Provide newsSourceName?: string = ''
// @Provide newsTitle?: string = ''
// @Provide editorName?: string = ''
// @Provide rmhInfo?: RmhInfoDTO | null = null
// @Provide userInfo?: UserInfoDTO | null = null
// @Provide message?: string = ''
// @Provide newsSummary?: string = ''
@Provide progressVal: number = 0;
@Provide videoLandScape?: number = 1; // 视频朝向, 横屏视频:1;竖屏视频:2
@Provide newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态
@Provide followStatus: string = '0' // 关注状态
// playVMChanged() {
// this.url = this.playVM.url
// this.newsSourceName = this.playVM.newsSourceName
// this.newsTitle = this.playVM.newsTitle
// this.editorName = this.playVM.editorName
// this.newsSummary = this.playVM.newsSummary
// this.videoLandScape = this.playVM.videoLandScape ?? 1
// this.curContId = this.playVM.contentId
// this.nextContId = this.playVM.nextContId
// this.canStart = this.playVM.canStart;
// this.message = this.playVM.message
// this.rmhInfo = this.playVM.rmhInfo
// this.userInfo = this.playVM.userInfo
// console.error('rmhInfo', this.rmhInfo)
// console.error('userInfo', this.userInfo)
// }
currentIndexChange() {
if (this.currentIndex != this.index) {
this.playerController.pause()
if (this.index < this.currentIndex - 5 && this.playerController.getPlayer()) {
this.playerController.release()
}
} else {
console.log('currentIndexChange====1', this.currentIndex)
this.playerController.play()
this.queryNewsInfoOfUser()
}
}
/**
* 查询用户点赞、收藏、关注等状态
*/
queryNewsInfoOfUser() {
if (HttpUrlUtils.getUserId()) {
const params: batchLikeAndCollectParams = {
contentList: [
{
contentId: this.contentDetailData?.newsId + '',
contentType: this.contentDetailData?.newsType + '',
}
]
}
// 已登录->查询用户对作品点赞、收藏状态
ContentDetailRequest.postBatchLikeAndCollectStatus(params).then(res => {
console.log('查询点赞、收藏状态==', JSON.stringify(res.data))
if (res.data) {
this.newsStatusOfUser = res.data[0]
}
})
const params1: postBatchAttentionStatusParams = {
creatorIds: [{ creatorId: this.contentDetailData?.rmhInfo?.rmhId ?? '' }]
}
// 已登录->批量查作品是否被号主关注
ContentDetailRequest.postBatchAttentionStatus(params1).then(res => {
console.log('批量查号主是否为用户关注==', JSON.stringify(res.data))
if (res.data) {
this.followStatus = res.data[0]?.status
}
})
}
}
aboutToAppear() {
console.log('开始设置setContentDetailData', JSON.stringify(this.contentDetailData))
// this.playVM.setContentDetailData(this.contentDetailData)
// this.playVMChanged()
this.queryNewsInfoOfUser()
this.playerController.onCanplay = () => {
if (this.index == 0 || this.currentIndex === this.index) {
this.videoLandScape = this.contentDetailData?.videoInfo[0]?.videoLandScape
this.playerController.firstPlay(this.contentDetailData?.videoInfo[0]?.videoUrl);
this.playerController.play()
}
}
// 设置播放地址
// this.url = 'https://media.w3.org/2010/05/sintel/trailer.mp4'
let listener = mediaquery.matchMediaSync('(orientation: landscape)');
listener.on("change", (mediaQueryResult) => {
if (mediaQueryResult.matches) {
console.log("横屏 yes")
this.isFullScreen = true
} else {
this.isFullScreen = false
console.log("横屏 no")
}
// WindowModel.shared.setMainWindowFullScreen(this.isFullScreen)
})
}
onPageShow() {
// WindowModel.shared.setPreferredOrientation(window.Orientation.AUTO_ROTATION_RESTRICTED);
}
aboutToDisappear(): void {
this.playerController?.pause();
}
onPageHide() {
// WindowModel.shared.setPreferredOrientation(window.Orientation.PORTRAIT);
devicePLSensorManager.devicePLSensorOff();
// this.status = PlayerConstants.STATUS_PAUSE;
this.playerController?.pause();
}
@Builder
playerViewContainerBuilder() {
// 播放窗口
WDPlayerRenderView({
playerController: this.playerController,
onLoad: async () => {
console.log('onload==', this.contentId, this.relId, this.relType)
}
})
.height('100%')
.width('100%')
.onClick(() => {
console.error('WDPlayerRenderView=== onClick')
this.playerController?.switchPlayOrPause();
})
}
@Builder
playControlViewContainerBuilder() {
// 播放窗口控制bar
PlayControlViewContainer({
playerController: this.playerController
})
}
@Builder
detailContainerBuilder() {
// DetailTabBarPageComponent({ pageId: this.pageId }).backgroundColor(Color.Black)
DetailContainer({
playerController: this.playerController
})
}
build() {
Row() {
PlayerDetailContainer({
playerView: () => {
this.playerViewContainerBuilder()
}, playControlView: () => {
// this.playControlViewContainerBuilder()
}, detailView: () => {
this.detailContainerBuilder()
}
})
.height('100%')
.width('100%')
.onClick(() => {
console.error('PlayerDetailContainer=== onClick')
this.playerController?.switchPlayOrPause();
})
}
.height('100%')
.width('100%')
.backgroundColor(Color.Black)
}
// 续播判断
// changeContinue() {
// if (this.nextContId) {
// this.playerController.continue = () => {
// this.playerController?.stop();
// // this.playVM.playWithContentId(this.nextContId ?? '');
// }
// return;
// }
// this.playerController.continue = undefined;
// }
// urlChanged() {
// console.error('urlChanged===')
// if (this.url) {
// this.status = PlayerConstants.STATUS_START;
// this.playerController.firstPlay(this.url);
// }
// }
// getPlayHistory() {
// SPHelper.default.get('playHistory', '').then((str) => {
// let result = str.toString();
// let time = 0;
// if (result != null && result != "") {
// let playHistory: Record<string, Record<string, number>> = JSON.parse(result);
// let userData: Record<string, number> = {};
// if (this.userId) {
// userData = playHistory[this.userId] ?? {};
// }
// if (this.curContId) {
// time = userData?.[this.curContId] ?? 0;
// }
// }
// this.playerController?.setStartTime(time);
// }).catch((err: Error) => {
// // Error: Inner error. Error code 15500000
// Logger.error(TAG, 'catch err:' + JSON.stringify(err));
// this.playerController?.setStartTime(0);
// });
// }
}
\ No newline at end of file
@CustomDialog
export struct DetailDialog {
controller: CustomDialogController
@Prop name: string
@Prop title: string
@Prop summary: string
@Link isOpen: boolean
build() {
Column() {
if (this.name + '1222222') {
Text(`@${this.name}` + '1222222')
.fontColor(Color.White)
.fontSize(14)
.fontWeight(600)
.lineHeight(17)
}
if (this.title) {
Text(this.title)
.fontColor(Color.White)
.fontSize(16)
.fontWeight(600)
.margin({ top: 8 })
.lineHeight(24)
}
Text(this.summary)
.fontColor(Color.White)
.fontSize(14)
.fontWeight(400)
.margin({ top: 8 })
.lineHeight(21)
Row() {
Image($r('app.media.ic_close'))
.height(24).margin({ top: 20 }).onClick(() => {
this.controller.close()
if (this.isOpen) {
this.isOpen = !this.isOpen
}
})
}.width('100%').justifyContent(FlexAlign.Center)
}
.width('100%')
.alignItems(HorizontalAlign.Start)
.backgroundColor(Color.Gray)
// .linearGradient({
// direction: GradientDirection.Top, // 渐变方向
// repeating: false, // 渐变颜色是否重复
// colors: [['rgba(0, 0, 0, 0.1)', 0.0], ['rgba(0, 0, 0, 0)', 1.0]] // 数组末尾元素占比小于1时满足重复着色效果
// })
.padding({ top: 20, bottom: 30, left: 16, right: 16 })
}
}
\ No newline at end of file
... ...
... ... @@ -198,7 +198,7 @@ export struct OperationListView {
}.height(60)
}
}.margin({ bottom: 30 })
}.margin({ bottom: 18 })
}
@Builder
... ...
... ... @@ -6,6 +6,7 @@ import { WDPlayerController } from 'wdPlayer';
import { devicePLSensorManager } from 'wdDetailPlayApi';
import { OperationListView } from './OperationListView';
import { ContentDetailDTO, RmhInfoDTO, UserInfoDTO } from 'wdBean/Index';
import { DetailDialog } from './DetailDialog';
@Component
export struct PlayerTitleComment {
... ... @@ -16,8 +17,22 @@ export struct PlayerTitleComment {
@Consume isFullScreen: boolean;
@Consume progressVal: number;
@Consume videoLandScape?: number
@State isOpen: boolean = false
dialogController: CustomDialogController = new CustomDialogController({
builder: DetailDialog({
name: this.getName(),
title: this.getTitle(),
summary: this.getSummary(),
isOpen: this.isOpen
}),
autoCancel: false,
customStyle: true,
alignment: DialogAlignment.Bottom
})
aboutToAppear() {
}
watchSpeed() {
... ... @@ -25,42 +40,50 @@ export struct PlayerTitleComment {
}
getName() {
return this.contentDetailData?.newsSourceName || this.contentDetailData?.editorName
return this.contentDetailData?.newsSourceName || this.contentDetailData?.editorName || ''
}
getTitle() {
return this.contentDetailData?.newsTitle || this.contentDetailData?.newsSummary
return this.contentDetailData?.newsTitle || this.contentDetailData?.newsSummary || ''
}
getSummary() {
return this.contentDetailData?.newsSummary || ''
}
build() {
Column() {
// Column() {
// Row() {
// Image($r('app.media.ic_switch_orientation'))
// .width(34)
// .aspectRatio(1)
// .objectFit(ImageFit.Contain)
// .padding({ left: 10, right: 5 })
// Text("全屏观看")
// .fontColor(Color.White)
// .fontSize('14fp')
// .maxLines(2)
// .layoutWeight(1)
// }
// .width(100)
// .backgroundColor(Color.Gray)
// .borderRadius(10)
// .alignItems(VerticalAlign.Center)
// .visibility(this.videoLandScape == 2 ? Visibility.Hidden : Visibility.Visible)
// .onClick(() => {
// this.isFullScreen = !this.isFullScreen;
// WindowModel.shared.setPreferredOrientation(window.Orientation.LANDSCAPE);
// devicePLSensorManager.devicePLSensorOn(window.Orientation.LANDSCAPE);
// })
// }
// .width('100%')
// // .margin({ bottom: 120 })
// .alignItems(HorizontalAlign.Center)
if (this.contentDetailData?.videoInfo[0]?.videoLandScape === 1) {
Column() {
Row() {
Image($r('app.media.ic_switch_orientation'))
.width(34)
.aspectRatio(1)
.objectFit(ImageFit.Contain)
.padding({ left: 10, right: 5 })
Text("全屏观看")
.fontColor(Color.White)
.fontSize('14fp')
.maxLines(2)
.layoutWeight(1)
}
.width(100)
.backgroundColor(Color.Gray)
.borderRadius(10)
.alignItems(VerticalAlign.Center)
.visibility(this.videoLandScape == 2 ? Visibility.Hidden : Visibility.Visible)
.onClick(() => {
this.isFullScreen = !this.isFullScreen;
WindowModel.shared.setPreferredOrientation(window.Orientation.LANDSCAPE);
devicePLSensorManager.devicePLSensorOn(window.Orientation.LANDSCAPE);
})
}
.width('100%')
// .margin({ bottom: 120 })
.alignItems(HorizontalAlign.Center)
}
Row() {
Column() {
... ... @@ -79,11 +102,22 @@ export struct PlayerTitleComment {
.textOverflow({ overflow: TextOverflow.Ellipsis })
}
Text('查看详情 > ')
.margin({ top: 5 })
.fontColor(Color.White)
.fontSize(12)
.maxLines(2)
if (this.contentDetailData?.newsSummary) {
Text('查看详情 > ')
.margin({ top: 8 })
.padding(6)
.borderRadius(2)
.backgroundColor('#636363')
.fontColor(Color.White)
.fontSize(12)
.onClick(() => {
console.log('click===', this.dialogController?.open)
this.isOpen = true
this.dialogController?.open()
})
}
}
.layoutWeight(1)
.alignItems(HorizontalAlign.Start)
... ... @@ -117,25 +151,7 @@ export struct PlayerTitleComment {
.height(24)
.aspectRatio(1)
.onClick(() => {
if (this.isFullScreen) {
if (deviceInfo.deviceType != "phone") {
WindowModel.shared.getWindowSize().then((size) => {
if (size.width > size.height) {
router.back();
} else {
this.isFullScreen = !this.isFullScreen;
WindowModel.shared.setPreferredOrientation(window.Orientation.PORTRAIT);
devicePLSensorManager.devicePLSensorOn(window.Orientation.PORTRAIT);
}
})
} else {
this.isFullScreen = !this.isFullScreen;
WindowModel.shared.setPreferredOrientation(window.Orientation.PORTRAIT);
devicePLSensorManager.devicePLSensorOn(window.Orientation.PORTRAIT);
}
} else {
router.back();
}
router.back();
})
TextInput({ placeholder: '说两句...', text: this.comment })
... ... @@ -158,5 +174,8 @@ export struct PlayerTitleComment {
.width('100%')
// .height('40%')
.alignItems(HorizontalAlign.Start)
.opacity(this.isOpen ? 0 : 1)
.animation({ duration: 200 })
}
}
\ No newline at end of file
}
... ...