Parcourir la source

feat: 用户协议的阅读和同意Page, app 的图标和初始化

YuJing il y a 1 mois
Parent
commit
e2cc58a2cf

+ 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/background.png


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


+ 1 - 1
commons/basic/src/main/ets/components/generalComp/YTDiaLogComp.ets

@@ -1,4 +1,4 @@
-import { YTDiaLogModel } from 'feature/src/main/ets/model/YTDiaLogModel'
+import { YTDiaLogModel } from '../../models/YTDiaLogModel'
 import { yTRouter } from '../../utils/YTRouter'
 
 @ComponentV2

+ 6 - 1
commons/basic/src/main/ets/constants/index.ets

@@ -52,7 +52,12 @@ export enum AppStorageKeyCollect {
    * @type string
    * @description 推送token
    */
-  PUSH_TOKEN = 'pushToken'
+  PUSH_TOKEN = 'pushToken',
+  /**
+   * @type boolean
+   * @description 是否为第一次进入app, 并阅读、同意app 协议
+   */
+  FIRST_ENTER_APP = 'firstEnterApp'
 }
 
 export enum EmitterKeyCollection {

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

@@ -68,7 +68,7 @@ export class ContextHelper {
   static init(context: UIContext) {
     ContextHelper.UIContext = context
     PersistentStorage.persistProp(AppStorageKeyCollect.TOKEN, '')
-    YTUserRequest.refreshUserInfo()
+    PersistentStorage.persistProp(AppStorageKeyCollect.FIRST_ENTER_APP, false)
     permissionController.init(ContextHelper.context)
       .then(() => {
         permissionController

+ 64 - 0
features/feature/src/main/ets/pages/EntryPage.ets

@@ -0,0 +1,64 @@
+import { common } from '@kit.AbilityKit'
+import { yTRouter } from 'basic'
+
+@ComponentV2
+struct EntryPage {
+
+  // 点击立刻体验按钮
+  _onClick() {
+    yTRouter.pushPathByName('PrivacyPage', null)
+  }
+
+  // 重写返回事件
+  _onBack() {
+    // 点击返回直接关闭 app
+    (this.getUIContext().getHostContext() as common.UIAbilityContext).terminateSelf()
+    return true
+  }
+
+  build() {
+    NavDestination() {
+      Column() {
+        Column(){
+          Column({space: 13}){
+            Image($r('app.media.app_icon'))
+              .width(100)
+              .aspectRatio(1)
+              .borderRadius(20)
+
+            Text($r('app.string.app_name'))
+              .fontSize(18)
+              .fontWeight(500)
+          }
+
+          Blank()
+            .height(197)
+
+          Text("立刻体验")
+            .fontSize(22)
+            .fontWeight(500)
+            .borderRadius(20)
+            .fontColor('#FAFAFA')
+            .backgroundColor('#7186F9')
+            .padding({left: 25, top: 7, right: 25, bottom: 7})
+            .onClick(() => { this._onClick() })
+        }
+        .justifyContent(FlexAlign.SpaceBetween)
+      }
+      .width('100%')
+      .height('100%')
+      .alignItems(HorizontalAlign.Center)
+      .justifyContent(FlexAlign.Center)
+      .linearGradient({
+        colors: [ ['#EBF7FF', 0.3], ['#A9A8FF', 1] ],
+      })
+    }
+    .hideTitleBar(true)
+    .onBackPressed(() => { return this._onBack() })
+  }
+}
+
+@Builder
+function EntryPageBuilder() {
+  EntryPage()
+}

+ 125 - 0
features/feature/src/main/ets/pages/PrivacyPage.ets

@@ -0,0 +1,125 @@
+import { AppStorageKeyCollect, BasicType, YTAvoid, YTRequest, yTRouter } from 'basic'
+import { webview } from '@kit.ArkWeb'
+
+@ComponentV2
+struct PrivacyPage {
+  @Local safeTop: number = 30
+
+  // 倒计时
+  @Local time: number = 5
+
+  private webviewController: WebviewController = new webview.WebviewController()
+  private forEach: Array<BasicType> = [
+    {
+      text: '隐私政策',
+      message: 'https://hm-static.ytpm.net/friend/doc/%E9%9A%90%E7%A7%81%E6%94%BF%E7%AD%96.html'
+    }, {
+      text: '用户协议',
+      message: 'https://hm-static.ytpm.net/friend/doc/%E7%94%A8%E6%88%B7%E5%8D%8F%E8%AE%AE.html'
+    }
+  ]
+
+  _onBack(){
+    yTRouter.pop()
+    return true
+  }
+
+  // 同意
+  _onConfirm(){
+    AppStorage.set(AppStorageKeyCollect.FIRST_ENTER_APP, true)
+    yTRouter.clear()
+  }
+
+  aboutToAppear(): void {
+    this.safeTop = AppStorage.get(YTAvoid.SAFE_TOP_KEY) as number
+
+    let _c = setInterval(() => {
+      this.time--
+      if(this.time == 0) clearInterval(_c)
+    }, 1000)
+  }
+
+
+  build() {
+    NavDestination() {
+      Column({space: 40}) {
+        Text('隐私政策及用户协议')
+          .fontSize(18)
+          .fontWeight(500)
+
+        // Main
+        Column({space: 10}){
+          ForEach(this.forEach, (item: BasicType) => {
+              Column({ space: 8 }) {
+                Text(item.text)
+
+                Row() {
+                  Web({
+                    src: item.message,
+                    controller: this.webviewController,
+                    renderMode: RenderMode.ASYNC_RENDER // 设置渲染模式
+                  })
+                }
+                .height(225)
+                .width('100%')
+                .padding(8)
+                .border({ width: 1 })
+              }
+              .alignItems(HorizontalAlign.Start)
+          })
+
+          Blank().height(10)
+
+          Row(){
+            Text('我不同意并返回')
+              .fontSize(16)
+              .fontWeight(400)
+              .fontColor('#676767')
+              .onClick(() => { this._onBack() })
+
+            Text(`我已全部了解${this.time != 0 ? ' ('+this.time+')' : '' }`)
+              .fontSize(18)
+              .fontWeight(500)
+              .borderRadius(20)
+              .fontColor('#FAFAFA')
+              .enabled(this.time == 0)
+              .backgroundColor(this.time == 0 ?'#7186F9' : '#ffacbaf3')
+              .padding({ left: 20, top: 8, right: 20, bottom: 8 })
+              .onClick(() => { this._onConfirm() })
+          }
+          .width('100%')
+          .padding({top: 5, bottom: 5})
+          .alignItems(VerticalAlign.Center)
+          .justifyContent(FlexAlign.SpaceBetween )
+
+          Row(){
+            Text('*请仔细阅读以上协议内容,点击同意表示您已充分理解并接受协议条款')
+              .fontSize(10)
+              .fontWeight(400)
+              .fontColor('#F50000')
+          }
+          .padding({top: 5})
+          .width("100%")
+          .justifyContent(FlexAlign.Center)
+        }
+        .width('100%')
+        .layoutWeight(1)
+        .alignItems(HorizontalAlign.Start)
+        .justifyContent(FlexAlign.Start)
+      }
+      .width('100%')
+      .height('100%')
+      .padding({left: 16, right: 16})
+      .alignItems(HorizontalAlign.Center)
+      .justifyContent(FlexAlign.Center)
+    }
+    .hideTitleBar(true)
+    .padding({ top: this.safeTop })
+    .onBackPressed(() => { return this._onBack() })
+  }
+}
+
+@Builder
+function PrivacyPageBuilder() {
+  PrivacyPage()
+}

+ 8 - 0
features/feature/src/main/resources/base/profile/router_map.json

@@ -4,6 +4,14 @@
       "name": "YTNaviDiaLog",
       "pageSourceFile": "src/main/ets/pages/YTNaviDiaLog.ets",
       "buildFunction": "YTNaviDiaLogBuilder"
+    }, {
+      "name": "EntryPage",
+      "pageSourceFile": "src/main/ets/pages/EntryPage.ets",
+      "buildFunction": "EntryPageBuilder"
+    }, {
+      "name": "PrivacyPage",
+      "pageSourceFile": "src/main/ets/pages/PrivacyPage.ets",
+      "buildFunction": "PrivacyPageBuilder"
     }
   ]
 }

+ 20 - 6
products/entry/src/main/ets/pages/Index.ets

@@ -1,4 +1,4 @@
-import { BasicType, ContextHelper, YTAvoid, yTRouter } from 'basic';
+import { AppStorageKeyCollect, BasicType, ContextHelper, YTAvoid, yTRouter } from 'basic';
 import { Mine } from 'user/src/main/ets/views/Mine';
 import { MainView, SecondView, ThirdView } from 'feature';
 
@@ -10,30 +10,45 @@ struct Index {
   //tabs展示内容
   contentList: BasicType<undefined>[] = [
     {
-      text: '日历',
+      text: '学生',
+      // 未选中
       src: $r('app.media.app_icon'),
+      // 选中
       acSrc: $r('app.media.app_icon')
     },
     {
-      text: '黄历',
+      text: '座位',
       src: $r('app.media.app_icon'),
       acSrc: $r('app.media.app_icon')
     },
     {
-      text: '卡片',
+      text: '点名',
       src: $r('app.media.app_icon'),
       acSrc: $r('app.media.app_icon')
     },
     {
-      text: '我的',
+      text: '成绩',
+      src: $r('app.media.app_icon'),
+      acSrc: $r('app.media.app_icon')
+    }, {
+      text: '课程表',
       src: $r('app.media.app_icon'),
       acSrc: $r('app.media.app_icon')
     }
   ]
   tabsController: TabsController = new TabsController()
 
+  // 检查是否第一次打开 app(是否阅读并同意用户协议)
+  checkFirstEnterApp() {
+    let isFirst = AppStorage.get(AppStorageKeyCollect.FIRST_ENTER_APP)! as boolean
+    if(!isFirst) {
+      yTRouter.pushPathByName('EntryPage', null)
+    }
+  }
+
   aboutToAppear(): void {
     ContextHelper.init(this.getUIContext())
+    this.checkFirstEnterApp()
   }
 
   build() {
@@ -78,7 +93,6 @@ struct Index {
       .width('100%')
       .height('100%')
       .backgroundColor(Color.White)
-
     }
     .mode(NavigationMode.Stack)
     .hideToolBar(true)

+ 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/background.png


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


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