navOprator.js 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. // *********************下载集中配置 Start*********************/
  2. let ti = 29;
  3. let timeout=60000;
  4. let timeChange = null;
  5. function clock () {
  6. if (ti > 0) {
  7. ti = ti - 1;
  8. document.getElementById('restart-time').innerHTML = ti;
  9. } else {
  10. clearInterval(timeChange);
  11. ti = 29;
  12. $('#boxRestart').fadeOut('slow');
  13. exitColck();
  14. DeviceService.RebootShell();
  15. }
  16. };
  17. function restart(){
  18. clearInterval(timeChange);
  19. ti = 29;
  20. $('#boxRestart').fadeOut('slow');
  21. exitColck();
  22. DeviceService.RebootShell();
  23. }
  24. function showToast(title){
  25. $('#toastErrTips').html(title);
  26. $('#loading_mask').hide();
  27. $('#toastErrorBox').fadeIn('slow')
  28. setTimeout(()=>{
  29. $('#toastErrorBox').fadeOut('slow')
  30. },2000)
  31. }
  32. function changeInput(obj){
  33. if(obj.value!=''){
  34. $('#btn-downLoad').removeAttr('disabled');
  35. }else{
  36. $('#btn-downLoad').attr('disabled','disabled');
  37. }
  38. }
  39. function showManuallyDownloadModal(){
  40. $('#modalErrorBox').fadeOut('slow');
  41. $('#ManuallyDownload').fadeIn('slow');
  42. // RebootShell()
  43. }
  44. /**
  45. * @description: 下载集中配置:自动下载失败,可以进行手动下载
  46. * @param {value:自动下载 auto | 手动下载 manual}
  47. * @return: downloadStat
  48. */
  49. function downLoadv3(value){
  50. if(value=='auto'){
  51. let req = new Request();
  52. $('#loading_mask').fadeIn('slow');
  53. let timeoutFn= setTimeout(function(){
  54. $('#loading_mask').fadeOut('slow');
  55. let tips = '请求超时'
  56. showToast(tips);
  57. },timeout)
  58. CenterSettingService.Downloadv3(req, function(ret) {
  59. logEvent("Download ret: "+JSON.stringify(ret));
  60. console.log("Download ret: "+JSON.stringify(ret));
  61. if(ret){
  62. clearInterval(timeChange);
  63. clearTimeout(timeoutFn);
  64. $('#loading_mask').fadeOut('slow');
  65. // downloadStat为1表示成功,2表示失败但是不需要手动下载,3表示不需要更新,4表示失败并且允许手动下载
  66. if(ret.downloadStat==1){
  67. // document.getElementById("configUrl").innerHTML = ret.retCenterConfigUrl;
  68. $('#boxRestart').fadeIn();
  69. timeChange = setInterval(clock, 1000);
  70. }else if(ret.downloadStat==3 || ret.downloadStat==2){
  71. let tips = ret.strErrMsg?ret.strErrMsg:'集中配置下载失败';
  72. showToast(tips);
  73. return false
  74. }else {
  75. let msg = ret.strErrMsg?ret.strErrMsg:'集中配置下载失败';
  76. let tips = msg + ',请联系总行信息部处理,是否进行手动下载?';
  77. $('#modalErrorBox').fadeIn('slow');
  78. $('#modalErrTips').html(tips);
  79. return false
  80. }
  81. }
  82. })
  83. }else{
  84. let req = new Request(),reqIn ={}
  85. req = Object.assign({},req,reqIn)
  86. $('#loading_mask').fadeIn('slow');
  87. let timeoutFn= setTimeout(function(){
  88. $('#loading_mask').fadeOut('slow');
  89. let tips = '请求超时'
  90. ModalPrompt(tips,'pathN')
  91. },timeout)
  92. CenterSettingService.Downloadv3(req, function(ret) {
  93. logEvent("Download ret: "+JSON.stringify(ret));
  94. console.log("Download ret: "+JSON.stringify(ret));
  95. if(ret){
  96. clearInterval(timeChange);
  97. clearTimeout(timeoutFn);
  98. $('#loading_mask').fadeOut('slow');
  99. // downloadStat为1表示成功,2表示失败但是不需要手动下载,3表示不需要更新,4表示失败并且允许手动下载
  100. if(ret.downloadStat==1){
  101. // document.getElementById("configUrl").innerHTML = ret.retCenterConfigUrl;
  102. $('#boxRestart').fadeIn();
  103. timeChange = setInterval(clock, 1000);
  104. }else if(ret.downloadStat==3){
  105. let tips = ret.strErrMsg?ret.strErrMsg:'集中配置是最新版本';
  106. showToast(tips);
  107. return false
  108. }else {
  109. let msg = ret.strErrMsg?ret.strErrMsg:'集中配置下载失败';
  110. let tips = msg + ',请联系总行信息部处理,是否进行手动下载?';
  111. $('#modalErrorBox').fadeIn('slow');
  112. $('#modalErrTips').html(tips);
  113. return false
  114. }
  115. }
  116. })
  117. }
  118. }
  119. // *********************下载集中配置 End*********************/
  120. //跳过扫码
  121. function handleNext(){
  122. $('#scanIdentity').fadeOut()
  123. setTimeout(()=>{ //延时显示,避免内容污染
  124. $('#RSAReseting').css({display:'flex'});
  125. initializeNew('other')
  126. },500)
  127. }
  128. // 密钥初始化Btn
  129. function resetRSA(){
  130. $('#entityCheckout').fadeOut()
  131. $('#serverNoAccess').fadeOut()
  132. $('#navBtns').fadeOut() //二维码没有菜单btns
  133. setTimeout(()=>{ //延时显示,避免内容污染
  134. $('#scanIdentity').css({display:'flex'});
  135. },300)
  136. getHardwareInfo()
  137. setTimeout(()=>{
  138. $('.btn-next').fadeIn()
  139. },30000)
  140. }
  141. // 扫码登录后接收code
  142. let codeIndentity
  143. window.onmessage = (event) => {
  144. console.log('event----',event)
  145. if (event && event.data.code) {
  146. //接收code参数,格式{code: "********",state:"***********"}
  147. codeIndentity = event.data.code;
  148. initializeNew(event.data.code)
  149. $('#scanIdentity').fadeOut()
  150. setTimeout(()=>{ //延时显示,避免内容污染
  151. $('#RSAReseting').css({display:'flex'});
  152. },300)
  153. if(navigator.userAgent.toLowerCase().indexOf('windows')<0){
  154. document.getElementById('restDot').innerHTML = '重置设备密钥中,稍后自动重启应用<dot class="dot-uos">●●●●●●</dot>'
  155. }else{
  156. document.getElementById('restDot').innerHTML = '重置设备密钥中,稍后自动重启应用<dot class="dot">●●●●●●</dot>'
  157. }
  158. }
  159. };
  160. function initializeNew(code){
  161. let req = new Request()
  162. req.strAuthServer = '';
  163. req.strUserID = code
  164. req.strPassword = '88888888' // 默认虚拟值,后台不做校验以及相关处理(仅供终端实体逻辑判断-loginway)
  165. req.timeout = 60000
  166. let timeoutFn= setTimeout(function(){
  167. let tips = '请求超时'
  168. ModalPrompt(tips,'pathN','InitializeNew')
  169. stopAnimation();
  170. document.getElementById('restDot').innerHTML = '重置设备密钥失败,请重试或联系厂商维修'
  171. },timeout)
  172. //重置密钥
  173. AccessAuthService.InitializeNew(req, function(ret) {
  174. logEvent("InitializeNew ret: "+JSON.stringify(ret));
  175. console.log("InitializeNew ret: "+JSON.stringify(ret));
  176. if(ret){
  177. stopAnimation();
  178. clearTimeout(timeoutFn)
  179. }
  180. if(ret.errorCode == 0) {
  181. if(ret.Errcode !== 0)
  182. {
  183. let tips = ret.ErrMsg ? ret.ErrMsg : '重置密钥失败'
  184. ModalPrompt(tips,'pathN','InitializeNew')
  185. document.getElementById('restDot').innerHTML = '重置设备密钥失败,请重试或联系厂商维修'
  186. if(ret.Errcode == 1344405505){
  187. $('.hardwareConfig').fadeIn()
  188. }else{
  189. $('.hardwareConfig').fadeOut()
  190. }
  191. }else{
  192. let tips = '加载主密钥成功'
  193. ModalPrompt(tips,'pathY')
  194. setTimeout(()=>{
  195. $('#modalPrompt').fadeOut('slow')
  196. DeviceService.RebootShell();
  197. exitColck()
  198. },2000)
  199. }
  200. }
  201. else{
  202. let tips = ret.errorMsg ? ret.errorMsg : '重置密钥失败'
  203. ModalPrompt(tips,'pathN','InitializeNew')
  204. document.getElementById('restDot').innerHTML = '重置设备密钥失败,请重试或联系厂商维修'
  205. }
  206. });
  207. }
  208. function startAnimation(){
  209. let elem = document.querySelector('.dot');
  210. if(elem){
  211. elem.classList.remove('paused')
  212. }
  213. }
  214. function stopAnimation(){
  215. let elem = document.querySelector('.dot');
  216. if(elem){
  217. elem.classList.add('paused')
  218. }
  219. }
  220. // 退出
  221. function exit(){
  222. $('#btn-downLoad').attr('disabled','disabled');
  223. // 进入的方式,决定退出的方式
  224. if(window.location.href.indexOf('entityCheck')>-1||window.location.href.indexOf('serverNoAccess')>-1||window.location.href.indexOf('audioErr')>-1||window.location.href.indexOf('homePageErr')>-1){
  225. $('#scanIdentity').fadeOut(); //二维码关闭
  226. $('#RSAReseting').fadeOut(); //重置密钥中···关闭
  227. $('#ManuallyDownload').fadeOut();
  228. $('.btn-next').fadeOut() //···关闭
  229. setTimeout(()=>{ //延时显示,避免内容污染
  230. $('#entityCheckout').fadeIn('slow')
  231. $('#serverNoAccess').fadeIn('slow')
  232. $('#navBtns').fadeIn('slow')
  233. },500)
  234. }else{
  235. let req = {};
  236. req.messageType = 0;
  237. req.command = 'ChromiumClose';
  238. sendRequest(req);
  239. }
  240. }
  241. // 最小化btn
  242. function Minimize(){
  243. let req = {};
  244. req.messageType = 0;
  245. req.command = 'ChromiumTomin';
  246. sendRequest(req);
  247. }
  248. let btnType
  249. //重启shell
  250. function RebootShell(){
  251. logEvent("RebootShell");
  252. btnType = 'RebootShell'
  253. modalConfirm('确认重启应用?')
  254. }
  255. //重启
  256. function RebootComputer(){
  257. logEvent("RebootComputer");
  258. modalConfirm('确认重启计算机?')
  259. btnType = 'RebootComputer'
  260. }
  261. //关机
  262. function PowerOff(){
  263. logEvent("PowerOff");
  264. btnType = 'PowerOff'
  265. modalConfirm('确认关闭计算机?')
  266. }
  267. // modal二次确认弹窗
  268. function modalConfirm(tips){
  269. $('#modalConfirm').fadeIn('slow')
  270. $('#errTipsErr').html(tips);
  271. }
  272. // modal 确定事件
  273. function clickSure(){
  274. if(!btnType)return false;
  275. $('#modalConfirm').fadeOut('slow')
  276. exitColck()
  277. switch(btnType)
  278. {
  279. case 'RebootShell': DeviceService.RebootShell(); break;
  280. case 'RebootComputer': DeviceService.RebootComputer();break
  281. case 'PowerOff': DeviceService.PowerOff(); break;
  282. }
  283. }
  284. // 20s后关闭错误页,自动退出
  285. function exitColck(){
  286. $('#modalExit').fadeIn('slow')
  287. let clock = 20
  288. let timer = setInterval(function(){
  289. clock--
  290. if(clock==0){
  291. let req = {};
  292. req.messageType = 0;
  293. req.command = 'ChromiumClose';
  294. sendRequest(req);
  295. clearInterval(timer)
  296. $('#modalExit').fadeOut('slow')
  297. }
  298. },1000)
  299. }
  300. function sendRequest(request){
  301. try{
  302. window.cefQuery({
  303. request: JSON.stringify(request),
  304. onSuccess: function() {
  305. console.log('window.cefQuery success');
  306. },
  307. onFailure: function(error_code, error_message) {
  308. console.log('window.cefQuery error,'+error_message + ' (' + error_code + ')');
  309. let tips = error_code + error_message
  310. ModalPrompt(tips,'pathN')
  311. }
  312. });
  313. }
  314. catch(ex) {
  315. console.log('window.cefQuery exception ',ex);
  316. let tips = '退出失败'
  317. ModalPrompt(tips,'pathN')
  318. }
  319. }