index.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. import {
  2. updateConfig,
  3. snConfig
  4. } from '../../../utils/api/api'
  5. import {
  6. getWaterDrop,
  7. } from '../../../utils/index/index'
  8. const app = getApp()
  9. Page({
  10. data: {
  11. list: [{
  12. name: '选择受访人超时时长(s)',
  13. value: 'chooseVisiteeTimeout'
  14. },
  15. {
  16. name: '刷身份证超时时长(s)',
  17. value: 'readIdcardTimeout'
  18. },
  19. {
  20. name: '输身份证超时时长(s)',
  21. value: 'inputIdcardTimeout'
  22. },
  23. {
  24. name: '输手机号超时时长(s)',
  25. value: 'inputPhoneTimeout'
  26. },
  27. {
  28. name: '签离扫码超时时长(s)',
  29. value: 'singOutTimeout'
  30. },
  31. {
  32. name: '结果页超时时长(s)',
  33. value: 'resultPageTimeout'
  34. },
  35. {
  36. name: '刷脸超时时间(s)',
  37. value: 'faceTimeout'
  38. },
  39. {
  40. name: '1v1比对超时时间(s)',
  41. value: 'oneToOneTimeout'
  42. },
  43. {
  44. name: '联网查询超时时间(s)',
  45. value: 'connectSearchTimeout'
  46. },
  47. ],
  48. form: {
  49. chooseVisiteeTimeout: 90,
  50. readIdcardTimeout: 15,
  51. inputIdcardTimeout: 30,
  52. inputPhoneTimeout: 30,
  53. singOutTimeout: 15,
  54. resultPageTimeout: 5,
  55. faceTimeout: 40,
  56. oneToOneTimeout: 40,
  57. connectSearchTimeout: 40,
  58. },
  59. isPortraitScreen: false,// 是否为竖屏:true竖屏 false横屏
  60. screenIntervalId: null, //定时器
  61. },
  62. onLoad() {
  63. my.hideBackHome();
  64. const _this = this
  65. this.initScreenType().then(isPortraitScreenRes => {
  66. console.log('isPortraitScreenRes', isPortraitScreenRes)
  67. _this.setData({
  68. isPortraitScreen: isPortraitScreenRes
  69. })
  70. })
  71. this.getForm()
  72. },
  73. initScreenType() {
  74. let that = this
  75. return new Promise((resolve, reject) => {
  76. if (app.globalData.isPortraitScreen) {
  77. if (app.globalData.isPortraitScreen != null) {
  78. resolve(app.globalData.isPortraitScreen)
  79. }
  80. } else {
  81. that.data.screenIntervalId = setInterval(function () {
  82. console.log('asdasdsaddasdad', app.globalData)
  83. if (app.globalData.isPortraitScreen != null) {
  84. resolve(app.globalData.isPortraitScreen)
  85. clearInterval(that.data.screenIntervalId);
  86. }
  87. }, 1000);
  88. }
  89. })
  90. },
  91. clickAudio() {
  92. getWaterDrop()
  93. },
  94. async getForm() {
  95. my.showLoading()
  96. try {
  97. let dto = {
  98. sn: app.globalData.sn,
  99. token: app.globalData.FKJConfiguration,
  100. }
  101. let res = await snConfig(dto)
  102. this.setData({
  103. form: res.data
  104. })
  105. } catch (error) { } finally {
  106. my.hideLoading()
  107. }
  108. },
  109. // 减
  110. minus(e) {
  111. let key = e.currentTarget.dataset.item.value
  112. let value = this.data.form[key]
  113. let NameVal = `form[${key}]`
  114. if (value <= 0 || !value) {
  115. return
  116. }
  117. this.setData({
  118. [NameVal]: value - 1
  119. })
  120. },
  121. // 加
  122. add(e) {
  123. let key = e.currentTarget.dataset.item.value
  124. let value = this.data.form[key]
  125. if (!value) {
  126. value = 0
  127. }
  128. let NameVal = `form[${key}]`
  129. this.setData({
  130. [NameVal]: value + 1
  131. })
  132. },
  133. getVal(e) {
  134. let key = e.currentTarget.dataset.item.value
  135. let value = e.detail.value
  136. let NameVal = `form[${key}]`
  137. this.setData({
  138. [NameVal]: value
  139. })
  140. },
  141. async sure() {
  142. let {
  143. form
  144. } = this.data
  145. form.sn = app.globalData.sn;
  146. form.modifyType = app.globalData.modifyType[2];
  147. form.token = app.globalData.FKJConfiguration;
  148. my.showLoading()
  149. try {
  150. let res = await updateConfig(form)
  151. app.globalData.snDisposition.chooseVisiteeTimeout = form.chooseVisiteeTimeout;
  152. app.globalData.snDisposition.readIdcardTimeout = form.readIdcardTimeout;
  153. app.globalData.snDisposition.inputIdcardTimeout = form.inputIdcardTimeout;
  154. app.globalData.snDisposition.inputPhoneTimeout = form.inputPhoneTimeout;
  155. app.globalData.snDisposition.singOutTimeout = form.singOutTimeout;
  156. app.globalData.snDisposition.resultPageTimeout = form.resultPageTimeout;
  157. app.globalData.snDisposition.faceTimeout = form.faceTimeout;
  158. app.globalData.snDisposition.oneToOneTimeout = form.oneToOneTimeout;
  159. app.globalData.snDisposition.connectSearchTimeout = form.connectSearchTimeout;
  160. // console.log(app.globalData.snDisposition);
  161. my.setStorageSync({
  162. data: app.globalData.snDisposition,
  163. key: 'snDisposition'
  164. });
  165. my.reLaunch({
  166. url: "/pages/settings/index/index"
  167. })
  168. } catch (error) {
  169. console.log(error);
  170. } finally {
  171. my.hideLoading()
  172. }
  173. },
  174. });