ソースを参照

feat: 修改 app 的部分配置文件, 修改首页数据的展示

YuJing 1 ヶ月 前
コミット
88823431f2

+ 1 - 1
AppScope/resources/base/element/string.json

@@ -2,7 +2,7 @@
   "string": [
     {
       "name": "app_name",
-      "value": "YTSketch"
+      "value": "鹿学长"
     }
   ]
 }

BIN
AppScope/resources/base/media/app_icon.png


BIN
AppScope/resources/base/media/foreground.png


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

@@ -153,8 +153,8 @@ class YTRouter extends NavPathStack {
   }
 
   // 进入书籍详情页面
-  router2BookItemDetailPage(book?: BookItem){
-    this.pushPathByName('BookItemDetailPage', book)
+  router2BookItemDetailPage(book: BookItem){
+    this.pushPathByName('BookItemDetailPage', new BookItem(book))
   }
 
   // 进入订单详情确认页

+ 3 - 2
features/feature/src/main/ets/apis/BookListApi.ets

@@ -1,4 +1,4 @@
-import { BookItem, YTRequest } from "basic";
+import { BookItem, userInfo, YTRequest } from "basic";
 import { BookListItem, BookListTypeItem, BookListTypeList, HotSearchItem } from "../model/BookModelIndex";
 import { searchBookListQuery, searchBookQuery } from "../model/Query";
 import { PageResponse } from "../model/PageResponse";
@@ -56,7 +56,8 @@ class BookListApi {
    * @returns
    */
   getBookListDetail(bookListId: string): Promise<Array<BookItem>>{
-    return YTRequest.post<Array<BookItem>>(ApiUrl.getBookListDetail, {bookListId})
+    let userId: string = userInfo.getId()!
+    return YTRequest.post<Array<BookItem>>(ApiUrl.getBookListDetail, {bookListId, userId})
   }
 }
 

+ 9 - 2
features/feature/src/main/ets/components/BookItemComp.ets

@@ -1,4 +1,4 @@
-import { BookItem, yTRouter } from "basic"
+import { BookItem, userInfo, yTRouter } from "basic"
 import { OrderApi } from "../apis/OrderApi"
 import { CustomTextStyle } from "../style/CustomTextStyle"
 import { tagItemComp } from "./BuilderIndex"
@@ -11,7 +11,14 @@ export struct BookItemComp {
 
   @Event addCar: () => void
 
+  // 添加至购物车
   async addCarEvent(){
+    // 添加购物车需要校验是否登录
+    if (!userInfo.checkLogin()) {
+      yTRouter.router2LoginPage(true)
+      return
+    }
+
     if(this.item.schoolbagFlag == '0') {
       await OrderApi.addBookToBag(this.item.id!)
       this.item.schoolbagFlag = '1'
@@ -100,7 +107,7 @@ export struct BookItemComp {
           tagItemComp('情绪价值', '#FF4EB1EF', '#FFEDF7FD')
         }
 
-        Image(this.item.schoolbagFlag == '0' ? $r('[basic].media.icon_deerIncrease') : $r('[basic].media.icon_reduce'))
+        Image(this.item.schoolbagFlag == '1' ? $r('[basic].media.icon_reduce') : $r('[basic].media.icon_deerIncrease'))
           .width(24)
           .aspectRatio(1)
           .onClick(() => {

+ 8 - 6
features/feature/src/main/ets/view/MainView.ets

@@ -1,4 +1,4 @@
-import { BasicType, yTRouter } from "basic"
+import { BasicType, BookItem, yTRouter } from "basic"
 import { tagItemComp } from "../components/BuilderIndex"
 import { DeerSearch } from "../components/DeerSearch"
 import { ytBuildComp } from "../components/ytComp/ytBuildComp"
@@ -112,27 +112,29 @@ export struct MainView {
                 .alignItems(VerticalAlign.Bottom)
 
                 Grid(){
-                  ForEach(new Array(4).fill(''), (item: string, index) => {
+                  ForEach(this.vm.newBookList, (item: BookItem, 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')
+                        Image(item.coverUrl)
                           .width('100%')
                           .aspectRatio(148/100)
 
                         Column({space: 5}){
-                          Text('红楼梦幼儿美绘本 第四卷红楼梦幼儿美绘本 第四卷')
+                          Text(item.bookTitle)
                             .maxLines(2)
                             .textOverflow({overflow: TextOverflow.Ellipsis})
                             .attributeModifier(new CustomTextStyle({size: 14, weight: 400}))
 
                           Row({space: 8}){
                             tagItemComp('情绪价值', '#4EB1EF', '#EDF7FD')
-                            tagItemComp('3-8岁', '#FC9911', '#FFF5E7')
+                            tagItemComp(`${item.minAge}-${item.maxAge}岁`, '#FC9911', '#FFF5E7')
                           }
                           .width("100%")
                           .justifyContent(FlexAlign.Start)
                         }
                         .width("100%")
+                        .alignItems(HorizontalAlign.Start)
+                        .justifyContent(FlexAlign.SpaceBetween)
                         .padding({left: 8, right: 8, top: 8, bottom: 8})
                       }
                       .width('100%')
@@ -140,7 +142,7 @@ export struct MainView {
                       .aspectRatio(152/180)
                       .backgroundColor(Color.White)
                       .border({width: 2, color: '#000000'})
-                      .onClick(() => { yTRouter.router2BookItemDetailPage() })
+                      .onClick(() => { yTRouter.router2BookItemDetailPage(item) })
                     }
                   })
                 }

+ 16 - 1
features/feature/src/main/ets/view/viewModel/MainViewModel.ets

@@ -1,4 +1,6 @@
-import { BasicType, YTAvoid, YTRequest, yTRouter } from "basic"
+import { BasicType, BookItem, YTAvoid, YTRequest, yTRouter } from "basic"
+import { bookListApi } from "../../apis/BookListApi"
+import { searchBookQuery } from "../../model/Query"
 
 @ObservedV2
 export class MainViModel{
@@ -6,6 +8,8 @@ export class MainViModel{
 
   @Trace scrollIndex: number = 0
 
+  @Trace newBookList: Array<BookItem> = []
+
   // 功能栏
   function1: Array<BasicType> = [
     {
@@ -28,4 +32,15 @@ export class MainViModel{
       }
     },
   ]
+
+  constructor() {
+    this.getNewBookList()
+  }
+
+  async getNewBookList(){
+    let query: searchBookQuery = new searchBookQuery()
+
+    this.newBookList = (await bookListApi.searchBooks(query.clone())).slice(0, 4)
+  }
+
 }

+ 2 - 7
products/entry/src/main/ets/pages/EntryPage.ets

@@ -3,11 +3,6 @@
 @Entry
 @Component
 struct EntryPage {
-  // 渐变色
-  linear: LinearGradientOptions = {
-    colors: [ ['#EBF7FF', 0.3], ['#A9A8FF', 1] ],
-  }
-
   // 点击立刻体验按钮
   _onClick() {
     this.getUIContext().getRouter().pushUrl({ url: 'pages/PrivacyPage' })
@@ -23,10 +18,11 @@ struct EntryPage {
             .aspectRatio(1)
             .borderRadius(20)
 
-          Text($r('app.string.app_name'))
+          Text('欢迎来到鹿学长')
             .fontSize(18)
             .fontWeight(500)
             .fontColor(Color.Black)
+
         }
         .backgroundColor(Color.Transparent)
 
@@ -48,6 +44,5 @@ struct EntryPage {
     .height('100%')
     .alignItems(HorizontalAlign.Center)
     .justifyContent(FlexAlign.Center)
-    .linearGradient(this.linear)
   }
 }

+ 1 - 1
products/entry/src/main/resources/base/element/string.json

@@ -10,7 +10,7 @@
     },
     {
       "name": "EntryAbility_label",
-      "value": "label"
+      "value": "鹿学长"
     },
     {
       "name": "reason",

BIN
products/entry/src/main/resources/base/media/app_icon.png


BIN
products/entry/src/main/resources/base/media/foreground.png


BIN
products/entry/src/main/resources/base/media/startIcon.png