陈剑华

Merge remote-tracking branch 'origin/main'

Showing 47 changed files with 1471 additions and 288 deletions
... ... @@ -34,6 +34,8 @@ export class SpConstants{
//定位相关
static LOCATION_CITY_NAME = "location_city_name" //定位
static LOCATION_CITY_CODE = "location_city_code" //定位
static LOCATION_PROVINCE_CODE = "location_province_code" //定位,省份code
static LOCATION_DISTRICT_CODE = "location_district_code" //定位,区县,返回9位,如:合肥-瑶海区-310115114
static LOCATION_PERMISSION_REFUSE = "location_permission_refuse" //定位
//启动页数据存储key
... ...
... ... @@ -15,6 +15,9 @@ export enum EmitterEventId {
/*发布评论*/
COMMENT_PUBLISH = 6,
// 关注,取消关注
PEOPLE_SHIP_ATTENTION = 7,
// App回到前台
APP_ENTER_FOREGROUD = 100,
// App进入后台
... ...
import data_preferences from '@ohos.data.preferences';
import { Logger } from './Logger';
const TAG = 'SPHelper'
/**
* sp存储
*
* 单例模式
* TODO 新增内存存储,避免频繁sp获取
*/
// SPHelper.default.get("key1", "defValue1").then((value1) => {
// this.message = value1.toString();
// })
// let value2: string = await SPHelper.default.get("key2", "defValue2");
// this.message = result;
export class SPHelper {
private static context: Context;
private static spFilename: string = '__SPHelper';
... ... @@ -51,7 +45,11 @@ export class SPHelper {
saveSync(key: string, value: data_preferences.ValueType) {
const preferences: data_preferences.Preferences = this.getVideoPreferencesSync();
preferences.putSync(key, value)
preferences.flush() // todo:Asynchronously
preferences.flush().then(() => {
Logger.debug(TAG, 'saveSync flush success')
}).catch((error: object) => {
Logger.debug(TAG, 'saveSync flush failed: ' + JSON.stringify(error))
});
}
async get(key: string, defValue: data_preferences.ValueType): Promise<data_preferences.ValueType> {
... ... @@ -86,7 +84,11 @@ export class SPHelper {
deleteSync(key: string) {
const preferences: data_preferences.Preferences = this.getVideoPreferencesSync();
preferences.deleteSync(key)
preferences.flush(); // todo:Asynchronously
preferences.flush().then(() => {
Logger.debug(TAG, 'deleteSync flush success')
}).catch((error: object) => {
Logger.debug(TAG, 'deleteSync flush failed: ' + JSON.stringify(error))
});
}
async clearSync() {
... ... @@ -98,12 +100,6 @@ export class SPHelper {
});
}
// clearSync() {
// let preferences: data_preferences.Preferences = this.getVideoPreferencesSync()
// preferences.clearSync()
// preferences.flush()
// }
public getPreferences() {
let preferences = data_preferences.getPreferences(SPHelper.context, SPHelper.spFilename);
return preferences;
... ...
... ... @@ -25,15 +25,14 @@ export class HttpParams {
headers['imei'] = DeviceUtil.clientId()
headers['Accept-Language'] = 'zh'
headers['timestamp'] = DateTimeUtils.getTimeStamp() + ''
headers['mpassid'] = 'ZbHTMeTsfaYDAHqt8ZHIzcPs'
HttpParams.setLocationHeader(headers)
// // TODO 判断是否登录
headers['RMRB-X-TOKEN'] = HttpUtils.getXToken()
if (HttpUtils.getXToken() != '') {
headers['cookie'] = 'RMRB-X-TOKEN=' + HttpUtils.getXToken()
if (HttpUtils.isLogin()) {
headers['RMRB-X-TOKEN'] = HttpUtils.getUserToken()
headers['cookie'] = 'RMRB-X-TOKEN=' + HttpUtils.getUserToken()
headers['userId'] = HttpUtils.getUserId()
headers['userType'] = HttpUtils.getUserType()
}
headers['userId'] = HttpUtils.getUserId()
headers['userType'] = HttpUtils.getUserType()
headers['mpassid'] = 'ZbHTMeTsfaYDAHqt8ZHIzcPs'
HttpParams.addSpecialHeaders(headers);
return headers;
}
... ...
... ... @@ -284,6 +284,22 @@ export class HttpUrlUtils {
*/
static readonly SEARCH_SUGGEST_DATA_PATH: string = "/api/rmrb-bff-display-zh/recommend/zh/c/list";
/**
* 人民号号主推荐
*/
static readonly RMH_RECOMMEND_DATA_PATH: string = "/api/rmrb-bff-display-zh/recommend/zh/c/rmh";
/**
* 关注号主发布内容接口
*/
static readonly ATTENTION_CONTENT_LIST_DATA_PATH: string = "/api/rmrb-bff-display-zh/content/zh/c/attention/contentList";
/**
* 一键关注接口
*/
static readonly ATTENTION_BATCH_DATA_PATH: string = "/api/rmrb-interact/interact/zh/c/attention/batch";
static getHost(): string {
return HostManager.getHost();
}
... ... @@ -650,4 +666,23 @@ export class HttpUrlUtils {
let url = HttpUrlUtils.getHost() + "/api/rmrb-bff-display-zh/display/zh/c/themeList";
return url;
}
// 人民号号主推荐
static getRmhRecommendUrl() {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.RMH_RECOMMEND_DATA_PATH;
return url;
}
// 关注号主发布内容接口
static getAttentionContentListUrl() {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.ATTENTION_CONTENT_LIST_DATA_PATH;
return url;
}
// 一键关注接口
static getAttentionBatchUrl() {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.ATTENTION_BATCH_DATA_PATH;
return url;
}
}
\ No newline at end of file
... ...
import { SpConstants } from 'wdConstant/Index';
import { DeviceUtil, SPHelper, StringUtils } from 'wdKit/Index';
import { HttpParams } from '../http/HttpCommonParams';
import { HttpRequest } from '../http/HttpRequest';
const TAG: string = '[HttpUtils]'
... ... @@ -9,27 +8,6 @@ const TAG: string = '[HttpUtils]'
* http相关工具类,对外暴露
*/
export class HttpUtils {
private static userId = ''
private static userType = ''
private static token = ''
/**
* 添加公共参数,如登录后,添加登录信息
*/
static addCommonHeader() {
HttpRequest.addGlobalHeaderProvider(() => {
let headers: Record<string, string> = {};
return headers;
})
}
/**
* 添加公共参数,如登出后,移除登录信息
*/
static removeCommonHeader() {
}
static getRefreshToken() {
let refreshToken = SPHelper.default.getSync(SpConstants.USER_REFRESH_TOKEN, "")
if (StringUtils.isNotEmpty(refreshToken)) {
... ... @@ -49,25 +27,27 @@ export class HttpUtils {
* 定位,城市code
*/
public static getCityCode(): string {
// TODO
// 城市编码
return '340100';
return SPHelper.default.getSync(SpConstants.LOCATION_CITY_CODE, '') as string
}
/**
* 定位,省份code
*/
public static getProvinceCode(): string {
// TODO
return '340000';
return SPHelper.default.getSync(SpConstants.LOCATION_PROVINCE_CODE, '') as string
}
/**
* 定位,地区code
*/
public static getDistrictCode(): string {
// TODO
return '340103';
let districtCode = SPHelper.default.getSync(SpConstants.LOCATION_DISTRICT_CODE, '') as string
if (districtCode === '') {
return districtCode
}
// 截取前6位,如返回310115114,需要310115 (上海浦东)
return districtCode.substring(0, 6);
}
public static getImei(): string {
... ... @@ -75,43 +55,22 @@ export class HttpUtils {
}
public static getUserId(): string {
// TODO 对接登录
if (StringUtils.isNotEmpty(HttpUtils.userId)) {
return HttpUtils.userId
}
HttpUtils.userId = SPHelper.default.getSync(SpConstants.USER_ID, "") as string
return HttpUtils.userId;
return SPHelper.default.getSync(SpConstants.USER_ID, "") as string
}
public static getUserType(): string {
if (StringUtils.isNotEmpty(HttpUtils.userType)) {
return HttpUtils.userType
}
HttpUtils.userType = SPHelper.default.getSync(SpConstants.USER_Type, "") as string
return HttpUtils.userType;
}
static getXToken(): string {
if (StringUtils.isNotEmpty(HttpUtils.token)) {
return HttpUtils.token
}
HttpUtils.token = SPHelper.default.getSync(SpConstants.USER_JWT_TOKEN, "") as string
if (StringUtils.isNotEmpty(HttpUtils.token)) {
return HttpUtils.token
}
return ''
return SPHelper.default.getSync(SpConstants.USER_Type, "") as string
}
public static setUserId(userId: string) {
// TODO 优化赋值
HttpUtils.userId = userId;
static getUserToken(): string {
return SPHelper.default.getSync(SpConstants.USER_JWT_TOKEN, "") as string
}
public static setUserType(userType: string) {
HttpUtils.userType = userType;
}
public static setUserToken(token: string) {
HttpUtils.token = token;
public static isLogin(): boolean {
let token = HttpUtils.getUserToken()
if (token == null || token == undefined || token.length <= 0) {
return false
}
return true
}
}
\ No newline at end of file
... ...
... ... @@ -153,3 +153,15 @@ export {
UserExtend
} from './src/main/ets/bean/user/UserDetail';
export {
RmhRecommendDTO
} from './src/main/ets/bean/peoples/RmhRecommendDTO';
export {
PeopleShipContentListDTO
} from './src/main/ets/bean/peoples/PeopleShipContentListDTO';
export {
AttentionBatchDTO,
CreatorDTO
} from './src/main/ets/bean/peoples/AttentionBatchDTO';
... ...
export class AttentionBatchDTO{
creators: CreatorDTO[];
constructor(creators: CreatorDTO[] = []) {
this.creators = creators
}
}
export class CreatorDTO {
attentionUserType: string;
attentionUserId: string;
attentionCreatorId: string;
constructor(attentionUserType: string, attentionUserId: string, attentionCreatorId: string) {
this.attentionUserType = attentionUserType
this.attentionUserId = attentionUserId
this.attentionCreatorId = attentionCreatorId
}
}
... ...
import { ContentDTO } from '../content/ContentDTO'
export interface PeopleShipContentListDTO {
followCreators: boolean;
hasNext: number;
list: ContentDTO[];
pageNum: number;
pageSize: number;
totalCount: number;
}
\ No newline at end of file
... ...
export interface RmhRecommendDTO {
authIcon: string;
authTitle: string;
authTitle2: string;
cnAttention: number;
cnMainControl: number;
creatorId: string;
fansNum: number;
headPhotoUrl: string;
introduction: string;
itemId: string;
itemType: string;
itemTypeCode: string;
posterShareControl: number;
region: string;
sceneId: string;
subSceneId: string;
traceId: string;
traceInfo: string;
userId: string;
userName: string;
userType: string;
}
... ...
... ... @@ -47,46 +47,64 @@ export struct CompParser {
// if (compDTO.operDataList[0]?.objectType !== '3' && compDTO.operDataList[0]?.objectType !== '13') { //暂时屏蔽活动和音频详情入口
if (compDTO.compStyle === CompStyle.Label_03) {
LabelComponent({ compDTO: compDTO })
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (compDTO.compStyle === CompStyle.Zh_Carousel_Layout_01) {
ZhCarouselLayout01({ compDTO: compDTO })
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (compDTO.compStyle === CompStyle.Zh_Single_Row_01 && compDTO.imageScale === 2) {
LiveHorizontalCardComponent({ compDTO: compDTO })
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (compDTO.compStyle === CompStyle.Zh_Single_Row_01 && compDTO.imageScale === 3) {
if (compDTO.operDataList.length > 1) {
HorizontalStrokeCardThreeTwoRadioForMoreComponent({ compDTO: compDTO })
} else {
HorizontalStrokeCardThreeTwoRadioForOneComponent({ compDTO: compDTO })
}
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (compDTO.compStyle === CompStyle.Zh_Single_Row_02) {
ZhSingleRow02({ compDTO })
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (compDTO.compStyle === CompStyle.Zh_Single_Row_03) {
ZhSingleRow03({ compDTO: compDTO })
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (compDTO.compStyle === CompStyle.Zh_Grid_Layout_02) {
ZhGridLayout02({ compDTO: compDTO })
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (compDTO.compStyle === CompStyle.Zh_Grid_Layout_03) {
ZhGridLayout03({ compDTO: compDTO })
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (compDTO.compStyle === CompStyle.Zh_Single_Row_04) {
ZhSingleRow04({ compDTO: compDTO })
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (compDTO.compStyle === CompStyle.Zh_Single_Row_05) {
ZhSingleRow05({ compDTO })
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (compDTO.compStyle === CompStyle.Zh_Single_Row_06) {
ZhSingleRow06({ compDTO })
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (compDTO.compStyle === CompStyle.Zh_Single_Column_02) {
//头图卡 和comStyle 2相同,
Card5Component({ contentDTO: compDTO.operDataList[0] })
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (compDTO.compStyle === CompStyle.Zh_Single_Column_03) {
// 大图卡
Card2Component({ contentDTO: compDTO.operDataList[0] })
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (compDTO.compStyle === CompStyle.Zh_Single_Column_04) {
ZhSingleColumn04({ compDTO: compDTO })
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (compDTO.compStyle === CompStyle.Zh_Single_Column_05) {
ZhSingleColumn05({ compDTO: compDTO })
// ZhSingleColumn05({ compDTO: compDTO })
// Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (compDTO.compStyle === CompStyle.Zh_Single_Column_09) {
ZhSingleColumn09({ compDTO })
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (compDTO.compStyle === CompStyle.Card_Comp_Adv) { // 广告
AdvCardParser({compDTO})
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (!Number.isNaN(Number(compDTO.compStyle))) {
CardParser({ contentDTO: compDTO.operDataList[0] });
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
}
else {
Text(compDTO.compStyle)
... ... @@ -97,8 +115,8 @@ export struct CompParser {
WDRouterRule.jumpWithPage(WDRouterPage.QualityCommentsPage)
}
})
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
}
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
}
// }
... ...
... ... @@ -335,6 +335,7 @@ export struct DynamicDetailComponent {
.width($r('app.float.margin_36'))
.height($r('app.float.margin_36'))
.objectFit(ImageFit.Cover)
.margin({ left: $r('app.float.margin_6_negative'),right: $r('app.float.margin_6_negative')})
if(this.interactDataDTO?.likeNum != 0){
Text(NumberFormatterUtils.formatNumberWithWan(this.interactDataDTO?.likeNum))
.fontColor($r('app.color.color_999999'))
... ... @@ -435,7 +436,6 @@ export struct DynamicDetailComponent {
// 未登录,跳转登录
const user_id = await SPHelper.default.get(SpConstants.USER_ID, '')
if (!user_id) {
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
return
}
try {
... ... @@ -464,7 +464,6 @@ export struct DynamicDetailComponent {
// 未登录,跳转登录
const user_id = await SPHelper.default.get(SpConstants.USER_ID, '')
if (!user_id) {
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
this.followStatus = '0';
return
}
... ...
... ... @@ -152,6 +152,8 @@ export struct MorningEveningPaperComponent {
if (imageSource) {
this.pickColor(imageSource)
} else {
this.mixedBgColor = this.pageInfoBean.backgroundColor
}
}
... ...
... ... @@ -32,6 +32,7 @@ export class commentListModel extends PageModel {
pageNum: number = 1
pageSize: number = 10
totalCount: number = 0
totalCommentNum: string = '0'
hasNext: number = 0
list: commentItemModel[] = []
// constructor(pageNum:number, pageSize:number, totalCount: number, hasNext: number, list: commentItemModel[]) {
... ...
... ... @@ -177,6 +177,7 @@ export struct CommentComponent {
async getData() {
commentViewModel.fetchContentCommentList('1', this.publishCommentModel.targetId, this.publishCommentModel.targetType)
.then(commentListModel => {
this.publishCommentModel.totalCommentNumer = commentListModel.totalCount + ''
if (commentListModel && commentListModel.list && commentListModel.list.length > 0) {
commentListModel.list.forEach(element => {
element.hasMore = Number.parseInt(element.childCommentNum) ? true : false
... ...
import { EmitterEventId, EmitterUtils } from 'wdKit/Index'
import { DisplayUtils, EmitterEventId, EmitterUtils } from 'wdKit/Index'
import { publishCommentModel } from '../model/PublishCommentModel'
import { CommentCustomDialog } from './CommentCustomDialog'
import measure from '@ohos.measure'
@Preview
@Component
export struct CommentTabComponent {
@ObjectLink publishCommentModel: publishCommentModel
/*展示类型*/
@State type:number = 1
@State type: number = 1
@State placeHolder: string = '说两句...'
@State dialogController: CustomDialogController | null = null;
/*回调方法*/
dialogControllerConfirm: () => void = () => {}
dialogControllerConfirm: () => void = () => {
}
aboutToAppear() {
... ... @@ -24,9 +21,9 @@ export struct CommentTabComponent {
builder: CommentCustomDialog({
confirm: (value: Record<string, string>) => {
this.dialogControllerConfirm();
EmitterUtils.sendEvent(EmitterEventId.COMMENT_PUBLISH,this.publishCommentModel.targetId)
EmitterUtils.sendEvent(EmitterEventId.COMMENT_PUBLISH, this.publishCommentModel.targetId)
},
publishCommentModel:this.publishCommentModel
publishCommentModel: this.publishCommentModel
}),
autoCancel: true,
alignment: DialogAlignment.Bottom,
... ... @@ -40,13 +37,13 @@ export struct CommentTabComponent {
}
build() {
Row(){
Stack({alignContent:Alignment.Start}){
Row() {
Stack({ alignContent: Alignment.Start }) {
Image($r('app.media.comment_img_input_hui')).width(151).height(30)
Text(this.placeHolder).fontSize(12).fontColor('#999999').margin({left:10})
Text(this.placeHolder).fontSize(12).fontColor('#999999').margin({ left: 10 })
}
}.width(151).height(30)
.onClick(()=>{
.onClick(() => {
this.publishCommentModel.parentId = '-1';
this.dialogController?.open();
})
... ... @@ -58,54 +55,84 @@ export struct CommentTabComponent {
export struct CommentIconComponent {
@ObjectLink publishCommentModel: publishCommentModel
/*展示类型*/
@State type:number = 1
@State type: number = 1
// aboutToAppear(): void {
// setTimeout(() => {
// this.publishCommentModel.totalCommentNumer = '444'
// }, 3000);
//
// setTimeout(() => {
// this.publishCommentModel.totalCommentNumer = '2'
// }, 4000);
// }
/*回调方法*/
onClickItem: () => void = () => {}
onClickItem: () => void = () => {
}
build() {
Row(){
Stack({alignContent:Alignment.TopEnd}){
Row() {
Stack({ alignContent: Alignment.TopEnd }) {
Image($r('app.media.comment_icon')).width(24).height(24)
// Stack({alignContent:Alignment.Start}) {
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({
// if(Number.parseInt(this.publishCommentModel.totalCommentNumer) != 0){
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
.id("Image")
Text(this.publishCommentModel.totalCommentNumer)// Text("44444444")
.fontSize(8)
.fontColor('#ffffff')// .backgroundColor('#ED2800')
.height(12)
.textAlign(TextAlign.Center)
.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")
.width(this.getMeasureText(this.publishCommentModel.totalCommentNumer) + 12)// .backgroundColor(Color.Green)
.id("Text")
// .offset({
// x: 3
// })
}
}
// }
.offset({
x:12
x: 12
})
// }
}
}.width(24).height(24)
// .backgroundColor(Color.Blue)
}
}
\ No newline at end of file
private getMeasureText(text: string) {
let width = measure.measureText({
textContent: text,
fontSize: 8,
lineHeight: 12,
constraintWidth: DisplayUtils.getDeviceWidth(),
})
width = px2vp(width)
return width
}
}
... ...
... ... @@ -25,6 +25,41 @@ export struct FollowListDetailUI {
curPageNum: number = 1;
preferences: dataPreferences.Preferences | null = null;
@State isGetRequest: boolean = false
observer = (key: string) => {
if (key == UserDataLocal.USER_FOLLOW_OPERATION) {
if (this.creatorDirectoryId === -1) {
let value = SPHelper.default.getSync(UserDataLocal.USER_FOLLOW_OPERATION, "") as string
let arr = value.split(',')
if (arr[1] == "0") {
this.data.getDataArray().forEach((element, index) => {
if (element.creatorId === arr[0]) {
this.data.deleteItem(index)
this.count = this.data.size()
}
});
} else {
if (!this.isLoading) {
this.isLoading = true
this.hasMore = true
this.curPageNum = 1
this.data.clear()
this.data.notifyDataReload()
this.getMyFollowListDetail()
}
}
}else{
let value = SPHelper.default.getSync(UserDataLocal.USER_FOLLOW_OPERATION, "") as string
let arr = value.split(',')
if (arr[1] == "0"){
this.data.getDataArray().forEach((element, index) => {
if (element.creatorId === arr[0]) {
this.data.getData(index).status = "0"
}
})
}
}
}
}
aboutToAppear() {
this.getNewPageData()
... ... @@ -76,42 +111,13 @@ export struct FollowListDetailUI {
async addFollowStatusObserver() {
this.preferences = await SPHelper.default.getPreferences();
let observer = (key: string) => {
if (key == UserDataLocal.USER_FOLLOW_OPERATION) {
if (this.creatorDirectoryId === -1) {
let value = SPHelper.default.getSync(UserDataLocal.USER_FOLLOW_OPERATION, "") as string
let arr = value.split(',')
if (arr[1] == "0") {
this.data.getDataArray().forEach((element, index) => {
if (element.creatorId === arr[0]) {
this.data.deleteItem(index)
this.count = this.data.size()
}
});
} else {
if (!this.isLoading) {
this.isLoading = true
this.hasMore = true
this.curPageNum = 1
this.data.clear()
this.data.notifyDataReload()
this.getMyFollowListDetail()
}
}
}else{
let value = SPHelper.default.getSync(UserDataLocal.USER_FOLLOW_OPERATION, "") as string
let arr = value.split(',')
if (arr[1] == "0"){
this.data.getDataArray().forEach((element, index) => {
if (element.creatorId === arr[0]) {
this.data.getData(index).status = "0"
}
})
}
}
}
this.preferences.on('change', this.observer);
}
aboutToDisappear(): void {
if(this.preferences){
this.preferences.off('change', this.observer);
}
this.preferences.on('change', observer);
}
getMyFollowListDetail() {
... ...
... ... @@ -28,6 +28,29 @@ export struct HomePageBottomComponent{
@Link commentNum:number
preferences: dataPreferences.Preferences | null = null;
@State isGetRequest:boolean = false
observer = (key: string) => {
if (key == UserDataLocal.USER_FOLLOW_OPERATION) {
let value = SPHelper.default.getSync(UserDataLocal.USER_FOLLOW_OPERATION,"") as string
let arr = value.split(',')
if(arr[1] == "0"){
this.data_follow.getDataArray().forEach((element,index) => {
if (element.creatorId === arr[0]) {
this.data_follow.deleteItem(index)
this.count = this.data_follow.size()
}
});
}else{
if(!this.isLoading){
this.isLoading = true
this.hasMore = true
this.curPageNum = 1
this.data_follow.clear()
this.data_follow.notifyDataReload()
this.getMyFollowListDetail()
}
}
}
}
aboutToAppear(){
this.getNewPageData()
... ... @@ -36,30 +59,13 @@ export struct HomePageBottomComponent{
async addFollowStatusObserver() {
this.preferences = await SPHelper.default.getPreferences();
let observer = (key: string) => {
if (key == UserDataLocal.USER_FOLLOW_OPERATION) {
let value = SPHelper.default.getSync(UserDataLocal.USER_FOLLOW_OPERATION,"") as string
let arr = value.split(',')
if(arr[1] == "0"){
this.data_follow.getDataArray().forEach((element,index) => {
if (element.creatorId === arr[0]) {
this.data_follow.deleteItem(index)
this.count = this.data_follow.size()
}
});
}else{
if(!this.isLoading){
this.isLoading = true
this.hasMore = true
this.curPageNum = 1
this.data_follow.clear()
this.data_follow.notifyDataReload()
this.getMyFollowListDetail()
}
}
}
this.preferences.on('change', this.observer);
}
aboutToDisappear(): void {
if(this.preferences){
this.preferences.off('change', this.observer);
}
this.preferences.on('change', observer);
}
build(){
... ...
... ... @@ -390,6 +390,33 @@ export struct PaperSingleColumn999CardView {
private item: ContentDTO = {} as ContentDTO;
private index: number = -1;
getPublishTime(): string {
const publishTimestamp = parseInt(this.item?.publishTime)
const currentTime = Date.now(); // 当前时间戳
// 计算差异
const timeDifference = currentTime - publishTimestamp;
// 转换为分钟、小时和天
const minutes = Math.floor(timeDifference / (1000 * 60));
const hours = Math.floor(timeDifference / (1000 * 60 * 60));
const days = Math.floor(timeDifference / (1000 * 60 * 60 * 24));
// 根据时间差返回对应的字符串
let result: string;
if (minutes < 60) {
result = `${minutes}分钟前`;
} else if (hours < 24) {
result = `${hours}小时前`;
} else {
result = `${days}天前`;
}
console.log(result);
return result
}
build() {
Column() {
Text(this.item?.newsTitle)
... ... @@ -429,14 +456,33 @@ export struct PaperSingleColumn999CardView {
}
if (this.item?.visitorComment) {
Row() {
Text(this.item?.visitorComment + "评")
.fontSize(12)
.fontColor(Color.Gray)
.margin({ left: 22 })
Row() {
Text(this.item?.source)
.fontSize(12)
.fontColor(Color.Gray)
.margin({ left: 22 })
Image($r('app.media.point'))
.width(16)
.height(16)
.margin({ top: 10, bottom: 10 })
Text(this.getPublishTime())
.fontSize(12)
.fontColor(Color.Gray)
Text(this.item?.visitorComment + "评")
.fontSize(12)
.fontColor(Color.Gray)
.margin({ left: 6 })
}
.justifyContent(FlexAlign.Start)
Image($r('app.media.icon_forward'))
.width(16)
.height(16)
.margin({ left: 10, right: 22, top: 10, bottom: 10 })
.alignRules({
center: { anchor: '__container__', align: VerticalAlign.Center },
right: { anchor: '__container__', align: HorizontalAlign.End }
})
}.width(CommonConstants.FULL_PARENT)
.justifyContent(FlexAlign.SpaceBetween)
}
... ...
... ... @@ -24,6 +24,15 @@ export struct MinePageComponent {
@State moreData:MinePageMoreFunctionModel[] = []
scroller: Scroller = new Scroller()
preferences: dataPreferences.Preferences | null = null;
observer = (key: string) => {
if(key == SpConstants.USER_ID){
if(StringUtils.isEmpty(SPHelper.default.getSync(SpConstants.USER_ID,""))){
this.isLogin = false
}else {
this.isLogin = true
}
}
}
aboutToAppear(){
this.getUserLogin()
... ... @@ -33,16 +42,13 @@ export struct MinePageComponent {
async addLoginStatusObserver(){
this.preferences = await SPHelper.default.getPreferences();
let observer = (key: string) => {
if(key == SpConstants.USER_ID){
if(StringUtils.isEmpty(SPHelper.default.getSync(SpConstants.USER_ID,""))){
this.isLogin = false
}else {
this.isLogin = true
}
}
this.preferences.on('change', this.observer);
}
aboutToDisappear(): void {
if(this.preferences){
this.preferences.off('change', this.observer);
}
this.preferences.on('change', observer);
}
... ...
... ... @@ -6,6 +6,8 @@ import { ChannelSubscriptionLayout } from './ChannelSubscriptionLayout';
import { FirstTabTopSearchComponent } from '../search/FirstTabTopSearchComponent';
import { VideoChannelDetail } from 'wdDetailPlayShortVideo/Index';
import { AssignChannelParam } from 'wdRouter/src/main/ets/utils/HomeChannelUtils';
import { PeopleShipMainComponent } from '../peopleShip/PeopleShipMainComponent';
const TAG = 'TopNavigationComponent';
... ... @@ -58,6 +60,11 @@ export struct TopNavigationComponent {
// 当前底导index
@State navIndex: number = 0
@State animationDuration: number = 0
@State indicatorLeftMargin: number = 0
@State indicatorWidth: number = 0
private tabsWidth: number = 0
topOrBottomNavChange() {
if (this.currentBottomNavName === this.currentBottomNavInfo?.name) {
this.setBarBackgroundColor()
... ... @@ -162,6 +169,7 @@ export struct TopNavigationComponent {
return item.name === '版面'
}
build() {
Column() {
// 顶部搜索、日报logo、早晚报
... ... @@ -218,7 +226,16 @@ export struct TopNavigationComponent {
pageId: navItem.pageId + '',
channelId: navItem.channelId + '',
})
} else
}
else if (this.currentBottomNavName === '人民号' && navItem.name === '关注') {
PeopleShipMainComponent({
currentTopNavSelectedIndex: $currentTopNavSelectedIndex,
navIndex: index,
pageId: navItem.pageId + '',
channelId: navItem.channelId + '',
})
}
else
if (!this.isBroadcast(navItem) && !this.isLayout(navItem)) {
PageComponent({
currentTopNavSelectedIndex: $currentTopNavSelectedIndex,
... ... @@ -237,9 +254,13 @@ export struct TopNavigationComponent {
.barMode(BarMode.Scrollable)
.vertical(false)
.barBackgroundColor(this.barBackgroundColor)
.onAreaChange((oldValue: Area,newValue: Area)=> {
let width = Number.parseFloat(newValue.width.toString())
this.tabsWidth = Number.isNaN(width) ? 0 : width
})
.animationDuration(this.animationDuration)
.onChange((index: number) => {
this.currentTopNavName = this._currentNavIndex === 0 ? this.myChannelList[index].name : this.topNavList[index].name
Logger.info(TAG, `onChange index : ${index}`);
if (!this.isBroadcast(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) &&
!this.isLayout(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index])
... ... @@ -256,6 +277,39 @@ export struct TopNavigationComponent {
this.tabsController.changeIndex(this.currentTopNavSelectedIndex)
}
})
.onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => {
if (!this.isBroadcast(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) &&
!this.isLayout(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index])
) {
return
}
this.currentTopNavSelectedIndex = targetIndex
// 切换动画开始时触发该回调。下划线跟着页面一起滑动,同时宽度渐变。
let targetIndexInfo = this.getTextInfo(targetIndex)
this.startAnimateTo(this.animationDuration, targetIndexInfo.left, targetIndexInfo.width)
})
.onAnimationEnd((index: number,event: TabsAnimationEvent) => {
if (!this.isBroadcast(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) &&
!this.isLayout(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index])
) {
return
}
// 切换动画结束时触发该回调。下划线动画停止。
let currentIndicatorInfo = this.getCurrentIndicatorInfo(index,event)
this.startAnimateTo(0,currentIndicatorInfo.left,currentIndicatorInfo.width)
})
.onGestureSwipe((index: number,event: TabsAnimationEvent) => {
if (!this.isBroadcast(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) &&
!this.isLayout(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index])
) {
return
}
// 在页面跟手滑动过程中,逐帧触发该回调。
let currentIndicatorInfo = this.getCurrentIndicatorInfo(index,event)
this.currentTopNavSelectedIndex = currentIndicatorInfo.index
this.indicatorLeftMargin = currentIndicatorInfo.left
this.indicatorWidth = currentIndicatorInfo.width
})
// 分类列表最右侧频道设置
if (this._currentNavIndex === 0) {
... ... @@ -296,6 +350,17 @@ export struct TopNavigationComponent {
.fontColor(this.getTopNavFontColor(item, index))
.padding({ top: $r('app.float.top_tab_item_padding_top'), bottom: $r('app.float.top_tab_item_padding_bottom') })
.maxLines(this.MAX_LINE)
.id(index.toString())
.onAreaChange((oldValue: Area,newValue: Area) => {
if (this.currentTopNavSelectedIndex === index && (this.indicatorLeftMargin === 0 || this.indicatorWidth === 0)){
if (newValue.position.x != undefined) {
let positionX = Number.parseFloat(newValue.position.x.toString())
this.indicatorLeftMargin = Number.isNaN(positionX) ? 0 : positionX
}
let width = Number.parseFloat(newValue.width.toString())
this.indicatorWidth = Number.isNaN(width) ? 0 : width
}
})
// .backgroundImage(this.currentTopNavSelectedIndex === index ? item.iconCUrl : item.iconUrl)
if (this.currentTopNavSelectedIndex === index) {
Row()
... ... @@ -418,4 +483,46 @@ export struct TopNavigationComponent {
}
return null
}
private getTextInfo(index: number): Record<string, number> {
let strJson = getInspectorByKey(index.toString())
try {
let obj: Record<string, string> = JSON.parse(strJson)
let rectInfo: number[][] = JSON.parse('[' + obj.$rect + ']')
return { 'left': px2vp(rectInfo[0][0]), 'width': px2vp(rectInfo[1][0] - rectInfo[0][0]) }
} catch (error) {
return { 'left': 0, 'width': 0 }
}
}
private getCurrentIndicatorInfo(index: number, event: TabsAnimationEvent): Record<string, number> {
let nextIndex = index
if (index > 0 && event.currentOffset > 0) {
nextIndex--
} else if (index < 3 && event.currentOffset < 0) {
nextIndex++
}
let indexInfo = this.getTextInfo(index)
let nextIndexInfo = this.getTextInfo(nextIndex)
let swipeRatio = Math.abs(event.currentOffset / this.tabsWidth)
let currentIndex = swipeRatio > 0.5 ? nextIndex : index // 页面滑动超过一半,tabBar切换到下一页。
let currentLeft = indexInfo.left + (nextIndexInfo.left - indexInfo.left) * swipeRatio
let currentWidth = indexInfo.width + (nextIndexInfo.width - indexInfo.width) * swipeRatio
return { 'index': currentIndex, 'left': currentLeft, 'width': currentWidth }
}
private startAnimateTo(duration: number, leftMargin: number, width: number) {
animateTo({
duration: duration, // 动画时长
curve: Curve.Linear, // 动画曲线
iterations: 1, // 播放次数
playMode: PlayMode.Normal, // 动画模式
onFinish: () => {
console.info('play end')
}
}, () => {
this.indicatorLeftMargin = leftMargin
this.indicatorWidth = width
})
}
}
\ No newline at end of file
... ...
import { PeopleShipAttentionContentListTopComponent } from './PeopleShipAttentionContentListTopComponent'
import { FollowListDetailItem } from '../../viewmodel/FollowListDetailItem';
import { ContentDTO } from 'wdBean'
import { CardParser } from '../CardParser'
@Preview
@Component
export struct PeopleShipAttentionContentListComponent {
@Prop followList: FollowListDetailItem[]
@Prop attentionList: ContentDTO[]
build() {
List(){
// 头部关注列表
ListItem(){
PeopleShipAttentionContentListTopComponent({
followList: this.followList
})
}
ForEach(this.attentionList, (item: ContentDTO) => {
ListItem() {
CardParser({ contentDTO: item })
}.width("100%")
.backgroundColor(Color.Transparent)
}, (item: ContentDTO, index: number) => item.objectId + index.toString())
}
.scrollBar(BarState.Off)
.width('100%')
.height('100%')
}
}
... ...
import { FollowListDetailItem } from '../../viewmodel/FollowListDetailItem';
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'
import { ProcessUtils } from 'wdRouter';
import { PeopleShipHomePageHeadComponent } from '../peopleShipHomePage/PeopleShipHomePageHeadComponent'
@Component
export struct PeopleShipAttentionContentListTopComponent {
@Prop followList: FollowListDetailItem[]
build() {
Column() {
List(){
ListItem() {
PeopleShipAttentionContentListHeadComponent({
index: 0,
item: this.followList[0]
})
}.onClick(() => {
// 跳转到关注列表-我的
WDRouterRule.jumpWithPage(WDRouterPage.followListPage)
})
ForEach(this.followList, (item: FollowListDetailItem, index: number) => {
ListItem() {
PeopleShipAttentionContentListHeadComponent({
index: index + 1,
item: item
})
}.onClick(() => {
let creatorId = item.attentionCreatorId || ''
ProcessUtils.gotoPeopleShipHomePage(creatorId)
})
}, (item: FollowListDetailItem) => item.attentionCreatorId)
}
.listDirection(Axis.Horizontal)
.scrollBar(BarState.Off)
.width('100%')
.height('102vp')
Divider().strokeWidth(1).color($r('app.color.color_F5F5F5'))
}
}
}
@Component
struct PeopleShipAttentionContentListHeadComponent {
@State index: number = 0
@ObjectLink item: FollowListDetailItem
build() {
Column(){
// 头像
PeopleShipHomePageHeadComponent({
diameter: 48,
iconDiameter: 16,
headPhotoUrl: this.index == 0 ? $r('app.media.attention_mine') :
((this.item.attentionHeadPhotoUrl && this.item.attentionHeadPhotoUrl.length > 0) ?
this.item.attentionHeadPhotoUrl : $r('app.media.WDAccountOwnerHedaerDefaultIcon')),
authIcon: this.index == 0 ? '' : this.item.authIcon
}).margin({
bottom: '8vp'
})
Text(this.index == 0 ? '我的关注' : this.item.attentionUserName)
.fontColor($r('app.color.color_666666'))
.fontSize($r('app.float.vp_13'))
.fontWeight(400)
.height('18vp')
.lineHeight('18vp')
.maxLines(1)
.textOverflow({overflow: TextOverflow.Ellipsis})
.padding({
left: '2vp',
right: '2vp'
})
}
.alignItems(HorizontalAlign.Center)
.width('78vp')
.margin({
left: this.index == 0 ? '8vp' : '4vp',
top: '14vp',
bottom: '14vp'
})
}
}
\ No newline at end of file
... ...
import { PeopleShipRecommendComponent } from './PeopleShipRecommendComponent';
import { PeopleShipMainViewModel } from '../../viewmodel/PeopleShipMainViewModel';
import { HttpUtils } from 'wdNetwork/Index';
import { Logger, DateTimeUtils, EmitterEventId, EmitterUtils } from 'wdKit';
import { RmhRecommendDTO, ContentDTO, AttentionBatchDTO, CreatorDTO } from 'wdBean';
import { ViewType } from 'wdConstant/src/main/ets/enum/ViewType';
import { channelSkeleton } from '../skeleton/channelSkeleton'
import { EmptyComponent } from '../view/EmptyComponent';
import { ErrorComponent } from '../view/ErrorComponent';
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'
import MinePageDatasModel from '../../model/MinePageDatasModel';
import { FollowListDetailRequestItem } from '../../viewmodel/FollowListDetailRequestItem';
import { FollowListDetailItem } from '../../viewmodel/FollowListDetailItem';
import { CustomPullToRefresh } from '../reusable/CustomPullToRefresh';
import PageModel from '../../viewmodel/PageModel';
import PageAdModel from '../../viewmodel/PageAdvModel';
import PageHelper from '../../viewmodel/PageHelper';
import { PeopleShipAttentionContentListTopComponent } from './PeopleShipAttentionContentListTopComponent'
import { CardParser } from '../CardParser'
import NoMoreLayout from '../page/NoMoreLayout';
@Preview
@Component
export struct PeopleShipMainComponent {
@State private pageModel: PageModel = new PageModel();
@State private pageAdvModel: PageAdModel = new PageAdModel();
navIndex: number = 0;
pageId: string = "";
channelId: string = "";
@Link @Watch('onChange') currentTopNavSelectedIndex: number
private scroller: Scroller = new Scroller()
private listScroller: Scroller = new Scroller()
@State rmhList: RmhRecommendDTO[] = []
@Provide rmhSelectedList: string[] = []
@State viewType: ViewType = ViewType.LOADING
// 一键关注处理
@State @Watch('onOneFollowChange') oneKeyFollow: boolean = false
// 已经关注的列表
@State followList: FollowListDetailItem[] = []
// 换一换
@State @Watch('onChangeButtonClick') changeButton: boolean = false
@State attentionList: ContentDTO[] = []
@State private hasMore: boolean = true
@State private currentPage: number = 1
@State private isLoading: boolean = false
@State private loadTime: string = ''
// 页面展示监听
@Consume @Watch('onPageShowChange') pageShow: number
@State private pageAttentionChange: boolean = false
build() {
if (this.viewType == ViewType.LOADING) {
this.LoadingLayout()
} else if (this.viewType == ViewType.ERROR) {
ErrorComponent()
} else if (this.viewType == ViewType.EMPTY) {
EmptyComponent()
} else {
if (this.followList.length == 0) {
CustomPullToRefresh({
alldata: this.rmhList,
scroller: this.scroller,
hasMore: false,
customList: () => {
this.ListLayout()
},
onRefresh: (resolve) => {
this.currentPage = 1
this.getData(resolve)
},
})
}else {
CustomPullToRefresh({
alldata: this.attentionList,
scroller: this.listScroller,
hasMore: this.hasMore,
customList: () => {
this.ListAttentionLayout()
},
onRefresh: (resolve) => {
this.currentPage = 1
this.getData(resolve)
},
onLoadMore:(resolve)=> {
if (this.hasMore === false) {
if(resolve) {
resolve('')
}
return
}
if(!this.isLoading && this.hasMore){
//加载分页数据
this.currentPage++;
this.getAttentionContentListData(resolve)
}else {
if(resolve) {
resolve('')
}
}
},
})
}
}
}
@Builder
LoadingLayout() {
channelSkeleton()
}
@Builder
ListLayout() {
Scroll(this.scroller) {
// 推荐人民号
PeopleShipRecommendComponent({
rmhList: this.rmhList,
oneKeyFollow: this.oneKeyFollow,
changeButton: this.changeButton
})
}
.edgeEffect(EdgeEffect.None)
.scrollBar(BarState.Off)
.width('100%')
.height('100%')
}
@Builder
ListAttentionLayout() {
List({scroller: this.listScroller}){
// 头部关注列表
ListItem(){
PeopleShipAttentionContentListTopComponent({
followList: this.followList
})
}
ForEach(this.attentionList, (item: ContentDTO) => {
ListItem() {
CardParser({ contentDTO: item })
}.width("100%")
.backgroundColor(Color.Transparent)
}, (item: ContentDTO, index: number) => item.objectId + index.toString())
// 加载更多
ListItem() {
if (!this.hasMore && !this.isLoading) {
NoMoreLayout()
}
}
}
.edgeEffect(EdgeEffect.None)
.scrollBar(BarState.Off)
.width('100%')
.height('100%')
// PeopleShipAttentionContentListComponent({
// followList: this.followList,
// attentionList: this.attentionList
// })
}
aboutToAppear() {
if (this.navIndex == this.currentTopNavSelectedIndex && this.viewType == ViewType.LOADING) {
this.getData()
}
// 有登录-退出登录-关注接口等问题
EmitterUtils.receiveEvent(EmitterEventId.PEOPLE_SHIP_ATTENTION, () => {
Logger.debug('PeopleShipMainComponent', 'PEOPLE_SHIP_ATTENTION')
this.pageAttentionChange = true
})
}
onChange() {
if (this.navIndex === this.currentTopNavSelectedIndex && (this.viewType == ViewType.LOADING || this.pageAttentionChange)) {
this.getData();
}
}
private async getData(resolve?: (value: string | PromiseLike<string>) => void) {
if (this.isLoading) {
if (resolve) {
resolve('已更新至最新')
}
return
}
this.pageAttentionChange = false
this.isLoading = true
this.getInitData()
try {
// 登录后获取
if (HttpUtils.getUserId()) {
// 获取用户关注人数
let object = new FollowListDetailRequestItem(-1, 20, 1)
let followInfo = await MinePageDatasModel.getMineFollowListData(object, getContext(this))
Logger.debug('PeopleShipMainComponent', '获取页面信息' + `${JSON.stringify(followInfo)}`)
if (followInfo.list.length == 0) {
this.followList = []
this.getRmhRecommendInfo(resolve)
} else {
this.followList = []
// this.followList = followInfo.list
this.followList.push(...followInfo.list)
this.attentionList = []
this.currentPage = 1
this.loadTime = DateTimeUtils.getCurDate(DateTimeUtils.PATTERN_DATE_TIME_HYPHEN)
this.getAttentionContentListData(resolve)
}
} else {
this.followList = []
this.getRmhRecommendInfo(resolve)
}
} catch (exception) {
this.viewType = ViewType.ERROR
this.isLoading = false
}
}
// 获取人民号号主推荐
private async getRmhRecommendInfo(resolve?: (value: string | PromiseLike<string>) => void) {
try {
// 获取页面信息
this.rmhList = await PeopleShipMainViewModel.getPeopleRemRecommendInfo()
this.rmhSelectedList = []
this.rmhList.forEach((item: RmhRecommendDTO) => {
this.rmhSelectedList.push(item.creatorId)
})
this.viewType = ViewType.LOADED
this.changeButton = false
this.isLoading = false
Logger.debug('PeopleShipMainComponent', 'getRmhRecommendInfo' + `${JSON.stringify(this.rmhList)}`)
if (resolve) {
resolve('已更新至最新')
}
} catch (exception) {
if (resolve) {
resolve('')
}
this.viewType = ViewType.ERROR
this.changeButton = false
this.isLoading = false
}
}
// 获取关注
private async getAttentionContentListData(resolve?: (value: string | PromiseLike<string>) => void) {
if (this.isLoading && this.currentPage != 1) {
if (resolve) {
resolve('')
}
return
}
this.isLoading = true
try {
// 获取列表数据
let listData = await PeopleShipMainViewModel.getAttentionContentListInfo(this.currentPage, 20, this.loadTime)
Logger.debug('PeopleShipMainComponent', '获取页面信息' + `${JSON.stringify(listData)}`)
if (resolve ) {
if (this.currentPage == 1) {
resolve('已更新至最新')
}else {
resolve('')
}
}
if (listData && listData.list && listData.list.length > 0) {
if (listData.list.length === 20) {
this.hasMore = true;
} else {
this.hasMore = false;
}
if (this.currentPage == 1) {
this.attentionList = []
}
this.attentionList.push(...listData.list)
}
this.viewType = ViewType.LOADED
this.isLoading = false
} catch (exception) {
this.viewType = ViewType.ERROR
this.isLoading = false
}
}
// 说是首页必须要调用
async getInitData() {
Logger.debug('PeopleShipMainComponent', `getData id: ${this.pageId} , ${this.channelId} , navIndex: ${this.currentTopNavSelectedIndex}`);
this.pageModel.pageId = this.pageId;
this.pageModel.groupId = this.pageId;
this.pageModel.channelId = this.channelId;
this.pageModel.currentPage = 1;
PageHelper.getInitData(this.pageModel, this.pageAdvModel)
}
// 点击一键关注
onOneFollowChange() {
if (this.oneKeyFollow) {
if (this.rmhSelectedList.length > 0) {
if (!HttpUtils.getUserId()) {
this.oneKeyFollow = false
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
return
}
//调用接口
this.attentionBatchPort()
} else {
this.oneKeyFollow = false
}
}
}
// 一键关注接口
private async attentionBatchPort() {
try {
// 获取列表数据
let objects = new AttentionBatchDTO()
this.rmhList.forEach((element: RmhRecommendDTO) => {
if ( this.rmhSelectedList.indexOf(element.creatorId) != -1) {
const creator = new CreatorDTO(element.userType, element.userId, element.creatorId)
objects.creators.push(creator)
}
})
Logger.debug('PeopleShipMainComponent', `一键关注接口参数: ${JSON.stringify(objects)}`);
let batchInfo = await PeopleShipMainViewModel.getAttentionBatchInfo(objects)
if (batchInfo.code === 0 || batchInfo.code.toString() === "0") {
this.getData()
}
} catch (exception) {
}
}
// 点击换一换
onChangeButtonClick() {
if (this.changeButton) {
this.getRmhRecommendInfo()
}
}
// 页面展示监听
onPageShowChange() {
if (this.navIndex === this.currentTopNavSelectedIndex && this.pageAttentionChange ) {
this.getData()
}
}
}
\ No newline at end of file
... ...
import { PeopleShipRecommendHeadComponent } from './PeopleShipRecommendHeadComponent'
import { RmhRecommendDTO } from 'wdBean';
import { Logger } from 'wdKit/Index';
import NoMoreLayout from '../page/NoMoreLayout';
@Component
export struct PeopleShipRecommendComponent {
@Prop rmhList: RmhRecommendDTO[] = []
@Consume rmhSelectedList: string[]
// 一键关注处理
@Link oneKeyFollow: boolean
// 换一换
@Link changeButton: boolean
build() {
Column({ space: 0 }) {
Row() {
Image($r('app.media.redLine'))
.width('3vp')
.height('16vp')
.objectFit(ImageFit.Cover)
.margin({
left: '16vp',
right: '4vp'
})
Text('为你推荐优质号主')
.height('30vp')
.fontColor($r('app.color.color_222222'))
.fontWeight(600)
.fontSize($r('app.float.vp_18'))
Blank()
Button({ type: ButtonType.Normal, stateEffect: true }) {
Row() {
Text('换一换')
.height('30vp')
.fontColor($r('app.color.color_999999'))
.fontWeight(400)
.fontSize($r('app.float.vp_14'))
Image($r('app.media.ic_refresh'))
.width('14vp')
.height('14vp')
.objectFit(ImageFit.Cover)
}
}
.margin({
right: '16vp'
})
.backgroundColor(Color.Transparent)
.onClick(() => {
// 点击换一换
if (!this.changeButton) {
this.changeButton = true
}
})
}
.width('100%')
.alignSelf(ItemAlign.Start)
.margin({
top: '10vp',
bottom: '10vp'
})
Grid() {
ForEach(this.rmhList, (item: RmhRecommendDTO) => {
GridItem() {
PeopleShipRecommendHeadComponent({
rmhInfo: item
})
.onClick(() => {
this.clickRecommendHeadSelected(item)
})
}
}, (item: RmhRecommendDTO) => item.creatorId)
}
.columnsTemplate('1fr 1fr 1fr')
.columnsGap(20)
.rowsGap(20)
.height(Math.ceil(this.rmhList.length / 3.0) * 136)
.backgroundColor(Color.Transparent)
.margin({
right: '20vp',
left: '20pv'
})
// 为你推荐
Button(this.rmhSelectedList.length == 0 ? '一键关注' : `一键关注 (${this.rmhSelectedList.length})`, { type: ButtonType.Normal, stateEffect: this.rmhSelectedList.length != 0 })
.margin({
top: '24vp'
})
.width('120vp')
.height('36vp')
.backgroundColor(this.rmhSelectedList.length != 0 ? $r('app.color.color_ED2800') : $r('app.color.color_B0B0B0'))
.borderRadius('3vp')
.fontColor($r('app.color.color_999999'))
.fontWeight(500)
.fontSize($r('app.float.vp_14'))
.fontColor(Color.White)
.onClick(() => {
// 点击一键关注
if (!this.oneKeyFollow && this.rmhSelectedList.length > 0 ){
this.oneKeyFollow = true
}
})
// 没有更多
NoMoreLayout()
}
.width('100%')
}
// 选中
private clickRecommendHeadSelected(rmhInfo: RmhRecommendDTO) {
if (this.rmhSelectedList.length > 0 && rmhInfo ) {
const num = this.rmhSelectedList.indexOf(rmhInfo.creatorId)
if ( num != -1) {
this.rmhSelectedList.splice(num, 1)
}else {
this.rmhSelectedList.push(rmhInfo.creatorId)
}
}else {
this.rmhSelectedList.push(rmhInfo.creatorId)
}
}
}
\ No newline at end of file
... ...
import { RmhRecommendDTO } from 'wdBean';
import { ToastUtils } from 'wdKit/Index';
@Component
export struct PeopleShipRecommendHeadComponent {
@State isSelected: boolean = true
@Consume rmhSelectedList: string[]
@State rmhInfo: RmhRecommendDTO = {} as RmhRecommendDTO
build() {
Column(){
Stack({ alignContent: Alignment.BottomEnd }) {
Image(this.rmhInfo.headPhotoUrl.length > 0 ? this.rmhInfo.headPhotoUrl : $r('app.media.WDAccountOwnerHedaerDefaultIcon'))
.width('44vp')
.height('44vp')
.borderRadius('22vp')
.objectFit(ImageFit.Cover)
Image( this.isSelectedRmhInfo() ? $r('app.media.rmh_selected') : $r('app.media.rmh_unselected') )
.width('18vp')
.height('18vp')
.objectFit(ImageFit.Cover)
.margin({
right: '-3vp'
})
}.margin({ top: 12, bottom: 8 })
Text(this.rmhInfo.userName)
.fontColor($r('app.color.color_222222'))
.fontSize($r('app.float.vp_14'))
.fontWeight(600)
.maxLines(1)
.textOverflow({overflow: TextOverflow.Ellipsis})
Text(this.rmhInfo.introduction)
.fontColor($r('app.color.color_B0B0B0'))
.fontSize($r('app.float.vp_12'))
.margin({ top: 8, bottom: 14 })
.textOverflow({overflow: TextOverflow.Ellipsis})
.maxLines(2)
.height(34)
}
.width('100%')
.height('116vp')
}
private isSelectedRmhInfo() {
if (this.rmhSelectedList.length > 0 && this.rmhInfo ) {
if (this.rmhSelectedList.indexOf(this.rmhInfo.creatorId) != -1) {
return true
}
}
return false
}
}
\ No newline at end of file
... ...
... ... @@ -20,7 +20,6 @@ import { RefreshLayoutBean } from '../page/RefreshLayoutBean'
import CustomRefreshLoadLayout from '../page/CustomRefreshLoadLayout'
import { ErrorComponent } from '../view/ErrorComponent';
import NoMoreLayout from '../page/NoMoreLayout';
// import { LazyDataSource } from 'wdKit';
import { CustomPullToRefresh } from '../reusable/CustomPullToRefresh'
const TAG = 'PeopleShipHomeArticleListComponent';
... ...
... ... @@ -36,7 +36,7 @@ export struct PeopleShipHomePageNavComponent {
PeopleShipHomePageHeadComponent({
diameter: 30,
iconDiameter: 10,
headPhotoUrl: this.detailModel.headPhotoUrl,
headPhotoUrl: (this.detailModel.headPhotoUrl && this.detailModel.headPhotoUrl.length > 0 ) ? this.detailModel.headPhotoUrl : $r('app.media.WDAccountOwnerHedaerDefaultIcon'),
authIcon: this.detailModel.authIcon
})
.margin({
... ...
... ... @@ -2,13 +2,13 @@
export struct PeopleShipHomePageHeadComponent {
@State diameter: number = 30
@State iconDiameter: number = 10
@Prop headPhotoUrl: string = ''
@Prop headPhotoUrl: string | ResourceStr = ''
@Prop authIcon: string = ''
build() {
Stack({ alignContent: Alignment.BottomEnd }) {
// 头像
Image( this.headPhotoUrl.length > 0 ? this.headPhotoUrl : $r('app.media.home_page_header_authority') )
Image( this.headPhotoUrl )
.width(this.diameter)
.height(this.diameter)
.borderRadius(this.diameter/2)
... ... @@ -16,6 +16,7 @@ export struct PeopleShipHomePageHeadComponent {
.borderStyle(BorderStyle.Solid)
.borderColor(Color.White)
.objectFit(ImageFit.Cover)
.backgroundColor(Color.White)
if(this.authIcon.length > 0 ) {
Image( this.authIcon )
.width(this.iconDiameter)
... ...
... ... @@ -46,7 +46,7 @@ export struct PeopleShipHomePageTopComponent {
PeopleShipHomePageHeadComponent({
diameter: 80,
iconDiameter: 20,
headPhotoUrl: this.detailModel.headPhotoUrl,
headPhotoUrl:(this.detailModel.headPhotoUrl && this.detailModel.headPhotoUrl.length > 0) ? this.detailModel.headPhotoUrl : $r('app.media.WDAccountOwnerHedaerDefaultIcon') ,
authIcon: this.detailModel.authIcon
}).margin({
left: '10vp',
... ...
import { Params } from 'wdBean';
import { AppUtils, StringUtils } from 'wdKit/Index';
import { WDRouterPage, WDRouterRule } from 'wdRouter';
import { EnvironmentCustomDialog } from './EnvironmentCustomDialog';
... ... @@ -32,6 +33,10 @@ export struct AboutPageUI {
aboutToAppear() {
let context = getContext();
context.getApplicationContext();
let appVerion = AppUtils.getAppVersionName()
if (StringUtils.isNotEmpty(appVerion)) {
this.version = "版本号:" + appVerion
}
}
@Builder
... ...
import { BottomNavi, CommonConstants, SpConstants } from 'wdConstant';
import { Logger, SPHelper, ToastUtils, UserDataLocal } from 'wdKit';
import { Logger, SPHelper, ToastUtils, UserDataLocal, EmitterEventId, EmitterUtils } from 'wdKit';
import { TopNavigationComponent } from '../page/TopNavigationComponent';
import PageViewModel from '../../viewmodel/PageViewModel';
import {MineMainSettingFunctionItem} from '../../viewmodel/MineMainSettingFunctionItem';
... ... @@ -430,7 +430,7 @@ export struct AccountAndSecurityLayout {
let login = new LoginViewModel;
login.logOut().then(()=>{
promptAction.showToast({ message: '退出登录' })
router.back();
EmitterUtils.sendEvent(EmitterEventId.PEOPLE_SHIP_ATTENTION)
router.back();
}).catch((error:string)=>{
promptAction.showToast({ message: error })
... ...
... ... @@ -110,7 +110,7 @@ export struct ENewspaperListDialog {
ListItem() {
Column() {
if (itemIndex == 0) {
Text(item.pageNum + item.pageName)
Text(item.pageNum + '版:' + item.pageName)
.fontSize($r('app.float.font_size_14'))
.fontColor($r('app.color.color_ED2800'))
.fontWeight(600)
... ... @@ -130,6 +130,7 @@ export struct ENewspaperListDialog {
Text(positionItem.title)
.fontSize($r('app.float.font_size_17'))
.fontColor($r('app.color.color_222222'))
.fontWeight(600)
.margin({ top: 8 })
.maxLines(2)
}
... ... @@ -172,9 +173,12 @@ export struct ENewspaperListDialog {
// }
})
}
})
}
.divider({
strokeWidth: 0.5,
color: '#EDEDED'
})
}
})
}
... ...
... ... @@ -4,7 +4,7 @@ import MinePageCreatorFunctionsItem from '../viewmodel/MinePageCreatorFunctionsI
import MinePageMoreFunctionModel from '../viewmodel/MinePageMoreFunctionModel';
import { HttpBizUtil, HttpUrlUtils, HttpUtils, ResponseDTO, WDHttp } from 'wdNetwork';
import { MineAppointmentListItem } from '../viewmodel/MineAppointmentListItem';
import { Logger, StringUtils } from 'wdKit';
import { Logger, StringUtils, EmitterUtils, EmitterEventId } from 'wdKit';
import { MineFollowListDetailItem } from '../viewmodel/MineFollowListDetailItem';
import { FollowListDetailRequestItem } from '../viewmodel/FollowListDetailRequestItem';
import { FollowListItem } from '../viewmodel/FollowListItem';
... ... @@ -545,6 +545,7 @@ class MinePageDatasModel{
return
}
Logger.info(TAG, "getAppointmentList then,AppointmentResDTO.timeStamp:" + navResDTO.timestamp);
EmitterUtils.sendEvent(EmitterEventId.PEOPLE_SHIP_ATTENTION)
success(navResDTO);
}).catch((err: Error) => {
Logger.error(TAG, `fetchAppointmentListDataApi catch, error.name : ${err.name}, error.message:${err.message}`);
... ...
... ... @@ -182,20 +182,47 @@ struct MineHomePage {
Divider().width('100%').height('12lpx').color($r('app.color.color_F5F5F5')).strokeWidth('12lpx')
//tab 页面
Tabs({controller: this.controller}) {
TabContent() {
HomePageBottomComponent({style:0,commentNum:$commentNum})
}.tabBar(this.TabBuilder(0,"评论"))
TabContent() {
HomePageBottomComponent({style:1,commentNum:$commentNum})
}.tabBar(this.TabBuilder(1,"关注"))
Stack({ alignContent: Alignment.Top }){
Tabs({controller: this.controller}) {
TabContent() {
HomePageBottomComponent({style:0,commentNum:$commentNum})
}
TabContent() {
HomePageBottomComponent({style:1,commentNum:$commentNum})
}
}
.backgroundColor($r('app.color.white'))
.animationDuration(0)
.onChange((index: number) => {
this.currentIndex = index
})
.vertical(false)
.barHeight("77lpx")
Column() {
// 页签
Row({ space: 7 }) {
Scroll() {
Row() {
this.TabBuilder(0,"评论")
this.TabBuilder(1,"关注")
}
.justifyContent(FlexAlign.Start)
}
.align(Alignment.Start)
.scrollable(ScrollDirection.Horizontal)
.scrollBar(BarState.Off)
.width('100%')
.padding({left:'31lpx'})
}
.alignItems(VerticalAlign.Bottom)
.width('100%')
}
.backgroundColor($r('app.color.white'))
.alignItems(HorizontalAlign.Start)
.width('100%')
.height('77lpx')
}
.backgroundColor($r('app.color.white'))
.animationDuration(0)
.onChange((index: number) => {
this.currentIndex = index
})
.vertical(false)
}.width("100%")
}
.edgeEffect(EdgeEffect.None)
... ... @@ -341,9 +368,9 @@ struct MineHomePage {
this.currentIndex = index
this.controller.changeIndex(this.currentIndex)
})
.height('100%')
.width('100%')
.margin({right:'9lpx'})
.height('77lpx')
.width('70lpx')
.margin({right:'29lpx'})
}
/**
... ...
... ... @@ -176,20 +176,47 @@ struct OtherNormalUserHomePage {
Divider().width('100%').height('12lpx').color($r('app.color.color_F5F5F5')).strokeWidth('12lpx')
//tab 页面
Tabs({controller: this.controller}) {
TabContent() {
OtherHomePageBottomCommentComponent({curUserId:this.curUserId,levelHead:this.levelHead,commentNum:$commentNum})
}.tabBar(this.TabBuilder(0,"评论"))
TabContent() {
OtherHomePageBottomFollowComponent({curUserId:this.curUserId})
}.tabBar(this.TabBuilder(1,"关注"))
Stack({ alignContent: Alignment.Top }){
Tabs({controller: this.controller}) {
TabContent() {
OtherHomePageBottomCommentComponent({curUserId:this.curUserId,levelHead:this.levelHead,commentNum:$commentNum})
}
TabContent() {
OtherHomePageBottomFollowComponent({curUserId:this.curUserId})
}
}
.backgroundColor($r('app.color.white'))
.animationDuration(0)
.onChange((index: number) => {
this.currentIndex = index
})
.vertical(false)
.barHeight('77lpx')
Column() {
// 页签
Row({ space: 7 }) {
Scroll() {
Row() {
this.TabBuilder(0,"评论")
this.TabBuilder(1,"关注")
}
.justifyContent(FlexAlign.Start)
}
.align(Alignment.Start)
.scrollable(ScrollDirection.Horizontal)
.scrollBar(BarState.Off)
.width('90%')
.padding({left:'31lpx'})
}
.alignItems(VerticalAlign.Bottom)
.width('100%')
}
.backgroundColor($r('app.color.white'))
.alignItems(HorizontalAlign.Start)
.width('100%')
.height('77lpx')
}
.backgroundColor($r('app.color.white'))
.animationDuration(0)
.onChange((index: number) => {
this.currentIndex = index
})
.vertical(false)
}.width("100%")
}
.edgeEffect(EdgeEffect.None)
... ... @@ -300,9 +327,9 @@ struct OtherNormalUserHomePage {
this.currentIndex = index
this.controller.changeIndex(this.currentIndex)
})
.height('100%')
.width('100%')
.margin({right:'9lpx'})
.height('77lpx')
.width('70lpx')
.margin({right:'29lpx'})
}
... ...
import { HttpUrlUtils, HttpUtils, ResponseDTO, WDHttp } from 'wdNetwork';
import { DateTimeUtils, Logger, StringUtils } from 'wdKit';
import { DateTimeUtils, Logger, StringUtils, EmitterUtils, EmitterEventId } from 'wdKit';
import {
batchLikeAndCollectResult,
CompInfoBean,
... ... @@ -313,10 +314,32 @@ export class PageRepository {
/**
* 关注号主
*/
static postInteractAccentionOperate(params: postInteractAccentionOperateParams): Promise<ResponseDTO> {
private static postInteractAccentionOperateInfo(params: postInteractAccentionOperateParams): Promise<ResponseDTO> {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_ACCENTION_OPERATION
return WDHttp.post(url, params)
}
/**
* 关注号主
*/
static postInteractAccentionOperate(params: postInteractAccentionOperateParams): Promise<ResponseDTO> {
return new Promise<ResponseDTO>((success, error) => {
Logger.debug(TAG, `postInteractAccentionOperate pageInfo start`);
PageRepository.postInteractAccentionOperateInfo(params)
.then((resDTO: ResponseDTO) => {
if (!resDTO || resDTO.code != 0) {
error(null)
return
}
Logger.debug(TAG, "postInteractAccentionOperate then,navResDTO.timestamp:" + resDTO.timestamp);
EmitterUtils.sendEvent(EmitterEventId.PEOPLE_SHIP_ATTENTION)
success(resDTO);
})
.catch((err: Error) => {
Logger.error(TAG, `postInteractAccentionOperate catch, error.name : ${err.name}, error.message:${err.message}`);
error(err);
})
})
}
static fetchNewspaperInfo(date: string) {
let url = PageRepository.getNewspaperInfoUrl(date)
... ...
... ... @@ -29,9 +29,6 @@ export class LogoutViewModel{
SPHelper.default.saveSync(SpConstants.USER_Type, '')
SPHelper.default.saveSync(SpConstants.USER_NAME, '')
SPHelper.default.saveSync(SpConstants.USER_PHONE, '')
HttpUtils.setUserId("")
HttpUtils.setUserType("")
HttpUtils.setUserToken('')
UserDataLocal.clearUserData()
}
}
\ No newline at end of file
... ...
import { Logger } from 'wdKit';
import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork';
import HashMap from '@ohos.util.HashMap';
import {
RmhRecommendDTO,
PeopleShipContentListDTO,
AttentionBatchDTO
} from 'wdBean';
const TAG = 'PeopleShipMainViewModel'
export class PeopleShipMainViewModel {
/*人民号号主推荐*/
static fetchPeopleRemRecommendData() {
let url = HttpUrlUtils.getRmhRecommendUrl()
let bean: Record<string, string> = {};
return WDHttp.post<ResponseDTO<RmhRecommendDTO[]>>(url, bean)
}
static async getPeopleRemRecommendInfo(): Promise<RmhRecommendDTO[]> {
return new Promise<RmhRecommendDTO[]>((success, error) => {
Logger.debug(TAG, `getMorningEveningCompInfo pageInfo start`);
PeopleShipMainViewModel.fetchPeopleRemRecommendData()
.then((resDTO: ResponseDTO<RmhRecommendDTO[]>) => {
if (!resDTO || !resDTO.data) {
Logger.error(TAG, 'getPeopleRemRecommendInfo then navResDTO is empty');
error('resDTO is empty');
return
}
if (resDTO.code != 0) {
Logger.error(TAG, `getPeopleRemRecommendInfo then code:${resDTO.code}, message:${resDTO.message}`);
error('resDTO Response Code is failure');
return
}
Logger.debug(TAG, "getPeopleRemRecommendInfo then,navResDTO.timestamp:" + resDTO.timestamp);
success(resDTO.data);
})
.catch((err: Error) => {
Logger.error(TAG, `getPeopleRemRecommendInfo catch, error.name : ${err.name}, error.message:${err.message}`);
error(err);
})
})
}
/*关注号主发布内容接口*/
static fetchAttentionContentListData(pageNum: number, pageSize: number, time: string) {
let url = HttpUrlUtils.getAttentionContentListUrl()
let params: Record<string, Object> = {};
params['pageNum'] = pageNum
params['pageSize'] = pageSize
params['time'] = time
return WDHttp.post<ResponseDTO<PeopleShipContentListDTO>>(url, params)
}
static async getAttentionContentListInfo(pageNum:number, pageSize: number, time: string): Promise<PeopleShipContentListDTO> {
return new Promise<PeopleShipContentListDTO>((success, error) => {
Logger.debug(TAG, `getAttentionContentListInfo pageInfo start`);
PeopleShipMainViewModel.fetchAttentionContentListData(pageNum, pageSize, time)
.then((resDTO: ResponseDTO<PeopleShipContentListDTO>) => {
if (!resDTO || !resDTO.data) {
Logger.error(TAG, 'getAttentionContentListInfo then navResDTO is empty');
error('resDTO is empty');
return
}
if (resDTO.code != 0) {
Logger.error(TAG, `getAttentionContentListInfo then code:${resDTO.code}, message:${resDTO.message}`);
error('resDTO Response Code is failure');
return
}
Logger.debug(TAG, "getAttentionContentListInfo then,navResDTO.timestamp:" + resDTO.timestamp);
success(resDTO.data);
})
.catch((err: Error) => {
Logger.error(TAG, `getAttentionContentListInfo catch, error.name : ${err.name}, error.message:${err.message}`);
error(err);
})
})
}
/*一键关注接口*/
static fetchAttentionBatchData(params: AttentionBatchDTO) {
let url = HttpUrlUtils.getAttentionBatchUrl()
return WDHttp.post<ResponseDTO>(url, params)
}
static async getAttentionBatchInfo(params: AttentionBatchDTO): Promise<ResponseDTO> {
return new Promise<ResponseDTO>((success, error) => {
Logger.debug(TAG, `getAttentionBatchInfo pageInfo start`);
PeopleShipMainViewModel.fetchAttentionBatchData(params)
.then((resDTO: ResponseDTO) => {
if (!resDTO || resDTO.code != 0) {
error(resDTO.message)
return
}
Logger.debug(TAG, "getAttentionBatchInfo then,navResDTO.timestamp:" + resDTO.timestamp);
success(resDTO);
})
.catch((err: Error) => {
Logger.error(TAG, `getAttentionBatchInfo catch, error.name : ${err.name}, error.message:${err.message}`);
error(err);
})
})
}
}
\ No newline at end of file
... ...
... ... @@ -57,6 +57,10 @@
"value": "-4vp"
},
{
"name": "margin_6_negative",
"value": "-6vp"
},
{
"name": "main_margin",
"value": "14vp"
},
... ... @@ -271,6 +275,14 @@
{
"name": "vp_14",
"value": "14vp"
},
{
"name": "vp_18",
"value": "18vp"
},
{
"name": "vp_13",
"value": "13vp"
}
]
}
... ...
import { Logger, ResourcesUtils } from 'wdKit';
import { Logger, ResourcesUtils, EmitterUtils, EmitterEventId } from 'wdKit';
import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork';
import { ContentDetailDTO, InteractDataDTO } from 'wdBean';
import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest';
... ... @@ -321,8 +321,32 @@ export class ContentDetailRequest {
/**
* 关注号主
*/
static postInteractAccentionOperate(params: postInteractAccentionOperateParams): Promise<ResponseDTO> {
private static postInteractAccentionOperateInfo(params: postInteractAccentionOperateParams): Promise<ResponseDTO> {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_ACCENTION_OPERATION
return WDHttp.post(url, params)
}
/**
* 关注号主
*/
static postInteractAccentionOperate(params: postInteractAccentionOperateParams): Promise<ResponseDTO> {
return new Promise<ResponseDTO>((success, error) => {
Logger.debug(TAG, `postInteractAccentionOperate pageInfo start`);
ContentDetailRequest.postInteractAccentionOperateInfo(params)
.then((resDTO: ResponseDTO) => {
if (!resDTO || resDTO.code != 0) {
error(null)
return
}
Logger.debug(TAG, "postInteractAccentionOperate then,navResDTO.timestamp:" + resDTO.timestamp);
// 关注号后发送-更新关注页面
EmitterUtils.sendEvent(EmitterEventId.PEOPLE_SHIP_ATTENTION)
success(resDTO);
})
.catch((err: Error) => {
Logger.error(TAG, `postInteractAccentionOperate catch, error.name : ${err.name}, error.message:${err.message}`);
error(err);
})
})
}
}
\ No newline at end of file
... ...
... ... @@ -9,8 +9,6 @@ import { ResponseDTO } from 'wdNetwork/Index';
* 系统定位服务实现
* */
export class HWLocationUtils {
static LOCATION: Permissions = 'ohos.permission.LOCATION'
static APPROXIMATELY_LOCATION: Permissions = 'ohos.permission.APPROXIMATELY_LOCATION'
... ... @@ -115,17 +113,23 @@ export class HWLocationUtils {
if (cityName == name) {
return
}
let code = await HWLocationUtils.getCityCode(data[0].administrativeArea, data[0].subAdministrativeArea)
if (code) {
// code=[省份code,城市code]
let code: string[] = await HWLocationUtils.getCityCode(data[0].administrativeArea, data[0].subAdministrativeArea)
if (code && code.length >= 2) {
SPHelper.default.save(SpConstants.LOCATION_CITY_NAME, cityName)
SPHelper.default.save(SpConstants.LOCATION_CITY_CODE, code)
SPHelper.default.save(SpConstants.LOCATION_PROVINCE_CODE, code[0])
SPHelper.default.save(SpConstants.LOCATION_CITY_CODE, code[1])
}
if (data[0].descriptions && data[0].descriptions.length > 1) {
// 保存区县code,9位数字
let districtCode = data[0].descriptions[1] || ''
SPHelper.default.save(SpConstants.LOCATION_DISTRICT_CODE, districtCode)
}
}
}
})
}
//取消定位
static cancelLocation() {
// geoLocationManager.off('locationChange')
... ... @@ -143,10 +147,14 @@ export class HWLocationUtils {
if (bean.code == 0 && bean.data) {
for (let i = 0; i < bean.data.length; i++) {
if (bean.data[i].label == administrativeArea) {
let str:string[] = []
let provinceCode = bean.data[i].code
str[0] = provinceCode
for (let j = 0; j < bean.data[i].children.length; j++) {
if (bean.data[i].children[j].label == cityName) {
Logger.debug("huaw" + bean.data[i].children[j].code)
return bean.data[i].children[j].code
str[1] = bean.data[i].children[j].code
return str
}
}
}
... ... @@ -155,7 +163,7 @@ export class HWLocationUtils {
}
}
return ''
return []
}
// 通过省份code获取省份名称
... ...
... ... @@ -37,7 +37,7 @@ export struct LoginInputComponent {
.type(InputType.PhoneNumber)
.onChange((content) => {
this.phoneContent = content
this.isSubmit = (this.phoneContent.length >= 11 && this.codeContent.length >= 6)
this.isSubmit = (this.phoneContent.length >= 11 && this.codeContent.length >= 4)
if (content.length >= 11) {
this.codeBtnState = true
} else {
... ... @@ -55,7 +55,7 @@ export struct LoginInputComponent {
.type(InputType.Number)
.onChange((content) => {
this.phoneContent = content
this.isSubmit = (this.phoneContent.length >= 11 && this.codeContent.length >= 6)
this.isSubmit = (this.phoneContent.length >= 11 && this.codeContent.length >= 4)
if (content.length >= 11) {
this.codeBtnState = true
} else {
... ... @@ -78,7 +78,7 @@ export struct LoginInputComponent {
// .backgroundImageSize(ImageSize.Contain)
.onChange((value) => {
this.codeContent = value
this.isSubmit = (this.phoneContent.length >= 11 && this.codeContent.length >= 6)
this.isSubmit = (this.phoneContent.length >= 11 && this.codeContent.length >= 4)
})
Text(this.isCodeSend ? this.timeCount + "s" : this.isFirst?"发送验证码":'重新发送')
... ...
... ... @@ -13,9 +13,9 @@ export class LoginModel {
sendVerifyCode(number: string) {
let bean: Record<string, string> = {};
bean['phoneNum'] = number
return new Promise<string>((success, fail) => {
HttpRequest.post<ResponseDTO<string>>(HttpUrlUtils.getVerifyCodeUrl(), bean).then((data: ResponseDTO<string>) => {
if (!data || !data.data) {
return new Promise<object>((success, fail) => {
HttpRequest.post<ResponseDTO<object>>(HttpUrlUtils.getVerifyCodeUrl(), bean).then((data: ResponseDTO<object>) => {
if (!data) {
fail("数据为空")
return
}
... ... @@ -23,7 +23,7 @@ export class LoginModel {
fail(data.message)
return
}
success(data.data)
success(data)
}, (error: Error) => {
fail(error.message)
Logger.debug("LoginViewModel:error ", error.toString())
... ... @@ -84,7 +84,11 @@ export class LoginModel {
// {"password":"523acd319228efde34e8a30268ee8ca5e4fc421d72affa531676e1765940d22c","phone":"13625644528","loginType":0,"oldPassword":"BA5FD74F827AF9B271FE17CADC489C36","deviceId":"60da5af6-9c59-3566-8622-8c6c00710994"}
appLoginByPassword(phone: string, loginType: number, password: string, oldPassword: string) {
let bean: Record<string, string | number> = {};
bean['phone'] = phone
if (loginType == 0) {
bean['phone'] = phone
} else {
bean['userName'] = phone
}
bean['loginType'] = loginType
bean['deviceId'] = '60da5af6-9c59-3566-8622-8c6c00710994'
bean['password'] = password
... ...
import { Logger } from 'wdKit/src/main/ets/utils/Logger'
import { Logger, EmitterEventId, EmitterUtils } from 'wdKit'
import { CustomProtocolDialog } from './CustomProtocolDialog'
import router from '@ohos.router'
import { LoginViewModel } from './LoginViewModel'
... ... @@ -196,7 +196,6 @@ struct LoginPage {
Column() {
TextInput({ placeholder: "请输入账号", controller: this.phoneController })
.fontSize(16)
.maxLength(11)
.height(48)
.backgroundColor("#F5F5F5")
.borderRadius(4)
... ... @@ -325,6 +324,7 @@ struct LoginPage {
let interestsModel = new InterestsHobbiesModel()
interestsModel.updateInterests()
this.queryUserDetail()
EmitterUtils.sendEvent(EmitterEventId.PEOPLE_SHIP_ATTENTION)
}).catch((error:string)=>{
promptAction.showToast({ message: error })
})
... ... @@ -332,11 +332,12 @@ struct LoginPage {
this.loginViewModel.appLoginByPassword(this.accountContent, 0, this.passwordContent, "").then((data) => {
Logger.debug(TAG, "requestLogin: " + data.jwtToken)
promptAction.showToast({ message: '登录成功' })
///同步兴趣tag
let interestsModel = new InterestsHobbiesModel()
interestsModel.updateInterests()
this.queryUserDetail()
EmitterUtils.sendEvent(EmitterEventId.PEOPLE_SHIP_ATTENTION)
// router.back({
// params: { userName: data.userName,
// userId:data.id},
... ...
import { Logger } from 'wdKit/src/main/ets/utils/Logger'
import { LoginModel } from './LoginModel'
import { LoginBean } from './LoginBean'
import { SPHelper } from 'wdKit'
import { SPHelper, StringUtils } from 'wdKit'
import { CheckVerifyBean } from './CheckVerifyBean'
import cryptoFramework from '@ohos.security.cryptoFramework'
import buffer from '@ohos.buffer'
... ... @@ -22,7 +22,7 @@ export class LoginViewModel {
//发送验证码
sendVerifyCode(number: string) {
return new Promise<string>((success, fail) => {
return new Promise<object>((success, fail) => {
this.loginModel.sendVerifyCode(number).then((data) => {
success(data)
}).catch((message: string) => {
... ... @@ -55,9 +55,6 @@ export class LoginViewModel {
SPHelper.default.saveSync(SpConstants.USER_STATUS, data.status)
SPHelper.default.saveSync(SpConstants.USER_Type, data.userType)
SPHelper.default.saveSync(SpConstants.USER_NAME, data.userName)
HttpUtils.setUserId(data.id+"")
HttpUtils.setUserType(data.userType+"")
HttpUtils.setUserToken(data.jwtToken)
success(data)
}).catch((error:string) => {
fail(error)
... ... @@ -66,11 +63,17 @@ export class LoginViewModel {
}
async appLoginByPassword(phone: string, loginType: number, password: string, oldPassword: string) {
let newLoginType: number
let isPhone = this.verifyIsPhoneNumber(phone)
if (isPhone) {
newLoginType = 0;
} else {
newLoginType = 8;
}
return new Promise<LoginBean>(async (success, fail) => {
let passwordNew = await this.doMd(password)
Logger.debug(TAG, "PASSWORD:" + passwordNew)
this.loginModel.appLoginByPassword(phone, loginType, passwordNew, oldPassword).then((data: LoginBean) => {
this.loginModel.appLoginByPassword(phone, newLoginType, passwordNew, oldPassword).then((data: LoginBean) => {
SPHelper.default.saveSync(SpConstants.USER_FIRST_MARK, data.firstMark)
SPHelper.default.saveSync(SpConstants.USER_ID, data.id)
SPHelper.default.saveSync(SpConstants.USER_JWT_TOKEN, data.jwtToken)
... ... @@ -79,9 +82,6 @@ export class LoginViewModel {
SPHelper.default.saveSync(SpConstants.USER_STATUS, data.status)
SPHelper.default.saveSync(SpConstants.USER_Type, data.userType)
SPHelper.default.saveSync(SpConstants.USER_NAME, data.userName)
HttpUtils.setUserId(data.id+"")
HttpUtils.setUserType(data.userType+"")
HttpUtils.setUserToken(data.jwtToken)
success(data)
}).catch((value: string) => {
fail(value)
... ... @@ -157,9 +157,6 @@ export class LoginViewModel {
SPHelper.default.saveSync(SpConstants.USER_STATUS, '')
SPHelper.default.saveSync(SpConstants.USER_Type, '')
SPHelper.default.saveSync(SpConstants.USER_NAME, '')
HttpUtils.setUserId("")
HttpUtils.setUserType("")
HttpUtils.setUserToken('')
success(data)
}).catch((message: string) => {
fail(message)
... ... @@ -234,4 +231,18 @@ export class LoginViewModel {
})
})
}
public verifyIsPhoneNumber(phone: string): boolean {
const regex = /^1[3-9]\d{9}$/;
let isMatch: boolean;
if (StringUtils.isEmpty(phone)) {
return false;
} else if (phone.length != 11) {
return false;
} else {
isMatch = regex.test(phone)
}
return isMatch;
}
}
\ No newline at end of file
... ...