|
|
@@ -1,5 +1,8 @@
|
|
|
import { AppStorageKeyFishCollect, avPlayerManager,
|
|
|
BlessCustomCustomDialog,
|
|
|
+ IBestInit,
|
|
|
+ IBestToast,
|
|
|
+ Params,
|
|
|
Vibration, YTAvoid, YTHeader, yTRouter,
|
|
|
YTUserRequest } from 'basic';
|
|
|
import { faceDetector } from '@kit.CoreVisionKit';
|
|
|
@@ -40,17 +43,45 @@ export struct MainView{
|
|
|
|
|
|
//动画true/false
|
|
|
@State isAnimation:boolean=false
|
|
|
- //进度条
|
|
|
- @State currentMerit:number=0
|
|
|
- @State totalMerit:number=10
|
|
|
+
|
|
|
|
|
|
//时间间隔
|
|
|
@State time:number=1000
|
|
|
|
|
|
@State isShowTimeManger:boolean=false
|
|
|
+
|
|
|
+ //当前分钟
|
|
|
@State valueTime:number=10
|
|
|
|
|
|
|
|
|
+ @Watch('caluc')
|
|
|
+ @State countdownHour:number=0.1
|
|
|
+ @State countdownTime:number=1
|
|
|
+ //
|
|
|
+ @Watch('caluc')
|
|
|
+ @State countdownCount:string="1"
|
|
|
+
|
|
|
+ @State countAutoHour:string=""
|
|
|
+
|
|
|
+ caluc(){
|
|
|
+ //计算间隔时长
|
|
|
+ this.countdownTime=this.countdownHour*60*60/Number(this.countdownCount)
|
|
|
+ }
|
|
|
+
|
|
|
+ @State fixedNum:number=1
|
|
|
+ @State fixedTime:number=1
|
|
|
+ @State fixedNumText:string="1"
|
|
|
+ @State fixedTimeText:string="1"
|
|
|
+
|
|
|
+ @State infiniteTime:number=1 //无限模式间隔时长
|
|
|
+ @State infiniteTimeText:string="1"
|
|
|
+ @State woodenfishModel:number=1
|
|
|
+ //进度条
|
|
|
+ @State currentMerit:number=0
|
|
|
+ @State totalMerit:number=10
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
dialogController: CustomDialogController=new CustomDialogController({
|
|
|
@@ -90,6 +121,7 @@ export struct MainView{
|
|
|
if(this.isOpenVibration){
|
|
|
Vibration.startVibration()
|
|
|
}
|
|
|
+ this.clockFish()
|
|
|
this.isAnimation=true
|
|
|
this.currentMerit++
|
|
|
// this.openDialog(this.currentIndex,this.totalMerit)
|
|
|
@@ -129,18 +161,39 @@ export struct MainView{
|
|
|
Row(){
|
|
|
Image($r('[basic].media.quxiao')).width(20).onClick(()=>{
|
|
|
this.isShowTimeManger = false
|
|
|
+
|
|
|
+ //发送请求
|
|
|
+ YTUserRequest.updateFishWoodenModel(
|
|
|
+ {
|
|
|
+ countdownHour:this.countdownHour,
|
|
|
+ countdownTime:this.countdownTime,
|
|
|
+ fixedNum:this.fixedNum,
|
|
|
+ fixedTime:this.fixedTime,
|
|
|
+ incenseTime:this.infiniteTime,
|
|
|
+ woodenfishModel:this.woodenfishModel
|
|
|
+ } as Params)
|
|
|
+
|
|
|
+ promptAction.showToast({
|
|
|
+ message:JSON.stringify( {
|
|
|
+ countdownHour:this.countdownHour,
|
|
|
+ countdownTime:this.countdownTime,
|
|
|
+ fixedNum:this.fixedNum,
|
|
|
+ fixedTime:this.fixedTime,
|
|
|
+ incenseTime:this.infiniteTime,
|
|
|
+ woodenfishModel:this.woodenfishModel
|
|
|
+ } as Params)
|
|
|
+ })
|
|
|
})
|
|
|
|
|
|
}.width('100%')
|
|
|
.justifyContent(FlexAlign.End)
|
|
|
Row(){
|
|
|
-
|
|
|
Text('自动敲击设置').fontColor(Color.White).fontSize(20)
|
|
|
}.width('100%')
|
|
|
.justifyContent(FlexAlign.Center)
|
|
|
.margin({bottom:20})
|
|
|
Stack({alignContent:Alignment.Top}) {
|
|
|
- Tabs({ barPosition: BarPosition.Start, controller: this.tabsController }) {
|
|
|
+ Tabs({ barPosition: BarPosition.Start, controller: this.tabsController,index:this.currentIndex }) {
|
|
|
TabContent() {
|
|
|
Column() {
|
|
|
Column({ space: 16 }) {
|
|
|
@@ -154,7 +207,7 @@ export struct MainView{
|
|
|
|
|
|
|
|
|
Row() {
|
|
|
- TextInput()
|
|
|
+ TextInput({text:this.infiniteTimeText})
|
|
|
.width(70)
|
|
|
.height(40)
|
|
|
.padding(0)
|
|
|
@@ -163,6 +216,27 @@ export struct MainView{
|
|
|
.borderRadius(4)
|
|
|
.backgroundColor(Color.Gray)
|
|
|
.margin({ right: 5 })
|
|
|
+ .onChange((value)=>{
|
|
|
+ if(Number(value)>10){
|
|
|
+ IBestToast.show({
|
|
|
+ message:"间隔时间不能大于10秒"
|
|
|
+ })
|
|
|
+ this.infiniteTimeText="10"
|
|
|
+ this.infiniteTime=10
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(Number(value)<=0){
|
|
|
+ IBestToast.show({
|
|
|
+ message:"间隔时间不能小于一秒"
|
|
|
+ })
|
|
|
+ this.infiniteTimeText="1"
|
|
|
+ this.infiniteTime=1
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.infiniteTime=Number(value)
|
|
|
+ this.infiniteTimeText=this.infiniteTime.toString()
|
|
|
+
|
|
|
+ })
|
|
|
|
|
|
Text('秒').fontColor('rgba(250, 222, 113, 1)')
|
|
|
}.width('100%').justifyContent(FlexAlign.Center)
|
|
|
@@ -188,7 +262,7 @@ export struct MainView{
|
|
|
|
|
|
|
|
|
Row() {
|
|
|
- TextInput()
|
|
|
+ TextInput({text:this.fixedNumText})
|
|
|
.width(70)
|
|
|
.height(40)
|
|
|
.padding(0)
|
|
|
@@ -197,8 +271,29 @@ export struct MainView{
|
|
|
.borderRadius(4)
|
|
|
.backgroundColor(Color.Gray)
|
|
|
.margin({right:5})
|
|
|
+ .onChange((value)=>{
|
|
|
+ if(Number(value)>9999){
|
|
|
+ IBestToast.show({
|
|
|
+ message:"敲击次数不能大于9999"
|
|
|
+ })
|
|
|
+ this.fixedNumText="9999"
|
|
|
+ this.fixedNum=9999
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(Number(value)<=0){
|
|
|
+ IBestToast.show({
|
|
|
+ message:"敲击次数不能小于1"
|
|
|
+ })
|
|
|
+ this.fixedNumText="1"
|
|
|
+ this.fixedNum=1
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.fixedNum=Number(value)
|
|
|
+ this.fixedNumText=this.fixedNum.toString()
|
|
|
|
|
|
- Text('秒').fontColor('rgba(250, 222, 113, 1)')
|
|
|
+ })
|
|
|
+
|
|
|
+ Text('次').fontColor('rgba(250, 222, 113, 1)')
|
|
|
}.width('100%').justifyContent(FlexAlign.Center)
|
|
|
|
|
|
Row(){
|
|
|
@@ -211,7 +306,7 @@ export struct MainView{
|
|
|
|
|
|
|
|
|
Row() {
|
|
|
- TextInput()
|
|
|
+ TextInput({text:this.fixedTimeText})
|
|
|
.width(70)
|
|
|
.height(40)
|
|
|
.padding(0)
|
|
|
@@ -220,6 +315,29 @@ export struct MainView{
|
|
|
.borderRadius(4)
|
|
|
.backgroundColor(Color.Gray)
|
|
|
.margin({right:5})
|
|
|
+ .onChange((value)=>{
|
|
|
+ if(Number(value)>10){
|
|
|
+ IBestToast.show({
|
|
|
+ message:"间隔时间不能大于10秒"
|
|
|
+ })
|
|
|
+ this.fixedTimeText="10"
|
|
|
+ this.fixedTime=10
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(Number(value)<=0){
|
|
|
+ IBestToast.show({
|
|
|
+ message:"间隔时间不能小于一秒"
|
|
|
+ })
|
|
|
+ this.fixedTimeText="1"
|
|
|
+ this.fixedTime=1
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.fixedTime=Number(value)
|
|
|
+ this.fixedTimeText=this.fixedTime.toString()
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
|
|
|
Text('秒').fontColor('rgba(250, 222, 113, 1)')
|
|
|
}.width('100%').justifyContent(FlexAlign.Center)
|
|
|
@@ -234,7 +352,6 @@ export struct MainView{
|
|
|
Row(){
|
|
|
Text() {
|
|
|
Span('倒计时').fontSize(16)
|
|
|
- Span('(1-9999次)').fontSize(12)
|
|
|
}.fontColor(Color.White)
|
|
|
}.width('100%')
|
|
|
.justifyContent(FlexAlign.Start)
|
|
|
@@ -252,6 +369,7 @@ export struct MainView{
|
|
|
.onClick(() => {
|
|
|
if (index != 6) {
|
|
|
this.valueTime = item //比实际小10
|
|
|
+ this.countdownHour=(this.valueTime+10)/60
|
|
|
} else {
|
|
|
this.valueTime=item
|
|
|
this.currentIndex = 3
|
|
|
@@ -262,7 +380,7 @@ export struct MainView{
|
|
|
.backgroundColor(this.valueTime == item ? Color.Yellow : Color.White)
|
|
|
Column() {
|
|
|
if (item != 60) {
|
|
|
- Text(item + "分钟")
|
|
|
+ Text(Number(item+10) + "分钟")
|
|
|
.fontSize(10)
|
|
|
.fontColor(this.valueTime == item ? Color.White : 'rgba(255, 255, 255, 0.55)')
|
|
|
} else {
|
|
|
@@ -290,7 +408,7 @@ export struct MainView{
|
|
|
}.width('100%')
|
|
|
.justifyContent(FlexAlign.Start)
|
|
|
Row() {
|
|
|
- TextInput()
|
|
|
+ TextInput({text:this.countdownCount})
|
|
|
.width(70)
|
|
|
.height(40)
|
|
|
.padding(0)
|
|
|
@@ -298,8 +416,27 @@ export struct MainView{
|
|
|
.textAlign(TextAlign.Center)
|
|
|
.borderRadius(4)
|
|
|
.backgroundColor(Color.Gray)
|
|
|
+ .onChange((value)=>{
|
|
|
+ if(Number(value)>9999){
|
|
|
+ IBestToast.show({
|
|
|
+ message:"敲击次数不能大于9999"
|
|
|
+ })
|
|
|
+ this.countdownCount="9999"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(Number(value)<=0){
|
|
|
+ IBestToast.show({
|
|
|
+ message:"敲击次数不能小于1"
|
|
|
+ })
|
|
|
+ this.countdownCount="1"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.countdownCount=value
|
|
|
|
|
|
- Text('秒').fontColor('rgba(250, 222, 113, 1)')
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
+ Text('次').fontColor('rgba(250, 222, 113, 1)')
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -310,10 +447,10 @@ export struct MainView{
|
|
|
}.tabBar('倒计时').layoutWeight(1)
|
|
|
TabContent() {
|
|
|
Column(){
|
|
|
- Column() {
|
|
|
- Text('自定义时间')
|
|
|
+ Column({space:30}) {
|
|
|
+ Text('自定义时间').fontColor(Color.White)
|
|
|
Row() {
|
|
|
- TextInput()
|
|
|
+ TextInput({text:this.countAutoHour})
|
|
|
.width(70)
|
|
|
.height(40)
|
|
|
.padding(0)
|
|
|
@@ -321,8 +458,19 @@ export struct MainView{
|
|
|
.textAlign(TextAlign.Center)
|
|
|
.borderRadius(4)
|
|
|
.backgroundColor(Color.Gray)
|
|
|
+ .onChange((value)=>{
|
|
|
+ if(Number(value)>120){
|
|
|
+ IBestToast.show({
|
|
|
+ message:'最多不得超过120分钟'
|
|
|
+ })
|
|
|
+ this.countAutoHour="120"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.countAutoHour=value
|
|
|
+ this.countdownHour=Number(this.countAutoHour)/60
|
|
|
+ })
|
|
|
|
|
|
- Text('秒').fontColor('rgba(250, 222, 113, 1)')
|
|
|
+ Text('分钟').fontColor('rgba(250, 222, 113, 1)')
|
|
|
}
|
|
|
}
|
|
|
}.layoutWeight(1).justifyContent(FlexAlign.Start)
|
|
|
@@ -340,6 +488,8 @@ export struct MainView{
|
|
|
.onClick(()=>{
|
|
|
this.currentIndex=0
|
|
|
this.tabsController.changeIndex(this.currentIndex)
|
|
|
+ this.woodenfishModel=2
|
|
|
+
|
|
|
|
|
|
})
|
|
|
Text('固定次数')
|
|
|
@@ -351,6 +501,7 @@ export struct MainView{
|
|
|
.backgroundColor(this.currentIndex==1?'rgba(250, 222, 113, 1)':Color.Transparent).onClick(()=>{
|
|
|
this.currentIndex=1
|
|
|
this.tabsController.changeIndex(this.currentIndex)
|
|
|
+ this.woodenfishModel=3
|
|
|
|
|
|
})
|
|
|
Text('倒计时')
|
|
|
@@ -363,6 +514,7 @@ export struct MainView{
|
|
|
.onClick(()=>{
|
|
|
this.currentIndex=2
|
|
|
this.tabsController.changeIndex(this.currentIndex)
|
|
|
+ this.woodenfishModel=4
|
|
|
|
|
|
})
|
|
|
|
|
|
@@ -385,15 +537,57 @@ export struct MainView{
|
|
|
for (let i = 0; i < this.count; i++) {
|
|
|
this.list.push(new Cell()); // 初始化 Cell 数组
|
|
|
}
|
|
|
-
|
|
|
YTUserRequest.getFishFra((res)=>{
|
|
|
- promptAction.showToast({
|
|
|
- message:JSON.stringify(res)
|
|
|
- })
|
|
|
+ AppStorage.setOrCreate('updateID',res.id as number)
|
|
|
+ this.currentMerit=res.meritsValue as number
|
|
|
+ this.woodenfishModel=res.woodenfishModel as number
|
|
|
+ //无限间隔时长
|
|
|
+ this.infiniteTime=res.infiniteTime as number
|
|
|
+ //固定
|
|
|
+ this.fixedNum=res.fixedNum as number
|
|
|
+ this.fixedTime=res.fixedTime as number
|
|
|
+
|
|
|
+ //倒计时
|
|
|
+ this.countdownTime=res.countdownTime as number
|
|
|
+ this.countdownHour=(res.countdownHour as number)*60
|
|
|
+ //判断是否自动并设置敲击时间
|
|
|
+ if(res.woodenfishModel==1){
|
|
|
+ this.isAuto=false
|
|
|
+ }else if(res.woodenfishModel==2){
|
|
|
+ setInterval(()=>{
|
|
|
+ this.onclikMerit()
|
|
|
+ },this.infiniteTime*1000)
|
|
|
+ }else if(res.woodenfishModel==3){
|
|
|
+ const a=setInterval(()=>{
|
|
|
+ this.onclikMerit()
|
|
|
+
|
|
|
+ },this.fixedTime)
|
|
|
+ const b=setTimeout(()=>{
|
|
|
+ clearInterval(a)
|
|
|
+ clearTimeout(b)
|
|
|
+ },this.fixedTime*this.fixedNum)
|
|
|
+ }else if(res.woodenfishModel==4){
|
|
|
+
|
|
|
+ this.onclikMerit()
|
|
|
+ const a=setInterval(()=>{
|
|
|
+ this.onclikMerit()
|
|
|
+ },this.countdownTime)
|
|
|
+ const b=setTimeout(()=>{
|
|
|
+ clearInterval(a)
|
|
|
+ clearTimeout(b)
|
|
|
+ },this.countdownHour*this.countdownHour)
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
+ clockFish(){
|
|
|
+ YTUserRequest.knockingFish()
|
|
|
+ }
|
|
|
+
|
|
|
build() {
|
|
|
Stack() {
|
|
|
Image($r('[basic].media.dengguang')).width('100%').height('100%')
|
|
|
@@ -426,6 +620,7 @@ export struct MainView{
|
|
|
.fontColor('rgba(0, 0, 0, 0.95)')
|
|
|
.onClick(() => {
|
|
|
this.currentMerit = 0
|
|
|
+ YTUserRequest.resetFish()
|
|
|
})
|
|
|
|
|
|
|
|
|
@@ -482,12 +677,13 @@ export struct MainView{
|
|
|
.onClick(() => {
|
|
|
this.isAuto = !this.isAuto
|
|
|
//如果是本来自动,再点击就是手动,不需要设置任何东西
|
|
|
- // if (!this.isHand) {
|
|
|
- // this.isHand = true
|
|
|
- // } else {
|
|
|
- // //如果本来是手动,再点击就是自动,就需要设置东西
|
|
|
- // this.isHand = false
|
|
|
- // }
|
|
|
+ if (this.isAuto) {
|
|
|
+ // this.woodenfishModel
|
|
|
+ } else {
|
|
|
+ //如果本来是手动,再点击就是自动,就需要设置东西
|
|
|
+ // this.isHand = false
|
|
|
+ this.woodenfishModel=1
|
|
|
+ }
|
|
|
})
|
|
|
if (this.isAuto) {
|
|
|
Column({ space: 10 }) {
|
|
|
@@ -502,6 +698,9 @@ export struct MainView{
|
|
|
.backgroundColor('#252111')
|
|
|
.onClick(() => {
|
|
|
this.isAuto = !this.isAuto
|
|
|
+ if(this.isAuto==false){
|
|
|
+ this.woodenfishModel=1
|
|
|
+ }
|
|
|
})
|
|
|
Text('无限')
|
|
|
.padding({
|
|
|
@@ -516,9 +715,15 @@ export struct MainView{
|
|
|
width: '100%',
|
|
|
height: 400,
|
|
|
showClose: false,
|
|
|
+ onWillDismiss: ((dismissSheetAction: DismissSheetAction) => {
|
|
|
+ if (dismissSheetAction.reason == DismissReason.SLIDE_DOWN) {
|
|
|
+ dismissSheetAction.dismiss(); //注册dismiss行为
|
|
|
+ }
|
|
|
+ }),
|
|
|
})
|
|
|
.onClick(() => {
|
|
|
this.isShowTimeManger = true
|
|
|
+ this.woodenfishModel=2
|
|
|
})
|
|
|
Text('设置')
|
|
|
.padding({
|
|
|
@@ -575,7 +780,9 @@ export struct MainView{
|
|
|
level: ClickEffectLevel.LIGHT // 效果级别
|
|
|
})
|
|
|
.onClick(() => { // 点击图片时触发的回调
|
|
|
- this.onclikMerit()
|
|
|
+ if(!this.isAuto) {
|
|
|
+ this.onclikMerit()
|
|
|
+ }
|
|
|
})
|
|
|
|
|
|
Row() {
|