MainView.ets 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800
  1. import { AppStorageKeyFishCollect, avPlayerManager,
  2. BlessCustomCustomDialog,
  3. IBestInit,
  4. IBestToast,
  5. Params,
  6. Vibration, YTAvoid, YTHeader, yTRouter,
  7. YTUserRequest } from 'basic';
  8. import { faceDetector } from '@kit.CoreVisionKit';
  9. import { trustedAppService } from '@kit.DeviceSecurityKit';
  10. import { promptAction } from '@kit.ArkUI';
  11. import { Cell } from '../models';
  12. import { it } from '@ohos/hypium';
  13. import { TimeTextCom } from '../component/TimeTextCom';
  14. import { CountTextCom } from '../component/CountTextCom';
  15. import { TimeProgressCom } from '../component/TimeProgressCom';
  16. import { AutoAdComponent } from '@ohos.advertising.AutoAdComponent';
  17. import { AutoDesiciTime } from '../component/AutoDesiciTime';
  18. @Component
  19. export struct MainView{
  20. @Watch('changeText')
  21. @StorageProp(AppStorageKeyFishCollect.FISHTEXT)
  22. text:string=""
  23. @State private currentIndex: number = 0
  24. tabsController: TabsController = new TabsController()
  25. @StorageProp(YTAvoid.SAFE_TOP_KEY) top: number = 0
  26. @State list: Cell[] = []; // 存储所有 Cell 对象的数组
  27. private indexCount: number = 0; // 记录当前滚动的索引
  28. private count: number = 10; // 列表中 Cell 对象的数量
  29. private image: ResourceStr=$r('app.media.muyu')
  30. changeText(){
  31. if(this.text!="") {
  32. this.list.forEach(item => item.value = this.text)
  33. }
  34. }
  35. //是否是手动
  36. @State isAuto:boolean=false
  37. //是否展示侧边工具栏
  38. @State isShowSilder:boolean=true
  39. //是否展示信息展示
  40. @State isShowMessage:boolean=true
  41. //是否开启声音
  42. @State isOpenMusic:boolean=true
  43. //是否开启震动
  44. @State isOpenVibration:boolean=true
  45. //动画true/false
  46. @State isAnimation:boolean=false
  47. @State isShowTimeManger:boolean=false
  48. //时间间隔
  49. @State time:number=1000
  50. //当前倒计时 分钟渲染参数
  51. @State valueTime:number=10
  52. //全部用分钟来计算,实际传递给后端用小时制
  53. //实际后端要的小时来算的数据
  54. // @Watch('caluc')
  55. @State countdownHour:number=10
  56. //倒计时时间间隔
  57. @State countdownTime:number=1
  58. //倒计时敲击次数渲染文本
  59. // @Watch('caluc')
  60. @State countdownCount:string="1"
  61. //倒计时自定义的文本分钟
  62. @State countAutoHour:string=""
  63. caluc(){
  64. //计算间隔时长
  65. this.countdownTime=this.countdownHour*60/Number(this.countdownCount)
  66. }
  67. //固定次数
  68. @State fixedNum:number=1
  69. //固定间隔时间
  70. @State fixedTime:number=1
  71. //固定次数渲染文本
  72. @State fixedNumText:string="1"
  73. //固定间隔时间渲染文本
  74. @State fixedTimeText:string="1"
  75. //无限模式间隔时长
  76. @State infiniteTime:number=1
  77. //无限模式间隔时长渲染文本
  78. @State infiniteTimeText:string="1"
  79. //模式 1(结束 手动) 2无限,3固定次数 4倒计时
  80. @State woodenfishModel:number=1
  81. //进度条功德数
  82. @Watch('total')
  83. @State currentMerit:number=0
  84. //总功德数
  85. @State totalMerit:number=10
  86. private Merit:number[]=[10,200,500,1000,2000,5000,6000,8000]
  87. private MeritIndex:number=0
  88. //自动点击缩放参数
  89. @State scaleValue:number=1
  90. @State inversetId:number=-1
  91. dialogController: CustomDialogController=new CustomDialogController({
  92. builder:BlessCustomCustomDialog({
  93. imgIndex:Math.floor(Math.random()*12)
  94. }),
  95. alignment:DialogAlignment.Center,
  96. customStyle:true,
  97. width:'100%',
  98. height:'100%',
  99. })
  100. total(){
  101. if(this.currentMerit>this.totalMerit){
  102. this.MeritIndex++
  103. this.totalMerit=this.Merit[this.MeritIndex]
  104. }
  105. }
  106. // 初始化方法,在组件即将显示时被调用
  107. aboutToAppear(): void {
  108. for (let i = 0; i < this.count; i++) {
  109. this.list.push(new Cell()); // 初始化 Cell 数组
  110. }
  111. YTUserRequest.getFishFra((res)=>{
  112. // promptAction.showToast({
  113. // message:JSON.stringify(res)
  114. // })
  115. AppStorage.setOrCreate('updateID',res.id as number)
  116. this.currentMerit=res.meritsValue as number
  117. this.woodenfishModel=res.woodenfishModel as number
  118. //无限间隔时长
  119. this.infiniteTime=res.infiniteTime as number
  120. //固定
  121. this.fixedNum=res.fixedNum as number
  122. this.fixedTime=res.fixedTime as number
  123. //倒计时
  124. this.countdownTime=res.countdownTime as number
  125. this.countdownHour=(res.countdownHour as number)
  126. if(this.countdownHour>60){
  127. this.countAutoHour=this.countdownHour.toString()
  128. }
  129. this.isAuto=this.woodenfishModel!=1?true:false
  130. this.text=res.suspensionCharacters as string
  131. //需要渲染
  132. this.infiniteTimeText=this.infiniteTime.toString()
  133. this.fixedNumText=this.fixedNum.toString()
  134. this.fixedTimeText=this.fixedTime.toString()
  135. this.countdownCount=(this.countdownHour*60/this.countdownTime).toString()
  136. for (let i = 0; i < this.Merit.length; i++) {
  137. if(this.currentMerit>this.Merit[i]&&this.currentMerit<this.Merit[i+1]){
  138. this.totalMerit=this.Merit[i+1]
  139. }
  140. }
  141. // promptAction.showToast({
  142. // message:this.countdownCount
  143. // })
  144. //判断是否自动并设置敲击时间
  145. clearInterval(this.inversetId)
  146. //自动敲击
  147. this.autoOnclick()
  148. })
  149. }
  150. //开启关闭音乐
  151. async openMusic(){
  152. await avPlayerManager.playByRawSrc('music3.mp3')
  153. }
  154. async closeMusic(){
  155. await avPlayerManager.stop()
  156. }
  157. //功德满足情况弹窗
  158. // openDialog(currNumber:number,totalNumber:number){
  159. // if(currNumber==totalNumber){
  160. // this.dialogController.open()
  161. // }
  162. // }
  163. //点击动画
  164. onclikMerit(){
  165. if(this.isAnimation){
  166. return
  167. }
  168. if(this.isOpenMusic){
  169. this.openMusic()
  170. }
  171. if(this.isOpenVibration){
  172. Vibration.startVibration()
  173. }
  174. this.clockFish()
  175. this.isAnimation=true
  176. this.currentMerit++
  177. // this.openDialog(this.currentIndex,this.totalMerit)
  178. if(this.currentMerit==this.totalMerit){
  179. this.dialogController.open()
  180. }
  181. let index = this.indexCount % this.count; // 计算当前滚动的索引
  182. this.indexCount++; // 更新索引计数器
  183. animateToImmediately({
  184. // 立即开始动画
  185. duration: 250, // 动画持续时间为0毫秒
  186. curve: Curve.Linear,
  187. onFinish: () => { // 动画完成后的回调
  188. this.scaleValue=1
  189. animateToImmediately({
  190. // 再次立即开始动画
  191. duration: 250, // 动画持续时间为1000毫秒
  192. onFinish:()=>{
  193. this.isAnimation=false
  194. this.closeMusic()
  195. }
  196. }, () => {
  197. this.list[index].y = -150 // 设置 Cell 的垂直偏移量
  198. this.list[index].opacity = 0 // 设置 Cell 的透明度
  199. })
  200. }
  201. }, () => {
  202. this.list[index].y = 0 // 设置 Cell 的垂直偏移量
  203. this.list[index].opacity = 1 // 设置 Cell 的透明度
  204. this.scaleValue=0.8
  205. })
  206. }
  207. //自动敲击
  208. autoOnclick(){
  209. clearInterval(this.inversetId)
  210. if(this.woodenfishModel==1){
  211. this.isAuto=false
  212. }else if(this.woodenfishModel==2){
  213. this.inversetId= setInterval(()=>{
  214. this.onclikMerit()
  215. },this.infiniteTime*1000)
  216. }else if(this.woodenfishModel==3){
  217. this.inversetId=setInterval(()=>{
  218. this.onclikMerit()
  219. },this.fixedTime*1000)
  220. const b=setTimeout(()=>{
  221. clearInterval(this.inversetId)
  222. clearTimeout(b)
  223. },this.fixedTime*1000*this.fixedNum)
  224. }else if(this.woodenfishModel==4){
  225. this.onclikMerit()
  226. this.inversetId=setInterval(()=>{
  227. this.onclikMerit()
  228. },this.countdownTime*1000)
  229. const b=setTimeout(()=>{
  230. clearInterval(this.inversetId)
  231. clearTimeout(b)
  232. },this.countdownHour*60000)
  233. }
  234. }
  235. @Builder
  236. TimeMangerBuilder(){
  237. Column(){
  238. //图标
  239. Row(){
  240. Image($r('[basic].media.quxiao')).width(20).onClick(()=>{
  241. this.isShowTimeManger = false
  242. this.caluc()
  243. // 发送请求
  244. YTUserRequest.updateFishWoodenModel(
  245. {
  246. countdownHour:this.countdownHour,
  247. countdownTime:this.countdownTime,
  248. fixedNum:this.fixedNum,
  249. fixedTime:this.fixedTime,
  250. infiniteTime:this.infiniteTime,
  251. woodenfishModel:this.woodenfishModel
  252. } as Params)
  253. // promptAction.showToast({
  254. // message:JSON.stringify( {
  255. // countdownHour:this.countdownHour,
  256. // countdownTime:this.countdownTime,
  257. // fixedNum:this.fixedNum,
  258. // fixedTime:this.fixedTime,
  259. // infiniteTime:this.infiniteTime,
  260. // woodenfishModel:this.woodenfishModel
  261. // } as Params)
  262. // })
  263. this.autoOnclick()
  264. })
  265. }.width('100%')
  266. .justifyContent(FlexAlign.End)
  267. //标题
  268. Row(){
  269. Text('自动敲击设置').fontColor(Color.White).fontSize(20)
  270. }.width('100%')
  271. .justifyContent(FlexAlign.Center)
  272. .margin({bottom:20})
  273. Stack({alignContent:Alignment.Top}) {
  274. Tabs({ barPosition: BarPosition.Start, controller: this.tabsController,index:this.currentIndex }) {
  275. TabContent() {
  276. Column() {
  277. Column() {
  278. TimeTextCom({
  279. onclickTime: this.infiniteTimeText,
  280. changeText: (value: string) => {
  281. this.infiniteTimeText = value
  282. //获取到无限模式间隔时间
  283. this.infiniteTime=Number(this.infiniteTimeText)
  284. }
  285. })
  286. }.width('100%')
  287. .height(136)
  288. .borderRadius(8)
  289. .padding(20)
  290. .backgroundColor('rgba(77, 77, 77, 1)')
  291. }.layoutWeight(1).justifyContent(FlexAlign.Start)
  292. }.tabBar('无限').layoutWeight(1)
  293. TabContent() {
  294. Column(){
  295. Column({space:16}) {
  296. CountTextCom({
  297. onclickCount:this.fixedNumText,
  298. changeOnclickCount:(value:string)=>{
  299. this.fixedNumText=value
  300. //固定模式敲击次数
  301. this.fixedNum=Number(this.fixedNumText)
  302. }
  303. })
  304. TimeTextCom({
  305. onclickTime:this.fixedTimeText,
  306. changeText:(value:string)=>{
  307. this.fixedTimeText=value
  308. //固定模式间隔时间
  309. this.fixedTime=Number(this.fixedTimeText)
  310. }
  311. })
  312. }.width('100%').height(210).borderRadius(8).padding(20).backgroundColor('rgba(77, 77, 77, 1)')
  313. }.layoutWeight(1).justifyContent(FlexAlign.Start)
  314. }.tabBar('固定次数').layoutWeight(1)
  315. TabContent() {
  316. Column(){
  317. Column({space:16}) {
  318. TimeProgressCom({
  319. progressValue:this.countdownHour,
  320. changeTabCurrNumberAndCountTime:(progressValue:string,tabIndex?:number,)=>{
  321. if(progressValue!='自定义') {
  322. this.countdownHour = Number(progressValue)
  323. }
  324. if(tabIndex==3) {
  325. this.tabsController.changeIndex(tabIndex)
  326. }
  327. }
  328. })
  329. CountTextCom({
  330. onclickCount:this.countdownCount,
  331. changeOnclickCount:(value:string)=>{
  332. this.countdownCount=value
  333. }
  334. })
  335. }.width('100%').borderRadius(8).padding(20).backgroundColor('rgba(77, 77, 77, 1)')
  336. }.layoutWeight(1).justifyContent(FlexAlign.Start)
  337. }.tabBar('倒计时').layoutWeight(1)
  338. TabContent() {
  339. Column(){
  340. AutoDesiciTime({
  341. countAutoHour:this.countAutoHour,
  342. changeAutoHour:(countAutoHour:string)=>{
  343. this.countAutoHour=countAutoHour
  344. this.countdownHour=Number(this.countAutoHour)
  345. },
  346. backTab:(woodenfishModel:number,tabChangeIndex:number)=>{
  347. this.woodenfishModel=woodenfishModel
  348. this.tabsController.changeIndex(tabChangeIndex)
  349. }
  350. })
  351. }.layoutWeight(1).justifyContent(FlexAlign.Start)
  352. }.tabBar('自定义').layoutWeight(1)
  353. }.width('100%').margin({top:20}).barHeight(0)
  354. Row(){
  355. Text('无限')
  356. .layoutWeight(1)
  357. .textAlign(TextAlign.Center)
  358. .borderRadius(10)
  359. .height(40)
  360. .fontColor(this.currentIndex==0?Color.Black:'rgba(255, 255, 255, 0.35)')
  361. .backgroundColor(this.currentIndex==0?'rgba(250, 222, 113, 1)':Color.Transparent)
  362. .onClick(()=>{
  363. this.currentIndex=0
  364. this.tabsController.changeIndex(this.currentIndex)
  365. this.woodenfishModel=2
  366. })
  367. Text('固定次数')
  368. .layoutWeight(1)
  369. .textAlign(TextAlign.Center)
  370. .borderRadius(10)
  371. .height(40)
  372. .fontColor(this.currentIndex==1?Color.Black:'rgba(255, 255, 255, 0.35)')
  373. .backgroundColor(this.currentIndex==1?'rgba(250, 222, 113, 1)':Color.Transparent).onClick(()=>{
  374. this.currentIndex=1
  375. this.tabsController.changeIndex(this.currentIndex)
  376. this.woodenfishModel=3
  377. })
  378. Text('倒计时')
  379. .layoutWeight(1)
  380. .borderRadius(10)
  381. .textAlign(TextAlign.Center)
  382. .height(40)
  383. .fontColor((this.currentIndex==2||this.currentIndex==3)?Color.Black:'rgba(255, 255, 255, 0.35)')
  384. .backgroundColor((this.currentIndex==2||this.currentIndex==3)?'rgba(250, 222, 113, 1)':Color.Transparent)
  385. .onClick(()=>{
  386. this.currentIndex=2
  387. this.tabsController.changeIndex(this.currentIndex)
  388. this.woodenfishModel=4
  389. })
  390. }.width('100%')
  391. .borderRadius(10)
  392. .height(40)
  393. .backgroundColor('rgba(77, 77, 77, 1)')
  394. }.layoutWeight(1)
  395. }.width('100%')
  396. .height('100%')
  397. .padding(20)
  398. .backgroundColor('rgba(25, 25, 25, 1)')
  399. }
  400. clockFish(){
  401. YTUserRequest.knockingFish()
  402. }
  403. build() {
  404. Stack() {
  405. Image($r('[basic].media.dengguang')).width('100%').height('100%')
  406. Image($r('[basic].media.dizuo')).width(256).height(60).margin({top:460})
  407. Column() {
  408. Stack({ alignContent: Alignment.Bottom }) {
  409. Column() {
  410. if (this.isShowMessage) {
  411. Row() {
  412. Column({ space: 20 }) {
  413. //积功德+清零
  414. Row() {
  415. Text() {
  416. Span('积功德: ').fontColor(Color.White).fontSize(18)
  417. Span(`${this.currentMerit}`).fontSize(18).fontColor($r('[basic].color.login_main_yellow'))
  418. }.margin({ left: 50 })
  419. Row() {
  420. Text('清零')
  421. .borderRadius(20)
  422. .fontSize(14)
  423. .padding({
  424. left: 8,
  425. right: 8,
  426. top: 5,
  427. bottom: 5
  428. })
  429. .backgroundColor($r('[basic].color.login_main_yellow'))
  430. .fontColor('rgba(0, 0, 0, 0.95)')
  431. .onClick(() => {
  432. this.currentMerit = 0
  433. this.totalMerit=this.Merit[0]
  434. YTUserRequest.resetFish()
  435. })
  436. }
  437. }.width('100%').justifyContent(FlexAlign.SpaceAround)
  438. //进度条
  439. Column() {
  440. Stack({ alignContent: Alignment.Center }) {
  441. Progress({ value: this.currentMerit, total: this.totalMerit, type: ProgressType.Ring })
  442. .width(80).color('rgba(61, 186, 208, 1)')
  443. .style({ strokeWidth: 7, shadow: true })
  444. .backgroundColor(Color.White)
  445. .value(this.currentMerit)
  446. Text('集福').fontSize(20).fontColor('rgba(252, 253, 237, 1)')
  447. }.margin({ left: 10 })
  448. Text() {
  449. Span(`${this.currentMerit}`).fontColor($r('[basic].color.login_main_yellow'))
  450. Span(`/${this.totalMerit}`)
  451. }.fontColor(Color.White).margin({ left: 10 }).width(80).textAlign(TextAlign.Center)
  452. }.width('100%').justifyContent(FlexAlign.Start).alignItems(HorizontalAlign.Start)
  453. }.layoutWeight(1)
  454. //右边的按钮
  455. Column({ space: 20 }) {
  456. Image($r('[basic].media.shezhix')).width(32).onClick(() => {
  457. this.isShowSilder = !this.isShowSilder
  458. })
  459. if (this.isShowSilder) {
  460. //是否开启声音
  461. Image($r('[basic].media.zhendong')).width(32).onClick(() => {
  462. this.isOpenMusic = !this.isOpenMusic
  463. })
  464. //是否开启震动
  465. Image($r('[basic].media.shengying')).width(32).onClick(() => {
  466. this.isOpenVibration = !this.isOpenVibration
  467. })
  468. Column() {
  469. Column() {
  470. Text(this.isAuto ? '自动' : '手动')
  471. .padding({
  472. left: 3,
  473. right: 3,
  474. top: 10,
  475. bottom: 10
  476. })
  477. .margin({ bottom: 10 })
  478. .backgroundColor('#252111')
  479. .fontColor(Color.White)
  480. .onClick(() => {
  481. this.isAuto = !this.isAuto
  482. //如果是本来自动,再点击就是手动,不需要设置任何东西
  483. if (this.isAuto) {
  484. // this.woodenfishModel
  485. } else {
  486. //如果本来是手动,再点击就是自动,就需要设置东西
  487. // this.isHand = false
  488. this.woodenfishModel=1
  489. clearInterval(this.inversetId)
  490. }
  491. })
  492. if (this.isAuto) {
  493. Column({ space: 10 }) {
  494. Text('结束')
  495. .padding({
  496. left: 3,
  497. right: 3,
  498. top: 10,
  499. bottom: 10
  500. })
  501. .fontColor(Color.White)
  502. .backgroundColor('#252111')
  503. .onClick(() => {
  504. this.isAuto = !this.isAuto
  505. if(this.isAuto==false){
  506. this.woodenfishModel=1
  507. clearInterval(this.inversetId)
  508. }
  509. })
  510. Text('无限')
  511. .padding({
  512. left: 3,
  513. right: 3,
  514. top: 10,
  515. bottom: 10
  516. })
  517. .fontColor(Color.White)
  518. .backgroundColor('#252111')
  519. .bindSheet($$this.isShowTimeManger, this.TimeMangerBuilder
  520. , {
  521. width: '100%',
  522. height: 400,
  523. showClose: false,
  524. onWillDismiss: ((dismissSheetAction: DismissSheetAction) => {
  525. if (dismissSheetAction.reason == DismissReason.SLIDE_DOWN) {
  526. dismissSheetAction.dismiss(); //注册dismiss行为
  527. }
  528. }),
  529. })
  530. .onClick(() => {
  531. this.isShowTimeManger = true
  532. this.woodenfishModel=2
  533. // YTUserRequest.getFishFra((res)=>{
  534. //
  535. // promptAction.showToast({
  536. // message:JSON.stringify(res)
  537. // })
  538. // AppStorage.setOrCreate('updateID',res.id as number)
  539. // this.currentMerit=res.meritsValue as number
  540. // this.woodenfishModel=res.woodenfishModel as number
  541. // //无限间隔时长
  542. // this.infiniteTime=res.infiniteTime as number
  543. // //固定
  544. // this.fixedNum=res.fixedNum as number
  545. // this.fixedTime=res.fixedTime as number
  546. //
  547. // //倒计时
  548. // this.countdownTime=res.countdownTime as number
  549. // this.countdownHour=(res.countdownHour as number)
  550. // this.isAuto=this.woodenfishModel!=1?true:false
  551. // //判断是否自动并设置敲击时间
  552. // clearInterval(this.inversetId)
  553. // //自动敲击
  554. //
  555. // this.autoOnclick()
  556. //
  557. // })
  558. })
  559. Text('设置')
  560. .padding({
  561. left: 3,
  562. right: 3,
  563. top: 10,
  564. bottom: 10
  565. })
  566. .fontColor(Color.White)
  567. .backgroundColor('#252111')
  568. .onClick(() => {
  569. //去往设置页面
  570. yTRouter.router2FishSettingPage()
  571. })
  572. }
  573. }
  574. }
  575. }
  576. }
  577. }.width(50)
  578. .justifyContent(FlexAlign.Center)
  579. .alignItems(HorizontalAlign.End)
  580. }.width('100%')
  581. .height(400)
  582. .alignItems(VerticalAlign.Top)
  583. }
  584. }
  585. .height('100%')
  586. .margin({ top: 20 })
  587. Column() {
  588. Stack() { // 创建一个堆栈布局容器
  589. ForEach(this.list, (item: Cell, _index: number) => { // 遍历 list 中的每一个 Cell
  590. Text(item.value)// 显示 Cell 中的文字
  591. .fontColor(Color.White)// 设置文字颜色为白色
  592. .fontSize('50lpx')// 设置文字大小
  593. .translate({ x: 0, y: `${item.y}lpx` })// 设置文字的垂直偏移量
  594. .opacity(item.opacity) // 设置文字的透明度
  595. })
  596. }
  597. .width(200) //
  598. .height(70)
  599. .align(Alignment.BottomEnd)
  600. Image(this.image)
  601. .width(200)
  602. .height(200)
  603. .objectFit(ImageFit.Contain)
  604. .scale({
  605. x:this.scaleValue,
  606. y:this.scaleValue
  607. })
  608. // .clickEffect({
  609. // // 点击效果配置
  610. // scale: 0.5, // 缩放比例
  611. // level: ClickEffectLevel.LIGHT // 效果级别
  612. // })
  613. .onClick(() => { // 点击图片时触发的回调
  614. if(!this.isAuto) {
  615. this.onclikMerit()
  616. }
  617. })
  618. Row() {
  619. Image($r('[basic].media.suoxiao')).width(24).onClick(() => {
  620. this.isShowMessage = !this.isShowMessage
  621. })
  622. }.width('100%')
  623. .margin({ top: 50 })
  624. .justifyContent(FlexAlign.End)
  625. }
  626. .width('100%')
  627. .margin({ bottom: 20 })
  628. }.height('100%')
  629. // Row(){
  630. // Button('改变文字').onClick(()=>{
  631. // this.list.forEach(item=>{item.value='吴亮+1'})
  632. // })
  633. // Button('敲击时长间隔1秒').onClick(()=>{
  634. // this.time=1000
  635. //
  636. // })
  637. // Button('固定10次').onClick(()=>{
  638. // //自动敲击
  639. // const a=setInterval(()=>{
  640. // this.onclikMerit()
  641. //
  642. // },this.time)
  643. // const b=setTimeout(()=>{
  644. // clearInterval(a)
  645. // clearTimeout(b)
  646. // },this.time*10)
  647. //
  648. //
  649. // })
  650. // Button('倒计时规定时间').onClick(()=>{
  651. // this.onclikMerit()
  652. // const a=setInterval(()=>{
  653. // this.onclikMerit()
  654. // },this.time)
  655. // const b=setTimeout(()=>{
  656. // clearInterval(a)
  657. // clearTimeout(b)
  658. // },10000)
  659. //
  660. // })
  661. // }
  662. //
  663. // Button('xxx').bindSheet($$this.isShowTimeManger,this.timeMangerBuilder(),{
  664. // width:'100%',
  665. // height:400,
  666. // showClose:false
  667. // }).onClick(()=>{
  668. // this.isShowTimeManger=true
  669. // })
  670. //
  671. // Button('震动').onClick(()=>{
  672. // Vibration.startVibration()
  673. // })
  674. // Stack() {
  675. // Progress({ value: this.valueTime, total: 70, type: ProgressType.Linear }).backgroundColor(Color.White)
  676. // Row({space:30}){
  677. // ForEach([0,10,20,30,40,50,60,70],(item:number)=>{
  678. // Column(){
  679. // }.width(10)
  680. // .height(10)
  681. // .borderRadius('50%')
  682. // .onClick(()=>{
  683. // this.valueTime=item
  684. // })
  685. // .backgroundColor(this.valueTime>=item?Color.Pink:Color.White)
  686. // })
  687. //
  688. //
  689. // }.width('100%')
  690. //
  691. // }
  692. }.width('100%')
  693. .height('100%')
  694. .padding({
  695. top: this.top + 22,
  696. left: 20,
  697. right: 20
  698. })
  699. }.backgroundColor(Color.Black)
  700. }
  701. }