yangchenggong1_wd

主页(客态) 个人中心接口对接

Showing 24 changed files with 950 additions and 43 deletions
... ... @@ -91,6 +91,25 @@ export class HttpUrlUtils {
* 个人中心 我的评论列表
*/
static readonly MINE_COMMENT_LIST_DATA_PATH: string = "/api/rmrb-comment/comment/zh/c/myCommentList";
/**
* 个人中心 APP获取用户等级
*/
static readonly MINE_USER_LEVEL_DATA_PATH: string = "/api/rmrb-user-point/auth/level/zh/c/queryUserLevel";
/**
* 个人中心 APP获取其他用户等级
*/
static readonly OTHER_USER_LEVEL_DATA_PATH: string = "/api/rmrb-user-point/auth/level/zh/c/batchUser";
/**
* 个人中心 (号主/普通用户)我的基本信息
*/
static readonly MINE_USER_DETAIL_DATA_PATH: string = "/api/rmrb-contact/contact/zh/c/my/detail";
/**
* 个人中心 (普通用户)其他用户 的基本信息
*/
static readonly OTHER_USER_DETAIL_DATA_PATH: string = "/api/rmrb-contact/contact/zh/c/master/detail";
/**
* 早晚报列表
* 根据页面id获取页面楼层列表
... ... @@ -339,6 +358,27 @@ export class HttpUrlUtils {
return url
}
static getMineUserLevelDataUrl() {
let url = HttpUrlUtils.HOST_SIT + HttpUrlUtils.MINE_USER_LEVEL_DATA_PATH
return url
}
static getOtherUserLevelDataUrl() {
let url = HttpUrlUtils.HOST_SIT + HttpUrlUtils.OTHER_USER_LEVEL_DATA_PATH
return url
}
static getMineUserDetailDataUrl() {
let url = HttpUrlUtils.HOST_SIT + HttpUrlUtils.MINE_USER_DETAIL_DATA_PATH
return url
}
static getOtherUserDetailDataUrl() {
let url = HttpUrlUtils.HOST_SIT + HttpUrlUtils.OTHER_USER_DETAIL_DATA_PATH
return url
}
static getYcgCommonHeaders(): HashMap<string, string> {
let headers: HashMap<string, string> = new HashMap<string, string>()
... ...
... ... @@ -64,5 +64,8 @@ export class WDRouterPage {
// 设置密码页、设置手机号页等等 (需要传参)
static settingPasswordPage = new WDRouterPage("wdLogin", "ets/pages/login/SettingPasswordPage");
//其他普通用户 主页
static otherNormalUserHomePagePage = new WDRouterPage("wdComponent", "ets/pages/OtherNormalUserHomePage");
// static loginProtocolPage = new WDRouterPage("wdLogin", "ets/pages/login/LoginProtocolWebview");
}
... ...
... ... @@ -27,6 +27,7 @@ export default struct MinePageCreatorFunctionUI {
.width('27lpx')
.height('27lpx')
.objectFit(ImageFit.Auto)
.interpolation(ImageInterpolation.High)
}
}.setFullWidth()
... ... @@ -42,6 +43,8 @@ export default struct MinePageCreatorFunctionUI {
Image(item.imgSrc)
.width('50lpx')
.height('50lpx')
.objectFit(ImageFit.Auto)
.interpolation(ImageInterpolation.High)
Text(`${item.msg}`)
.margin({top:'15lpx'})
.width('96lpx')
... ...
... ... @@ -37,6 +37,8 @@ export default struct MinePageMoreFunctionUI {
.width('38lpx')
.height('38lpx')
.margin({ right: '15lpx' })
.objectFit(ImageFit.Auto)
.interpolation(ImageInterpolation.High)
}
Text(`${item.msg}`)
.width('456lpx')
... ... @@ -50,6 +52,7 @@ export default struct MinePageMoreFunctionUI {
.width('27lpx')
.height('27lpx')
.objectFit(ImageFit.Auto)
.interpolation(ImageInterpolation.High)
.margin({ left: '81lpx', right: '29lpx' })
}.alignItems(VerticalAlign.Center)
.justifyContent(FlexAlign.Center)
... ...
... ... @@ -5,6 +5,13 @@ import router from '@ohos.router'
@Component
export default struct MinePagePersonFunctionUI {
@Link personalData:MinePagePersonalFunctionsItem[]
@Prop isLogin:boolean
@Consume('isLogin')@Watch('loginChange') loginState:Record<string,string>
loginChange(){
if(this.loginState){
this.isLogin=true
}
}
build() {
Grid(){
... ... @@ -15,6 +22,8 @@ export default struct MinePagePersonFunctionUI {
Image(item.imgSrc)
.width('46lpx')
.height('46lpx')
.objectFit(ImageFit.Auto)
.interpolation(ImageInterpolation.High)
Text(`${item.msg}`)
.margin({top:'8lpx'})
.width('50lpx')
... ... @@ -37,18 +46,34 @@ export default struct MinePagePersonFunctionUI {
console.log(index+"")
switch (item.msg){
case "预约":{
if(!this.isLogin){
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
return
}
WDRouterRule.jumpWithPage(WDRouterPage.appointmentListPage)
break;
}
case "关注":{
if(!this.isLogin){
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
return
}
WDRouterRule.jumpWithPage(WDRouterPage.followListPage)
break;
}
case "收藏":{
if(!this.isLogin){
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
return
}
WDRouterRule.jumpWithPage(WDRouterPage.myCollectionListPagePage)
break;
}
case "历史":{
if(!this.isLogin){
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
return
}
WDRouterRule.jumpWithPage(WDRouterPage.browsingHistoryPage)
break;
}
... ...
import { Logger } from 'wdKit'
import { WDRouterPage, WDRouterRule } from 'wdRouter'
import MinePageDatasModel from '../../model/MinePageDatasModel'
const TAG = "MinePageUserSimpleInfoUI"
@Component
export default struct MinePageUserSimpleInfoUI {
@Prop isLogin:boolean
@Prop userName:string
@Consume('isLogin')@Watch('loginChange') isLogin2:Record<string,string>
@Watch('loginStateChange') @Prop isLogin :boolean
@State userName:string = "登陆注册"
@State headPhotoUrl:string = ""
@State levelHead:string = ""
@State levelId:number = 0
aboutToAppear(){
if(this.isLogin){
this.getUserInfo()
this.getUserLevel()
}
}
@Consume('isLogin')@Watch('loginChange') loginState:Record<string,string>
loginChange(){
Logger.debug("isLogin",'MinePageUserSimpleInfoUI')
if(this.isLogin2){
if(this.loginState){
this.isLogin=true
this.userName=this.isLogin2['userName']
}
if(this.isLogin){
this.getUserInfo()
this.getUserLevel()
}
}
loginStateChange(){
if(this.isLogin){
this.getUserInfo()
this.getUserLevel()
}
}
... ... @@ -18,24 +43,22 @@ export default struct MinePageUserSimpleInfoUI {
Row(){
//头像
Stack(){
Button({type:ButtonType.Circle})
.backgroundColor($r('app.color.main_red'))
.width('110lpx')
.height('110lpx')
Image($r('app.media.default_head'))
Image(this.headPhotoUrl)
.alt($r('app.media.default_head'))
.width('108lpx')
.height('108lpx')
.objectFit(ImageFit.Cover)
.borderRadius(50)
}.width('110lpx')
.height('110lpx')
Image(this.levelHead)
.width('120lpx')
.height('120lpx')
.objectFit(ImageFit.Cover)
.borderRadius(50)
}.width('120lpx')
.height('120lpx')
.alignContent(Alignment.Center)
.onClick(()=>{
if(!this.isLogin){
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
}else {
WDRouterRule.jumpWithPage(WDRouterPage.mineHomePage)
}
this.jumpLogin()
})
if(this.isLogin){
... ... @@ -55,13 +78,16 @@ export default struct MinePageUserSimpleInfoUI {
.objectFit(ImageFit.Cover)
Blank()
}.width('100%')
.onClick(()=>{
this.jumpLogin()
})
Stack(){
Image($r('app.media.mine_grade_bg'))
.width('84lpx')
.height('29lpx')
.objectFit(ImageFit.Auto)
Text("等级8")
Text(`等级${this.levelId}`)
.textAlign(TextAlign.Center)
.fontColor($r('app.color.white'))
.fontSize('19lpx')
... ... @@ -84,7 +110,9 @@ export default struct MinePageUserSimpleInfoUI {
.margin({left:'15lpx'})
.objectFit(ImageFit.Cover)
Blank()
}
}.onClick(()=>{
this.jumpLogin()
})
.margin({top:'11lpx',left:'17lpx'})
.width('352lpx')
}
... ... @@ -122,4 +150,33 @@ export default struct MinePageUserSimpleInfoUI {
@Styles setFullHeight(){
.height('100%')
}
getUserInfo(){
MinePageDatasModel.getUserDetailData(getContext(this)).then((value)=>{
if(value!=null){
this.userName = value.userName
this.headPhotoUrl = value.headPhotoUrl
}
}).catch((err:Error)=>{
console.log(TAG,JSON.stringify(err))
})
}
getUserLevel(){
MinePageDatasModel.getUserLevelData(getContext(this)).then((value)=>{
if(value!=null){
this.levelHead = value.levelHead
this.levelId = value.levelId
}
}).catch((err:Error)=>{
console.log(TAG,JSON.stringify(err))
})
}
jumpLogin(){
if(!this.isLogin){
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
}else {
WDRouterRule.jumpWithPage(WDRouterPage.mineHomePage)
}
}
}
... ...
... ... @@ -9,6 +9,8 @@ export struct AppointmentListChildComponent{
Stack(){
Image(this.item?.imageUrl[0])
.objectFit(ImageFit.Auto)
.interpolation(ImageInterpolation.High)
if(this.item.relType === 1){
Row(){
... ... @@ -17,6 +19,8 @@ export struct AppointmentListChildComponent{
.width('42lpx')
.height('35lpx')
.objectFit(ImageFit.Auto)
.interpolation(ImageInterpolation.High)
Text("预约")
.fontWeight(400)
.fontSize('21lpx')
... ... @@ -51,6 +55,7 @@ export struct AppointmentListChildComponent{
if(this.item.relType === 2){
Image($r('app.media.play_status_history_icon'))
.objectFit(ImageFit.Auto)
.interpolation(ImageInterpolation.High)
.width('38lpx')
.height('38lpx')
.margin({right:'12lpx'})
... ... @@ -60,6 +65,7 @@ export struct AppointmentListChildComponent{
}else {
Image($r('app.media.play_status_icon'))
.objectFit(ImageFit.Auto)
.interpolation(ImageInterpolation.High)
.width('38lpx')
.height('38lpx')
.margin({right:'12lpx'})
... ... @@ -68,6 +74,7 @@ export struct AppointmentListChildComponent{
.fontSize('23lpx')
Image($r('app.media.point_icon'))
.objectFit(ImageFit.Auto)
.interpolation(ImageInterpolation.High)
.width('12lpx')
.height('31lpx')
.margin({right:'4lpx'})
... ...
... ... @@ -6,6 +6,7 @@ const TAG = "FollowFirstTabsComponent"
@Component
export struct FollowFirstTabsComponent{
@State currentIndex: number = 0
@Prop changeIndex: number
private controller: TabsController = new TabsController()
@State data:FollowListItem[] = []
fontColor: string = '#999999'
... ... @@ -22,6 +23,14 @@ export struct FollowFirstTabsComponent{
this.data.push(element)
})
console.log("ycg",this.data.length.toString());
if(this.controller != null && this.data.length>1 && this.changeIndex === 1){
//个人主页 跳转 关注页 tab 2
let intervalID = setInterval(() => {
this.currentIndex = this.changeIndex
this.controller.changeIndex(this.currentIndex)
clearInterval(intervalID);
}, 500);
}
}).catch((err:Error)=>{
console.log(TAG,JSON.stringify(err))
})
... ...
import { Params } from 'wdBean';
import { LazyDataSource, StringUtils } from 'wdKit';
import { WDRouterPage, WDRouterRule } from 'wdRouter';
import MinePageDatasModel from '../../../model/MinePageDatasModel';
import { CommentListItem } from '../../../viewmodel/CommentListItem';
import { FollowListDetailItem } from '../../../viewmodel/FollowListDetailItem';
... ... @@ -15,6 +17,8 @@ export struct HomePageBottomComponent{
@State hasMore:boolean = true
curPageNum:number = 1;
@State count:number = 0;
@State isMineAccount:boolean = true;
@State userId:string = "";
aboutToAppear(){
this.getNewPageData()
... ... @@ -53,7 +57,12 @@ export struct HomePageBottomComponent{
.justifyContent(FlexAlign.Center)
.backgroundColor($r('app.color.color_F5F5F5'))
.margin({top:'31lpx',bottom:'4lpx'})
}
}.onClick(()=>{
let params: Params = {
pageID: "1"
}
WDRouterRule.jumpWithPage(WDRouterPage.followListPage,params)
})
LazyForEach(this.data_follow, (item: FollowListDetailItem, index: number = 0) => {
ListItem() {
... ...
import { Params } from 'wdBean';
import { FollowFirstTabsComponent } from '../mine/follow/FollowFirstTabsComponent'
import router from '@ohos.router';
@Entry
@Component
struct FollowListPage {
@State params:Params = router.getParams() as Params;
@State curIndex: string = '0';
onPageShow() {
this.curIndex = this.params?.pageID;
}
build() {
Column() {
//Tab 详情
FollowFirstTabsComponent()
FollowFirstTabsComponent({changeIndex:Number(this.curIndex)})
}
.backgroundColor($r('app.color.color_F9F9F9'))
.height('100%')
... ...
... ... @@ -20,7 +20,6 @@ export struct MinePageComponent {
//是否是创作者
@State isCreator:boolean = false
@State isLogin:boolean = false //默认 false 测试放开
@State userName:string = "登陆注册"
@State personalData:MinePagePersonalFunctionsItem[] = []
@State creatorData:MinePageCreatorFunctionsItem[] = []
@State moreData:MinePageMoreFunctionModel[] = []
... ... @@ -61,9 +60,9 @@ export struct MinePageComponent {
@Builder MinePageUI(){
Column(){
//头像层
MinePageUserSimpleInfoUI({isLogin:this.isLogin,userName:this.userName})
MinePageUserSimpleInfoUI({isLogin:this.isLogin})
//Grid 区域
MinePagePersonFunctionUI({personalData:$personalData})
MinePagePersonFunctionUI({personalData:$personalData,isLogin:this.isLogin})
//Card
MinePageCardUI()
//创作者区域
... ... @@ -83,8 +82,6 @@ export struct MinePageComponent {
let userid = await SPHelper.default.get(SpConstants.USER_ID,"")
if(StringUtils.isNotEmpty(userid)){
this.isLogin = true
let userName = await SPHelper.default.get(SpConstants.USER_NAME,"") as string
this.userName = userName
}else{
this.isLogin = false
}
... ...
... ... @@ -13,6 +13,7 @@ export struct CustomTitleUI {
.width('46lpx')
.height('46lpx')
.objectFit(ImageFit.Auto)
.interpolation(ImageInterpolation.High)
.id("back_icon")
.alignRules({
center: {anchor: "__container__", align: VerticalAlign.Center},
... ...
... ... @@ -18,6 +18,7 @@ export struct ListHasNoMoreDataUI{
.width('200lpx')
.height('200lpx')
.objectFit(ImageFit.Auto)
.interpolation(ImageInterpolation.High)
Text("暂无内容")
.fontColor($r('app.color.color_999999'))
.fontWeight('500lpx')
... ...
... ... @@ -5,7 +5,7 @@ import MinePageMoreFunctionModel from '../viewmodel/MinePageMoreFunctionModel';
import HashMap from '@ohos.util.HashMap';
import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork';
import { MineAppointmentListItem } from '../viewmodel/MineAppointmentListItem';
import { Logger, ResourcesUtils } from 'wdKit';
import { Logger, ResourcesUtils, StringUtils } from 'wdKit';
import { MineFollowListDetailItem } from '../viewmodel/MineFollowListDetailItem';
import { FollowListDetailRequestItem } from '../viewmodel/FollowListDetailRequestItem';
import { FollowListItem } from '../viewmodel/FollowListItem';
... ... @@ -13,6 +13,9 @@ import { MineFollowListItem } from '../viewmodel/MineFollowListItem';
import { QueryListIsFollowedItem } from '../viewmodel/QueryListIsFollowedItem';
import { FollowListStatusRequestItem } from '../viewmodel/FollowListStatusRequestItem';
import { MineCommentListDetailItem } from '../viewmodel/MineCommentListDetailItem';
import { MineUserLevelItem } from '../viewmodel/MineUserLevelItem';
import { MineUserDetailItem } from '../viewmodel/MineUserDetailItem';
import { OtherUserDetailRequestItem } from '../viewmodel/OtherUserDetailRequestItem';
const TAG = "MinePageDatasModel"
... ... @@ -337,6 +340,163 @@ class MinePageDatasModel{
return compRes.data
}
/**
* 个人中心 获取用户等级
*/
getUserLevelData(context: Context): Promise<MineUserLevelItem> {
return new Promise<MineUserLevelItem>((success, error) => {
Logger.info(TAG, `getAppointmentList start`);
this.fetchMineUserLevelData().then((navResDTO: ResponseDTO<MineUserLevelItem>) => {
if (!navResDTO || navResDTO.code != 0) {
success(this.getMineUserLevelDataLocal(context))
return
}
Logger.info(TAG, "getAppointmentList then,AppointmentResDTO.timeStamp:" + navResDTO.timestamp);
let navigationBean = navResDTO.data as MineUserLevelItem
success(navigationBean);
}).catch((err: Error) => {
Logger.error(TAG, `fetchMineUserLevelData catch, error.name : ${err.name}, error.message:${err.message}`);
success(this.getMineUserLevelDataLocal(context))
})
})
}
fetchMineUserLevelData() {
let url = HttpUrlUtils.getMineUserLevelDataUrl()
let headers: HashMap<string, string> = HttpUrlUtils.getYcgCommonHeaders();
return WDHttp.get<ResponseDTO<MineUserLevelItem>>(url, headers)
};
async getMineUserLevelDataLocal(context: Context): Promise<MineUserLevelItem> {
Logger.info(TAG, `getMineUserLevelDataLocal start`);
let compRes: ResponseDTO<MineUserLevelItem> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<MineUserLevelItem>>(context,'mine_user_level.json' );
if (!compRes || !compRes.data) {
Logger.info(TAG, `getMineUserLevelDataLocal compRes is empty`);
return new MineUserLevelItem()
}
Logger.info(TAG, `getMineUserLevelDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`);
return compRes.data
}
/**
* 个人中心 获取用户详细信息
*/
getUserDetailData(context: Context): Promise<MineUserDetailItem> {
return new Promise<MineUserDetailItem>((success, error) => {
Logger.info(TAG, `getAppointmentList start`);
this.fetchMineUserDetailData().then((navResDTO: ResponseDTO<MineUserDetailItem>) => {
if (!navResDTO || navResDTO.code != 0) {
success(this.getMineUserDetailDataLocal(context))
return
}
Logger.info(TAG, "getUserDetailData then,timeStamp:" + navResDTO.timestamp);
let navigationBean = navResDTO.data as MineUserDetailItem
success(navigationBean);
}).catch((err: Error) => {
Logger.error(TAG, `fetchMineUserDetailData catch, error.name : ${err.name}, error.message:${err.message}`);
success(this.getMineUserDetailDataLocal(context))
})
})
}
fetchMineUserDetailData() {
let url = HttpUrlUtils.getMineUserDetailDataUrl()
let headers: HashMap<string, string> = HttpUrlUtils.getYcgCommonHeaders();
return WDHttp.get<ResponseDTO<MineUserDetailItem>>(url, headers)
};
async getMineUserDetailDataLocal(context: Context): Promise<MineUserDetailItem> {
Logger.info(TAG, `getMineUserLevelDataLocal start`);
let compRes: ResponseDTO<MineUserDetailItem> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<MineUserDetailItem>>(context,'mine_user_detail.json' );
if (!compRes || !compRes.data) {
Logger.info(TAG, `getMineUserDetailDataLocal compRes is empty`);
return new MineUserDetailItem()
}
Logger.info(TAG, `getMineUserDetailDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`);
return compRes.data
}
/**
* 个人中心 获取其他用户详细信息
*/
getOtherUserDetailData(item:OtherUserDetailRequestItem,context: Context): Promise<MineUserDetailItem> {
return new Promise<MineUserDetailItem>((success, error) => {
Logger.info(TAG, `getAppointmentList start`);
this.fetchOtherUserDetailData(item).then((navResDTO: ResponseDTO<MineUserDetailItem>) => {
if (!navResDTO || navResDTO.code != 0) {
success(this.getOtherUserDetailDataLocal(context))
return
}
Logger.info(TAG, "getUserDetailData then,timeStamp:" + navResDTO.timestamp);
let navigationBean = navResDTO.data as MineUserDetailItem
success(navigationBean);
}).catch((err: Error) => {
Logger.error(TAG, `fetchMineUserDetailData catch, error.name : ${err.name}, error.message:${err.message}`);
success(this.getOtherUserDetailDataLocal(context))
})
})
}
fetchOtherUserDetailData(item:OtherUserDetailRequestItem) {
let url = HttpUrlUtils.getOtherUserDetailDataUrl()
let headers: HashMap<string, string> = HttpUrlUtils.getYcgCommonHeaders();
return WDHttp.post<ResponseDTO<MineUserDetailItem>>(url, item,headers)
};
async getOtherUserDetailDataLocal(context: Context): Promise<MineUserDetailItem> {
Logger.info(TAG, `getMineUserLevelDataLocal start`);
let compRes: ResponseDTO<MineUserDetailItem> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<MineUserDetailItem>>(context,'other_user512157124138245_detail.json' );
if (!compRes || !compRes.data) {
Logger.info(TAG, `getMineUserDetailDataLocal compRes is empty`);
return new MineUserDetailItem()
}
Logger.info(TAG, `getMineUserDetailDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`);
return compRes.data
}
/**
* 个人中心 获取其他用户等级
*/
getOtherUserLevelData(item:string[],context: Context): Promise<MineUserLevelItem[]> {
return new Promise<MineUserLevelItem[]>((success, error) => {
Logger.info(TAG, `getAppointmentList start`);
this.fetchOtherUserLevelData(item).then((navResDTO: ResponseDTO<MineUserLevelItem[]>) => {
if (!navResDTO || navResDTO.code != 0) {
success(this.getOtherUserLevelDataLocal(context))
return
}
Logger.info(TAG, "getAppointmentList then,AppointmentResDTO.timeStamp:" + navResDTO.timestamp);
let navigationBean = navResDTO.data as MineUserLevelItem[]
if(navigationBean.length>0 && StringUtils.isNotEmpty(navigationBean[0].levelHead)){
success(navigationBean);
}else{
success(this.getOtherUserLevelDataLocal(context))
}
}).catch((err: Error) => {
Logger.error(TAG, `fetchMineUserLevelData catch, error.name : ${err.name}, error.message:${err.message}`);
success(this.getOtherUserLevelDataLocal(context))
})
})
}
fetchOtherUserLevelData(item:string[]) {
let url = HttpUrlUtils.getOtherUserLevelDataUrl()
let headers: HashMap<string, string> = HttpUrlUtils.getYcgCommonHeaders();
return WDHttp.post<ResponseDTO<MineUserLevelItem[]>>(url,item, headers)
};
async getOtherUserLevelDataLocal(context: Context): Promise<MineUserLevelItem[]> {
Logger.info(TAG, `getMineUserLevelDataLocal start`);
let compRes: ResponseDTO<MineUserLevelItem[]> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<MineUserLevelItem[]>>(context,'other_user512157124138245_level.json' );
if (!compRes || !compRes.data) {
Logger.info(TAG, `getMineUserLevelDataLocal compRes is empty`);
return []
}
Logger.info(TAG, `getMineUserLevelDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`);
return compRes.data
}
}
... ...
import router from '@ohos.router'
import { Params } from 'wdBean';
import { StringUtils } from 'wdKit';
import { WDRouterPage, WDRouterRule } from 'wdRouter';
import { HomePageBottomComponent } from '../components/mine/home/HomePageBottomComponent';
import MinePageDatasModel from '../model/MinePageDatasModel';
const TAG = "MineHomePage"
@Entry
@Component
struct MineHomePage {
@State tileOpacity: number = 0;
firstPositionY:number = 0;
@State isHasIntroduction: boolean = true
@State desc:string = "点击添加简介,让大家认识你" //text 搞两个样式,如果三行,就显示 另外一个text 没有显示高度的
fontColor: string = '#999999'
selectedFontColor: string = '#000000'
@State currentIndex: number = 0
private controller: TabsController = new TabsController()
isChangeToUserEdit = false;
@State userName:string = ""
@State headPhotoUrl:string = ""
@State levelHead:string = ""
@State levelId:number = 0
@State desc:string = "点击添加简介,让大家认识你" //text 搞两个样式,如果三行,就显示 另外一个text 没有显示高度的
@State isHasIntroduction: boolean = false
@State browseNum:number = 0//阅读数
@State commentNum:number = 0//评论数
@State attentionNum:number = 0//关注数
registTime:number = 0//账号注册时间
@State registerTimeForDay:number = 0
aboutToAppear(){
this.getUserInfo()
this.getUserLevel()
}
build() {
... ... @@ -33,15 +53,28 @@ struct MineHomePage {
Column() {
//用户信息区域
Row() {
Image($r('app.media.default_head'))
.width('115lpx')
.height('115lpx')
.objectFit(ImageFit.Cover)
.borderRadius(50)
Stack(){
Image(this.headPhotoUrl)
.alt($r('app.media.default_head'))
.width('115lpx')
.height('115lpx')
.objectFit(ImageFit.Cover)
.borderRadius(50)
Image(this.levelHead)
.width('130lpx')
.height('130lpx')
.objectFit(ImageFit.Cover)
.borderRadius(50)
}.onClick(()=>{
let params: Params = {
pageID: "-1"
}
WDRouterRule.jumpWithPage(WDRouterPage.otherNormalUserHomePagePage,params)
})
Column() {
Row() {
Text("人民日报6G")
Text(`${this.userName}`)
.fontColor($r('app.color.white'))
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
... ... @@ -49,7 +82,7 @@ struct MineHomePage {
.lineHeight('50lpx')
.fontWeight('500lpx')
Text("等级8")
Text(`等级${this.levelId}`)
.textAlign(TextAlign.Center)
.fontColor($r('app.color.color_ED2800'))
.backgroundColor($r('app.color.white'))
... ... @@ -62,7 +95,7 @@ struct MineHomePage {
Row() {
Row() {
Text("3.6万")
Text(`${this.browseNum}`)
.textStyle()
Text("阅读")
.textStyle2()
... ... @@ -76,7 +109,7 @@ struct MineHomePage {
.vertical(true)
.opacity(0.4)
Row() {
Text("6242")
Text(`${this.commentNum}`)
.textStyle()
Text("评论")
.textStyle2()
... ... @@ -89,7 +122,7 @@ struct MineHomePage {
.vertical(true)
.opacity(0.4)
Row() {
Text("86")
Text(`${this.attentionNum}`)
.textStyle()
Text("关注")
.textStyle2()
... ... @@ -132,7 +165,7 @@ struct MineHomePage {
.objectFit(ImageFit.Auto)
}
}
Text("来到人民日报365天")
Text(`来到人民日报${this.registerTimeForDay}天`)
.fontSize('23lpx')
.lineHeight('25lpx')
.fontWeight('400lpx')
... ... @@ -233,11 +266,13 @@ struct MineHomePage {
.onClick(() => {
router.back()
})
Image($r('app.media.default_head'))
Image(`${this.headPhotoUrl}`)
.alt($r('app.media.default_head'))
.width('60lpx')
.height('60lpx')
.objectFit(ImageFit.Auto)
.id("head_icon")
.borderRadius(50)
.alignRules({
center: { anchor: "__container__", align: VerticalAlign.Center },
left: { anchor: "back_icon", align: HorizontalAlign.End }
... ... @@ -247,7 +282,7 @@ struct MineHomePage {
router.back()
})
Text("我的昵称")
Text(`${this.userName}`)
.height('42lpx')
.maxLines(1)
.id("title")
... ... @@ -326,6 +361,41 @@ struct MineHomePage {
WDRouterRule.jumpWithPage(WDRouterPage.editUserInfoPage)
}
}
getUserInfo(){
MinePageDatasModel.getUserDetailData(getContext(this)).then((value)=>{
if(value!=null){
this.userName = value.userName
this.headPhotoUrl = value.headPhotoUrl
if(StringUtils.isNotEmpty(value.introduction)){
this.desc = value.introduction
this.isHasIntroduction = true
}
this.browseNum = value.browseNum
this.commentNum = value.commentNum
this.attentionNum = value.attentionNum
this.registTime = value.registTime
this.getRegisterDays()
}
}).catch((err:Error)=>{
console.log(TAG,JSON.stringify(err))
})
}
getUserLevel(){
MinePageDatasModel.getUserLevelData(getContext(this)).then((value)=>{
if(value!=null){
this.levelHead = value.levelHead
this.levelId = value.levelId
}
}).catch((err:Error)=>{
console.log(TAG,JSON.stringify(err))
})
}
getRegisterDays(){
if(this.registTime!=null){
let curDate = new Date()
this.registerTimeForDay = Math.ceil((curDate.getTime()-this.registTime)/(1000*60*60*24))
}
}
}
... ...
import router from '@ohos.router'
import { Params } from 'wdBean';
import { StringUtils } from 'wdKit';
import { HomePageBottomComponent } from '../components/mine/home/HomePageBottomComponent';
import MinePageDatasModel from '../model/MinePageDatasModel';
import { OtherUserDetailRequestItem } from '../viewmodel/OtherUserDetailRequestItem';
const TAG = "OtherNormalUserHomePage"
@Entry
@Component
struct OtherNormalUserHomePage {
@State params:Params = router.getParams() as Params;
@State curUserId: string = '-1';
onPageShow() {
this.curUserId = this.params?.pageID;
}
@State tileOpacity: number = 0;
firstPositionY:number = 0;
fontColor: string = '#999999'
selectedFontColor: string = '#000000'
@State currentIndex: number = 0
private controller: TabsController = new TabsController()
isChangeToUserEdit = false;
@State userName:string = ""
@State headPhotoUrl:string = ""
@State levelHead:string = ""
@State levelId:number = 0
@State browseNum:number = 0//阅读数
@State commentNum:number = 0//评论数
@State attentionNum:number = 0//关注数
aboutToAppear(){
this.getUserInfo()
this.getUserLevel()
}
build() {
Stack({ alignContent: Alignment.Top }){
Image($r('app.media.title_bg'))
.width('100%')
.height('355lpx')
.objectFit(ImageFit.Cover)
Column(){
Stack({ alignContent: Alignment.Top }){
this.MineHomeTitleTransparent()
this.MineHomeTitleWhite()
}
Scroll() {
Column() {
//用户信息区域
Row() {
Stack(){
Image(this.headPhotoUrl)
.alt($r('app.media.default_head'))
.width('115lpx')
.height('115lpx')
.objectFit(ImageFit.Cover)
.borderRadius(50)
Image(this.levelHead)
.width('130lpx')
.height('130lpx')
.objectFit(ImageFit.Cover)
.borderRadius(50)
}
Column() {
Row() {
Text(`${this.userName}`)
.fontColor($r('app.color.white'))
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.fontSize('38lpx')
.lineHeight('50lpx')
.fontWeight('500lpx')
Text(`等级${this.levelId}`)
.textAlign(TextAlign.Center)
.fontColor($r('app.color.color_ED2800'))
.backgroundColor($r('app.color.white'))
.fontSize('19lpx')
.width('96lpx')
.height('35lpx')
.margin({ left: '10lpx' })
Blank()
}.width('507lpx')
Row() {
Row() {
Text(`${this.browseNum}`)
.textStyle()
Text("阅读")
.textStyle2()
}
.margin({ right: '15lpx' })
Divider()
.height('19lpx')
.width('2lpx')
.color($r('app.color.white'))
.vertical(true)
.opacity(0.4)
Row() {
Text(`${this.commentNum}`)
.textStyle()
Text("评论")
.textStyle2()
}.margin({ right: '15lpx', left: '15lpx' })
Divider()
.height('19lpx')
.width('2lpx')
.color($r('app.color.white'))
.vertical(true)
.opacity(0.4)
Row() {
Text(`${this.attentionNum}`)
.textStyle()
Text("关注")
.textStyle2()
}.margin({ left: '15lpx' })
}.margin({ top: '23lpx' })
}.alignItems(HorizontalAlign.Start)
.margin({ left: '32lpx' })
}
.onAreaChange((oldValue: Area, newValue: Area) => {
if (this.firstPositionY === 0) {
this.firstPositionY = newValue.globalPosition.y as number
}else{
let persent = (this.firstPositionY - Number(newValue.globalPosition.y)) / (this.firstPositionY * 0.3)
if(persent > 1){
persent = 1
}
this.tileOpacity = persent
}
})
.backgroundColor($r('app.color.color_transparent'))
.height('184lpx')
.width('100%')
.padding({ left: '35lpx' })
//间隔符
Divider().width('100%').height('12lpx').color($r('app.color.color_F5F5F5')).strokeWidth('12lpx')
//tab 页面
Tabs({controller: this.controller}) {
TabContent() {
HomePageBottomComponent({style:0})
}.tabBar(this.TabBuilder(0,"评论"))
TabContent() {
HomePageBottomComponent({style:1})
}.tabBar(this.TabBuilder(1,"关注"))
}
.backgroundColor($r('app.color.white'))
.animationDuration(0)
.onChange((index: number) => {
this.currentIndex = index
})
.vertical(false)
.height("100%")
}.width("100%")
}
.edgeEffect(EdgeEffect.None)
.scrollBar(BarState.Off)
.width('100%')
.height('100%')
}
}.width('100%')
.height('100%')
}
@Builder MineHomeTitleTransparent() {
RelativeContainer() {
//标题栏目
Image($r('app.media.icon_arrow_left_white') )
.width('46lpx')
.height('46lpx')
.objectFit(ImageFit.Auto)
.id("back_icon")
.alignRules({
center: { anchor: "__container__", align: VerticalAlign.Center },
left: { anchor: "__container__", align: HorizontalAlign.Start }
})
.margin({ left: '31lpx' })
.onClick(() => {
router.back()
})
}
.visibility(this.tileOpacity > 0 ? 1 : 0)
.height('84lpx')
.width('100%')
.backgroundColor($r('app.color.color_transparent'))
}
@Builder MineHomeTitleWhite() {
RelativeContainer() {
//标题栏目
Image($r('app.media.back_icon'))
.width('46lpx')
.height('46lpx')
.objectFit(ImageFit.Auto)
.id("back_icon")
.alignRules({
center: { anchor: "__container__", align: VerticalAlign.Center },
left: { anchor: "__container__", align: HorizontalAlign.Start }
})
.margin({ left: '31lpx' })
.onClick(() => {
router.back()
})
Image(this.headPhotoUrl)
.alt($r('app.media.default_head'))
.width('60lpx')
.height('60lpx')
.borderRadius(50)
.objectFit(ImageFit.Auto)
.id("head_icon")
.alignRules({
center: { anchor: "__container__", align: VerticalAlign.Center },
left: { anchor: "back_icon", align: HorizontalAlign.End }
})
.margin({ left: '31lpx' })
.onClick(() => {
router.back()
})
Text(`${this.userName}`)
.height('42lpx')
.maxLines(1)
.id("title")
.fontSize('35lpx')
.fontWeight('400lpx')
.fontColor($r('app.color.color_222222'))
.lineHeight('42lpx')
.alignRules({
center: { anchor: "__container__", align: VerticalAlign.Center },
left: { anchor: "head_icon", align: HorizontalAlign.End }
})
.margin({ left: '12lpx' })
}
.visibility(this.tileOpacity > 0 ? 0 : 1)
.height('84lpx')
.width('100%')
.backgroundColor($r('app.color.white'))
.opacity(this.tileOpacity )
}
@Builder TabBuilder(index: number, title: string) {
Stack(){
Text(title)
.height('38lpx')
.fontSize('33lpx')
.fontWeight(this.currentIndex === index ? 600 : 400)
.fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor)
.lineHeight('38lpx')
if(this.currentIndex === index){
Divider()
.width('31lpx')
.height('4lpx')
.color('#ED2800')
.strokeWidth('4lpx')
.margin({top:'50lpx'})
.id("divTag")
}
}.onClick(()=>{
this.currentIndex = index
this.controller.changeIndex(this.currentIndex)
})
.height('100%')
.width('100%')
.margin({right:'9lpx'})
}
getUserInfo(){
let item = new OtherUserDetailRequestItem("","1",this.curUserId)
MinePageDatasModel.getOtherUserDetailData(item,getContext(this)).then((value)=>{
if(value!=null){
this.userName = value.userName
this.headPhotoUrl = value.headPhotoUrl
this.browseNum = StringUtils.isEmpty(value.browseNum)?0:value.browseNum
this.commentNum = StringUtils.isEmpty(value.commentNum)?0:value.commentNum
this.attentionNum = StringUtils.isEmpty(value.attentionNum)?0:value.attentionNum
}
}).catch((err:Error)=>{
console.log(TAG,JSON.stringify(err))
})
}
getUserLevel(){
MinePageDatasModel.getOtherUserLevelData([this.curUserId],getContext(this)).then((value)=>{
if(value!=null){
this.levelHead = value[0].levelHead
this.levelId = value[0].level
}
}).catch((err:Error)=>{
console.log(TAG,JSON.stringify(err))
})
}
}
@Extend(Text) function textStyle() {
.fontColor($r('app.color.white'))
.textStyleDefault()
.margin({ right: '10lpx' })
}
@Extend(Text) function textStyle2() {
.textStyleDefault()
.fontColor($r('app.color.color_B2FFFFFF'))
}
@Extend(Text) function textStyleDefault() {
.textAlign(TextAlign.Start)
.fontSize('23lpx')
.fontWeight('400lpx')
.lineHeight('31lpx')
}
... ...
export class MineUserDetailItem{
userName:string = ""
headPhotoUrl:"" = ""
introduction:string = ""
userType:string = "1"
creatorId:string = ""
browseNum:number = 0//阅读数
commentNum:number = 0//评论数
attentionNum:number = 0//关注数
registTime:number = 0//账号注册时间
}
\ No newline at end of file
... ...
export class MineUserLevelItem{
levelHead:string = ""
levelId:number = 0
level:number = 0
levelName:string = ""
}
\ No newline at end of file
... ...
export class OtherUserDetailRequestItem {
creatorId: string = ""
userType: string = "1"
userId: string = "-1"
constructor(creatorId: string ,
userType: string,
userId: string ) {
this.creatorId = creatorId
this.userType = userType
this.userId = userId
}
}
\ No newline at end of file
... ...
... ... @@ -11,6 +11,7 @@
"components/page/EditUserNikeNamePage",
"components/page/EditUserIntroductionPage",
"components/page/BrowsingHistoryPage",
"components/page/MyCollectionListPage"
"components/page/MyCollectionListPage",
"pages/OtherNormalUserHomePage"
]
}
\ No newline at end of file
... ...
{
"code": "0",
"data": {
"articleCreation": 0,
"attentionNum": 22,
"authIcon": "",
"authId": 0,
"authPersonal": "",
"authTitle": "",
"avatarFrame": "",
"browseNum": 22,
"categoryAuth": "",
"city": "",
"cnContentPublish": 0,
"cnLivePublish": 0,
"cnShareControl": 0,
"collectNum": 4,
"commentNum": 0,
"contentPublish": 0,
"creatorId": "",
"district": "",
"dynamicControl": 0,
"dynamicCreation": 0,
"fansNum": 0,
"headPhotoUrl": "https://sitcontentjdcdn.aikan.pdnews.cn//img/user/2024031215/48d5bd53227d436b9faa937b3ac14600.png",
"honoraryIcon": "",
"honoraryTitle": "",
"introduction": "",
"isComment": 0,
"isLike": 0,
"livePublish": 0,
"liveSwitch": 1,
"mainControl": 1,
"originUserId": "",
"pictureCollectionCreation": 0,
"posterShareControl": 1,
"province": "",
"region": "安徽省",
"registTime": 1710227567000,
"reserveNum": 6,
"shareControl": 0,
"shareUrl": "",
"speakControl": 0,
"subjectType": 0,
"userId": "567387477063621",
"userName": "人民日报网友aPrtq5",
"userType": "1",
"videoCollectionCreation": 0,
"videoCreation": 0
},
"message": "Success",
"meta": null,
"requestId": "",
"success": true,
"timestamp": 1711357314033
}
... ...
{
"code": "0",
"data": {
"createTime": "2024-03-12 15:12:47",
"id": 132386,
"levelHead": "http://rmrb-video-content-sit.oss-cn-beijing.aliyuncs.com/sjbj-20240125/image/display/88c45bf56ac941b883c69bd8ed373164.png",
"levelId": 2,
"levelName": "初入武林",
"levelNum": 155,
"modifyTime": "2024-03-25 16:35:57",
"status": 1,
"userId": 567387477063621
},
"message": "Success",
"success": true,
"timestamp": 1711357314136
}
\ No newline at end of file
... ...
{
"code": "0",
"data": {
"articleCreation": 0,
"attentionNum": 1,
"authIcon": "",
"authId": 0,
"authPersonal": "",
"authTitle": "",
"avatarFrame": "",
"banControl": 0,
"browseNum": 76,
"categoryAuth": "",
"city": "",
"cnContentPublish": 0,
"cnIsComment": 0,
"cnIsLike": 0,
"cnLiveCommentControl": 0,
"cnLiveGiftControl": 0,
"cnLiveLikeControl": 0,
"cnLivePublish": 0,
"cnLiveShareControl": 0,
"cnShareControl": 0,
"contentPublish": 0,
"creatorId": "",
"district": "",
"dynamicControl": 0,
"dynamicCreation": 0,
"fansNum": 0,
"headPhotoUrl": "https://sitcontentjdcdn.aikan.pdnews.cn/null20240127/1630371072/1706336907262.jpg",
"honoraryIcon": "",
"honoraryTitle": "",
"introduction": "",
"isAttention": 0,
"isComment": 0,
"isLike": 0,
"liveCommentControl": 0,
"liveGiftControl": 0,
"liveLikeControl": 0,
"livePublish": 0,
"liveShareControl": 0,
"liveSwitch": 0,
"mainControl": 1,
"originUserId": "",
"pictureCollectionCreation": 0,
"posterShareControl": 1,
"province": "",
"region": "安徽省",
"registTime": 1703485580000,
"shareControl": 0,
"shareUrl": "",
"subjectType": 0,
"userId": "512157124138245",
"userName": "树下🍑 1122334",
"userType": "1",
"videoCollectionCreation": 0,
"videoCreation": 0
},
"message": "Success",
"meta": null,
"requestId": "",
"success": true,
"timestamp": 1711440875633
}
\ No newline at end of file
... ...
{
"code": "0",
"data": [
{
"level": 2,
"levelHead": "http://rmrb-video-content-sit.oss-cn-beijing.aliyuncs.com/sjbj-20240125/image/display/88c45bf56ac941b883c69bd8ed373164.png",
"userId": 512157124138245
}
],
"message": "Success",
"success": true,
"timestamp": 1711440876088
}
\ No newline at end of file
... ...