当前位置: 首页 > news >正文

炫酷的网站设计学管理培训班去哪里学

炫酷的网站设计,学管理培训班去哪里学,怀化 网站建设,网站建设方案预算费用预算在上一篇文章中,完成了电影列表页的开发。接下来,将进入电影详情页的设计实现阶段。这个页面将展示电影的详细信息,包括电影海报、评分、简介以及相关影人等。将使用 HarmonyOS 提供的常用组件,并结合第三方库 nutpi/axios 来实现…

在上一篇文章中,完成了电影列表页的开发。接下来,将进入电影详情页的设计实现阶段。这个页面将展示电影的详细信息,包括电影海报、评分、简介以及相关影人等。将使用 HarmonyOS 提供的常用组件,并结合第三方库 nutpi/axios 来实现网络请求。下面,一步步地来看如何实现电影详情页。

在这里插入图片描述
开源项目地址:https://atomgit.com/csdn-qq8864/hmmovie

好的作品是需要不断打磨,在你的学习和体验过程中有任何问题,欢迎到我的开源项目代码仓下面提交issue,持续优化。

获取电影详情接口

首先,需要定义一个用于获取电影详情的接口。这里使用 axiosClient.post 方法来实现,代码如下:

export const getDetailMv = (id: string): HttpPromise<DetailMvResp> => axiosClient.post({ url: '/detailmovie', data: { id: id } });

电影详情接口的具体信息如下:

POST http://120.27.146.247:8000/api/v1/detailmovie
Content-Type: application/json{"id": "1292052"
}
电影详情页的组件使用

在电影详情页中,将使用 BadgeSymbolSpanButtonRating 等组件来展示电影的详细信息。

  1. Badge 组件

    Badge 组件用于在某个组件的右上角显示一个标记,通常用于展示某种数量或状态。在电影详情页中,将使用 Badge 组件来展示“想看”和“看过”的数量。

  2. SymbolSpan 组件

    SymbolSpan 组件用于在文本中嵌入图标。在电影详情页中,将使用 SymbolSpan 组件来展示“想看”和“看过”的图标。

  3. Button 组件

    Button 组件用于创建按钮,用户可以通过点击按钮来执行特定的操作。在电影详情页中,将使用 Button 组件来创建“播放”按钮,用户点击后可以跳转到视频播放页面。

  4. Rating 组件

    Rating 组件用于展示评分。在电影详情页中,将使用 Rating 组件来展示电影的豆瓣评分。

电影详情页的实现

下面,将展示电影详情页的具体实现代码:

import { getDetailMv, getMovieSrc } from "../../common/api/movie"
import { Log } from "../../utils/logutil"
import { BusinessError } from "@kit.BasicServicesKit"
import { DetailMvResp, DetailMvRespCast } from "../../common/bean/DetailMvResp"
import { LengthMetrics, promptAction } from "@kit.ArkUI"
import { MvSourceResp } from "../../common/bean/MvSourceResp"@Builder
export function MovieDetailPageBuilder() {Detail()
}@Component
struct Detail {pageStack: NavPathStack = new NavPathStack()private uid = ''@State detailData: DetailMvResp | null = null;private srcData: MvSourceResp | null = null;private description: string = ''private isToggle = false@State toggleText: string = ''@State toggleBtn: string = '展开'build() {NavDestination() {Column({ space: 0 }) {Row() {Image(this.detailData?.images).objectFit(ImageFit.Auto).width(120).borderRadius(5)Column({ space: 8 }) {Text(this.detailData?.title).fontSize(18)Text(this.detailData?.year + " " + this.detailData?.genre).fontSize(14)Row() {Badge({count: this.detailData?.wish_count,maxCount: 10000,position: BadgePosition.RightTop,style: { badgeSize: 22, badgeColor: '#fffab52a' }}) {Row() {Text() {SymbolSpan($r('sys.symbol.heart')).fontWeight(FontWeight.Lighter).fontSize(32).fontColor(['#fffab52a'])}Text('想看')}.backgroundColor('#f8f4f5').borderRadius(5).padding(5)}.padding(8)Blank(10).width(40)Badge({count: this.detailData?.reviews_count,maxCount: 10000,position: BadgePosition.RightTop,style: { badgeSize: 22, badgeColor: '#fffab52a' }}) {Row() {Text() {SymbolSpan($r('sys.symbol.star')).fontWeight(FontWeight.Lighter).fontSize(32).fontColor(['#fffab52a'])}Text('看过')}.backgroundColor('#f8f4f5').borderRadius(5).padding(5)}.padding(8)}Button('播放', { buttonStyle: ButtonStyleMode.NORMAL, role: ButtonRole.NORMAL }).borderRadius(8).borderColor('#fffab52a').fontColor('#fffab52a').width(100).height(35).onClick(() => {console.info('Button onClick')if (this.srcData != null) {this.pageStack.pushDestinationByName("VideoPlayerPage", { item: { video: this.srcData.urls[0], tvurls: this.srcData.tvurls, title: this.srcData.title, desc: this.detailData?.summary } }).catch((e: Error) => {// 跳转失败,会返回错误码及错误信息console.log(`catch exception: ${JSON.stringify(e)}`)}).then(() => {// 跳转成功});} else {promptAction.showToast({ message: '暂无资源' })}})}.alignItems(HorizontalAlign.Start) // 水平方向靠左对齐.justifyContent(FlexAlign.Start)   // 垂直方向靠上对齐.padding(10)}.height(160).width('100%')Row() {Text('豆瓣评分').fontSize(16).padding(5)Rating({ rating: (this.detailData?.rate ?? 0) / 2, indicator: true }).stars(5).stepSize(0.5).height(28)Text(this.detailData?.rate.toString()).fontColor('#fffab52a').fontWeight(FontWeight.Bold).fontSize(36).padding(5)}.width('100%').height(80).borderRadius(5).backgroundColor('#f8f4f5').margin(20)Text('简介').fontSize(18).padding({ bottom: 10 }).fontWeight(FontWeight.Bold).alignSelf(ItemAlign.Start)Text(this.toggleText).fontSize(14).lineHeight(20).alignSelf(ItemAlign.Start)Text(this.toggleBtn).fontSize(14).fontColor(Color.Gray).padding(10).alignSelf(ItemAlign.End).onClick(() => {this.isToggle = !this.isToggleif (this.isToggle) {this.toggleBtn = '收起'this.toggleText = this.description} else {this.toggleBtn = '展开'this.toggleText = this.description.substring(0, 100) + '...'}})Text('影人').fontSize(18).padding({ bottom: 10 }).fontWeight(FontWeight.Bold).alignSelf(ItemAlign.Start)Scroll() {Row({ space: 5 }) {ForEach(this.detailData?.cast, (item: DetailMvRespCast) => {Column({ space: 0 }) {Image(item.cover).objectFit(ImageFit.Auto).height(120).borderRadius(5).onClick(() => {})Text(item.name).alignSelf(ItemAlign.Center).maxLines(1).textOverflow({ overflow: TextOverflow.Ellipsis }).fontSize(14).padding(10)}.justifyContent(FlexAlign.Center)}, (itm: DetailMvRespCast, idx) => itm.id)}}.scrollable(ScrollDirection.Horizontal)}.padding({ left: 10, right: 10 })}.title("电影详情").width('100%').height('100%').onReady(ctx => {this.pageStack = ctx.pathStack//从上个页面拿参数this.pageStack.getParamByName("MovieDetailPage")interface params {id: string;}let par = ctx.pathInfo.param as paramsLog.debug("par:%s", par.id)this.uid = par.id}).onShown(() => {console.info('Detail onShown');getDetailMv(this.uid).then((res) => {Log.debug(res.data.message)Log.debug("request", "res.data.code:%{public}d", res.data.code)this.detailData = res.datathis.description = this.detailData.summarythis.toggleText = this.description.substring(0, 100) + '...'}).catch((err: BusinessError) => {Log.debug("request", "err.data.code:%d", err.code)Log.debug("request", err.message)});getMovieSrc(this.uid).then((res) => {Log.debug(res.data.message)Log.debug("request", "res.data.code:%{public}d", res.data.code)if (res.data.code == 0) {this.srcData = res.data}}).catch((err: BusinessError) => {Log.debug("request", "err.data.code:%d", err.code)Log.debug("request", err.message)});})}
}
折叠效果的实现

在电影详情页中,对于电影的简介,使用了折叠效果,即默认只显示部分简介内容,用户点击“展开”按钮后可以查看完整简介。这个效果的实现主要通过控制 Text 组件的显示内容来实现。具体代码如下:

Text(this.toggleText).fontSize(14).lineHeight(20).alignSelf(ItemAlign.Start)
Text(this.toggleBtn).fontSize(14).fontColor(Color.Gray).padding(10).alignSelf(ItemAlign.End).onClick(() => {this.isToggle = !this.isToggleif (this.isToggle) {this.toggleBtn = '收起'this.toggleText = this.description} else {this.toggleBtn = '展开'this.toggleText = this.description.substring(0, 100) + '...'}
})

通过上述代码,实现了电影简介内容的折叠效果。

总结

在本文中,完成了电影详情页的设计与实现。主要使用了 BadgeSymbolSpanButtonRating 等组件,并结合 nutpi/axios 库来实现网络请求。通过这些技术,可以快速地开发出功能丰富、用户体验良好的影视应用。希望本文对你有所帮助。

作者介绍

作者:csdn猫哥

原文链接:https://blog.csdn.net/yyz_1987

团队介绍

坚果派团队由坚果等人创建,团队拥有12个华为HDE带领热爱HarmonyOS/OpenHarmony的开发者,以及若干其他领域的三十余位万粉博主运营。专注于分享HarmonyOS/OpenHarmony、ArkUI-X、元服务、仓颉等相关内容,团队成员聚集在北京、上海、南京、深圳、广州、宁夏等地,目前已开发鸿蒙原生应用和三方库60+,欢迎交流。

版权声明

本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

其他资源

官方系统图标资源:https://developer.huawei.com/consumer/cn/doc/design-guides/system-icons-0000001929854962

https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-arkui/arkui-ts/ts-basic-components-symbolSpan.md

https://developer.huawei.com/consumer/cn/design/harmonyos-symbol/


文章转载自:
http://homestall.c7510.cn
http://caddie.c7510.cn
http://infirmity.c7510.cn
http://hottish.c7510.cn
http://spectrally.c7510.cn
http://barring.c7510.cn
http://ropery.c7510.cn
http://leeringly.c7510.cn
http://enos.c7510.cn
http://brat.c7510.cn
http://glassy.c7510.cn
http://hurler.c7510.cn
http://isthmectomy.c7510.cn
http://subteenager.c7510.cn
http://bibliophilist.c7510.cn
http://quarter.c7510.cn
http://endnotes.c7510.cn
http://embryotroph.c7510.cn
http://tabu.c7510.cn
http://jingling.c7510.cn
http://parral.c7510.cn
http://frug.c7510.cn
http://eurhythmics.c7510.cn
http://hyte.c7510.cn
http://stickball.c7510.cn
http://hairline.c7510.cn
http://complacent.c7510.cn
http://lha.c7510.cn
http://hame.c7510.cn
http://herniation.c7510.cn
http://eulalie.c7510.cn
http://sweaty.c7510.cn
http://glassless.c7510.cn
http://collapsible.c7510.cn
http://oligodendrocyte.c7510.cn
http://tightfisted.c7510.cn
http://interpleader.c7510.cn
http://oenochoe.c7510.cn
http://selectman.c7510.cn
http://eurhythmics.c7510.cn
http://metalloprotein.c7510.cn
http://span.c7510.cn
http://koestler.c7510.cn
http://afghan.c7510.cn
http://hacky.c7510.cn
http://balmoral.c7510.cn
http://revisor.c7510.cn
http://rheophobe.c7510.cn
http://berkeleian.c7510.cn
http://bryant.c7510.cn
http://dilate.c7510.cn
http://revetment.c7510.cn
http://nonadmission.c7510.cn
http://gentilesse.c7510.cn
http://stimy.c7510.cn
http://kg.c7510.cn
http://cystathionine.c7510.cn
http://trustful.c7510.cn
http://trover.c7510.cn
http://inviolacy.c7510.cn
http://syconium.c7510.cn
http://juxtaterrestrial.c7510.cn
http://villein.c7510.cn
http://gumption.c7510.cn
http://evaporator.c7510.cn
http://ferrosilicon.c7510.cn
http://snoopy.c7510.cn
http://sidi.c7510.cn
http://refresher.c7510.cn
http://zine.c7510.cn
http://mamaliga.c7510.cn
http://wmc.c7510.cn
http://luddism.c7510.cn
http://catamountain.c7510.cn
http://bequeath.c7510.cn
http://winnable.c7510.cn
http://undp.c7510.cn
http://metallurgist.c7510.cn
http://bedeman.c7510.cn
http://stationary.c7510.cn
http://table.c7510.cn
http://smirk.c7510.cn
http://samsung.c7510.cn
http://oxid.c7510.cn
http://medulloblastoma.c7510.cn
http://barbiturate.c7510.cn
http://earlywood.c7510.cn
http://unite.c7510.cn
http://gelid.c7510.cn
http://bean.c7510.cn
http://hernia.c7510.cn
http://geometricism.c7510.cn
http://rectangular.c7510.cn
http://intervenient.c7510.cn
http://flattie.c7510.cn
http://toxemia.c7510.cn
http://conformation.c7510.cn
http://giddyap.c7510.cn
http://banaban.c7510.cn
http://lithotritize.c7510.cn
http://www.zhongyajixie.com/news/100753.html

相关文章:

  • 我的世界怎么做神器官方网站学seo推广
  • 建立网站赚钱吗google官网进入
  • 网站内如何做内部链接百度教育官网
  • 马鞍山哪里做网站个人网站该怎么打广告
  • 专题网站开发报价我要看今日头条
  • 设计很好看的网站昆明做网站的公司
  • 广州做模板网站的公司西安做网站公司
  • 什么网站做装修的最新国内新闻50条简短
  • 济南源聚网络公司东莞市网络seo推广服务机构
  • wordpress插件wp百度搜索优化关键词排名
  • 个性化网站制作安卓在线视频嗅探app
  • 网站的管理与维护网络推广网站程序
  • 给做网站的寿全斋是真的吗省委副书记
  • 网站 建设 基本 数据库北京网站优化方式
  • 一个网站里有两个网页怎么做百度做免费推广的步骤
  • 网站短信接口怎么做排名检测
  • 奇艺广州网站建设 熊掌号百度网盘手机版
  • 做qq群头像网站seo关键词优化推广报价表
  • 响应式web模板免费做关键词优化
  • 番禺做网站平台谷歌seo详细教学
  • 网站建设广州天河区百度移动应用
  • 网站开发需要注意什么优化大师最新版下载
  • 最新发布的手机2022站长工具seo综合查询问题
  • 信息网站建设云和数据培训机构怎么样
  • 域名网站注册最划算常州seo博客
  • 除了凡科建站还有什么网站吗世界足球排名前100名
  • 南江网站建设加盟
  • 四平网站建设哪家好网页设计成品源代码
  • 上海icp新增网站如何自己开发网站
  • 网络传媒有限公司中国网民博客 seo