index.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import { openSecondaryScreen, openCycleSecondaryScreen,closeSecondaryScreen, viceBroadcast, stopVoiceBroadcast } from "../../utils/index/callAmpe";
  2. const app = getApp()
  3. Page({
  4. data: {
  5. timer: 60,
  6. count: 0,
  7. reminderCount: 0,
  8. remainingTime: '',
  9. intervalId1: null,
  10. img: '',
  11. confirmCountdownTime: 15,
  12. isDisabled: true,
  13. confirmCountdownSwitch: true,
  14. isBack: false,// 是否点击退出按钮
  15. },
  16. onLoad() {
  17. my.hideBackHome();
  18. let remainingTime = '操作时间 ' + this.data.timer + ' 秒'
  19. console.log(app.globalData.snDisposition, app.globalData.snDisposition.confirmCountdownTime)
  20. let confirmCountSwitch = true
  21. if (app.globalData.snDisposition.confirmCountdownSwitch != null) {
  22. confirmCountSwitch = app.globalData.snDisposition.confirmCountdownSwitch
  23. }
  24. this.setData({
  25. remainingTime,
  26. img: app.globalData.snDisposition.reminder,
  27. confirmCountdownSwitch: confirmCountSwitch,
  28. confirmCountdownTime: app.globalData.snDisposition.confirmCountdownTime || 15,
  29. count: this.data.timer,
  30. reminderCount: app.globalData.snDisposition.confirmCountdownTime || 15
  31. })
  32. setTimeout(()=>{
  33. !this.data.isBack && viceBroadcast(app.globalData.snDisposition.reminderPlayText)
  34. }, 1500)
  35. this.startCountdown()
  36. },
  37. // 倒计时
  38. startCountdown() {
  39. let that = this
  40. let {
  41. count,
  42. reminderCount
  43. } = that.data
  44. if (count) {
  45. that.data.intervalId1 && clearInterval(that.data.intervalId1);
  46. that.data.intervalId1 = setInterval(() => {
  47. count--
  48. if(reminderCount>0){
  49. reminderCount--
  50. }
  51. console.log()
  52. let remainingTime = '操作时间 ' + count + ' 秒'
  53. that.setData({
  54. remainingTime,
  55. reminderCount,
  56. isDisabled: that.data.confirmCountdownSwitch && (reminderCount > 0)
  57. })
  58. if (count <= 0) {
  59. // 倒计时结束,清除定时器
  60. clearInterval(that.data.intervalId1)
  61. my.reLaunch({
  62. url: '/pages/home/index',
  63. })
  64. }
  65. }, 1000) // 每秒更新一次倒计时数字
  66. }
  67. },
  68. sure() {
  69. if (this.data.isDisabled) {
  70. return
  71. }
  72. stopVoiceBroadcast()
  73. this.setData({
  74. isBack: true
  75. })
  76. clearInterval(this.data.intervalId1)
  77. // 是否启用副屏处理中页面
  78. let processingPageSwitch = app.globalData.snDisposition.processingPageSwitch;
  79. if (app.data.isSecondaryScreenState && processingPageSwitch) {
  80. console.log('打开副屏', app.data.isSecondaryScreenState);
  81. openSecondaryScreen(app.globalData.snDisposition.processingPageImage || '')
  82. }
  83. my.reLaunch({
  84. url: '/pages/interviewee/index'
  85. })
  86. },
  87. logOut() {
  88. stopVoiceBroadcast()
  89. this.setData({
  90. isBack: true
  91. })
  92. clearInterval(this.data.intervalId1)
  93. my.reLaunch({
  94. url: '/pages/home/index'
  95. });
  96. },
  97. });