wangyujian_wd

Merge remote-tracking branch 'origin/main'

Showing 91 changed files with 1614 additions and 496 deletions
... ... @@ -244,6 +244,30 @@
]
}
]
},
{
"name": "wdShareBase",
"srcPath": "./commons/wdShareBase",
"targets": [
{
"name": "default",
"applyToProducts": [
"default"
]
}
]
},
{
"name": "wdShare",
"srcPath": "./features/wdShare",
"targets": [
{
"name": "default",
"applyToProducts": [
"default"
]
}
]
}
]
}
\ No newline at end of file
... ...
... ... @@ -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
... ...
... ... @@ -7,7 +7,7 @@ export class CallBackMessage {
callbackId: string = ""; //callbackId
responseId: string = ""; //responseId
responseData: string = ""; //responseData
data?: string; //data of message
data?: object; //data of message
handlerName: string = ""; //name of handler
/**
... ...
... ... @@ -128,11 +128,11 @@ export class BridgeWebViewControl extends webview.WebviewController {
* native 主动调用JSBridge方法
* @param msg
*/
callHandle(handlerName: string, data: string, callBack: Callback) {
callHandle(handlerName: string, data: object, callBack: Callback) {
this.doSend(handlerName, data, callBack)
}
private doSend(handlerName: string, data: string, callBack: Callback) {
private doSend(handlerName: string, data: object, callBack: Callback) {
let msg: CallBackMessage = new CallBackMessage()
if (StringUtils.isNotEmpty(data)) {
msg.data = data
... ...
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;
}
... ...
... ... @@ -46,10 +46,6 @@ export class HttpUrlUtils {
*/
static readonly INTERACT_EXECUTELIKE: string = "/api/rmrb-interact/interact/zh/c/like/executeLike";
/**
* 收藏、取消收藏
*/
static readonly INTERACT_EXECUTECOLLECTRECORD: string = "/api/rmrb-interact/interact/zh/c/collect/executeCollcetRecord";
/**
* 关注号主
*/
static readonly INTERACT_ACCENTION_OPERATION: string = "/api/rmrb-interact/interact/zh/c/attention/operation";
... ... @@ -651,7 +647,7 @@ export class HttpUrlUtils {
//获取点赞数
static getLikeCount() {
let url = HttpUrlUtils.getHost() + "/api/rmrb-contact/contact/zh/c/v2/content/interactData";
let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_V2_DATA_PATH;
return url;
}
... ...
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
... ...
/node_modules
/oh_modules
/.preview
/build
/.cxx
/.test
\ No newline at end of file
... ...
export { WDShareObject, WDShareBase } from "./src/main/ets/WDShareBase"
export { ShareContent, ShareScene, ShareType } from "./src/main/ets/Constant"
\ No newline at end of file
... ...
{
"apiType": "stageMode",
"buildOption": {
},
"buildOptionSet": [
{
"name": "release",
"arkOptions": {
"obfuscation": {
"ruleOptions": {
"enable": true,
"files": [
"./obfuscation-rules.txt"
]
}
}
},
},
],
"targets": [
{
"name": "default"
}
]
}
\ No newline at end of file
... ...
import { hspTasks } from '@ohos/hvigor-ohos-plugin';
export default {
system: hspTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
}
... ...
# Define project specific obfuscation rules here.
# You can include the obfuscation configuration files in the current module's build-profile.json5.
#
# For more details, see
# https://gitee.com/openharmony/arkcompiler_ets_frontend/blob/master/arkguard/README.md
# Obfuscation options:
# -disable-obfuscation: disable all obfuscations
# -enable-property-obfuscation: obfuscate the property names
# -enable-toplevel-obfuscation: obfuscate the names in the global scope
# -compact: remove unnecessary blank spaces and all line feeds
# -remove-log: remove all console.* statements
# -print-namecache: print the name cache that contains the mapping from the old names to new names
# -apply-namecache: reuse the given cache file
# Keep options:
# -keep-property-name: specifies property names that you want to keep
# -keep-global-name: specifies names that you want to keep in the global scope
\ No newline at end of file
... ...
{
"name": "wdsharebase",
"version": "1.0.0",
"description": "Please describe the basic information.",
"main": "Index.ets",
"author": "",
"license": "Apache-2.0",
"packageType": "InterfaceHar",
"dependencies": {
}
}
\ No newline at end of file
... ...
export const enum ShareType {
System = 0,
WeChat,
QQ,
Weibo,
}
export const enum ShareScene {
System = 0,
WeChatSession,
WeChatTimeline,
QQFriend,
QQZone,
Weibo,
}
export const enum ShareContentType {
PrueText = 1,
ImageAndText,
Link,
}
export interface ShareContentText {
text: string
}
export interface ShareContentImageAndText {
title: string
desc?: string
imgURI: string
}
export interface ShareContentLink {
title: string
desc?: string
link: string
icon?: string
}
export type ShareContent = ShareContentText | ShareContentImageAndText | ShareContentLink
... ...
import { ShareContent, ShareContentImageAndText, ShareContentLink, ShareContentText,
ShareContentType,
ShareScene } from '../Constant';
import { WDShareInterface } from '../WDShareInterface';
import { AsyncCallback } from '@kit.BasicServicesKit';
import { common } from '@kit.AbilityKit';
import { systemShare } from '@kit.ShareKit';
import { uniformTypeDescriptor as utd } from '@kit.ArkData';
export class WDSystemShare implements WDShareInterface {
shareContent(scene: ShareScene, content: ShareContent, contentType: ShareContentType): Promise<string> {
return new Promise((resolve, fail) => {
try {
let controller: systemShare.ShareController = new systemShare.ShareController(this.getShareData(content, contentType));
let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext
controller.on('dismiss', () => {
resolve("dismiss")
});
controller.show(context, {
previewMode: systemShare.SharePreviewMode.DEFAULT,
selectionMode: systemShare.SelectionMode.SINGLE
});
console.log("分享控制器调用完成")
} catch (e) {
fail(e)
}
})
}
getShareData(content: ShareContent, contentType: ShareContentType) : systemShare.SharedData {
if (contentType === ShareContentType.PrueText) {
let prueText = content as ShareContentText
console.log("分享纯文本")
return new systemShare.SharedData({
utd: utd.UniformDataType.PLAIN_TEXT,
content: prueText.text
});
}
if (contentType === ShareContentType.ImageAndText) {
let imageAndText = content as ShareContentImageAndText
console.log("分享图片和文本")
let data: systemShare.SharedData = new systemShare.SharedData({
utd: utd.UniformDataType.PLAIN_TEXT,
content: imageAndText.title
});
data.addRecord({
utd: utd.UniformDataType.PNG,
uri: imageAndText.imgURI
});
return data
}
console.log("分享链接和文本")
let link = content as ShareContentLink
let data: systemShare.SharedData = new systemShare.SharedData({
utd: utd.UniformDataType.PLAIN_TEXT,
content: link.title
});
data.addRecord({
utd: utd.UniformDataType.HYPERLINK,
uri: link.link
});
return data
}
}
\ No newline at end of file
... ...
import { ShareContent, ShareContentType, ShareScene, ShareType } from './Constant'
import { HashMap } from '@kit.ArkTS'
import { WDShareInterface } from './WDShareInterface'
import { WDSystemShare } from './System/WDSystemShare'
export interface WDShareObject {
to: ShareType,
scene: ShareScene,
type: ShareContentType,
obj: ShareContent
}
export class WDShareBase {
private static instance?: WDShareBase
static getInstance() : WDShareBase {
if (!WDShareBase.instance) {
WDShareBase.instance = new WDShareBase()
WDShareBase.instance.register()
}
return WDShareBase.instance
}
private handles: HashMap<ShareType, WDShareInterface> = new HashMap()
register() {
this.handles.set(ShareType.System, new WDSystemShare())
}
share(obj: WDShareObject) : null | Promise<string> {
let shareHandler: WDShareInterface = this.handles.get(obj.to)
if (shareHandler) {
return shareHandler.shareContent(obj.scene, obj.obj, obj.type)
}
return null
}
}
\ No newline at end of file
... ...
import { ShareContent, ShareContentType, ShareScene } from './Constant'
import { AsyncCallback } from '@kit.BasicServicesKit'
export interface WDShareInterface {
// shareContent(scene:ShareScene, content: ShareContent, callback: AsyncCallback<void>): void
shareContent(scene:ShareScene, content: ShareContent, contentType: ShareContentType): Promise<string>
}
\ No newline at end of file
... ...
@Entry
@Component
struct IndexPage {
@State message: string = 'Hello World';
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
... ...
{
"module": {
"name": "wdShareBase",
"type": "shared",
"description": "$string:shared_desc",
"deviceTypes": [
"phone",
"tablet",
"2in1"
],
"deliveryWithInstall": true,
"pages": "$profile:main_pages"
}
}
\ No newline at end of file
... ...
{
"color": [
{
"name": "white",
"value": "#FFFFFF"
}
]
}
\ No newline at end of file
... ...
{
"string": [
{
"name": "shared_desc",
"value": "description"
}
]
}
\ No newline at end of file
... ...
{
"src": [
"pages/IndexPage"
]
}
\ No newline at end of file
... ...
import localUnitTest from './LocalUnit.test';
export default function testsuite() {
localUnitTest();
}
\ No newline at end of file
... ...
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
export default function localUnitTest() {
describe('localUnitTest',() => {
// Defines a test suite. Two parameters are supported: test suite name and test suite function.
beforeAll(() => {
// Presets an action, which is performed only once before all test cases of the test suite start.
// This API supports only one parameter: preset action function.
});
beforeEach(() => {
// Presets an action, which is performed before each unit test case starts.
// The number of execution times is the same as the number of test cases defined by **it**.
// This API supports only one parameter: preset action function.
});
afterEach(() => {
// Presets a clear action, which is performed after each unit test case ends.
// The number of execution times is the same as the number of test cases defined by **it**.
// This API supports only one parameter: clear action function.
});
afterAll(() => {
// Presets a clear action, which is performed after all test cases of the test suite end.
// This API supports only one parameter: clear action function.
});
it('assertContain', 0, () => {
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
let a = 'abc';
let b = 'b';
// Defines a variety of assertion methods, which are used to declare expected boolean conditions.
expect(a).assertContain(b);
expect(a).assertEqual(a);
});
});
}
\ No newline at end of file
... ...
This file is too large to display.
/**
* @Description: 广告扩展信息的解析模型
* @Author:
* @Email: liyubing@wondertek.com.cn
* @CreateDate:
* @UpdateRemark: 更新说明
* @Version: 1.0
*/
export interface AdvExtraData {
itemTopImage: string;
itemMore: AdvExtraItemData;
item: AdvExtraItemData[]
}
export interface AdvExtraItemData {
/**
* 图片地址
*/
image: string;
/**
* 标题
*/
title: string ;
/**
* 跳转地址
*/
linkUrl: string;
/**
* 跳转类型
*/
linkType: string;
}
\ No newline at end of file
... ...
... ... @@ -2,11 +2,11 @@
* 批查接口查询互动相关数据,返回数据bean
*/
export interface InteractDataDTO {
collectNum: number | String;
commentNum: number | String;
collectNum: number | string;
commentNum: number | string;
contentId: string;
contentType: number;
likeNum: number | String;
likeNum: number | string;
readNum: number;
shareNum: number;
}
\ No newline at end of file
... ...
... ... @@ -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 })
}
// }
... ...
... ... @@ -25,6 +25,9 @@ import { BusinessError } from '@ohos.base';
import { CommonConstants, SpConstants } from 'wdConstant/Index';
import { CardMediaInfo } from '../components/cardCommon/CardMediaInfo'
import router from '@ohos.router';
import { publishCommentModel } from './comment/model/PublishCommentModel';
import { CommentComponent } from './comment/view/CommentComponent';
const TAG = 'DynamicDetailComponent'
@Preview
@Component
... ... @@ -50,6 +53,8 @@ export struct DynamicDetailComponent {
//跳转
private mJumpInfo: ContentDTO = {} as ContentDTO;
@State publishCommentModel: publishCommentModel = new publishCommentModel()
async aboutToAppear() {
await this.getContentDetailData()
}
... ... @@ -355,8 +360,14 @@ export struct DynamicDetailComponent {
//点赞操作
this.toggleLikeStatus()
})
// 评论
if (this.contentDetailData?.openComment) {
Divider().strokeWidth(6).color('#f5f5f5')
CommentComponent({
publishCommentModel: this.publishCommentModel
})
}
Blank().layoutWeight(1)
//fixme 评论组件
}
}
.width(CommonConstants.FULL_WIDTH)
... ... @@ -365,42 +376,11 @@ export struct DynamicDetailComponent {
.scrollBar(BarState.Off)
.alignSelf(ItemAlign.Start)
//底部交互区
Row() {
Image($r('app.media.icon_arrow_left'))
.width(24)
.height(24)
.onClick((event: ClickEvent) => {
router.back()
})
Row() {
Image($r('app.media.icon_comment'))
.width(24)
.height(24)
.margin({ right: 24 })
.id('comment')
Image($r('app.media.icon_star'))
.width(24)
.height(24)
.margin({ right: 24 })
Image($r('app.media.icon_listen'))
.width(24)
.height(24)
.margin({ right: 24 })
Image($r('app.media.icon_forward'))
.width(24)
.height(24)
}
}
.width(CommonConstants.FULL_WIDTH)
.height(56)
.padding({ left: 15, right: 15, bottom: 50, top: 20 })
.justifyContent(FlexAlign.SpaceBetween)
.backgroundColor(Color.White)
OperRowListView({ contentDetailData: this.contentDetailData
,interactData:this.interactDataDTO
,newsStatusOfUser:this.newsStatusOfUser
,publishCommentModel: this.publishCommentModel
,needLike:false})
}
}
.alignSelf(ItemAlign.Start)
... ... @@ -419,6 +399,17 @@ export struct DynamicDetailComponent {
} catch (exception) {
console.log('请求失败',JSON.stringify(exception))
}
if (this.contentDetailData.openComment) {
this.publishCommentModel = {
targetId: String(this.contentDetailData?.newsId || ''),
targetRelId: this.contentDetailData?.reLInfo?.relId,
targetTitle: this.contentDetailData?.newsTitle,
targetRelType: this.contentDetailData?.reLInfo?.relType,
targetRelObjectId: String(this.contentDetailData?.reLInfo?.relObjectId),
keyArticle: String(this.contentDetailData?.keyArticle),
targetType: String(this.contentDetailData?.newsType),
} as publishCommentModel
}
this.getBatchAttentionStatus()
this.getInteractDataStatus()
this.makeJumpInfo()
... ...
... ... @@ -38,7 +38,8 @@ export struct ImageAndTextPageComponent {
@State interactData: InteractDataDTO = {} as InteractDataDTO
@State isPageEnd: boolean = false
@State publishTime: string = ''
@State publishCommentModel: publishCommentModel = {} as publishCommentModel
@State publishCommentModel: publishCommentModel = new publishCommentModel()
@State operationButtonList: string[] = ['comment', 'collect', 'share']
build() {
Column() {
... ... @@ -142,7 +143,11 @@ export struct ImageAndTextPageComponent {
//底部交互区
if (this.contentDetailData?.length) {
OperRowListView({ contentDetailData: this.contentDetailData[0] })
OperRowListView({
contentDetailData: this.contentDetailData[0],
publishCommentModel: this.publishCommentModel,
operationButtonList: this.operationButtonList,
})
}
}
... ... @@ -181,15 +186,16 @@ export struct ImageAndTextPageComponent {
this.queryContentInteractCount()
}
if (this.contentDetailData[0]?.openComment) {
this.publishCommentModel = {
targetId: String(this.contentDetailData[0]?.newsId || ''),
targetRelId: this.contentDetailData[0]?.reLInfo?.relId,
targetTitle: this.contentDetailData[0]?.newsTitle,
targetRelType: this.contentDetailData[0]?.reLInfo?.relType,
targetRelObjectId: String(this.contentDetailData[0]?.reLInfo?.relObjectId),
keyArticle: String(this.contentDetailData[0]?.keyArticle),
targetType: String(this.contentDetailData[0]?.newsType),
} as publishCommentModel
this.publishCommentModel.targetId = String(this.contentDetailData[0]?.newsId || '')
this.publishCommentModel.targetRelId = String(this.contentDetailData[0]?.reLInfo?.relId)
this.publishCommentModel.targetTitle = this.contentDetailData[0]?.newsTitle
this.publishCommentModel.targetRelType = String(this.contentDetailData[0]?.reLInfo?.relType)
this.publishCommentModel.targetRelObjectId = String(this.contentDetailData[0]?.reLInfo?.relObjectId)
this.publishCommentModel.keyArticle = String(this.contentDetailData[0]?.keyArticle)
this.publishCommentModel.targetType = String(this.contentDetailData[0]?.newsType)
}
if (this.contentDetailData[0]?.audioList?.length && this.contentDetailData[0]?.audioList[0].audioUrl) {
this.operationButtonList = ['comment', 'collect', 'listen', 'share']
}
}
}
... ... @@ -197,11 +203,10 @@ export struct ImageAndTextPageComponent {
private async getRecommend() {
let params: postRecommendListParams = {
// TODO ? imei: HttpUtils.getImei()
imei: "8272c108-4fa2-34ce-80b9-bc425a7c2a7e",
imei: HttpUtils.getImei(),
userId: HttpUtils.getUserId(),
contentId: String(this.contentDetailData[0]?.newsId),
recType: 1,
recType: Number(this.contentDetailData[0]?.reLInfo?.relType),
contentType: this.contentDetailData[0]?.newsType,
relId: this.contentDetailData[0]?.reLInfo?.relId,
channelId: String(this.contentDetailData[0]?.reLInfo?.channelId)
... ...
... ... @@ -119,7 +119,7 @@ export struct ImageAndTextWebComponent {
private sendContentData2H5(h5ReceiveAppData: H5ReceiveDetailBean) {
Logger.debug('ImageAndTextWebComponent', 'jsCall_receiveAppData');
this.webviewControl.callHandle(NativeCallH5Type.jsCall_receiveAppData,
JSON.stringify(h5ReceiveAppData), (data: string) => {
h5ReceiveAppData, (data: string) => {
Logger.debug('ImageAndTextWebComponent', "from js data = " + data);
})
}
... ...
... ... @@ -152,6 +152,8 @@ export struct MorningEveningPaperComponent {
if (imageSource) {
this.pickColor(imageSource)
} else {
this.mixedBgColor = this.pageInfoBean.backgroundColor
}
}
... ...
... ... @@ -7,6 +7,7 @@ import { detailedSkeleton } from './skeleton/detailSkeleton'
import { NativeCallH5Type } from 'wdWebComponent/src/main/ets/pages/NativeCallH5Type';
import { OperRowListView } from './view/OperRowListView';
import DetailViewModel from '../viewmodel/DetailViewModel';
import { publishCommentModel } from '../components/comment/model/PublishCommentModel';
const TAG: string = 'SpacialTopicPageComponent'
... ... @@ -21,6 +22,7 @@ export struct SpacialTopicPageComponent {
private h5ReceiveAppData: H5ReceiveDetailBean = { dataSource: '2' } as H5ReceiveDetailBean
private webPrepared = false;
private dataPrepared = false;
@State publishCommentModel: publishCommentModel = new publishCommentModel()
private trySendData2H5() {
if (!this.webPrepared || !this.dataPrepared) {
... ... @@ -37,7 +39,7 @@ export struct SpacialTopicPageComponent {
private sendContentData2H5(h5ReceiveAppData: H5ReceiveDetailBean) {
this.webviewControl.callHandle(NativeCallH5Type.jsCall_receiveAppData,
JSON.stringify(h5ReceiveAppData), (data: string) => {
h5ReceiveAppData, (data: string) => {
})
}
... ... @@ -61,6 +63,15 @@ export struct SpacialTopicPageComponent {
let detailBeans = await DetailViewModel.getDetailPageData(relId, contentId, relType)
if (detailBeans && detailBeans.length > 0) {
this.contentDetailData = detailBeans;
if (this.contentDetailData[0]?.openComment) {
this.publishCommentModel.targetId = String(this.contentDetailData[0]?.newsId || '')
this.publishCommentModel.targetRelId = String(this.contentDetailData[0]?.reLInfo?.relId)
this.publishCommentModel.targetTitle = this.contentDetailData[0]?.newsTitle
this.publishCommentModel.targetRelType = String(this.contentDetailData[0]?.reLInfo?.relType)
this.publishCommentModel.targetRelObjectId = String(this.contentDetailData[0]?.reLInfo?.relObjectId)
this.publishCommentModel.keyArticle = String(this.contentDetailData[0]?.keyArticle)
this.publishCommentModel.targetType = String(this.contentDetailData[0]?.newsType)
}
this.trySendData2H5()
}
}
... ... @@ -80,13 +91,16 @@ export struct SpacialTopicPageComponent {
}
.width(CommonConstants.FULL_WIDTH)
.height(CommonConstants.FULL_HEIGHT)
.padding({ bottom: 126 })
// .padding({ bottom: 76 })
if (!this.isPageEnd) {
detailedSkeleton()
}
//底部交互区
OperRowListView({ contentDetailData: this.contentDetailData[0] })
OperRowListView({
contentDetailData: this.contentDetailData[0],
publishCommentModel: this.publishCommentModel
})
}
}.width(CommonConstants.FULL_WIDTH).height(CommonConstants.FULL_HEIGHT)
}
... ...
... ... @@ -3,10 +3,12 @@
*/
import { RmhInfoDTO } from 'wdBean'
import { CommonConstants } from 'wdConstant/Index';
import { DateTimeUtils } from 'wdKit';
@Component
export struct RmhTitle {
@Prop rmhInfo: RmhInfoDTO
@Prop publishTime: string | undefined
build() {
Flex() {
... ... @@ -29,12 +31,22 @@ export struct RmhTitle {
.fontColor($r('app.color.color_222222'))
.fontWeight(600)
.alignSelf(ItemAlign.Start)
Text(this.rmhInfo.rmhDesc)
.fontSize($r("app.float.font_size_12"))
.fontColor($r("app.color.color_B0B0B0"))
.maxLines(1)
.alignSelf(ItemAlign.Start)
.textOverflow({ overflow: TextOverflow.Ellipsis })
Row() {
if (this.publishTime) {
Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.publishTime)))
.fontSize($r("app.float.font_size_12"))
.fontColor($r("app.color.color_B0B0B0"))
Image($r('app.media.point'))
.width(16)
.height(16)
}
Text(this.rmhInfo.rmhDesc)
.fontSize($r("app.float.font_size_12"))
.fontColor($r("app.color.color_B0B0B0"))
.maxLines(1)
.alignSelf(ItemAlign.Start)
.textOverflow({ overflow: TextOverflow.Ellipsis })
}
}
Blank()
... ...
//全标题 "appStyle":"2",
import { CompDTO, ContentDTO } from 'wdBean';
import { CompDTO } from 'wdBean';
import { CommonConstants } from 'wdConstant/Index';
import { ProcessUtils } from 'wdRouter';
import { CardMediaInfo } from '../cardCommon/CardMediaInfo'
import { CardSourceInfo } from '../cardCommon/CardSourceInfo'
import { CardAdvBottom } from './CardAdvBottom';
const TAG: string = 'Card2Component';
/**
* @Description: 广告---大图卡
* @Author:
* @Email: liyubing@wondertek.com.cn
* @CreateDate:
* @UpdateRemark: 更新说明
* @Version: 1.0
/**
* @Description: 广告---大图卡
* @Author:
* @Email: liyubing@wondertek.com.cn
* @CreateDate:
* @UpdateRemark: 更新说明
* @Version: 1.0
*/
@Component
export struct CardAdvBigImageComponent {
@State compDTO: CompDTO = {} as CompDTO
aboutToAppear(): void {
console.error('ZZZXXXXX', '----大图卡----aboutToAppear-----')
}
aboutToDisappear(): void {
... ... @@ -33,12 +33,21 @@ export struct CardAdvBigImageComponent {
build() {
Column() {
Text(this.compDTO.matInfo.advTitle)
.fontSize($r('app.float.font_size_17'))
.fontColor($r('app.color.color_222222'))
.maxLines(3)
.textOverflow({ overflow: TextOverflow.Ellipsis })// 超出的部分显示省略号。
.align(Alignment.Start)
//新闻标题
Text(this.compDTO.matInfo.advTitle).bottomTextStyle().margin({ bottom: 8, })
//大图
Image(this.compDTO.matInfo.matImageUrl[0])
.width(CommonConstants.FULL_WIDTH)
.aspectRatio(16 / 9)
.borderRadius(4)
.borderWidth(0.5)
.borderColor($r('app.color.color_0D000000'))
.width(CommonConstants.FULL_WIDTH)
CardAdvBottom().margin({
top: 8,
})
}
.width(CommonConstants.FULL_WIDTH)
.padding({
... ... @@ -48,13 +57,21 @@ export struct CardAdvBigImageComponent {
bottom: $r('app.float.card_comp_pagePadding_tb')
})
.onClick((event: ClickEvent) => {
//ProcessUtils.processPage(this.contentDTO)
ProcessUtils.openAdvDetail(this.compDTO.matInfo)
})
}
}
/*
标题样式
*/
@Extend(Text)
function bottomTextStyle() {
.fontSize(12)
.fontColor('#B0B0B0')
.fontSize('18fp')
.fontColor($r('app.color.color_222222'))
.maxLines(3)
.textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。
.align(Alignment.Start)
.width('100%')
.lineHeight(25)
}
\ No newline at end of file
... ...
//全标题 "appStyle":"2",
import { CompDTO, ContentDTO } from 'wdBean';
import { AdvExtraData, AdvExtraItemData } from 'wdBean/src/main/ets/bean/adv/AdvExtraData';
import { CompAdvMatInfoBean } from 'wdBean/src/main/ets/bean/adv/CompAdvInfoBean';
import { CommonConstants } from 'wdConstant/Index';
import { ProcessUtils } from 'wdRouter';
import { CardMediaInfo } from '../cardCommon/CardMediaInfo'
... ... @@ -7,22 +9,30 @@ import { CardSourceInfo } from '../cardCommon/CardSourceInfo'
const TAG: string = 'Card2Component';
/**
* @Description: 广告---冠名广告
* @Author:
* @Email: liyubing@wondertek.com.cn
* @CreateDate:
* @UpdateRemark: 更新说明
* @Version: 1.0
/**
* @Description: 广告---冠名广告
* @Author:
* @Email: liyubing@wondertek.com.cn
* @CreateDate:
* @UpdateRemark: 更新说明
* @Version: 1.0
*/
@Component
export struct CardAdvGanMiComponent {
@State compDTO: CompDTO = {} as CompDTO
@State advExtraData: AdvExtraData = {} as AdvExtraData
@State advLength: number = 0;
aboutToAppear(): void {
console.error('ZZZXXXXX', '--冠名广告------aboutToAppear-----')
let extraData = this.compDTO.matInfo.extraData
let labelDTO = JSON.parse(extraData) as AdvExtraData
this.advExtraData = labelDTO
//this.advExtraData.item = [this.advExtraData.item[0]]
// this.advExtraData.item[2].title ="我爱你中国我爱你中国我爱你中国我爱你中国我爱你中国我爱你中国我爱你中国我爱你中国我爱你中国我爱你中国我爱你中国我爱你中国我爱你中国我爱你中国我爱你中国"
this.advLength = this.advExtraData.item.length
}
aboutToDisappear(): void {
... ... @@ -33,28 +43,160 @@ export struct CardAdvGanMiComponent {
build() {
Column() {
Text(this.compDTO.matInfo.advTitle)
.fontSize($r('app.float.font_size_17'))
.fontColor($r('app.color.color_222222'))
.maxLines(3)
.textOverflow({ overflow: TextOverflow.Ellipsis })// 超出的部分显示省略号。
.align(Alignment.Start)
Row() {
Stack() {
//长图
Image(this.advExtraData.itemTopImage)
.width(CommonConstants.FULL_WIDTH)
.aspectRatio(343 / 40)
.borderRadius(4)
.borderWidth(0.5)
.borderColor($r('app.color.color_0D000000'))
// 广告标签和删除功能
Row() {
Text($r('app.string.comp_advertisement'))
.fontSize('10fp')
.fontColor($r('app.color.white'))
.width(28)
.height(16)
.backgroundColor('#4D000000')
.borderRadius(3)
.textAlign(TextAlign.Center)
Blank()
Stack() {
Image($r('app.media.comp_adv_close_white'))
.width(9)
.height(9)
.borderRadius({
topLeft: '4vp',
topRight: '4vp',
bottomLeft: '4vp',
bottomRight: '4vp'
})
}
.width(18)
.height(14)
.backgroundColor('#4D000000')
.borderWidth(0.5)
.borderColor($r('app.color.white'))
.borderRadius(3)
}.width('100%').padding({
top: 8,
left: 8,
right: 8
})
}
.alignContent(Alignment.Top)
.width(CommonConstants.FULL_WIDTH)
}.width('100%').padding({
left: $r('app.float.card_comp_pagePadding_lf'),
right: $r('app.float.card_comp_pagePadding_lf'),
})
//
List({ space: 8 }) {
ForEach(this.advExtraData.item, (content: AdvExtraItemData) => {
ListItem() {
// 广告列表信息
Column() {
Image(content.image)
.width('100%')
.aspectRatio(150 / 84)
.borderWidth(0.5)
.borderColor($r('app.color.color_0D000000'))
.borderRadius(4)
Text(content.title)
.fontSize('16fp')
.fontColor($r('app.color.color_222222'))
.fontSize('15fp')
.maxLines(3)
.lineHeight(20)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.width('100%')
.margin({ top: 8 })
}.width(this.advLength >= 3 ? 150 : this.advLength == 2 ? 210 : '100%').onClick(() => {
let matInfo: CompAdvMatInfoBean = {
linkUrl: content.linkUrl,
linkType: content.linkType
} as CompAdvMatInfoBean;
ProcessUtils.openAdvDetail(matInfo)
})
}
})
}
.width('100%')
.listDirection(Axis.Horizontal)
.edgeEffect(EdgeEffect.None)
.scrollBar(BarState.Off)
.contentStartOffset(this.advLength == 1 ? 0 : 16)
.contentEndOffset(this.advLength == 1 ? 0 : 16)
.margin({ top: 10, bottom: 10 })
.padding({
left: this.advLength == 1 ? 16 : 0,
right: this.advLength == 1 ? 16 : 0,
})
// 更多按钮
commonButton(this.advExtraData)
}
.width(CommonConstants.FULL_WIDTH)
.padding({
left: $r('app.float.card_comp_pagePadding_lf'),
right: $r('app.float.card_comp_pagePadding_lf'),
top: $r('app.float.card_comp_pagePadding_tb'),
bottom: $r('app.float.card_comp_pagePadding_tb')
})
.onClick((event: ClickEvent) => {
//ProcessUtils.processPage(this.contentDTO)
})
}
}
@Extend(Text)
function bottomTextStyle() {
.fontSize(12)
.fontColor('#B0B0B0')
/*
标题样式
*/
@Builder
function commonButton(advExtraData: AdvExtraData) {
Row() {
Row() {
Blank()
Text('查看更多').fontColor('#222222').fontSize('14fp')
Image($r('app.media.icon_comp_more_right_red')).width(16).height(16)
Blank()
}
.width('100%')
.backgroundColor('#F5F5F5')
.borderRadius(3)
.padding({ top: 10, bottom: 10, })
.onClick(() => {
let matInfo: CompAdvMatInfoBean = {
linkUrl: advExtraData.itemMore.linkUrl,
linkType: advExtraData.itemMore.linkType
} as CompAdvMatInfoBean;
ProcessUtils.openAdvDetail(matInfo)
})
}.width('100%').padding({
left: $r('app.float.card_comp_pagePadding_lf'),
right: $r('app.float.card_comp_pagePadding_lf'),
})
}
\ No newline at end of file
... ...
//全标题 "appStyle":"2",
import { CompDTO, ContentDTO } from 'wdBean';
import { CommonConstants } from 'wdConstant/Index';
import { CommonConstants, CompStyle } from 'wdConstant/Index';
import { ProcessUtils } from 'wdRouter';
import { CardMediaInfo } from '../cardCommon/CardMediaInfo'
import { CardSourceInfo } from '../cardCommon/CardSourceInfo'
import { CardAdvBottom } from './CardAdvBottom';
const TAG: string = 'Card2Component';
/**
* @Description: 广告---长通栏广告 和 顶部长通栏广告
* @Author:
* @Email: liyubing@wondertek.com.cn
* @CreateDate:
* @UpdateRemark: 更新说明
* @Version: 1.0
/**
* @Description: 广告---长通栏广告 和 顶部长通栏广告
* @Author:
* @Email: liyubing@wondertek.com.cn
* @CreateDate:
* @UpdateRemark: 更新说明
* @Version: 1.0
*/
@Component
export struct CardAdvLongImageComponent {
@State compDTO: CompDTO = {} as CompDTO
@State haveTitle : boolean = true
aboutToAppear(): void {
console.error('ZZZXXXXX', '--长通栏广告 和 顶部长通栏广告------aboutToAppear-----')
this.haveTitle = this.compDTO.matInfo.advSubType === CompStyle.Card_Adv_7;
}
aboutToDisappear(): void {
... ... @@ -33,12 +39,23 @@ export struct CardAdvLongImageComponent {
build() {
Column() {
Text(this.compDTO.matInfo.advTitle)
.fontSize($r('app.float.font_size_17'))
.fontColor($r('app.color.color_222222'))
.maxLines(3)
.textOverflow({ overflow: TextOverflow.Ellipsis })// 超出的部分显示省略号。
.align(Alignment.Start)
//新闻标题
if(this.haveTitle ){
Text(this.compDTO.matInfo.advTitle).bottomTextStyle().margin({ bottom: 8, })
}
//长图
Image(this.compDTO.matInfo.matImageUrl[0])
.width(CommonConstants.FULL_WIDTH)
.aspectRatio(343 / 96)
.borderRadius(4)
.borderWidth(0.5)
.borderColor($r('app.color.color_0D000000'))
CardAdvBottom().margin({
top: 8,
})
}
.width(CommonConstants.FULL_WIDTH)
.padding({
... ... @@ -48,13 +65,20 @@ export struct CardAdvLongImageComponent {
bottom: $r('app.float.card_comp_pagePadding_tb')
})
.onClick((event: ClickEvent) => {
//ProcessUtils.processPage(this.contentDTO)
ProcessUtils.openAdvDetail(this.compDTO.matInfo)
})
}
}
/*
标题样式
*/
@Extend(Text)
function bottomTextStyle() {
.fontSize(12)
.fontColor('#B0B0B0')
.fontSize('18fp')
.fontColor($r('app.color.color_222222'))
.maxLines(3)
.textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。
.align(Alignment.Start)
.lineHeight(25)
}
\ No newline at end of file
... ...
... ... @@ -62,6 +62,7 @@ export struct CardAdvSmallImageComponent {
.borderWidth(0.5)
.borderColor($r('app.color.color_0D000000'))
.borderRadius(4)
//.alt('wwww.baidu.com')
.alignRules({
top: { anchor: 'title_name', align: VerticalAlign.Top },
left: { anchor: 'title_name', align: HorizontalAlign.End },
... ...
//全标题 "appStyle":"2",
import { CompDTO, ContentDTO } from 'wdBean';
import { CompDTO, ContentDTO, VideoInfoDTO } from 'wdBean';
import { CommonConstants } from 'wdConstant/Index';
import { ProcessUtils } from 'wdRouter';
import { CardMediaInfo } from '../cardCommon/CardMediaInfo'
import { CardSourceInfo } from '../cardCommon/CardSourceInfo'
import { CardAdvBottom } from './CardAdvBottom';
const TAG: string = 'Card2Component';
/**
* @Description: 广告---视频广告
* @Author:
* @Email: liyubing@wondertek.com.cn
* @CreateDate:
* @UpdateRemark: 更新说明
* @Version: 1.0
/**
* @Description: 广告---视频广告
* @Author:
* @Email: liyubing@wondertek.com.cn
* @CreateDate:
* @UpdateRemark: 更新说明
* @Version: 1.0
*/
@Component
export struct CardAdvVideoComponent {
@State compDTO: CompDTO = {} as CompDTO
@State contentDTO: ContentDTO = {} as ContentDTO
aboutToAppear(): void {
console.error('ZZZXXXXX', '--视频广告------aboutToAppear-----')
// this.contentDTO.objectType = '1'
// this.contentDTO.videoInfo = { videoDuration: 1000 } as VideoInfoDTO
}
aboutToDisappear(): void {
... ... @@ -33,12 +37,29 @@ export struct CardAdvVideoComponent {
build() {
Column() {
Text(this.compDTO.matInfo.advTitle)
.fontSize($r('app.float.font_size_17'))
.fontColor($r('app.color.color_222222'))
.maxLines(3)
.textOverflow({ overflow: TextOverflow.Ellipsis })// 超出的部分显示省略号。
.align(Alignment.Start)
//新闻标题
Text(this.compDTO.matInfo.advTitle).bottomTextStyle()
//大图
Stack() {
Image(this.compDTO.matInfo.matImageUrl[0])
.width(CommonConstants.FULL_WIDTH)
.aspectRatio(16 / 9)
.borderRadius(4)
.borderWidth(0.5)
.borderColor($r('app.color.color_0D000000'))
//播放状态+时长
CardMediaInfo({
contentDTO: this.contentDTO
})
}
.alignContent(Alignment.BottomEnd)
.width(CommonConstants.FULL_WIDTH)
.margin({ top: 8 })
CardAdvBottom().margin({
top: 8,
})
}
.width(CommonConstants.FULL_WIDTH)
.padding({
... ... @@ -48,13 +69,21 @@ export struct CardAdvVideoComponent {
bottom: $r('app.float.card_comp_pagePadding_tb')
})
.onClick((event: ClickEvent) => {
//ProcessUtils.processPage(this.contentDTO)
ProcessUtils.openAdvDetail(this.compDTO.matInfo)
})
}
}
/*
标题样式
*/
@Extend(Text)
function bottomTextStyle() {
.fontSize(12)
.fontColor('#B0B0B0')
.fontSize('18fp')
.fontColor($r('app.color.color_222222'))
.maxLines(3)
.textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。
.align(Alignment.Start)
.width('100%')
.lineHeight(25)
}
\ No newline at end of file
... ...
//全标题 "appStyle":"2",
import { CompDTO, ContentDTO } from 'wdBean';
import { CompDTO } from 'wdBean';
import { AdvExtraData, AdvExtraItemData } from 'wdBean/src/main/ets/bean/adv/AdvExtraData';
import { CompAdvMatInfoBean } from 'wdBean/src/main/ets/bean/adv/CompAdvInfoBean';
import { CommonConstants } from 'wdConstant/Index';
import { ProcessUtils } from 'wdRouter';
import { CardMediaInfo } from '../cardCommon/CardMediaInfo'
import { CardSourceInfo } from '../cardCommon/CardSourceInfo'
const TAG: string = 'Card2Component';
/**
* @Description: 广告---冠名广告
* @Author:
* @Email: liyubing@wondertek.com.cn
* @CreateDate:
* @UpdateRemark: 更新说明
* @Version: 1.0
/**
* @Description: 广告---展会广告
* @Author:
* @Email: liyubing@wondertek.com.cn
* @CreateDate:
* @UpdateRemark: 更新说明
* @Version: 1.0
*/
@Component
export struct CardAdvVideoExComponent {
@State compDTO: CompDTO = {} as CompDTO
@State advExtraData: AdvExtraData = {} as AdvExtraData
aboutToAppear(): void {
console.error('ZZZXXXXX', '--冠名广告------aboutToAppear-----')
console.error('ZZZXXXXX', '--展会广告------aboutToAppear-----')
let extraData = this.compDTO.matInfo.extraData
let labelDTO = JSON.parse(extraData) as AdvExtraData
this.advExtraData = labelDTO
}
aboutToDisappear(): void {
console.error('ZZZXXXXX', '----冠名广告----aboutToDisappear-----')
console.error('ZZZXXXXX', '----展会广告----aboutToDisappear-----')
}
build() {
Column() {
Text(this.compDTO.matInfo.advTitle)
.fontSize($r('app.float.font_size_17'))
.fontColor($r('app.color.color_222222'))
.maxLines(3)
.textOverflow({ overflow: TextOverflow.Ellipsis })// 超出的部分显示省略号。
.align(Alignment.Start)
Stack() {
//长图
Image(this.advExtraData.itemTopImage)
.width(CommonConstants.FULL_WIDTH)
.aspectRatio(343 / 80)
.borderRadius(4)
.borderWidth(0.5)
.borderColor($r('app.color.color_0D000000'))
Row() {
Text($r('app.string.comp_advertisement'))
.fontSize('10fp')
.fontColor($r('app.color.white'))
.width(28)
.height(16)
.backgroundColor('#4D000000')
.borderRadius(4)
.textAlign(TextAlign.Center)
Blank()
Stack() {
Image($r('app.media.comp_adv_close_white'))
.width(9)
.height(9)
.borderRadius({
topLeft: '4vp',
topRight: '4vp',
bottomLeft: '4vp',
bottomRight: '4vp'
})
}
.width(18)
.height(14)
.backgroundColor('#4D000000')
.borderWidth(0.5)
.borderColor($r('app.color.white'))
.borderRadius(4)
}.width('100%').padding({
top: 8,
left: 8,
right: 8
})
}
.alignContent(Alignment.Top)
.width(CommonConstants.FULL_WIDTH)
//
List({ space: 10 }) {
ForEach(this.advExtraData.item, (content: AdvExtraItemData) => {
ListItem() {
Text(content.title).fontSize('16fp').fontColor($r('app.color.color_222222')).width('100%').onClick(() => {
let matInfo: CompAdvMatInfoBean = {
linkUrl: content.linkUrl,
linkType: content.linkType
} as CompAdvMatInfoBean;
ProcessUtils.openAdvDetail(matInfo)
})
}
})
}.width('100%').listDirection(Axis.Vertical).margin({ top: 10, bottom: 10 })
// 更多按钮
commonButton(this.advExtraData)
}
.width(CommonConstants.FULL_WIDTH)
.padding({
... ... @@ -47,14 +118,33 @@ export struct CardAdvVideoExComponent {
top: $r('app.float.card_comp_pagePadding_tb'),
bottom: $r('app.float.card_comp_pagePadding_tb')
})
.onClick((event: ClickEvent) => {
//ProcessUtils.processPage(this.contentDTO)
})
}
}
@Extend(Text)
function bottomTextStyle() {
.fontSize(12)
.fontColor('#B0B0B0')
/*
标题样式
*/
@Builder
function commonButton(advExtraData: AdvExtraData) {
Row() {
Blank()
Text('查看更多').fontColor('#222222').fontSize('14fp')
Image($r('app.media.icon_comp_more_right_red')).width(16).height(16)
Blank()
}
.width('100%')
.backgroundColor('#F5F5F5')
.borderRadius(3)
.padding({ top: 10, bottom: 10, })
.onClick(() => {
let matInfo: CompAdvMatInfoBean = {
linkUrl: advExtraData.itemMore.linkUrl,
linkType: advExtraData.itemMore.linkType
} as CompAdvMatInfoBean;
ProcessUtils.openAdvDetail(matInfo)
})
}
\ No newline at end of file
... ...
... ... @@ -20,7 +20,7 @@ export struct Card12Component {
Column() {
// rmh信息
if (this.contentDTO.rmhInfo) {
RmhTitle({ rmhInfo: this.contentDTO.rmhInfo })
RmhTitle({ rmhInfo: this.contentDTO.rmhInfo, publishTime: this.contentDTO.publishTime })
}
// 标题
if (this.contentDTO.newsTitle) {
... ...
... ... @@ -52,7 +52,7 @@ export struct Card14Component {
Column() {
// rmh信息
if (this.contentDTO.rmhInfo) {
RmhTitle({ rmhInfo: this.contentDTO.rmhInfo })
RmhTitle({ rmhInfo: this.contentDTO.rmhInfo, publishTime: this.contentDTO.publishTime })
}
// 左标题,右图
Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceBetween }) {
... ...
... ... @@ -58,7 +58,7 @@ export struct Card15Component {
build() {
Column() {
// rmh信息
RmhTitle({ rmhInfo: this.contentDTO.rmhInfo })
RmhTitle({ rmhInfo: this.contentDTO.rmhInfo, publishTime: this.contentDTO.publishTime })
//新闻标题
if (this.contentDTO.newsTitle) {
Text(this.contentDTO.newsTitle)
... ...
... ... @@ -25,7 +25,7 @@ export struct Card16Component {
Column() {
// rmh信息
if (this.contentDTO.rmhInfo) {
RmhTitle({ rmhInfo: this.contentDTO.rmhInfo })
RmhTitle({ rmhInfo: this.contentDTO.rmhInfo, publishTime: this.contentDTO.publishTime })
}
// 标题
if (this.contentDTO.newsTitle) {
... ...
... ... @@ -77,7 +77,7 @@ export struct Card19Component {
build() {
Column() {
// rmh信息
RmhTitle({ rmhInfo: this.contentDTO.rmhInfo })
RmhTitle({ rmhInfo: this.contentDTO.rmhInfo, publishTime: this.contentDTO.publishTime })
// 标题
if (this.contentDTO.newsTitle) {
Text(this.contentDTO.newsTitle)
... ...
... ... @@ -50,7 +50,7 @@ export struct Card20Component {
build() {
Column() {
// rmh信息
RmhTitle({ rmhInfo: this.contentDTO.rmhInfo })
RmhTitle({ rmhInfo: this.contentDTO.rmhInfo, publishTime: this.contentDTO.publishTime })
// 标题
if (this.contentDTO.newsTitle) {
Text(this.contentDTO.newsTitle)
... ...
... ... @@ -16,7 +16,7 @@ export struct Card21Component {
build() {
Column() {
// 顶部 rmh信息
RmhTitle({ rmhInfo: this.contentDTO.rmhInfo })
RmhTitle({ rmhInfo: this.contentDTO.rmhInfo, publishTime: this.contentDTO.publishTime })
// 中间内容
Grid() {
GridItem() {
... ...
... ... @@ -10,6 +10,7 @@ import { CommentCustomDialog } from './CommentCustomDialog'
import { publishCommentModel } from '../model/PublishCommentModel';
import { ifaa } from '@kit.OnlineAuthenticationKit';
import { HttpUrlUtils } from 'wdNetwork/Index';
import NoMoreLayout from '../../page/NoMoreLayout';
const TAG = 'CommentComponent';
... ... @@ -19,6 +20,8 @@ const testString = '因为读书的人\n是低着头向上看的人\n身处一
@Preview
@Component
export struct CommentComponent {
@State hasMore: boolean = true;
@State currentPage: number = 1;
// @State private browSingModel: commentListModel = new commentListModel()
/*必传*/
@ObjectLink publishCommentModel: publishCommentModel
... ... @@ -167,7 +170,19 @@ export struct CommentComponent {
}
}
}, (item: commentItemModel, index: number) => JSON.stringify(item) + index.toString())
// 加载更多
ListItem() {
if (this.hasMore === false) NoMoreLayout()
}
}
.onReachEnd(()=>{
if (this.hasMore) {
this.getData()
}
})
.enableScrollInteraction(false)
}
... ... @@ -175,10 +190,22 @@ export struct CommentComponent {
//获取数据
async getData() {
commentViewModel.fetchContentCommentList('1', this.publishCommentModel.targetId, this.publishCommentModel.targetType)
commentViewModel.fetchContentCommentList(this.currentPage + '', this.publishCommentModel.targetId, this.publishCommentModel.targetType)
.then(commentListModel => {
this.publishCommentModel.totalCommentNumer = commentListModel.totalCount + ''
this.currentPage++
if (Number.parseInt(commentListModel.totalCommentNum) > Number.parseInt(this.publishCommentModel.totalCommentNumer)) {
this.publishCommentModel.totalCommentNumer = commentListModel.totalCommentNum + ''
}
if (commentListModel.hasNext === 0) {
this.hasMore = false;
} else {
this.hasMore = true;
}
if (commentListModel && commentListModel.list && commentListModel.list.length > 0) {
commentListModel.list.forEach(element => {
element.hasMore = Number.parseInt(element.childCommentNum) ? true : false
let newModel = commentViewModel.deepCopyCommentItemModel(element)
... ... @@ -189,6 +216,8 @@ export struct CommentComponent {
});
}else{
this.hasMore = false
}
})
... ...
... ... @@ -6,7 +6,7 @@ import { ProcessUtils } from 'wdRouter';
import { HttpUtils } from 'wdNetwork/Index';
/**
* 小视频横划
* 直播预约
* Zh_Single_Row-02
*/
const TAG = 'Zh_Single_Row-03'
... ... @@ -42,7 +42,7 @@ export struct ZhSingleRow03 {
Row() {
Flex({justifyContent: FlexAlign.SpaceBetween}){
Row() {
Text(item.liveInfo.liveStartTime.split(' ')[0].slice(5))
Text(item.liveInfo.liveStartTime.split(' ')[0].slice(5).split('-').join('月')+'日')
.margin({right: 6})
.fontColor(0x000000)
.fontSize(13)
... ...
... ... @@ -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)
}
... ...
... ... @@ -250,10 +250,10 @@ struct ChannelDialog {
.fontSize(16)
.fontWeight(600)
.margin({ right: 4 })
Text(!this.isEditIng ? MY_CHANNEL_TIP1 : MY_CHANNEL_TIP2)
.fontSize(12)
.fontWeight(400)
.fontColor('#222222')
// Text(!this.isEditIng ? MY_CHANNEL_TIP1 : MY_CHANNEL_TIP2)
// .fontSize(12)
// .fontWeight(400)
// .fontColor('#222222')
}
Text(this.isEditIng ? EDIT_DOWN : EDIT_TEXT)
... ... @@ -276,9 +276,9 @@ struct ChannelDialog {
Row() {
Text(item.name)
.fontSize(14)
.fontColor(this.currentTopNavSelectedItem.channelId === item.channelId ? '#ED2800' : (item.homeChannel === '1' || item.movePermitted === 0 ? '#999999' : '#222222'))
.fontColor(this.currentTopNavSelectedItem.channelId === item.channelId ? '#ED2800' : (item.headlinesOn === 1 || item.movePermitted === 0 ? '#999999' : '#222222'))
if (this.isEditIng && item.delPermitted === 1) {
if (this.isEditIng && item.delPermitted === 1 && item.movePermitted === 1) {
Image($r('app.media.icon_audio_close'))
.width(12)
.margin({ left: 1 })
... ... @@ -287,12 +287,12 @@ struct ChannelDialog {
.width('100%')
.height('100%')
.justifyContent(FlexAlign.Center)
.backgroundColor(item.homeChannel === '1' || item.movePermitted === 0 ? '#F5F5F5' : '#ffffff')
.backgroundColor(item.headlinesOn === 1 || item.movePermitted === 0 ? '#F5F5F5' : '#ffffff')
}
.width('23%')
.height(40)
.border({
width: item.homeChannel === '1' ? 0 : 1,
width: item.headlinesOn === 1 || item.movePermitted === 0 ? 0 : 1,
color: '#EDEDED',
radius: 3
})
... ... @@ -303,7 +303,7 @@ struct ChannelDialog {
TapGesture()
.onAction((event?: GestureEvent) => {
if (this.isEditIng) {
if (item.delPermitted === 1) {
if (item.delPermitted === 1 && item.movePermitted === 1) {
this.delChannelItem(index)
}
} else {
... ...
... ... @@ -84,10 +84,10 @@ export struct PageComponent {
// 加载更多
ListItem() {
if (this.pageModel.hasMore) {
LoadMoreLayout({
refreshBean: new RefreshLayoutBean(this.pageModel.isVisiblePullUpLoad, this.pageModel.pullUpLoadImage,
this.pageModel.pullUpLoadText, this.pageModel.pullUpLoadHeight)
})
// LoadMoreLayout({
// refreshBean: new RefreshLayoutBean(this.pageModel.isVisiblePullUpLoad, this.pageModel.pullUpLoadImage,
// this.pageModel.pullUpLoadText, this.pageModel.pullUpLoadHeight)
// })
} else if (!this.pageModel.contentNeedScroll) {
PageNoMoreLayout({ noMoreBean: new NoMoreBean(this.pageModel.pageInfo.baselineCopywriting) })
}
... ...
... ... @@ -59,7 +59,6 @@ export struct TopNavigationComponent {
@State autoRefresh2Page: number = 0
// 当前底导index
@State navIndex: number = 0
@State animationDuration: number = 0
@State indicatorLeftMargin: number = 0
@State indicatorWidth: number = 0
... ... @@ -93,7 +92,8 @@ export struct TopNavigationComponent {
//defaultMyChannelList
defaultList.forEach(item => {
if (item.defaultPermitted === 1 || item.movePermitted === 0 || item.delPermitted === 0 || item.headlinesOn === 1) {
if (item.defaultPermitted === 1 || item.movePermitted === 0 || item.delPermitted === 0 ||
item.headlinesOn === 1) {
defaultMyChannelList.push(item);
}
if (item.defaultPermitted === 1) {
... ... @@ -136,13 +136,15 @@ export struct TopNavigationComponent {
}
//频道分类
if (item.myChannel === '1' && item.name !== '播报') {
_myChannelList.push(item)
_channelIds.push(item.channelId)
} else if (item.moreChannel === '1') {
this.moreChannelList.push(item)
} else if (item.localChannel === '1') {
this.localChannelList.push(item)
if (item.name !== '播报') { //暂时隐藏播报
if (item.myChannel === '1') {
_myChannelList.push(item)
_channelIds.push(item.channelId)
} else if (item.moreChannel === '1') {
this.moreChannelList.push(item)
} else if (item.localChannel === '1') {
this.localChannelList.push(item)
}
}
})
... ... @@ -169,7 +171,6 @@ export struct TopNavigationComponent {
return item.name === '版面'
}
build() {
Column() {
// 顶部搜索、日报logo、早晚报
... ... @@ -216,51 +217,51 @@ export struct TopNavigationComponent {
// 频道分类list
Stack({ alignContent: Alignment.TopEnd }) {
Tabs({ index: this.currentTopNavSelectedIndex, controller: this.tabsController }) {
ForEach(this.currentBottomNavName === '新闻' ? this.myChannelList : this.topNavList, (navItem: TopNavDTO, index: number) => {
TabContent() {
if (this.currentBottomNavName === '视频' && navItem.name === '视频') {
VideoChannelDetail({
bottomNavIndex: $_currentNavIndex,
topNavIndex: $currentTopNavSelectedIndex,
groupId: this.groupId + '',
pageId: navItem.pageId + '',
channelId: navItem.channelId + '',
})
}
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({
ForEach(this.currentBottomNavName === '新闻' ? this.myChannelList : this.topNavList,
(navItem: TopNavDTO, index: number) => {
TabContent() {
if (this.currentBottomNavName === '视频' && navItem.name === '视频') {
VideoChannelDetail({
bottomNavIndex: $_currentNavIndex,
topNavIndex: $currentTopNavSelectedIndex,
groupId: this.groupId + '',
pageId: navItem.pageId + '',
channelId: navItem.channelId + '',
})
} else if (this.currentBottomNavName === '人民号' && navItem.name === '关注') {
PeopleShipMainComponent({
currentTopNavSelectedIndex: $currentTopNavSelectedIndex,
navIndex: index,
pageId: navItem.pageId + '',
channelId: navItem.channelId + '',
autoRefresh: this.autoRefresh2Page
})
}
}
.tabBar(this.tabBarBuilder(navItem, index))
} else
if (!this.isBroadcast(navItem) && !this.isLayout(navItem)) {
PageComponent({
currentTopNavSelectedIndex: $currentTopNavSelectedIndex,
navIndex: index,
pageId: navItem.pageId + '',
channelId: navItem.channelId + '',
autoRefresh: this.autoRefresh2Page
})
}
}
.tabBar(this.tabBarBuilder(navItem, index))
}, (navItem: TopNavDTO) => JSON.stringify(navItem));
}, (navItem: TopNavDTO) => JSON.stringify(navItem));
}
.barHeight($r('app.float.top_tab_bar_height'))
.barMode(BarMode.Scrollable)
.vertical(false)
.barBackgroundColor(this.barBackgroundColor)
.onAreaChange((oldValue: Area,newValue: Area)=> {
.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
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])
... ... @@ -288,27 +289,27 @@ export struct TopNavigationComponent {
let targetIndexInfo = this.getTextInfo(targetIndex)
this.startAnimateTo(this.animationDuration, targetIndexInfo.left, targetIndexInfo.width)
})
.onAnimationEnd((index: number,event: TabsAnimationEvent) => {
.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)
// 切换动画结束时触发该回调。下划线动画停止。
let currentIndicatorInfo = this.getCurrentIndicatorInfo(index, event)
this.startAnimateTo(0, currentIndicatorInfo.left, currentIndicatorInfo.width)
})
.onGestureSwipe((index: number,event: TabsAnimationEvent) => {
.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
// 在页面跟手滑动过程中,逐帧触发该回调。
let currentIndicatorInfo = this.getCurrentIndicatorInfo(index, event)
this.currentTopNavSelectedIndex = currentIndicatorInfo.index
this.indicatorLeftMargin = currentIndicatorInfo.left
this.indicatorWidth = currentIndicatorInfo.width
})
// 分类列表最右侧频道设置
... ... @@ -351,8 +352,9 @@ export struct TopNavigationComponent {
.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)){
.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
... ... @@ -396,7 +398,8 @@ export struct TopNavigationComponent {
}
onTopNavigationDataUpdated() {
Logger.info(TAG, `onTopNavigationDataUpdated currentTopNavIndex: ${this.currentTopNavSelectedIndex},topNavList.length:${this.topNavList.length}`);
Logger.info(TAG,
`onTopNavigationDataUpdated currentTopNavIndex: ${this.currentTopNavSelectedIndex},topNavList.length:${this.topNavList.length}`);
}
onAutoRefresh() {
... ... @@ -505,7 +508,7 @@ export struct TopNavigationComponent {
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 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 }
... ...
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 { PeopleShipHomePageHeadComponent } from '../peopleShipHomePage/PeopleShipHomePageHeadComponent'
import { FollowListDetailItem } from '../../viewmodel/FollowListDetailItem';
@Component
export 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'
})
}
}
... ...
import { FollowListDetailItem } from '../../viewmodel/FollowListDetailItem';
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'
import { ProcessUtils } from 'wdRouter';
import { PeopleShipHomePageHeadComponent } from '../peopleShipHomePage/PeopleShipHomePageHeadComponent'
import { PeopleShipAttentionContentListHeadComponent } from './PeopleShipAttentionContentListHeadComponent'
@Component
export struct PeopleShipAttentionContentListTopComponent {
... ... @@ -41,45 +40,3 @@ export struct PeopleShipAttentionContentListTopComponent {
}
}
}
@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
... ...
... ... @@ -2,7 +2,14 @@ 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 {
RmhRecommendDTO,
ContentDTO,
AttentionBatchDTO,
CreatorDTO,
contentListParams,
InteractDataDTO
} from 'wdBean';
import { ViewType } from 'wdConstant/src/main/ets/enum/ViewType';
import { channelSkeleton } from '../skeleton/channelSkeleton'
import { EmptyComponent } from '../view/EmptyComponent';
... ... @@ -56,6 +63,13 @@ export struct PeopleShipMainComponent {
this.LoadingLayout()
} else if (this.viewType == ViewType.ERROR) {
ErrorComponent()
.onTouch((event: TouchEvent | undefined) => {
if (event) {
if (this.viewType === ViewType.ERROR) {
this.getData()
}
}
})
} else if (this.viewType == ViewType.EMPTY) {
EmptyComponent()
} else {
... ... @@ -155,11 +169,6 @@ export struct PeopleShipMainComponent {
.scrollBar(BarState.Off)
.width('100%')
.height('100%')
// PeopleShipAttentionContentListComponent({
// followList: this.followList,
// attentionList: this.attentionList
// })
}
aboutToAppear() {
... ... @@ -259,14 +268,6 @@ export struct PeopleShipMainComponent {
// 获取列表数据
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;
... ... @@ -276,14 +277,71 @@ export struct PeopleShipMainComponent {
if (this.currentPage == 1) {
this.attentionList = []
}
this.attentionList.push(...listData.list)
//批量查询各类型内容动态数据接口
this.checkContentInteractData(listData.list, resolve)
} else {
this.resolveEnd(true, resolve)
}
this.viewType = ViewType.LOADED
this.isLoading = false
} catch (exception) {
this.resolveEnd(false, resolve)
}
}
// 批量查询各类型内容动态数据接口
private async checkContentInteractData(list: ContentDTO[], resolve?: (value: string | PromiseLike<string>) => void) {
// 批量查询内容当前用户点赞、收藏状态
try {
// 获取列表数据
const params: contentListParams = {
contentList: []
}
list.forEach((item: ContentDTO) => {
params.contentList.push({
contentId: item.objectId,
contentType: Number(item.objectType ?? '1')
})
})
let listData = await PeopleShipMainViewModel.getContentInteractInfo(params)
Logger.debug('PeopleShipMainComponent', '获取页面信息' + `${JSON.stringify(listData)}`)
this.resolveEnd(true, resolve)
list.forEach((element: ContentDTO) => {
// 获取 interactData 数据
if (listData && listData.length > 0) {
const objc = listData.find((interactModel: InteractDataDTO) => {
return element.objectId == interactModel.contentId
})
if (objc) {
element.interactData = objc
}
}
// 设置人民号都不可关注
if (element.rmhInfo) {
element.rmhInfo.cnIsAttention = 0
}
this.attentionList.push(element)
})
} catch (exception) {
this.resolveEnd(false, resolve)
}
}
private resolveEnd(isTop: boolean, resolve?: (value: string | PromiseLike<string>) => void) {
if (resolve) {
if (this.currentPage == 1 && isTop) {
resolve('已更新至最新')
}else {
resolve('')
}
}
if (this.currentPage == 1 && !isTop) {
this.viewType = ViewType.ERROR
this.isLoading = false
} else {
this.viewType = ViewType.LOADED
}
this.isLoading = false
}
// 说是首页必须要调用
... ...
... ... @@ -15,6 +15,7 @@ import { MultiPictureDetailViewModel } from '../../viewmodel/MultiPictureDetailV
import { LikeComponent } from './LikeComponent';
import { CommentTabComponent, CommentIconComponent, } from '../comment/view/CommentTabComponent';
import { publishCommentModel } from '../comment/model/PublishCommentModel'
// import { AudioBarView } from '../MorningEveningPaper/AudioBarView'
import { HttpUrlUtils } from 'wdNetwork/Index';
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
import { PageRepository } from '../../repository/PageRepository';
... ... @@ -26,25 +27,28 @@ const TAG = 'OperRowListView';
* 稿件详情底部通栏组件:包含返回、评论、点赞、收藏、分享
* 上层传值:
* 1、(必传) contentDetailData---稿件详情
* 2、(非必传) operationButtonList---组件展示条件,['comment', 'like', 'collect', 'share'],需要展示什么传什么
* comment--评论;like--点赞;collect--收藏;share--分享;
* 2、(非必传) operationButtonList---组件展示条件,
* ['comment', 'like', 'collect', 'share'],需要展示什么传什么
* comment--评论;like--点赞;collect--收藏;listen--音频;share--分享;
*
* 传值示例:
OperRowListView({
contentDetailData: this.contentDetailData[0],
operationButtonList: ['comment', 'like', 'collect', 'share']
})
OperRowListView({
contentDetailData: this.contentDetailData[0],
operationButtonList: ['comment', 'like', 'collect', 'listen', 'share']
})
*/
@Preview
@Component
export struct OperRowListView {
@Prop contentDetailData: ContentDetailDTO // 稿件详情
@State operationButtonList: string[] = ['comment', 'like', 'collect', 'share'] // 组件展示条件
@Prop operationButtonList?: string[] = ['comment', 'collect', 'share'] // 组件展示条件
@ObjectLink publishCommentModel: publishCommentModel
// @State contentDetailData: ContentDetailDTO = {} as ContentDetailDTO
@State interactData: InteractDataDTO = {} as InteractDataDTO
@State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态
@State likeBean: Record<string, string> = {}
@State publishCommentModel: publishCommentModel = new publishCommentModel()
@State audioUrl: string= ''
needLike: boolean = true
async aboutToAppear() {
const user_id = await SPHelper.default.get(SpConstants.USER_ID, '')
... ... @@ -62,13 +66,18 @@ export struct OperRowListView {
console.info(TAG, 'contentDetailData----', JSON.stringify(this.contentDetailData))
console.info(TAG, 'likeBean----', JSON.stringify(this.likeBean))
// 评论需要数据
this.publishCommentModel.targetId = this.contentDetailData.newsId + ''
this.publishCommentModel.targetRelId = this.contentDetailData.reLInfo?.relId + ''
this.publishCommentModel.targetTitle = this.contentDetailData.newsTitle + ''
this.publishCommentModel.targetRelType = this.contentDetailData.reLInfo?.relType + ''
this.publishCommentModel.targetRelObjectId = this.contentDetailData.reLInfo?.relObjectId + ''
this.publishCommentModel.keyArticle = this.contentDetailData.keyArticle + ''
this.publishCommentModel.targetType = this.contentDetailData.newsType + ''
/* this.publishCommentModel.targetId = this.contentDetailData.newsId + ''
this.publishCommentModel.targetRelId = this.contentDetailData.reLInfo?.relId + ''
this.publishCommentModel.targetTitle = this.contentDetailData.newsTitle + ''
this.publishCommentModel.targetRelType = this.contentDetailData.reLInfo?.relType + ''
this.publishCommentModel.targetRelObjectId = this.contentDetailData.reLInfo?.relObjectId + ''
this.publishCommentModel.keyArticle = this.contentDetailData.keyArticle + ''
this.publishCommentModel.targetType = this.contentDetailData.newsType + ''*/
// 音频需要数据
if (this.operationButtonList?.includes('listen')) {
this.audioUrl = this.contentDetailData.audioList[0]?.audioUrl || ''
console.log(TAG, 'this.audioUrl+++', this.audioUrl)
}
}
build() {
... ... @@ -90,10 +99,12 @@ export struct OperRowListView {
ForEach(this.operationButtonList, (item: string, index: number) => {
if (item == 'comment') {
this.builderComment()
} else if (item == 'like') {
} else if (item == 'like' && this.needLike) {
this.builderLike()
} else if (item == 'collect') {
this.builderCollect()
} else if (item == 'listen') {
this.builderListen()
} else if (item == 'share') {
this.builderShare()
} else {
... ... @@ -175,6 +186,25 @@ export struct OperRowListView {
}
/**
* 音频组件
*/
// this.audioUrl
@Builder
builderListen() {
Column() {
Image($r('app.media.icon_listen'))
.width(24)
.height(24)
.aspectRatio(1)
.interpolation(ImageInterpolation.High)
.onClick((event: ClickEvent) => {
ToastUtils.showToast('音频为公共方法,待开发', 1000);
})
}
.width(42)
}
/**
* 分享组件
*/
@Builder
... ... @@ -232,7 +262,6 @@ export struct OperRowListView {
}
PageRepository.postExecuteCollectRecord(params).then(res => {
// console.log(TAG, '收藏、取消收藏', 'toggleLikeStatus==',)
if (this.newsStatusOfUser) {
this.newsStatusOfUser.collectStatus = this.newsStatusOfUser?.collectStatus === 1 ? 0 : 1
this.queryContentInteractCount()
... ... @@ -258,10 +287,13 @@ export struct OperRowListView {
this.interactData.collectNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.collectNum)
this.interactData.commentNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.commentNum)
// 评论组件需要数据
this.publishCommentModel.totalCommentNumer = this.interactData.commentNum + '' || '0'
if (Number.parseInt(this.interactData.commentNum) > Number.parseInt(this.publishCommentModel.totalCommentNumer)) {
this.publishCommentModel.totalCommentNumer = this.interactData.commentNum + '' || '0'
}
}
// console.log(TAG, '获取互动点赞等数据===', JSON.stringify(res))
console.log(TAG, 'this.interactData', JSON.stringify(this.interactData))
console.log(TAG, 'this.interactData44', JSON.stringify(this.interactData))
console.log(TAG, 'this.publishCommentModel', JSON.stringify(this.publishCommentModel))
})
}
}
\ No newline at end of file
... ...
... ... @@ -283,7 +283,7 @@ export class PageRepository {
* @returns
*/
static postExecuteCollectRecord(params: postExecuteCollectRecordParams): Promise<ResponseDTO> {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_EXECUTECOLLECTRECORD
let url = HttpUrlUtils.getExecuteCollcetUrl()
return WDHttp.post(url, params)
}
... ...
... ... @@ -35,7 +35,7 @@ export function listTouchEvent(pageModel: PageModel, pageAdvModel: PageAdModel,
touchUpPullRefresh(pageModel, pageAdvModel);
} else {
// Fingers up, handle loading more.
touchUpLoadMore(pageModel);
// touchUpLoadMore(pageModel);
}
break;
default:
... ...
... ... @@ -4,13 +4,18 @@ import PageHelper from '../viewmodel/PageHelper';
export function touchMoveLoadMore(model: PageModel, event: TouchEvent) {
// list size +1
if (model.endIndex === model.compList.totalCount() || model.endIndex === model.compList.totalCount() + 1) {
model.offsetY = event.touches[0].y - model.downY;
if (Math.abs(model.offsetY) > vp2px(model.pullUpLoadHeight) / 2) {
model.isCanLoadMore = true;
model.isVisiblePullUpLoad = true;
model.offsetY = -vp2px(model.pullUpLoadHeight) + model.offsetY * Const.Y_OFF_SET_COEFFICIENT;
}
if (model.endIndex >= model.compList.totalCount()-3 && model.endIndex <= model.compList.totalCount()) {
// model.offsetY = event.touches[0].y - model.downY;
// if (Math.abs(model.offsetY) > vp2px(model.pullUpLoadHeight) / 2) {
// model.isCanLoadMore = true;
// model.isVisiblePullUpLoad = true;
// model.offsetY = -vp2px(model.pullUpLoadHeight) + model.offsetY * Const.Y_OFF_SET_COEFFICIENT;
// }
// 不用分页动画,直接预加载
model.isCanLoadMore = true;
model.isVisiblePullUpLoad = true;
touchUpLoadMore(model);
}
}
... ...
... ... @@ -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
AttentionBatchDTO,
contentListParams,
InteractDataDTO
} from 'wdBean';
import { PageRepository } from '../repository/PageRepository'
const TAG = 'PeopleShipMainViewModel'
... ... @@ -103,5 +105,24 @@ export class PeopleShipMainViewModel {
})
}
static async getContentInteractInfo(params: contentListParams): Promise<InteractDataDTO[]> {
return new Promise<InteractDataDTO[]>((success, error) => {
Logger.debug(TAG, `getContentInteractInfo pageInfo start`);
PageRepository.getContentInteract(params)
.then((resDTO) => {
if (!resDTO.data || resDTO.code != 0) {
error(resDTO.message)
return
}
Logger.debug(TAG, "getContentInteractInfo then,navResDTO.timestamp:" + resDTO.timestamp);
success(resDTO.data);
})
.catch((err: Error) => {
Logger.error(TAG, `getContentInteractInfo catch, error.name : ${err.name}, error.message:${err.message}`);
error(err);
})
})
}
}
\ No newline at end of file
... ...
... ... @@ -288,7 +288,7 @@ export class ContentDetailRequest {
* @returns
*/
static postExecuteCollectRecord(params: postExecuteCollectRecordParams): Promise<ResponseDTO> {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_EXECUTECOLLECTRECORD
let url = HttpUrlUtils.getExecuteCollcetUrl()
return WDHttp.post(url, params)
}
... ...
... ... @@ -16,5 +16,6 @@
"wdConstant": "file:../../commons/wdConstant",
"wdDetailPlayApi": "file:../../features/wdDetailPlayApi",
// "wdComponent": "file:../../features/wdComponent"
"wdShare": "file:../../features/wdShare"
}
}
... ...
... ... @@ -11,6 +11,7 @@ import { SPHelper, ToastUtils, NumberFormatterUtils } from 'wdKit';
import { WDPlayerController } from 'wdPlayer/Index';
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
import { SpConstants } from 'wdConstant/Index'
import { WDShare } from "wdShare"
interface ILikeStyleResp {
url: Resource;
... ... @@ -336,6 +337,8 @@ export struct PlayerRightView {
.aspectRatio(1)
.onClick((event: ClickEvent) => {
ToastUtils.showToast('分享为公共方法,待开发', 1000);
this.share()
})
Text('分享')
.width('100%')
... ... @@ -349,4 +352,9 @@ export struct PlayerRightView {
}
.margin({ bottom: 20 })
}
share() {
WDShare.shareContent(this.contentDetailData)
}
}
\ 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获取省份名称
... ...
... ... @@ -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)
... ... @@ -85,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)
... ... @@ -163,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)
... ...
... ... @@ -43,8 +43,8 @@ export struct WDPlayerRenderView {
private xComponentController: XComponentController = new XComponentController();
private insId: string = "WDPlayRenderView" + insIndex;
onLoad?: ((event?: object) => void);
@State videoWidth: number = 0
@State videoHeight: number = 0
@State videoWidth: number = 16
@State videoHeight: number = 9
@State selfSize: Size = new Size('100%', '100%');
aboutToAppear() {
... ...
/node_modules
/oh_modules
/.preview
/build
/.cxx
/.test
\ No newline at end of file
... ...
export { WDShare } from './src/main/ets/WDShare'
... ...
{
"apiType": "stageMode",
"buildOption": {
},
"buildOptionSet": [
{
"name": "release",
"arkOptions": {
"obfuscation": {
"ruleOptions": {
"enable": true,
"files": [
"./obfuscation-rules.txt"
]
}
}
},
},
],
"targets": [
{
"name": "default"
}
]
}
\ No newline at end of file
... ...
import { hspTasks } from '@ohos/hvigor-ohos-plugin';
export default {
system: hspTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
}
... ...
# Define project specific obfuscation rules here.
# You can include the obfuscation configuration files in the current module's build-profile.json5.
#
# For more details, see
# https://gitee.com/openharmony/arkcompiler_ets_frontend/blob/master/arkguard/README.md
# Obfuscation options:
# -disable-obfuscation: disable all obfuscations
# -enable-property-obfuscation: obfuscate the property names
# -enable-toplevel-obfuscation: obfuscate the names in the global scope
# -compact: remove unnecessary blank spaces and all line feeds
# -remove-log: remove all console.* statements
# -print-namecache: print the name cache that contains the mapping from the old names to new names
# -apply-namecache: reuse the given cache file
# Keep options:
# -keep-property-name: specifies property names that you want to keep
# -keep-global-name: specifies names that you want to keep in the global scope
\ No newline at end of file
... ...
{
"meta": {
"stableOrder": true
},
"lockfileVersion": 3,
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
"specifiers": {
"@ohos/axios@^2.1.1": "@ohos/axios@2.2.0",
"wdBean@../wdBean": "wdBean@../wdBean",
"wdConstant@../../commons/wdConstant": "wdConstant@../../commons/wdConstant",
"wdKit@../../commons/wdKit": "wdKit@../../commons/wdKit",
"wdNetwork@../../commons/wdNetwork": "wdNetwork@../../commons/wdNetwork",
"wdRouter@../../commons/wdRouter": "wdRouter@../../commons/wdRouter",
"wdShareBase@../../commons/wdShareBase": "wdShareBase@../../commons/wdShareBase"
},
"packages": {
"@ohos/axios@2.2.0": {
"name": "@ohos/axios",
"integrity": "sha512-v1QBWk6DfcN8wUW3D0ieFbHTR1taSI5cOgxp5l6B5cegXuNYhSc8ggKlAIXe6h/14LsfM+NW0ZGfSXcNEIM5yA==",
"resolved": "https://repo.harmonyos.com/ohpm/@ohos/axios/-/axios-2.2.0.har",
"registryType": "ohpm"
},
"wdBean@../wdBean": {
"name": "wdbean",
"resolved": "../wdBean",
"registryType": "local"
},
"wdConstant@../../commons/wdConstant": {
"name": "wdconstant",
"resolved": "../../commons/wdConstant",
"registryType": "local"
},
"wdKit@../../commons/wdKit": {
"name": "wdkit",
"resolved": "../../commons/wdKit",
"registryType": "local"
},
"wdNetwork@../../commons/wdNetwork": {
"name": "wdnetwork",
"resolved": "../../commons/wdNetwork",
"registryType": "local",
"dependencies": {
"wdConstant": "file:../wdConstant",
"wdKit": "file:../wdKit",
"@ohos/axios": "^2.1.1"
}
},
"wdRouter@../../commons/wdRouter": {
"name": "wdrouter",
"resolved": "../../commons/wdRouter",
"registryType": "local",
"dependencies": {
"wdKit": "file:../wdKit",
"wdBean": "file:../../features/wdBean",
"wdNetwork": "file:../../commons/wdNetwork",
"wdConstant": "file:../../commons/wdConstant"
}
},
"wdShareBase@../../commons/wdShareBase": {
"name": "wdsharebase",
"resolved": "../../commons/wdShareBase",
"registryType": "local",
"packageType": "InterfaceHar"
}
}
}
\ No newline at end of file
... ...
{
"name": "wdshare",
"version": "1.0.0",
"description": "Please describe the basic information.",
"main": "Index.ets",
"author": "",
"license": "Apache-2.0",
"packageType": "InterfaceHar",
"dependencies": {
"wdKit": "file:../../commons/wdKit",
"wdBean": "file:../../features/wdBean",
"wdRouter": "file:../../commons/wdRouter",
"wdShareBase": "file:../../commons/wdShareBase"
}
}
\ No newline at end of file
... ...
import { ContentDetailDTO, ContentDTO, PageInfoDTO } from 'wdBean/Index';
import { ShareScene, ShareType, WDShareBase } from 'wdShareBase/Index';
import { ShareContentType } from 'wdShareBase/src/main/ets/Constant';
export class WDShare {
static shareContent(content: ContentDetailDTO, pageName: string ="", pageId: string = "") {
//TODO: 处理分享弹框交互和 海报逻辑
WDShareBase.getInstance().share({
to: ShareType.System,
scene: ShareScene.System,
type: ShareContentType.Link,
obj: {
title: content.shareInfo.shareTitle,
desc: content.shareInfo.shareSummary,
link: content.shareInfo.shareUrl,
}
})
}
static shareProgram(program: ContentDTO, pageName: string ="", pageId: string = "") {
}
static shareSubject(subject: PageInfoDTO) {
}
}
\ No newline at end of file
... ...
@Entry
@Component
struct Index {
@State message: string = 'Hello World';
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
... ...
export function add(a:number, b:number) {
return a + b;
}
\ No newline at end of file
... ...
{
"module": {
"name": "wdShare",
"type": "shared",
"description": "$string:shared_desc",
"deviceTypes": [
"phone",
"tablet",
"2in1"
],
"deliveryWithInstall": true,
"pages": "$profile:main_pages"
}
}
\ No newline at end of file
... ...
{
"color": [
{
"name": "white",
"value": "#FFFFFF"
}
]
}
\ No newline at end of file
... ...
{
"string": [
{
"name": "shared_desc",
"value": "description"
}
]
}
\ No newline at end of file
... ...
import localUnitTest from './LocalUnit.test';
export default function testsuite() {
localUnitTest();
}
\ No newline at end of file
... ...
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
export default function localUnitTest() {
describe('localUnitTest',() => {
// Defines a test suite. Two parameters are supported: test suite name and test suite function.
beforeAll(() => {
// Presets an action, which is performed only once before all test cases of the test suite start.
// This API supports only one parameter: preset action function.
});
beforeEach(() => {
// Presets an action, which is performed before each unit test case starts.
// The number of execution times is the same as the number of test cases defined by **it**.
// This API supports only one parameter: preset action function.
});
afterEach(() => {
// Presets a clear action, which is performed after each unit test case ends.
// The number of execution times is the same as the number of test cases defined by **it**.
// This API supports only one parameter: clear action function.
});
afterAll(() => {
// Presets a clear action, which is performed after all test cases of the test suite end.
// This API supports only one parameter: clear action function.
});
it('assertContain', 0, () => {
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
let a = 'abc';
let b = 'b';
// Defines a variety of assertion methods, which are used to declare expected boolean conditions.
expect(a).assertContain(b);
expect(a).assertEqual(a);
});
});
}
\ No newline at end of file
... ...
... ... @@ -16,6 +16,7 @@ import {
} from 'wdKit';
import { HostEnum, HostManager, WDHttp } from 'wdNetwork';
import { LoginModule } from 'wdLogin/src/main/ets/LoginModule';
import { ConfigurationConstant } from '@kit.AbilityKit';
export default class EntryAbility extends UIAbility {
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
... ... @@ -29,7 +30,8 @@ export default class EntryAbility extends UIAbility {
if (StringUtils.isNotEmpty(spHostUrl)) {
HostManager.changeHost(spHostUrl as HostEnum)
}
// 还没深色模式需求,暂直接不跟随系统。
this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT);
// 注册监听网络连接
EmitterUtils.receiveEvent(EmitterEventId.NETWORK_CONNECTED, ((str?: string) => {
let type: NetworkType | null = null
... ...