Переглянути джерело

feat: 新增 去登录 横幅

YuJing 1 місяць тому
батько
коміт
8be01227e6

+ 1 - 2
commons/basic/src/main/ets/utils/arkts/utils/ContextHelper.ets

@@ -84,9 +84,8 @@ export class ContextHelper {
   /**
    * 依赖上下文的工具类初始化 需要在第一个页面中设置UIContext后调用
    * @param context 上下文对象
-   * @param isOnline 是否为在线app
    */
-  static init(context: UIContext, oldContext: Context, isOnline: boolean = true) {
+  static init(context: UIContext, oldContext: Context) {
     ContextHelper.UIContext = context
     ContextHelper._oldContext = oldContext
 

+ 1 - 1
features/feature/src/main/ets/components/BuilderIndex.ets

@@ -1,4 +1,4 @@
-import { CustomTextStyle } from "../style/TextStyle"
+import { CustomTextStyle } from "../style/CustomTextStyle"
 
 @Builder
 export function tagItemComp(text: string, fontColor: ResourceColor, bgColor: ResourceColor){

+ 1 - 1
features/feature/src/main/ets/components/DeerSearch.ets

@@ -1,5 +1,5 @@
 import { YTButton } from "basic"
-import { CustomTextStyle } from "../style/TextStyle"
+import { CustomTextStyle } from "../style/CustomTextStyle"
 
 @ComponentV2
 export struct DeerSearch {

+ 71 - 0
features/feature/src/main/ets/components/ytBuildComp.ets

@@ -0,0 +1,71 @@
+import { EmitterKeyCollection, userInfo, yTRouter } from "basic"
+import { emitter } from "@kit.BasicServicesKit"
+import { CustomTextStyle } from "../style/CustomTextStyle"
+
+@ComponentV2
+export struct ytBuildComp {
+  @BuilderParam container: () => void
+
+  @Local isLogin: boolean = false
+
+  toLogin = () => {
+    yTRouter.router2LoginPage(false)
+  }
+
+  aboutToAppear(): void {
+    emitter.on(EmitterKeyCollection.LOGIN, () => {
+      this.isLogin = true
+    })
+    emitter.on(EmitterKeyCollection.LOGOUT, () => {
+      this.isLogin = false
+    })
+    this.isLogin = userInfo.checkLogin()
+  }
+
+  build() {
+    RelativeContainer(){
+      Column(){
+        this.container()
+      }
+      .width("100%")
+      .height("100%")
+      .alignRules({
+        top: { anchor: "__container__", align: VerticalAlign.Top},
+        left: { anchor: "__container__", align: HorizontalAlign.Start},
+      })
+
+      if(!this.isLogin){
+        Row() {
+          Row(){
+            Text("登录使用更多功能")
+              .attributeModifier(new CustomTextStyle({size: 16, weight: 400, color: '#B31C1C1C'}))
+
+            Text("马上登录")
+              .borderRadius(32)
+              .border({width: 1})
+              .onClick(this.toLogin)
+              .backgroundColor('#FFFECF2F')
+              .padding({ top: 8, bottom: 8, left: 16, right: 16 })
+              .attributeModifier(new CustomTextStyle({size: 12, weight: 400, color: '#FF000000'}))
+          }
+          .width("100%")
+          .borderRadius(8)
+          .backgroundColor(Color.White)
+          .justifyContent(FlexAlign.SpaceBetween)
+          .shadow({ radius: 32, color: '#000000' })
+          .padding({ left: 15, right: 15, top: 17, bottom: 17 })
+        }
+        .width("100%")
+        .alignItems(VerticalAlign.Center)
+        .backgroundColor(Color.Transparent)
+        .padding({ left: 20, right: 20, bottom: 18 })
+        .alignRules({
+          bottom: { anchor: "__container__", align: VerticalAlign.Bottom},
+          left: { anchor: "__container__", align: HorizontalAlign.Start},
+        })
+      }
+    }
+    .width("100%")
+    .height("100%")
+  }
+}

+ 5 - 0
features/feature/src/main/ets/pages/BookListPage.ets

@@ -18,3 +18,8 @@ struct BookListPage {
     .hideTitleBar(true)
   }
 }
+
+@Builder
+function BookListBuilder() {
+  BookListPage()
+}

+ 0 - 0
features/feature/src/main/ets/style/TextStyle.ets → features/feature/src/main/ets/style/CustomTextStyle.ets


+ 141 - 138
features/feature/src/main/ets/view/MainView.ets

@@ -1,7 +1,8 @@
 import { BasicType } from "basic"
 import { tagItemComp } from "../components/BuilderIndex"
 import { DeerSearch } from "../components/DeerSearch"
-import { CustomTextStyle } from "../style/TextStyle"
+import { ytBuildComp } from "../components/ytBuildComp"
+import { CustomTextStyle } from "../style/CustomTextStyle"
 import { MainViModel } from "../viewModel/MainViewModel"
 
 @ComponentV2
@@ -9,175 +10,177 @@ export struct MainView {
   vm: MainViModel = new MainViModel()
 
   build() {
-    Column() {
-      Stack({alignContent: Alignment.Top}){
-        List(){
-          // logo
-          ListItem(){
-            Text('京东快递合作伙伴')
-              .attributeModifier(new CustomTextStyle({size: 12, weight: 600}))
-              .padding({top: this.vm.safeTop})
-          }
-          .padding({bottom: 13})
+    ytBuildComp(){
+      Column() {
+        Stack({alignContent: Alignment.Top}){
+          List(){
+            // logo
+            ListItem(){
+              Text('京东快递合作伙伴')
+                .attributeModifier(new CustomTextStyle({size: 12, weight: 600}))
+                .padding({top: this.vm.safeTop})
+            }
+            .padding({bottom: 13})
 
-          // 搜索框
-          ListItem(){
-            DeerSearch()
-          }
+            // 搜索框
+            ListItem(){
+              DeerSearch()
+            }
 
 
 
-          ListItem(){
-            Column(){
-              // 轮播
-              Swiper(){
-                Row()
-                  .height(150)
-                  .width('100%')
-                  .backgroundColor(Color.Orange)
-              }
-              .height(150)
-              .width("100%")
-              .enabled(false)
-              .indicator(false)
-              .borderRadius(30)
+            ListItem(){
+              Column(){
+                // 轮播
+                Swiper(){
+                  Row()
+                    .height(150)
+                    .width('100%')
+                    .backgroundColor(Color.Orange)
+                }
+                .height(150)
+                .width("100%")
+                .enabled(false)
+                .indicator(false)
+                .borderRadius(30)
 
 
-              // 功能
-              Row(){
-                ForEach(this.vm.function1, (item: BasicType, index) => {
-                  Column({space: 5}){
-                    Image(item.src)
-                      .width(60)
-                      .aspectRatio(1)
+                // 功能
+                Row(){
+                  ForEach(this.vm.function1, (item: BasicType, index) => {
+                    Column({space: 5}){
+                      Image(item.src)
+                        .width(60)
+                        .aspectRatio(1)
 
-                    Text(item.text)
-                      .attributeModifier(new CustomTextStyle({size: 14, weight: 600}))
-                  }
-                  .onClick(item.click)
-                })
-              }
-              .width("100%")
-              .margin({top: 22})
-              .justifyContent(FlexAlign.SpaceAround)
+                      Text(item.text)
+                        .attributeModifier(new CustomTextStyle({size: 14, weight: 600}))
+                    }
+                    .onClick(item.click)
+                  })
+                }
+                .width("100%")
+                .margin({top: 22})
+                .justifyContent(FlexAlign.SpaceAround)
 
 
-              // 榜单
-              Row({space: 7}){
-                ForEach(['畅销版单TOP', '月度推荐'], (item: string, index) => {
-                  Column({space: 5}){
-                    Text(item)
-                      .attributeModifier(new CustomTextStyle({size: 16, weight: 600, color: '#663815'}))
+                // 榜单
+                Row({space: 7}){
+                  ForEach(['畅销版单TOP', '月度推荐'], (item: string, index) => {
+                    Column({space: 5}){
+                      Text(item)
+                        .attributeModifier(new CustomTextStyle({size: 16, weight: 600, color: '#663815'}))
 
-                    Text('查看更多>>')
-                      .attributeModifier(new CustomTextStyle({size: 12, weight: 600, color: index == 0 ?'#B27500' : '#E45C0B'}))
-                  }
-                  .layoutWeight(1)
-                  .aspectRatio(1)
-                  .justifyContent(FlexAlign.Start)
-                  .alignItems(HorizontalAlign.Start)
-                  .padding({left: 15, top: 17, right: 15, bottom: 17})
-                  .backgroundImage( index == 0 ?
+                      Text('查看更多>>')
+                        .attributeModifier(new CustomTextStyle({size: 12, weight: 600, color: index == 0 ?'#B27500' : '#E45C0B'}))
+                    }
+                    .layoutWeight(1)
+                    .aspectRatio(1)
+                    .justifyContent(FlexAlign.Start)
+                    .alignItems(HorizontalAlign.Start)
+                    .padding({left: 15, top: 17, right: 15, bottom: 17})
+                    .backgroundImage( index == 0 ?
                     $r('[basic].media.png_TopRecommend') :
                     $r('[basic].media.png_MonthRecommend') )
-                  .backgroundImageSize({ width: '100%', height: '100%'})
-                  .onClick(() => {
-                    // todo 完成榜单的跳转
+                    .backgroundImageSize({ width: '100%', height: '100%'})
+                    .onClick(() => {
+                      // todo 完成榜单的跳转
+                    })
                   })
-                })
-              }
-              .width("100%")
-              .margin({top: 18})
+                }
+                .width("100%")
+                .margin({top: 18})
 
 
-              // 新书上架
-              Column({space: 18}){
-                Row({space: 8}){
-                  Text('新书上架')
-                    .attributeModifier(new CustomTextStyle({size: 16, weight: 600}))
+                // 新书上架
+                Column({space: 18}){
+                  Row({space: 8}){
+                    Text('新书上架')
+                      .attributeModifier(new CustomTextStyle({size: 16, weight: 600}))
 
-                  Text('查看更多>>')
-                    .attributeModifier(new CustomTextStyle({size: 12, weight: 600, color: '#807A66'}))
-                }
-                .width("100%")
-                .justifyContent(FlexAlign.Start)
-                .alignItems(VerticalAlign.Bottom)
-
-                Grid(){
-                  ForEach(new Array(4).fill(''), (item: string, index) => {
-                    GridItem(){
-                      Column(){
-                        Image('https://th.bing.com/th/id/R.8bbf769b39bb26eefb9b6de51c23851d?rik=crTnc5i8A%2b8p7A&riu=http%3a%2f%2fpicview.iituku.com%2fcontentm%2fzhuanji%2fimg%2f202207%2f09%2fe7196ac159f7cf2b.jpg%2fnu&ehk=DYPLVpoNAXLj5qzwgR5vHf9DladFh%2b34s4UcuP3Kn6E%3d&risl=&pid=ImgRaw&r=0')
-                          .width('100%')
-                          .aspectRatio(148/100)
-
-                        Column({space: 5}){
-                          Text('红楼梦幼儿美绘本 第四卷红楼梦幼儿美绘本 第四卷')
-                            .maxLines(2)
-                            .textOverflow({overflow: TextOverflow.Ellipsis})
-                            .attributeModifier(new CustomTextStyle({size: 14, weight: 400}))
-
-                          Row({space: 8}){
-                            tagItemComp('情绪价值', '#4EB1EF', '#EDF7FD')
-                            tagItemComp('3-8岁', '#FC9911', '#FFF5E7')
+                    Text('查看更多>>')
+                      .attributeModifier(new CustomTextStyle({size: 12, weight: 600, color: '#807A66'}))
+                  }
+                  .width("100%")
+                  .justifyContent(FlexAlign.Start)
+                  .alignItems(VerticalAlign.Bottom)
+
+                  Grid(){
+                    ForEach(new Array(4).fill(''), (item: string, index) => {
+                      GridItem(){
+                        Column(){
+                          Image('https://th.bing.com/th/id/R.8bbf769b39bb26eefb9b6de51c23851d?rik=crTnc5i8A%2b8p7A&riu=http%3a%2f%2fpicview.iituku.com%2fcontentm%2fzhuanji%2fimg%2f202207%2f09%2fe7196ac159f7cf2b.jpg%2fnu&ehk=DYPLVpoNAXLj5qzwgR5vHf9DladFh%2b34s4UcuP3Kn6E%3d&risl=&pid=ImgRaw&r=0')
+                            .width('100%')
+                            .aspectRatio(148/100)
+
+                          Column({space: 5}){
+                            Text('红楼梦幼儿美绘本 第四卷红楼梦幼儿美绘本 第四卷')
+                              .maxLines(2)
+                              .textOverflow({overflow: TextOverflow.Ellipsis})
+                              .attributeModifier(new CustomTextStyle({size: 14, weight: 400}))
+
+                            Row({space: 8}){
+                              tagItemComp('情绪价值', '#4EB1EF', '#EDF7FD')
+                              tagItemComp('3-8岁', '#FC9911', '#FFF5E7')
+                            }
+                            .width("100%")
+                            .justifyContent(FlexAlign.Start)
                           }
                           .width("100%")
-                          .justifyContent(FlexAlign.Start)
+                          .padding({left: 8, right: 8, top: 8, bottom: 8})
                         }
-                        .width("100%")
-                        .padding({left: 8, right: 8, top: 8, bottom: 8})
+                        .width('100%')
+                        .borderRadius(8)
+                        .aspectRatio(152/180)
+                        .backgroundColor(Color.White)
+                        .border({width: 2, color: '#000000'})
                       }
-                      .width('100%')
-                      .borderRadius(8)
-                      .aspectRatio(152/180)
-                      .backgroundColor(Color.White)
-                      .border({width: 2, color: '#000000'})
-                    }
-                  })
+                    })
+                  }
+                  .rowsGap(16)
+                  .maxCount(2)
+                  .width("100%")
+                  .columnsGap(10)
+                  .layoutWeight(1)
+                  .columnsTemplate('repeat(2, 1fr)')
                 }
-                .rowsGap(16)
-                .maxCount(2)
+                .height(500)
+                .height(470)
                 .width("100%")
-                .columnsGap(10)
-                .layoutWeight(1)
-                .columnsTemplate('repeat(2, 1fr)')
+                .margin({top: 25})
+                .padding({left: 18, right: 18, top: 20})
+                .backgroundImage($r('[basic].media.png_newBook'))
+                .backgroundImageSize({width: '100%', height: '100%'})
               }
-              .height(500)
-              .height(470)
               .width("100%")
-              .margin({top: 25})
-              .padding({left: 18, right: 18, top: 20})
-              .backgroundImage($r('[basic].media.png_newBook'))
-              .backgroundImageSize({width: '100%', height: '100%'})
             }
-            .width("100%")
-          }
-          .margin({top: 13})
+            .margin({top: 13})
 
 
 
-          ListItem(){}
-          .padding({ bottom: 16 })
-        }
-        .width('100%')
-        .height('100%')
-        .scrollBar(BarState.Off)
-        .padding({ left: 16, right: 16 })
-        .onScrollIndex((index: number) => {
-          this.vm.scrollIndex = index
-          console.log(`index = ${JSON.stringify(index)}`)
-        })
-
-        if(this.vm.scrollIndex > 0){
-          Row(){
-            this.deerTitleComp()
+            ListItem(){}
+            .padding({ bottom: 16 })
+          }
+          .width('100%')
+          .height('100%')
+          .scrollBar(BarState.Off)
+          .padding({ left: 16, right: 16 })
+          .onScrollIndex((index: number) => {
+            this.vm.scrollIndex = index
+            console.log(`index = ${JSON.stringify(index)}`)
+          })
+
+          if(this.vm.scrollIndex > 0){
+            Row(){
+              this.deerTitleComp()
+            }
+            .transition(TransitionEffect.asymmetric(TransitionEffect.move(TransitionEdge.TOP), TransitionEffect.move(TransitionEdge.TOP)).animation({ duration: 100 }))
           }
-          .transition(TransitionEffect.asymmetric(TransitionEffect.move(TransitionEdge.TOP), TransitionEffect.move(TransitionEdge.TOP)).animation({ duration: 100 }))
         }
       }
+      .width('100%')
+      .linearGradient({ colors: [['#F9EDAE', 0], ['#FFFFFF', 0.4]] })
     }
-    .width('100%')
-    .linearGradient({ colors: [['#F9EDAE', 0], ['#FFFFFF', 0.4]] })
   }
 
   @Builder

+ 7 - 1
features/feature/src/main/resources/base/profile/router_map.json

@@ -1,3 +1,9 @@
 {
-  "routerMap": []
+  "routerMap": [
+    {
+      "name": "BookListPage",
+      "pageSourceFile": "src/main/ets/pages/BookListPage.ets",
+      "buildFunction": "BookListBuilder"
+    }
+  ]
 }