navOprator.js 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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. $('#ManuallyDownloadError').html("");
  85. $('#ManuallyDownloadError').hide();
  86. let req = new Request(),reqIn ={};
  87. let data = document.getElementsByTagName('input');
  88. reqIn.reqCenterConfigUrl = data['centerConfigUrl'].value;
  89. req = Object.assign({},req,reqIn)
  90. $('#loading_mask').fadeIn('slow');
  91. let timeoutFn= setTimeout(function(){
  92. $('#loading_mask').fadeOut('slow');
  93. let tips = '请求超时'
  94. ModalPrompt(tips,'pathN')
  95. },timeout)
  96. CenterSettingService.Downloadv3(req, function(ret) {
  97. logEvent("Download ret: "+JSON.stringify(ret));
  98. console.log("Download ret: "+JSON.stringify(ret));
  99. if(ret){
  100. clearInterval(timeChange);
  101. clearTimeout(timeoutFn);
  102. $('#loading_mask').fadeOut('slow');
  103. // downloadStat为1表示成功,2表示失败但是不需要手动下载,3表示不需要更新,4表示失败并且允许手动下载
  104. if(ret.downloadStat==1){
  105. // document.getElementById("configUrl").innerHTML = ret.retCenterConfigUrl;
  106. $('#boxRestart').fadeIn();
  107. timeChange = setInterval(clock, 1000);
  108. }else if(ret.downloadStat==3){
  109. let tips = ret.strErrMsg?ret.strErrMsg:'集中配置是最新版本';
  110. showToast(tips);
  111. return false
  112. }else {
  113. let msg = ret.strErrMsg?ret.strErrMsg:'集中配置下载失败';
  114. let tips = msg + ',请联系总行信息部处理,是否进行手动下载?';
  115. $('#modalErrorBox').fadeIn('slow');
  116. $('#modalErrTips').html(tips);
  117. return false
  118. }
  119. }
  120. })
  121. }
  122. }
  123. // *********************下载集中配置 End*********************/
  124. // 密钥初始化Btn
  125. function resetRSA(){
  126. $('#entityCheckout').fadeOut()
  127. $('#serverNoAccess').fadeOut()
  128. $('#navBtns').fadeOut() //二维码没有菜单btns
  129. setTimeout(()=>{ //延时显示,避免内容污染
  130. $('#scanIdentity').css({display:'flex'});
  131. },300)
  132. getHardwareInfo()
  133. }
  134. // 扫码登录后接收code
  135. let codeIndentity
  136. window.onmessage = (event) => {
  137. console.log('event----',event)
  138. if (event && event.data.code) {
  139. //接收code参数,格式{code: "********",state:"***********"}
  140. codeIndentity = event.data.code;
  141. initializeNew(event.data.code)
  142. $('#scanIdentity').fadeOut()
  143. setTimeout(()=>{ //延时显示,避免内容污染
  144. $('#RSAReseting').css({display:'flex'});
  145. },300)
  146. document.getElementById('restDot').innerHTML = '重置设备密钥中,稍后自动重启应用<dot class="dot">●●●●●●</dot>'
  147. }
  148. };
  149. function initializeNew(code){
  150. let req = new Request()
  151. req.strAuthServer = HostUrl;
  152. req.strUserID = code
  153. req.strPassword = '88888888' //默认值,后台不做校验
  154. req.timeout = 60000
  155. let timeoutFn= setTimeout(function(){
  156. let tips = '请求超时'
  157. ModalPrompt(tips,'pathN','InitializeNew')
  158. stopAnimation();
  159. document.getElementById('restDot').innerHTML = '重置设备密钥失败,请重试或联系厂商维修'
  160. },timeout)
  161. //重置密钥
  162. AccessAuthService.InitializeNew(req, function(ret) {
  163. logEvent("InitializeNew ret: "+JSON.stringify(ret));
  164. console.log("InitializeNew ret: "+JSON.stringify(ret));
  165. if(ret){
  166. stopAnimation();
  167. clearTimeout(timeoutFn)
  168. }
  169. if(ret.errorCode == 0) {
  170. if(ret.Errcode !== 0)
  171. {
  172. let tips = ret.ErrMsg ? ret.ErrMsg : '重置密钥失败'
  173. ModalPrompt(tips,'pathN','InitializeNew')
  174. document.getElementById('restDot').innerHTML = '重置设备密钥失败,请重试或联系厂商维修'
  175. }else{
  176. let tips = '加载主密钥成功'
  177. ModalPrompt(tips,'pathY')
  178. setTimeout(()=>{
  179. $('#modalPrompt').fadeOut('slow')
  180. DeviceService.RebootShell();
  181. exitColck()
  182. },2000)
  183. }
  184. }
  185. else{
  186. let tips = ret.errorMsg ? ret.errorMsg : '重置密钥失败'
  187. ModalPrompt(tips,'pathN','InitializeNew')
  188. document.getElementById('restDot').innerHTML = '重置设备密钥失败,请重试或联系厂商维修'
  189. }
  190. });
  191. }
  192. function startAnimation(){
  193. let elem = document.querySelector('.dot');
  194. if(elem){
  195. elem.classList.remove('paused')
  196. }
  197. }
  198. function stopAnimation(){
  199. let elem = document.querySelector('.dot');
  200. if(elem){
  201. elem.classList.add('paused')
  202. }
  203. }
  204. // 退出
  205. function exit(){
  206. document.getElementsByTagName('input')['centerConfigUrl'].value="";
  207. $('#ManuallyDownloadError').html("");
  208. $('#ManuallyDownloadError').hide();
  209. $('#btn-downLoad').attr('disabled','disabled');
  210. // 进入的方式,决定退出的方式
  211. if(window.location.href.indexOf('entityCheck')>-1||window.location.href.indexOf('serverNoAccess')>-1){
  212. $('#scanIdentity').fadeOut(); //二维码关闭
  213. $('#RSAReseting').fadeOut(); //重置密钥中···关闭
  214. $('#ManuallyDownload').fadeOut();
  215. setTimeout(()=>{ //延时显示,避免内容污染
  216. $('#entityCheckout').fadeIn('slow')
  217. $('#serverNoAccess').fadeIn('slow')
  218. $('#navBtns').fadeIn('slow')
  219. },500)
  220. }else{
  221. let req = {};
  222. req.messageType = 0;
  223. req.command = 'ChromiumClose';
  224. sendRequest(req);
  225. }
  226. }
  227. // 最小化btn
  228. function Minimize(){
  229. let req = {};
  230. req.messageType = 0;
  231. req.command = 'ChromiumTomin';
  232. sendRequest(req);
  233. }
  234. let btnType
  235. //重启shell
  236. function RebootShell(){
  237. logEvent("RebootShell");
  238. btnType = 'RebootShell'
  239. modalConfirm('确认重启应用?')
  240. }
  241. //重启
  242. function RebootComputer(){
  243. logEvent("RebootComputer");
  244. modalConfirm('确认重启计算机?')
  245. btnType = 'RebootComputer'
  246. }
  247. //关机
  248. function PowerOff(){
  249. logEvent("PowerOff");
  250. btnType = 'PowerOff'
  251. modalConfirm('确认关闭计算机?')
  252. }
  253. // modal二次确认弹窗
  254. function modalConfirm(tips){
  255. $('#modalConfirm').fadeIn('slow')
  256. $('#errTipsErr').html(tips);
  257. }
  258. // modal 确定事件
  259. function clickSure(){
  260. if(!btnType)return false;
  261. $('#modalConfirm').fadeOut('slow')
  262. exitColck()
  263. switch(btnType)
  264. {
  265. case 'RebootShell': DeviceService.RebootShell(); break;
  266. case 'RebootComputer': DeviceService.RebootComputer();break
  267. case 'PowerOff': DeviceService.PowerOff(); break;
  268. }
  269. }
  270. // 20s后关闭错误页,自动退出
  271. function exitColck(){
  272. $('#modalExit').fadeIn('slow')
  273. let clock = 20
  274. let timer = setInterval(function(){
  275. clock--
  276. if(clock==0){
  277. let req = {};
  278. req.messageType = 0;
  279. req.command = 'ChromiumClose';
  280. sendRequest(req);
  281. clearInterval(timer)
  282. $('#modalExit').fadeOut('slow')
  283. }
  284. },1000)
  285. }
  286. function sendRequest(request){
  287. try{
  288. window.cefQuery({
  289. request: JSON.stringify(request),
  290. onSuccess: function() {
  291. console.log('window.cefQuery success');
  292. },
  293. onFailure: function(error_code, error_message) {
  294. console.log('window.cefQuery error,'+error_message + ' (' + error_code + ')');
  295. let tips = error_code + error_message
  296. ModalPrompt(tips,'pathN')
  297. }
  298. });
  299. }
  300. catch(ex) {
  301. console.log('window.cefQuery exception ',ex);
  302. let tips = '退出失败'
  303. ModalPrompt(tips,'pathN')
  304. }
  305. }