XUYangWei 2 mesi fa
parent
commit
0b45b20c5b

+ 2 - 1
commons/basic/Index.ets

@@ -50,11 +50,12 @@ export { yTRouter } from "./src/main/ets/utils/YTRouter"
 
 export * from "./src/main/ets/utils/YTBreakPoint"
 
-export { BasicType } from './src/main/ets/models/index'
+export { BasicType,coinItem } from './src/main/ets/models/index'
 
 export * from '@mumu/crop'
 
 export * from './src/main/ets/models'
+export {bigWheelDB,BigWheel}from './src/main/ets/utils/BigWheelDB'
 
 
 

+ 7 - 1
commons/basic/src/main/ets/models/index.ets

@@ -91,4 +91,10 @@ export const decisionItemList:DecisionItem[]=[
     icon:$r('app.media.rannum'),
     pageName: "RanNumberView"
   }
-]
+]
+//抛硬币需要存到本地
+export interface coinItem{
+  back:number,
+  fore:number,
+  currRes:string
+}

+ 127 - 0
commons/basic/src/main/ets/utils/BigWheelDB.ets

@@ -0,0 +1,127 @@
+import { relationalStore, ValuesBucket } from '@kit.ArkData'
+
+// 图片和视频文件关键信息。(PhotoKeys)
+export interface BigWheel extends ValuesBucket {
+  id: number | null // 新增时 id 为 null ,自动生成自增 id
+  title: string //
+  color: string //
+  angle: number //
+  rotate: number //
+  angleStart:number
+  angleEnd:number
+  proportion:number
+}
+
+class BigWheelDB {
+  private store: relationalStore.RdbStore | null = null
+  private tableName = 'BigWheel'
+  // 创建数据库的语句
+  private sqlCreate = `CREATE TABLE IF NOT EXISTS ${this.tableName} (
+        id INTEGER PRIMARY KEY AUTOINCREMENT,
+        title TEXT,
+        color TEXT,
+        angle INTEGER,
+        rotate INTEGER,
+        angleStart:INTEGER
+        angleEnd:INTEGER
+        proportion:INTEGER
+      )`
+
+  async getStoreInstance() {
+    // 如果数据库已存在,直接退出
+    if (this.store) {
+      return this.store
+    }
+    // 存储 store 方便下次直接获取
+    this.store = await relationalStore.getRdbStore(getContext(), {
+      name: this.tableName + '.db', // 数据库名称
+      securityLevel: relationalStore.SecurityLevel.S4 // 安全等级
+    })
+    this.store.executeSql(this.sqlCreate)
+    // 返回 store 实例
+    return this.store
+  }
+
+  // 新增
+  async insert(value: BigWheel) {
+    const store = await this.getStoreInstance()
+    const rowId = await store.insert(this.tableName, value)
+    return rowId > -1 ? Promise.resolve(rowId) : Promise.reject('insert error')
+  }
+
+  // 批量新增
+  async batchInsert(values: BigWheel[]) {
+    const store = await this.getStoreInstance()
+    const rowId = await store.batchInsert(this.tableName, values)
+    return rowId ? Promise.resolve(rowId) : Promise.reject('batchInsert error')
+  }
+
+  // 更新
+  async update(item: BigWheel) {
+    if (!item.id) {
+      return Promise.reject('id error')
+    }
+    const store = await this.getStoreInstance()
+    const predicates = new relationalStore.RdbPredicates(this.tableName)
+    predicates.equalTo('id', item.id)
+    const rowCount = await store.update(item, predicates)
+    return rowCount ? Promise.resolve(rowCount) : Promise.reject('update error')
+  }
+
+  // 删除
+  async delete(id: number) {
+    const store = await this.getStoreInstance()
+    const predicates = new relationalStore.RdbPredicates(this.tableName)
+    predicates.equalTo('id', id)
+    const rowCount = await store.delete(predicates)
+    return rowCount ? Promise.resolve(rowCount) : Promise.reject('delete error')
+  }
+
+  // 批量删除
+  async batchDelete(ids: number[]) {
+    const store = await this.getStoreInstance()
+    const predicates = new relationalStore.RdbPredicates(this.tableName)
+    predicates.in('id', ids)
+    const rowCount = await store.delete(predicates)
+    return rowCount ? Promise.resolve(rowCount) : Promise.reject('delete error')
+  }
+
+  // 查询
+  async query(id?: number) {
+    const store = await this.getStoreInstance()
+    const predicates = new relationalStore.RdbPredicates(this.tableName)
+    // 如果有 id
+    if (id) {
+      predicates.equalTo('id', id)
+    }
+    const resultSet = await store.query(predicates)
+    const list: BigWheel[] = []
+    while (resultSet.goToNextRow()) {
+      // 获取数据
+      const data: BigWheel = {
+        id: resultSet.getLong(resultSet.getColumnIndex('id')),
+        title: resultSet.getString(resultSet.getColumnIndex('title')),
+        color: resultSet.getString(resultSet.getColumnIndex('color')),
+        angle: resultSet.getLong(resultSet.getColumnIndex('angle')),
+        rotate: resultSet.getLong(resultSet.getColumnIndex('rotate')),
+        angleStart: resultSet.getLong(resultSet.getColumnIndex('angleStart')),
+        angleEnd: resultSet.getLong(resultSet.getColumnIndex('angleEnd')),
+        proportion: resultSet.getLong(resultSet.getColumnIndex('proportion')),
+      }
+      // 追加到数组中
+      list.push(data)
+    }
+    // 释放资源
+    resultSet.close()
+    return list
+  }
+
+  // 查询数量
+  async queryCount() {
+    const store = await this.getStoreInstance()
+    const predicates = new relationalStore.RdbPredicates(this.tableName)
+    const resultSet = await store.query(predicates)
+    return resultSet.rowCount > 0 ? resultSet.rowCount : 0
+  }
+}
+export const bigWheelDB = new BigWheelDB()

+ 7 - 0
features/feature/src/main/ets/utils/Sector.ets

@@ -85,4 +85,11 @@ export class Cell {
     this.color = color; // 设置颜色
     this.id=id
   }
+}
+
+export interface CellStorage{
+  id:number,
+  title: string,
+  color: string,
+  proportion: number
 }

+ 243 - 63
features/feature/src/main/ets/view/BigWheelView.ets

@@ -1,6 +1,8 @@
-import { YTAvoid, YTHeader, yTRouter } from 'basic'
-import { Cell, Sector } from '../utils/Sector';
+import { BigWheel, bigWheelDB, YTAvoid, YTHeader, yTRouter } from 'basic'
+import { Cell, CellStorage, Sector } from '../utils/Sector';
 import { CounterComponent, CounterType, promptAction } from '@kit.ArkUI';
+import { it } from '@ohos/hypium';
+import { JSON } from '@kit.ArkTS';
 
 
 @Builder
@@ -15,7 +17,15 @@ function BigWheelViewBuilder(){
 struct BigWheelView{
   @StorageProp(YTAvoid.SAFE_TOP_KEY) safeBottom: number = 0
 
+  //持久化的数组,方便下次打开应用直接承接上一次的数据
+  @StorageLink('bigwheel')
+  DBCells:CellStorage[]=[]
+  @StorageLink('unselectbigwheel')
+  DBUnselectCell:Cell[]=[]
+  @StorageLink('selectbigwheel')
+  DBSelectCell:Cell[]=[]
 
+  //转盘操作数组
   @State cells: Cell[] = []; // 存储单元格的数组
   //随着每次操作,需要触发画布重新画
   @Watch('drawCircleWithCustomRadii')
@@ -38,7 +48,7 @@ struct BigWheelView{
   private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings)
 
   //转盘选中判断
-  @State currSelectNumber:number=3
+  @State currSelectNumber:number=1
   @State number:number=4 //转盘数量
 
   //打开半模态命名模态
@@ -65,9 +75,10 @@ struct BigWheelView{
     "#fff",
   ];
   filter(){
-    //每次选中的数组有变化,那就要重新过滤
-    this.UnSelected = this.cells.filter(item =>
-    !this.selected.some(selected => selected.id === item.id));
+    //每次选中的数组有变化,那就要重新过滤,就要移除没选中的数组里面的数据
+  this.UnSelected = this.cells.filter(item => !this.selected.includes(item));
+
+
     // promptAction.showToast({
     //   message:JSON.stringify(this.UnSelected)
     // })
@@ -75,20 +86,105 @@ struct BigWheelView{
     // this.cells.map((item)=>{
     //
     // })
+    this.DBUnselectCell=this.UnSelected
+    this.DBSelectCell=this.selected
 
   }
 
-  // 组件即将出现时调用
-  aboutToAppear(): void {
-    // 初始化单元格
-    this.cells.push(new Cell(1,1, "转盘1", this.colorPalette[this.colorIndex++ % this.colorPalette.length]));
-    this.cells.push(new Cell(2,1, "转盘2", this.colorPalette[this.colorIndex++ % this.colorPalette.length]));
-    this.cells.push(new Cell(3,1, "转盘3", this.colorPalette[this.colorIndex++ % this.colorPalette.length]));
-    this.cells.push(new Cell(4,1, "转盘4", this.colorPalette[this.colorIndex++ % this.colorPalette.length]));
-    this.UnSelected=this.cells
+  async selectCount(){
+    return await bigWheelDB.queryCount()
+  }
 
+  // this.cells.push(new Cell(1, 1, "转盘1", this.colorPalette[this.colorIndex++ % this.colorPalette.length]));
+  // 组件即将出现时调用
+  aboutToAppear() {
+    if(this.DBCells.length==0) {
+      this.cells.push(new Cell(1, 1, "转盘1",'#fff' ));
+      this.cells.push(new Cell(2, 1, "转盘2", '#fff' ));
+      this.cells.push(new Cell(3, 1, "转盘3",'#fff' ));
+      this.cells.push(new Cell(4, 1, "转盘4", '#fff' ));
+
+      this.UnSelected=this.cells
+    }else{
+      this.DBCells.forEach((item)=>{
+        this.cells.push(new Cell(item.id,item.proportion,item.title,item.color))
+      })
+      this.number=this.cells.length
+      this.UnSelected=this.DBUnselectCell
+      this.selected=this.DBSelectCell
+
+      // this.DBSelectCell.forEach((item)=>{
+      //   this.selected.push(new Cell(item.id,item.proportion,item.title,item.color))
+      // })
+      this.currSelectNumber=this.number-3
+    }
+    // this.UnSelected=this.cells
     this.calculateAngles(); // 计算角度
   }
+  //动画
+  private startAnimation(){
+
+    if (this.isAnimating) { // 如果正在动画中,返回
+      return;
+    }
+    if(this.selected.length==this.cells.length){
+      return
+    }
+    //如果都已经被选了,则不能再转了
+    this.calculateNoSelectedAngles()
+    this.selectedName = ""; // 清空选中的名称
+    this.isAnimating = true; // 设置动画状态为正在动画
+    animateTo({ // 开始动画
+      duration: this.spinDuration, // 动画持续时间为5000毫秒
+      curve: Curve.EaseInOut, // 动画曲线为缓入缓出
+      onFinish: () => { // 动画完成后的回调
+        this.currentAngle %= 360; // 保持当前角度在0到360之间
+        for (const cell of this.cells) {
+          // 遍历每个单元格
+          // 检查当前角度是否在单元格的角度范围内
+          if (360 - this.currentAngle >= cell.angleStart && 360 - this.currentAngle <= cell.angleEnd) {
+            if(!this.isRepeat) {
+              this.selected.push(cell)
+              //这里需要下次点击的时候
+              cell.color = '#e5e7ea'
+            }else{
+              this.selected=[]
+            }
+            this.selectedName = cell.title; // 设置选中的名称为当前单元格的标题
+            //每次转弯要保存
+
+
+            break; // 找到后退出循环
+          }
+        }
+        this.DBCells=this.cells.map((item)=>{
+          return {
+            id:item.id,
+            title:item.title,
+            proportion:item.proportion,
+            color:item.color
+          } as CellStorage
+        })
+        this.isAnimating = false; // 设置动画状态为未动画
+      },
+    }, () => { // 动画进行中的回调
+      //在这里判断
+      // this.randomAngle=Math.floor(Math.random()*360)
+      // this.currentAngle += (360 * this.spinDuration/1000 + Math.floor(Math.random() * 360)); // 更新当前角度,增加随机旋转
+      //在这里算已经选过的,不能在指了
+
+      // this.currentAngle += (360 * this.spinDuration/1000 + Math.floor(Math.random() * 360)); // 更新当前角度,增加随机旋转
+
+      // promptAction.showToast({
+      //   message:this.randomAngle.toString()
+      // })
+      this.currentAngle += (360 * this.spinDuration/1000)+this.randomAngle
+
+
+
+    });
+
+  }
 
   // 计算每个单元格的角度
   private calculateAngles() {
@@ -105,12 +201,30 @@ struct BigWheelView{
       cell.angleEnd = cumulativeAngle; // 设置结束角度
       cell.rotate = cumulativeAngle - (cell.angle / 2); // 计算旋转角度
     });
+
+
+    // bigWheelDB.batchDelete(this.cells.map(item=>item.id))
+    // bigWheelDB.batchInsert(this.cells.map((item)=>{
+    //   return {
+    //     id:item.id,
+    //     title:item.title,
+    //     angle:item.angle,
+    //     proportion:item.proportion,
+    //     color:item.color,
+    //     angleEnd:item.angleEnd,
+    //     angleStart:item.angleStart,
+    //     rotate:item.rotate
+    //   } as BigWheel
+    // }))
     //触发画布
     this.changeCanvas++
   }
 
   private calculateNoSelectedAngles(){
     //在这里计算
+    if(this.isRepeat){
+      return
+    }
 
     if(this.UnSelected.length!=0) {
       //随机选取一个没有选中的角度范围扇形
@@ -165,6 +279,16 @@ struct BigWheelView{
 
   }
 
+  // aboutToDisappear(): void {
+  //   //组件销毁保存数据
+  //   this.DBCells=this.cells
+  //   this.DBUnselectCell=this.UnSelected
+  //   promptAction.showToast({
+  //     message:"xxx"
+  //   })
+  //
+  // }
+
   build() {
     Stack({alignContent:Alignment.Center}){
       Stack({alignContent:Alignment.Top}){
@@ -197,7 +321,39 @@ struct BigWheelView{
           Row(){
             Column(){}.width(24).height(24)
             // Image($r('[basic].media.voicemuisc')).width(24)
-            Text('重置').fontColor('rgba(0, 0, 0, 0.65)')
+            Text('重置').fontColor('rgba(0, 0, 0, 0.65)').onClick(()=>{
+
+              if(!this.isRepeat){
+                //背景色变成白色
+                this.cells.forEach((item)=>{
+                  item.color='#fff'
+                })
+              }else{
+
+              }
+              //重置,所有的转盘重新开始
+              // this.DBCells.forEach((item)=>{
+              //   this.cells.push(new Cell(item.id,item.proportion,item.title,item.color))
+              // })
+              this.selected=[]
+              this.UnSelected=[]
+              this.UnSelected=this.cells
+
+              this.DBUnselectCell=this.UnSelected
+              this.DBSelectCell=this.selected
+              this.DBCells=this.cells.map((item)=>{
+                return {
+                  id:item.id,
+                  title:item.title,
+                  proportion:item.proportion,
+                  color:item.color
+                } as CellStorage
+              })
+              // this.DBCells=this.cells
+              // this.UnSelected=this.DBUnselectCell
+              // this.selected=this.DBSelectCell
+
+            })
           }.width('100%')
           .justifyContent(FlexAlign.SpaceBetween)
           .padding({left:30,right:30})
@@ -263,51 +419,9 @@ struct BigWheelView{
               .height('70lpx') // 设置按钮高度
               .objectFit(ImageFit.Contain)
               .clickEffect({ level: ClickEffectLevel.LIGHT }) // 设置点击效果
-              .onClick(() => { // 点击按钮时的回调函数
-                if (this.isAnimating) { // 如果正在动画中,返回
-                  return;
-                }
-                if(this.selected.length==this.cells.length){
-                  return
-                }
-                //如果都已经被选了,则不能再转了
-                this.calculateNoSelectedAngles()
-                this.selectedName = ""; // 清空选中的名称
-                this.isAnimating = true; // 设置动画状态为正在动画
-                animateTo({ // 开始动画
-                  duration: this.spinDuration, // 动画持续时间为5000毫秒
-                  curve: Curve.EaseInOut, // 动画曲线为缓入缓出
-                  onFinish: () => { // 动画完成后的回调
-                    this.currentAngle %= 360; // 保持当前角度在0到360之间
-                    for (const cell of this.cells) { // 遍历每个单元格
-                      // 检查当前角度是否在单元格的角度范围内
-                      if (360 - this.currentAngle >= cell.angleStart && 360 - this.currentAngle <= cell.angleEnd) {
-                        this.selected.push(cell)
-                        //这里需要下次点击的时候
-                        cell.color='#202020'
-                        this.selectedName = cell.title; // 设置选中的名称为当前单元格的标题
-                        break; // 找到后退出循环
-                      }
-                    }
-                    this.isAnimating = false; // 设置动画状态为未动画
-                  },
-                }, () => { // 动画进行中的回调
-                  //在这里判断
-                  // this.randomAngle=Math.floor(Math.random()*360)
-                  // this.currentAngle += (360 * this.spinDuration/1000 + Math.floor(Math.random() * 360)); // 更新当前角度,增加随机旋转
-                  //在这里算已经选过的,不能在指了
-
-                  // this.currentAngle += (360 * this.spinDuration/1000 + Math.floor(Math.random() * 360)); // 更新当前角度,增加随机旋转
-
-                  // promptAction.showToast({
-                  //   message:this.randomAngle.toString()
-                  // })
-                  this.currentAngle += (360 * this.spinDuration/1000)+this.randomAngle
-
-
-
-                });
-              });
+              // .onClick(() => { // 点击按钮时的回调函数
+              //
+              // });
           }
           .width(`${this.wheelWidth+26}lpx`)
           .height(`${this.wheelWidth+26}lpx`)
@@ -362,6 +476,7 @@ struct BigWheelView{
             .height(44).borderRadius(20)
             .margin({top:107,bottom:48})
             .onClick(()=>{
+              this.startAnimation()
             })
           Row({space:15}) {
             ForEach([2,3,4,5],(item:number,index:number)=>{
@@ -371,17 +486,82 @@ struct BigWheelView{
                 .textAlign(TextAlign.Center)
                 .border({width:1,color:'#000000'})
                 .borderRadius('50%')
-                .backgroundColor(this.currSelectNumber==index+2?'#bff2ff':'#f2f2f2')
+                .backgroundColor(this.currSelectNumber==index?'#bff2ff':'#f2f2f2')
                 .onClick(()=>{
+                  promptAction.showToast({
+                    message:JSON.stringify(this.selected)
+                  })
+
                   this.currSelectNumber=index
                   this.number=item+1
+                  const arr=this.cells
                   this.cells=[]
-                  for(let i=0;i<this.number;i++){
-                    this.cells.push(new Cell(i+1,1, "转盘"+(i+1), this.colorPalette[i]));
+                  //如果选中的长度比之前要长
+                  if(this.number>arr.length) {
+                    for (let i = 0; i < this.number; i++) {
+                      if (i < arr.length) {
+                        this.cells.push(arr[i])
+                      }else{
+                      this.cells.push(new Cell(i + 1, 1, "转盘" + (i + 1), '#fff'));
+                    }
+                      }
+                  }else{
+                    //短
+                    for (let i = 0; i < this.number; i++) {
+                      this.cells.push(arr[i])
+                    }
+
                   }
+                  //要继承之前没选中的,选中的数组根据id
+                  // this.UnSelected=this.cells
+                  // this.selected=[]
                   this.calculateAngles(); // 重新计算角度
+                  //选中的和没选中的也要重新计算角度
+                  let selId=[] as number[]
+                  let unselId=[] as number[]
+                  //找到id重新过滤
+                  this.selected.forEach((selItem)=>{
+                    selId.push(selItem.id)
+                  })
+                  this.UnSelected.forEach((unselItem)=>{
+                    unselId.push(unselItem.id)
+                  })
+                  this.selected=[]
+                  this.UnSelected=[]
 
+                  this.cells.forEach((selItem)=>{
+                    selId.forEach((i)=>{
+                      if(i==selItem.id){
+                        this.selected.push(selItem)
+                      }
+                    })
+                  })
 
+                  this.cells.forEach((unselItem)=>{
+                    unselId.forEach((i)=>{
+                      if(i==unselItem.id){
+                        this.UnSelected.push(unselItem)
+                      }
+                    })
+                  })
+
+
+                  this.DBUnselectCell=this.UnSelected
+                  this.DBSelectCell=this.selected
+                  // promptAction.showToast({
+                  //   message:JSON.stringify(this.cells)
+                  // })
+                  this.DBCells=[]
+                  this.DBCells=this.cells.map((item)=>{
+                    return {
+                      id:item.id,
+                      title:item.title,
+                      proportion:item.proportion,
+                      color:item.color
+                    } as CellStorage
+                  })
+                  // this.UnSelected=this.DBUnselectCell
+                  // this.selected=this.DBSelectCell
                 })
             })
 

+ 14 - 0
features/feature/src/main/ets/view/EatWhatView.ets

@@ -48,6 +48,20 @@ struct EatWhatView{
 
   }
 
+  private getNearEat(){
+    YTUserRequest.getNearEatResult((res)=>{
+      if(res!=null) {  //筛子一样,吃什么一样
+        const result = res as ReqString
+        this.eatResult= result['foodName']
+      }
+    })
+  }
+
+
+  aboutToAppear(): void {
+    this.getNearEat()
+  }
+
 
   build() {
     Column() {

+ 65 - 29
features/feature/src/main/ets/view/MainView.ets

@@ -1,10 +1,11 @@
-import { DecisionItem, decisionItemList, YTAvoid, yTRouter } from "basic"
+import { DecisionItem, decisionItemList, userInfo, UserInfo, YTAvoid, yTRouter } from "basic"
 
 
 @Component
 export struct MainView {
   @StorageProp(YTAvoid.SAFE_TOP_KEY)
   top:number=0
+  @StorageProp(UserInfo.KEY) userInfo: UserInfo = userInfo
   build() {
     Column(){
       Row(){
@@ -28,38 +29,73 @@ export struct MainView {
       // .backgroundColor(Color.Green)
 
 
-      Column() {
-        List({ space: 10 }) {
-          ForEach(decisionItemList, (item: DecisionItem, index) => {
-            ListItem() {
-              Row() {
-                Text(item.title).fontSize(30)
-
+      Stack({alignContent:Alignment.Center}) {
+        Column() {
+          List({ space: 10 }) {
+            ForEach(decisionItemList, (item: DecisionItem, index) => {
+              ListItem() {
+                Row() {
+                  Text(item.title).fontSize(30)
+
+                }
+                .width('95%')
+                .height(100)
+                .borderRadius(20)
+                .backgroundImage(item.icon)
+                .backgroundImageSize({ width: '100%', height: 100 })
+                // .backgroundColor(Color.Red)
+                .justifyContent(FlexAlign.Center)
+                .onClick(() => {
+                  yTRouter.router2DecisionPage(item.pageName)
+                })
               }
-              .width('95%')
-              .height(100)
-              .borderRadius(20)
-              .backgroundImage(item.icon)
-              .backgroundImageSize({ width: '100%', height: 100 })
-              // .backgroundColor(Color.Red)
-              .justifyContent(FlexAlign.Center)
-              .onClick(() => {
-                yTRouter.router2DecisionPage(item.pageName)
-              })
+            })
+
+          }.margin({ top: 10 })
+          .alignListItem(ListItemAlign.Center)
+          .scrollBar(BarState.Off)
+
+        }
+        .offset({ y: -20 })
+        .layoutWeight(1)
+        .padding({ left: 10, right: 10 })
+        .borderRadius({ topLeft: 20, topRight: 20 })
+        .backgroundColor(Color.White)
+
+
+        if(!this.userInfo.checkLogin()) {
+          Column() {
+            Column(){
+
+            }.layoutWeight(1)
+            Row() {
+              Text('登录使用更多功能').fontColor(Color.White).fontSize(20)
+
+              Text('马上登录')
+                .padding({
+                  left: 8,
+                  right: 8,
+                  top: 6,
+                  bottom: 6
+                })
+                .backgroundColor('rgba(253, 84, 227, 1)')
+                .borderRadius(22)
             }
+            .width('100%')
+            .justifyContent(FlexAlign.SpaceBetween)
+            .padding({ left: 20, right: 20 })
+            .height(56)
+            .backgroundColor('rgba(26, 26, 26, 0.4)')
+          }
+          .layoutWeight(1)
+          .width('100%')
+          .onClick(() => {
+            yTRouter.router2LoginPage()
           })
+          .justifyContent(FlexAlign.End)
+        }
 
-        }.margin({top:10})
-        .alignListItem(ListItemAlign.Center)
-        .scrollBar(BarState.Off)
-
-      }
-      .offset({y:-20})
-      .layoutWeight(1)
-      .padding({left:10,right:10})
-      .borderRadius({topLeft:20,topRight:20})
-      .backgroundColor(Color.White)
-
+      }.layoutWeight(1)
 
 
 

+ 54 - 6
features/feature/src/main/ets/view/RanNumberView.ets

@@ -26,11 +26,17 @@ struct RanNumberView{
   // 是否允许生成的随机数重复
   // @State private isUnique: boolean = true;
   // 随机数生成的起始值
+
+  @State startText:string=""
+  @State endText:string=""
+  @State countText:string=""
+
   private startValue: number = 0;
   // 随机数生成的结束值
- private endValue: number = 0;
+  private endValue: number = 0;
   // 要生成的随机数个数
  private  countValue: number = 0;
+
   @State private randomNumberArr:number[]=[]
 
 
@@ -58,8 +64,26 @@ struct RanNumberView{
 
     })
   }
+  private getNearNumber(){
+    YTUserRequest.getNearNumberResult((res)=>{
+      if(res!=null) {  //筛子一样,吃什么一样
+        const result = res as ReqString
+        this.startValue = Number(result['minValue'])
+        this.startText=result['minValue']
+        this.endValue = Number(result['maxValue'])
+        this.endText=result['maxValue']
+        this.countValue = Number(result['count'])
+        this.countText=result['count']
+        this.generatedNumbers = result['results']
+        this.randomNumberArr = this.generatedNumbers.split(',').map(item => Number(item))
+      }
+    })
+  }
 
 
+  aboutToAppear(): void {
+    this.getNearNumber()
+  }
 
   build() {
     Column() {
@@ -100,10 +124,14 @@ struct RanNumberView{
         Row() {
           Text('取值范围:').margin({right:30})
           Column() {
-            TextInput({ text: $$this.startValue }) // 输入框,显示占位符
+            TextInput({text: $$this.startText }) // 输入框,显示占位符
               .width(46)
               .height(46)
+              .padding(0)
               .type(InputType.Number) // 设置输入类型为数字
+              .placeholderColor('rgba(0, 0, 0, 0.95)')
+              .textAlign(TextAlign.Center)
+              .fontColor('rgba(0, 0, 0, 0.95)')
               .borderRadius(8) // 设置圆角半径
               .backgroundColor(Color.White) // 设置背景颜色
               .showUnderline(false) // 不显示下划线
@@ -120,6 +148,7 @@ struct RanNumberView{
                   })
                   return
                 }
+                this.startText=value
                 this.startValue = Number(value)
 
               }); // 输入值变化时的处理
@@ -133,10 +162,14 @@ struct RanNumberView{
           // Line().width(10) // 设置分隔符宽度
           Column().width(27).height(1).backgroundColor('rgba(0, 0, 0, 0.35)').margin({left:4,right:4})
           Column() {
-          TextInput({text:$$this.endValue}) // 输入框,显示占位符
+          TextInput({text:$$this.endText}) // 输入框,显示占位符
             .width(46)
             .height(46)
+            .padding(0)
             .type(InputType.Number) // 设置输入类型为数字
+            .textAlign(TextAlign.Center)
+            .placeholderColor('rgba(0, 0, 0, 0.95)')
+            .fontColor('rgba(0, 0, 0, 0.95)')
             .borderRadius(8) // 设置圆角半径
             .backgroundColor(Color.White) // 设置背景颜色
             .showUnderline(false) // 不显示下划线
@@ -153,6 +186,7 @@ struct RanNumberView{
                 })
                 return
               }
+              this.endText=value
               this.endValue = Number(value)
             }); // 输入值变化时的处理
           }.width(50)
@@ -168,10 +202,14 @@ struct RanNumberView{
         Row() {
           Text('生成个数:').margin({right:30})
           Column() {
-          TextInput({text:$$this.countValue}) // 输入框,显示占位符
+          TextInput({text:$$this.countText}) // 输入框,显示占位符
             .width(46)
             .height(46)
+            .padding(0)
+            .textAlign(TextAlign.Center)
             .type(InputType.Number) // 设置输入类型为数字
+            .placeholderColor('rgba(0, 0, 0, 0.95)')
+            .fontColor('rgba(0, 0, 0, 0.95)')
             .borderRadius(8) // 设置圆角半径
             .backgroundColor(Color.White) // 设置背景颜色
             .showUnderline(false) // 不显示下划线
@@ -189,6 +227,7 @@ struct RanNumberView{
                 return
               }
 
+              this.countText=value
             this.countValue = Number(value)
 
             }); // 输入值变化时的处理
@@ -250,11 +289,20 @@ struct RanNumberView{
             })
             return
           }
+
+          if(this.endText==""){
+            this.endText="0"
+          }
+          if(this.startText==""){
+            this.startText="0"
+          }
+          if(this.countText==""){
+            this.countText="0"
+          }
+
           this.getNumber(this.countValue,this.endValue,this.startValue)
           //不随机生成,从后端拿
           // this.generateRandomNumbers()
-
-
         },
         btContent:'随机数生成'
 

+ 17 - 0
features/feature/src/main/ets/view/RollDiceView.ets

@@ -68,6 +68,23 @@ struct RollDiceView {
 
 
 
+  }
+  private getNearRollDice(){
+    YTUserRequest.getNearRollDiceResult((res)=>{
+      if(res!=null) {  //筛子一样,吃什么一样
+        const result = res as ReqString
+        this.number= Number(result['diceCount'])
+        this.currSelectNumber=this.number-1
+        this.RollDiceList= result['diceResults'].split(',').map(item=>{
+          return Number(item)-1
+        })
+      }
+    })
+  }
+
+
+  aboutToAppear(): void {
+    this.getNearRollDice()
   }
 
   build() {

+ 33 - 4
features/feature/src/main/ets/view/TossCoinView.ets

@@ -1,4 +1,4 @@
-import { ReqString, YTAvoid, YTHeader, YTUserRequest } from 'basic'
+import { coinItem, ReqString, YTAvoid, YTHeader, YTUserRequest } from 'basic'
 import { promptAction } from '@kit.ArkUI'
 
 @Builder
@@ -19,6 +19,10 @@ struct TossCoinView{
   @State verticalOffset: number = 0 // 纵向位移
   @State isAnimRun: boolean = false // 动画是否正在执行
 
+  @State isfore:boolean=true
+  @StorageLink('coinData')
+  coinReslut:coinItem={} as coinItem
+
   number1:number[]=[22,26,30,34]
   number2:number[]=[24,28,32,36]
 
@@ -39,6 +43,10 @@ struct TossCoinView{
 
       })
   }
+  //后端没有给出重置相关接口,数据量不大可以存本地
+
+
+
 
 
   // 判断当前是否显示正面
@@ -50,11 +58,11 @@ struct TossCoinView{
     // 判断角度范围,确定是否显示正面
     if (normalizedAngle >= 0 && normalizedAngle < 90 || normalizedAngle >= 270 && normalizedAngle <= 360) {
       return true; // 显示正面
+    }else {
+      return false; // 显示反面
     }
-    return false; // 显示反面
   }
   runAnimation(){
-
     if (this.isAnimRun) {
       return;
     }
@@ -79,6 +87,7 @@ struct TossCoinView{
             } else { // 如果是反面
               this.headsCount++; // 正面朝上的次数加1
             }
+            this.coinReslut={back:this.tailsCount,fore:this.headsCount,currRes:this.isHeadsFaceUp()?'正面':'反面'}
             this.isAnimRun = false
           }
         }, () => {
@@ -102,6 +111,17 @@ struct TossCoinView{
         this.rotationAngle += 90; // 每次增加90度旋转
       });
     }
+
+  }
+  aboutToAppear(): void {
+    this.tailsCount=this.coinReslut.back
+    this.headsCount=this.coinReslut.fore
+    if (this.coinReslut.currRes=='正面') {
+      this.rotationAngle=0
+    }else {
+      this.rotationAngle=180
+    }
+
   }
 
   build() {
@@ -150,7 +170,12 @@ struct TossCoinView{
           .fontSize(20)
           .fontColor(Color.Black);
         Image($r('[basic].media.repeat')).width(30).height(30).margin({left:50,right:20}).onClick(()=>{
-          this.runAnimation()
+         //重置
+          this.tailsCount=0
+          this.headsCount=0
+          this.rotationAngle=0
+          this.isHeadsFaceUp()
+          this.coinReslut={back:0,fore:0,currRes:'正面'} as coinItem
         })
 
       }.width('100%').margin({top:20}).justifyContent(FlexAlign.Center); // 设置宽度和内容居中对齐
@@ -215,6 +240,9 @@ struct TossCoinView{
         .backgroundColor('#fd54e3').width('70%')
         .height(44).borderRadius(20)
         .onClick(()=>{
+          if (this.isAnimRun) {
+            return;
+          }
           this.runAnimation()
           setTimeout(()=>{
             this.getResult()
@@ -260,4 +288,5 @@ struct TossCoinView{
     .backgroundImageSize({width:'100%',height:'100%'})
 
   }
+
 }

+ 7 - 0
products/entry/src/main/ets/entryability/EntryAbility.ets

@@ -3,6 +3,7 @@ import { hilog } from '@kit.PerformanceAnalysisKit';
 import { window } from '@kit.ArkUI';
 import {
   AppStorageKeyCollect,
+  coinItem,
   jHStartAd,
   permissionController,
   YTAvoid,
@@ -13,6 +14,7 @@ import {
 import { preferences } from '@kit.ArkData';
 import { identifier } from '@kit.AdsKit';
 import { BusinessError } from '@kit.BasicServicesKit';
+import { Cell, CellStorage } from 'feature/src/main/ets/utils/Sector';
 
 const DOMAIN = 0x0000;
 
@@ -43,6 +45,11 @@ export default class EntryAbility extends UIAbility {
       })
 
       PersistentStorage.persistProp<string>(AppStorageKeyCollect.TOKEN, '')
+      PersistentStorage.persistProp<CellStorage[]>('bigwheel', [])
+      PersistentStorage.persistProp<Cell[]>('unselectbigwheel', [])
+      PersistentStorage.persistProp<Cell[]>('selectbigwheel', [])
+      //记录抛硬币数据
+      PersistentStorage.persistProp<coinItem>('coinData', {back:0,fore:0,currRes:'正面'} as coinItem)
       if (AppStorage.get<string>(AppStorageKeyCollect.TOKEN)) {
         YTUserRequest.refreshUserInfo()
       }