往期鸿蒙全套实战精彩文章必看内容:
- 鸿蒙开发焦点知识点,看这篇文章就够了
- 最新版!鸿蒙HarmonyOS Next应用开发实战学习蹊径
- 鸿蒙HarmonyOS NEXT开发技能最全学习蹊径指南
- 鸿蒙应用开发实战项目,看这一篇文章就够了(部门项目附源码)
本项目采取前后端分离计划,后端利用Apache+MySql+PHP,前端为鸿蒙原生。实现了完备的注册、登录、商品分类、购物车、购买、我的订单等功能,管理员可以在后端数据库对用户和商品举行增编削查操纵。
完备效果图:
下面跟各人分享本项目标一些知识要点。
首页部门是一个List组件,内部门为三部门,banner图利用Swiper组件,商品分类和商品列表都利用Grid组件,详细代码如下:
- List({space:8}){
- ListItem(){
- Swiper() {
- ForEach(this.data, (item:Resource) => {
- Image(item)
- .size({ width: '100%', height: 200 })
- .borderRadius(12)
- .padding(8)
- })
- }
- }
-
- ListItem(){
- Grid(){
- ForEach(this.classData,(item:object,index:number) => {
- GridItem(){
- Column(){
- Image(item['cover'])
- .width('100%')
- .height('80%')
- Text(item['classname'])
- .fontColor(Color.Black)
- .fontSize(14)
- .margin({top:3})
- }
- }
- .width(70)
- .height(90)
- })
- }
- .columnsTemplate('1fr 1fr 1fr 1fr')
- .rowsTemplate('1fr 1fr')
- .width('100%')
- .height(200)
- .backgroundColor(Color.White)
- }
- .width('100%')
- .height(200)
- ListItem(){
- Grid(){
- ForEach(this.goods,(item:object,index:number) => {
- GridItem(){
- Column(){
- Image(item['cover'])
- .width('100%')
- .height((this.screen_width - 25)/2)
- Text(item['name'])
- .fontColor(Color.Black)
- .fontSize(17)
- .margin({top:4})
- .fontWeight(FontWeight.Bold)
- .maxLines(2)
- Text(item['price'])
- .fontColor(Color.Red)
- .fontSize(15)
- .margin({top:6})
- }
- .alignItems(HorizontalAlign.Start)
- }
- .width((this.screen_width - 24)/2)
- .height(this.listHeight)
- })
- }
- .backgroundColor(Color.White)
- .columnsTemplate('1fr 1fr')
- .rowsGap(5)
- .columnsGap(5)
- .width('100%')
- }
- .width('100%')
- }
- .width('100%')
- .height('100%')
复制代码 分类界面分为两部门,左侧利用List组件,右侧利用Grid组件,点击List列表后革新右侧网格列表。

代码如下:
- Row() {
- List(){
- ForEach(this.classData,(item:object,index)=>{
- ListItem(){
- Text(item['classname'])
- .fontColor(Color.Gray)
- .fontSize(17)
- }
- .backgroundColor(index == this.classIndex? 'rgb(255,255,255)' : 'rgb(240,240,240)')
- .width(100)
- .height(55)
- .onClick(()=>{
- this.getSubClass(item['id'])
- this.classIndex = index
- })
- })
- }
- .width(100)
- .height('100%')
- .backgroundColor(Color.White)
- Grid(){
- ForEach(this.subClassData,(item:object,index)=>{
- GridItem(){
- Column(){
- Image(item['cover'])
- .width('100%')
- .height((this.screen_width - 100)/3)
- Text(item['name'])
- .fontSize(15)
- .fontColor(Color.Black)
- }
- .onClick(()=>{
-
- })
- }
- .backgroundColor(Color.White)
- .width((this.screen_width - 100)/3)
- .height((this.screen_width - 100)/3 + 20)
- })
- }
- .columnsTemplate('1fr 1fr 1fr')
- .columnsGap(5)
- .rowsGap(5)
- .width(this.screen_width - 100)
- .height('100%')
- }
复制代码 其他页面也都比力简朴,大多数利用list组件实现。
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |