navOprator.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  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. /**
  125. * @description: 读取配置 value=1,可以跳过扫码,直接重置密钥
  126. * @param {}
  127. * @return: value=1
  128. */
  129. let jumpScan = false //是否跳过扫码
  130. function ReadCenterScanConfig(){
  131. $('#loadContent').fadeIn('slow');
  132. let timeoutFn= setTimeout(function(){
  133. $('#loadContent').fadeOut('slow')
  134. let tips = '请求超时'
  135. ModalStyle(tips,'pathN')
  136. },timeout)
  137. let req = new Request();
  138. req["{e12a3dc0-3a0b-47c4-a8c3-75190a42ae68}"]={
  139. entity: 'AccessAuthorization' ,
  140. key: 'SkipScanCode' ,
  141. reserved1: 0,
  142. reserved2: 0,
  143. reserved3: '',
  144. reserved4: '',
  145. timeout: 60000,
  146. }
  147. HealthManagerService.ReadCenterConfigStr(req, function(ret) {
  148. logEvent("ReadCenterConfigStr ret: "+JSON.stringify(ret));
  149. console.log('ReadCenterScanConfig----',ret)
  150. if(ret){
  151. $('#loadContent').fadeOut('slow');
  152. clearTimeout(timeoutFn)
  153. }
  154. if(ret.errorCode ===0&&ret.value==1){
  155. jumpScan = true
  156. }else{
  157. jumpScan = false
  158. }
  159. })
  160. }
  161. // 密钥初始化Btn
  162. function resetRSA(){
  163. $('#entityCheckout').fadeOut()
  164. $('#serverNoAccess').fadeOut()
  165. $('#navBtns').fadeOut() //二维码没有菜单btns
  166. console.log('jumpScan---',jumpScan)
  167. if(jumpScan){
  168. setTimeout(()=>{ //延时显示,避免内容污染
  169. $('#RSAReseting').css({display:'flex'});
  170. initializeNew('admin')
  171. },500)
  172. }else{
  173. setTimeout(()=>{ //延时显示,避免内容污染
  174. $('#scanIdentity').css({display:'flex'});
  175. },300)
  176. }
  177. getHardwareInfo()
  178. }
  179. // 扫码登录后接收code
  180. let codeIndentity
  181. window.onmessage = (event) => {
  182. console.log('event----',event)
  183. if (event && event.data.code) {
  184. //接收code参数,格式{code: "********",state:"***********"}
  185. codeIndentity = event.data.code;
  186. initializeNew(event.data.code)
  187. $('#scanIdentity').fadeOut()
  188. setTimeout(()=>{ //延时显示,避免内容污染
  189. $('#RSAReseting').css({display:'flex'});
  190. },300)
  191. if(navigator.userAgent.toLowerCase().indexOf('windows')<0){
  192. document.getElementById('restDot').innerHTML = '重置设备密钥中,稍后自动重启应用<dot class="dot-uos">●●●●●●</dot>'
  193. }else{
  194. document.getElementById('restDot').innerHTML = '重置设备密钥中,稍后自动重启应用<dot class="dot">●●●●●●</dot>'
  195. }
  196. }
  197. };
  198. function initializeNew(code){
  199. let req = new Request()
  200. req.strAuthServer = HostUrl;
  201. req.strUserID = code
  202. req.strPassword = '88888888' //默认值,后台不做校验
  203. req.timeout = 60000
  204. let timeoutFn= setTimeout(function(){
  205. let tips = '请求超时'
  206. ModalPrompt(tips,'pathN','InitializeNew')
  207. stopAnimation();
  208. document.getElementById('restDot').innerHTML = '重置设备密钥失败,请重试或联系厂商维修'
  209. $('.hardwareConfig').fadeIn()
  210. },timeout)
  211. //重置密钥
  212. AccessAuthService.InitializeNew(req, function(ret) {
  213. logEvent("InitializeNew ret: "+JSON.stringify(ret));
  214. console.log("InitializeNew ret: "+JSON.stringify(ret));
  215. if(ret){
  216. stopAnimation();
  217. clearTimeout(timeoutFn)
  218. }
  219. if(ret.errorCode == 0) {
  220. if(ret.Errcode !== 0)
  221. {
  222. let tips = ret.ErrMsg ? ret.ErrMsg : '重置密钥失败'
  223. ModalPrompt(tips,'pathN','InitializeNew')
  224. document.getElementById('restDot').innerHTML = '重置设备密钥失败,请重试或联系厂商维修'
  225. $('.hardwareConfig').fadeIn()
  226. }else{
  227. let tips = '加载主密钥成功'
  228. ModalPrompt(tips,'pathY')
  229. setTimeout(()=>{
  230. $('#modalPrompt').fadeOut('slow')
  231. DeviceService.RebootShell();
  232. exitColck()
  233. },2000)
  234. }
  235. }
  236. else{
  237. let tips = ret.errorMsg ? ret.errorMsg : '重置密钥失败'
  238. ModalPrompt(tips,'pathN','InitializeNew')
  239. document.getElementById('restDot').innerHTML = '重置设备密钥失败,请重试或联系厂商维修'
  240. $('.hardwareConfig').fadeIn()
  241. }
  242. });
  243. }
  244. function startAnimation(){
  245. let elem = document.querySelector('.dot');
  246. if(elem){
  247. elem.classList.remove('paused')
  248. }
  249. }
  250. function stopAnimation(){
  251. let elem = document.querySelector('.dot');
  252. if(elem){
  253. elem.classList.add('paused')
  254. }
  255. }
  256. // 退出
  257. function exit(){
  258. document.getElementsByTagName('input')['centerConfigUrl'].value="";
  259. $('#ManuallyDownloadError').html("");
  260. $('#ManuallyDownloadError').hide();
  261. $('#btn-downLoad').attr('disabled','disabled');
  262. // 进入的方式,决定退出的方式
  263. if(window.location.href.indexOf('entityCheck')>-1||window.location.href.indexOf('serverNoAccess')>-1){
  264. $('#scanIdentity').fadeOut(); //二维码关闭
  265. $('#RSAReseting').fadeOut(); //重置密钥中···关闭
  266. $('#ManuallyDownload').fadeOut();
  267. setTimeout(()=>{ //延时显示,避免内容污染
  268. $('#entityCheckout').fadeIn('slow')
  269. $('#serverNoAccess').fadeIn('slow')
  270. $('#navBtns').fadeIn('slow')
  271. },500)
  272. }else{
  273. let req = {};
  274. req.messageType = 0;
  275. req.command = 'ChromiumClose';
  276. sendRequest(req);
  277. }
  278. }
  279. // 最小化btn
  280. function Minimize(){
  281. let req = {};
  282. req.messageType = 0;
  283. req.command = 'ChromiumTomin';
  284. sendRequest(req);
  285. }
  286. let btnType
  287. //重启shell
  288. function RebootShell(){
  289. logEvent("RebootShell");
  290. btnType = 'RebootShell'
  291. modalConfirm('确认重启应用?')
  292. }
  293. //重启
  294. function RebootComputer(){
  295. logEvent("RebootComputer");
  296. modalConfirm('确认重启计算机?')
  297. btnType = 'RebootComputer'
  298. }
  299. //关机
  300. function PowerOff(){
  301. logEvent("PowerOff");
  302. btnType = 'PowerOff'
  303. modalConfirm('确认关闭计算机?')
  304. }
  305. // modal二次确认弹窗
  306. function modalConfirm(tips){
  307. $('#modalConfirm').fadeIn('slow')
  308. $('#errTipsErr').html(tips);
  309. }
  310. // modal 确定事件
  311. function clickSure(){
  312. if(!btnType)return false;
  313. $('#modalConfirm').fadeOut('slow')
  314. exitColck()
  315. switch(btnType)
  316. {
  317. case 'RebootShell': DeviceService.RebootShell(); break;
  318. case 'RebootComputer': DeviceService.RebootComputer();break
  319. case 'PowerOff': DeviceService.PowerOff(); break;
  320. }
  321. }
  322. // 20s后关闭错误页,自动退出
  323. function exitColck(){
  324. $('#modalExit').fadeIn('slow')
  325. let clock = 20
  326. let timer = setInterval(function(){
  327. clock--
  328. if(clock==0){
  329. let req = {};
  330. req.messageType = 0;
  331. req.command = 'ChromiumClose';
  332. sendRequest(req);
  333. clearInterval(timer)
  334. $('#modalExit').fadeOut('slow')
  335. }
  336. },1000)
  337. }
  338. function sendRequest(request){
  339. try{
  340. window.cefQuery({
  341. request: JSON.stringify(request),
  342. onSuccess: function() {
  343. console.log('window.cefQuery success');
  344. },
  345. onFailure: function(error_code, error_message) {
  346. console.log('window.cefQuery error,'+error_message + ' (' + error_code + ')');
  347. let tips = error_code + error_message
  348. ModalPrompt(tips,'pathN')
  349. }
  350. });
  351. }
  352. catch(ex) {
  353. console.log('window.cefQuery exception ',ex);
  354. let tips = '退出失败'
  355. ModalPrompt(tips,'pathN')
  356. }
  357. }