0
0

show_old.html 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822
  1. {extend name="common/common2" /}
  2. {block name="main"}
  3. <style>
  4. .col-xs-3{
  5. padding: 10px 20px;
  6. }
  7. .model-btn{
  8. display: block;
  9. width: 100%;
  10. height: 200px;
  11. text-align: center;
  12. color: #fff;
  13. text-decoration: none;
  14. padding: 40px;
  15. }
  16. .model-btn:hover,.model-btn:focus,.model-btn:active{
  17. color: #fff;
  18. text-decoration: none;
  19. }
  20. .model-btn .model-btn-icon{
  21. font-size: 500%;
  22. margin: 0;
  23. }
  24. .model-btn .model-btn-title{
  25. font-size: 150%;
  26. margin: 0;
  27. }
  28. .bg-color-green{
  29. background-color: #0BB20C;
  30. }
  31. .bg-color-green:hover{
  32. background-color: #339933;
  33. }
  34. .bg-color-purple{
  35. background-color: #6a47d5;
  36. }
  37. .bg-color-purple:hover{
  38. /*background-color: #603cba;*/
  39. background-color: #6600CC;
  40. }
  41. .bg-color-red{
  42. background-color: #FF0000;
  43. }
  44. .bg-color-red:hover{
  45. background-color: #e1113d;
  46. }
  47. .bg-color-blue{
  48. background-color: #3366FF;
  49. }
  50. .bg-color-blue:hover{
  51. background-color: #3333CC;
  52. }
  53. </style>
  54. <div class="row">
  55. <div class="col-sm-12">
  56. <div class="ibox float-e-margins" style="display: block;">
  57. <div class="ibox-title">
  58. <h5>电话监控日志</h5>
  59. </div>
  60. <div class="ibox-content">
  61. <textarea id="StatusArea" rows="13" name="S1" class="form-control" readonly></textarea>
  62. <br>
  63. <input type="button" value="检查本地驱动是否安装" name="B0" onClick="I_CheckActiveX()">
  64. <input type="button" value="弹出电话" onClick="openPhone()">
  65. </div>
  66. </div>
  67. <div class="ibox float-e-margins" style="display: none;">
  68. <div class="ibox-title">
  69. <h5>监控信息</h5>
  70. </div>
  71. <div class="ibox-content">
  72. <div style="margin-top: 10px;margin-bottom: 10px;"></div>
  73. <div class="row metro">
  74. {foreach $worktype as $k=>$v}
  75. <div class="col-xs-3">
  76. <a
  77. href="javascript:;" onclick="layer_open(this,1)" url="{:url('orders/dispatchadd',[],'')}/mode/{$v.id}"
  78. data-title="{$v.title}"
  79. {if $v['id'] == 1}
  80. class="model-btn bg-color-green btn-dialog-form"
  81. {/if}
  82. {if $v['id'] == 2}
  83. class="model-btn bg-color-purple btn-dialog-form"
  84. {/if}
  85. {if $v['id'] == 3}
  86. class="model-btn bg-color-blue btn-dialog-form"
  87. {/if}
  88. {if $v['id'] == 4}
  89. class="model-btn bg-color-red btn-dialog-form"
  90. {/if} >
  91. <p class="model-btn-icon">
  92. {if $v['id'] == 1}
  93. <i class="glyphicon glyphicon-wrench"></i>
  94. {/if}
  95. {if $v['id'] == 2}
  96. <i class="glyphicon glyphicon-plus"></i>
  97. {/if}
  98. {if $v['id'] == 3}
  99. <i class="glyphicon glyphicon-transfer"></i>
  100. {/if}
  101. {if $v['id'] == 4}
  102. <i class="glyphicon glyphicon-ban-circle"></i>
  103. {/if}
  104. </p>
  105. <p class="model-btn-title">{$v.title}</p>
  106. </a>
  107. </div>
  108. {/foreach}
  109. </div>
  110. <div style="margin-top: 10px;margin-bottom: 20px;"></div>
  111. </div>
  112. </div>
  113. <div class="panel-group">
  114. <div class="panel panel-default">
  115. <div class="panel-heading clearfix">
  116. <div class="btn-group pull-right"></div>
  117. <div class="btn-group pull-left">
  118. 近50条电话记录
  119. </div>
  120. </div>
  121. <div class="panel-body" style="max-height: 300px;overflow: auto">
  122. <table class="table table-striped">
  123. <tr>
  124. <th>时间</th>
  125. <th>科室</th>
  126. <th>负责人</th>
  127. <th>电话</th>
  128. <th>备注</th>
  129. <th>操作</th>
  130. </tr>
  131. <tbody id="slistphone">
  132. <!-- <tr>-->
  133. <!-- <td>时间</td>-->
  134. <!-- <td>科室</td>-->
  135. <!-- <td>负责人</td>-->
  136. <!-- <td>电话</td>-->
  137. <!-- <td>-->
  138. <!-- <a href="#">报修</a> &nbsp;&nbsp;-->
  139. <!-- <a href="#">保洁</a> &nbsp;&nbsp;-->
  140. <!-- <a href="#">运送</a> &nbsp;&nbsp;-->
  141. <!-- <a href="#">应急</a> &nbsp;&nbsp;-->
  142. <!-- </td>-->
  143. <!-- </tr>-->
  144. </tbody>
  145. </table>
  146. </div>
  147. </div>
  148. </div>
  149. </div>
  150. </div>
  151. {/block}
  152. {block name="script"}
  153. <script language="javascript" type="text/javascript" src="/static/phonejs/qnviccub.js"></script>
  154. <script language="javascript" type="text/javascript" src="/static/phonejs/qnvfunc.js"></script>
  155. <script language="javascript" type="text/javascript" src="/static/phonejs/json2.js"></script>
  156. <script language="javascript" type="text/javascript" src="/static/phonejs/deviceapi.js"></script>
  157. <script>
  158. $(document).ready(function(){
  159. // TV_Initialize();
  160. // getEvent(T_GetEvent);
  161. });
  162. $(window).unload(function(){
  163. // TV_Disable();
  164. });
  165. setInterval(function () {
  166. // OpenDevice(ODT_LBRIDGE,function(nResult){AppendStatus('打开设备.');});
  167. },30000);
  168. //离开页面
  169. $(window).bind('beforeunload',function(){
  170. // TV_Disable();
  171. });
  172. var plist = {:json_encode($list)};
  173. var id = 0;
  174. var name = '';
  175. var dep = '';
  176. var phone = '';
  177. var remark = '';
  178. var time = '';
  179. var slphone = localStorage.slist;
  180. var slist = slphone ? JSON.parse(slphone) : [];
  181. slistPhoneHtml();
  182. function openPhone() {
  183. let gphone = "13838379499";
  184. check_phone(gphone);
  185. setTimeout(function () {
  186. check_phone(gphone);
  187. },3000);
  188. }
  189. function selectPhone(){
  190. slist.unshift({
  191. id: id,
  192. name: name,
  193. dep: dep,
  194. phone: phone,
  195. time: time,
  196. remark:remark
  197. });
  198. if(slist.length > 50){
  199. slist.pop();
  200. }
  201. localStorage.slist = JSON.stringify(slist);
  202. slistPhoneHtml();
  203. }
  204. function slistPhoneHtml(){
  205. console.log('slistPhoneHtml',slist);
  206. if(slist.length > 0){
  207. let str = '';
  208. for (let o in slist){
  209. str += '<tr>';
  210. str += '<td>' + slist[o].time + '</td>';
  211. str += '<td>' + slist[o].dep + '</td>';
  212. str += '<td>' + slist[o].name + '</td>';
  213. str += '<td>' + slist[o].phone + '</td>';
  214. str += '<td>' + slist[o].remark + '</td>';
  215. str += '<td>';
  216. str += '<a href="javascript:;" data-title="创建报修订单" onclick="layer_open(this,1)" url="{:url("Orders/dispatchAdd",[],"")}/mode/1?id='+slist[o].id+'">报修</a> &nbsp;&nbsp;';
  217. str += '<a href="javascript:;" data-title="创建保洁订单" onclick="layer_open(this,1)" url="{:url("Orders/dispatchAdd",[],"")}/mode/2?id='+slist[o].id+'">保洁</a> &nbsp;&nbsp;';
  218. str += '<a href="javascript:;" data-title="创建运送订单" onclick="layer_open(this,1)" url="{:url("Orders/dispatchAdd",[],"")}/mode/3?id='+slist[o].id+'">运送</a> &nbsp;&nbsp;';
  219. str += '<a href="javascript:;" data-title="创建应急订单" onclick="layer_open(this,1)" url="{:url("Orders/dispatchAdd",[],"")}/mode/4?id='+slist[o].id+'">应急</a> &nbsp;&nbsp;';
  220. str += '</td>';
  221. str += '</tr>';
  222. }
  223. $('#slistphone').html(str);
  224. }
  225. }
  226. $('.btn-dialog-myform').click(function (e) {
  227. /*if(id <= 0){
  228. layer.msg('未测到科室信息');
  229. return false;
  230. }*/
  231. var url = $(this).attr('href') + '&id=' + id;
  232. var title = '添加' + $(this).attr('data-title');
  233. // jFlyer.show_dialog_form(title, url);
  234. layer.open({
  235. type: 2,
  236. shade: 0.8,
  237. title: title,
  238. area: 'auto',
  239. area: ['800px', '90%'],
  240. fix: false, //不固定
  241. maxmin: true,
  242. content: url,
  243. skin: 'layer-ext-moon',
  244. success: function(layero, index) {
  245. layer.iframeAuto(index);
  246. //设置标题
  247. //layer.title($this.text(), index);
  248. },
  249. btn: ['取消']
  250. });
  251. return false;
  252. });
  253. function check_phone(gphone) {
  254. var url = '{:url("orders/phone")}?phone=' + gphone;
  255. var title = '添加订单';
  256. layer.open({
  257. type: 2,
  258. shade: 0.8,
  259. title: title,
  260. area: 'auto',
  261. area: ['800px', '90%'],
  262. fix: false, //不固定
  263. maxmin: true,
  264. content: url,
  265. skin: 'layer-ext-moon',
  266. success: function(layero, index) {
  267. layer.iframeAuto(index);
  268. //设置标题
  269. //layer.title($this.text(), index);
  270. },
  271. btn: ['取消']
  272. });
  273. return false;
  274. }
  275. //check_phone('13800000000')
  276. function check_phone_old(gphone) {
  277. id = 0;
  278. name = '';
  279. dep = '';
  280. phone = '';
  281. time = '';
  282. remark = '';
  283. if(plist.length <= 0){
  284. return false;
  285. }
  286. for (let o in plist){
  287. if(gphone == plist[o].phone){
  288. id = plist[o].id;
  289. name = plist[o].real_name;
  290. dep = plist[o].dep;
  291. phone = plist[o].phone;
  292. remark = plist[o].remark;
  293. time = getCurrentDate(2);
  294. break;
  295. }
  296. }
  297. if(id > 0){
  298. // $('#dep').html('科室:' + dep);
  299. // $('#name').html(' &nbsp;&nbsp;负责人:' + name);
  300. // $('#phone').html(' &nbsp;&nbsp;电话:' + phone);
  301. // $('#time').html(' &nbsp;&nbsp;来电时间:' + time);
  302. selectPhone();
  303. var url = '{:url("orders/phoneAdd")}?id=' + id;
  304. var title = '添加订单';
  305. // jFlyer.show_dialog_form(title, url);
  306. layer.open({
  307. type: 2,
  308. shade: 0.8,
  309. title: title,
  310. area: 'auto',
  311. area: ['800px', '90%'],
  312. fix: false, //不固定
  313. maxmin: true,
  314. content: url,
  315. skin: 'layer-ext-moon',
  316. success: function(layero, index) {
  317. layer.iframeAuto(index);
  318. //设置标题
  319. //layer.title($this.text(), index);
  320. },
  321. btn: ['取消']
  322. });
  323. return false;
  324. }else{
  325. // $('#dep').html('');
  326. // $('#name').html('');
  327. // $('#phone').html('');
  328. // $('#time').html('');
  329. }
  330. }
  331. function AppendStatus(szStatus)
  332. {
  333. $("#StatusArea").append(szStatus+"\r\n" );
  334. var scrollTop = $("#StatusArea")[0].scrollHeight;
  335. $("#StatusArea").scrollTop(scrollTop);
  336. }
  337. function AppendStatusEx(uID,szStatus)
  338. {
  339. uID=uID+1;
  340. AppendStatus("通道"+uID+":"+szStatus);
  341. }
  342. function showDlg(flag)
  343. {
  344. var urlStr=prompt("请输入上传的文件的URL,格式如php文件上传","");
  345. if (urlStr!=null && urlStr != "")
  346. {
  347. if(flag==0)
  348. TV_uploadFile(urlStr);
  349. else
  350. ali_uploadFile(urlStr);
  351. }
  352. else{
  353. alert('上传url不能为空!');
  354. }
  355. }
  356. function T_GetEvent(uID,uEventType,uHandle,uResult,szdata)
  357. {
  358. // console.log(uID,uEventType,uHandle,uResult,szdata);
  359. //var vValueArray=qnviccub.QNV_Event(0,2,0,"","",1024);
  360. if(uEventType == -1)
  361. return;
  362. var vValue=" type="+uEventType+" Handle="+uHandle+" Result="+uResult+" szdata="+szdata;
  363. switch(uEventType)
  364. {
  365. case BriEvent_PhoneHook:// 本地电话机摘机事件
  366. AppendStatusEx(uID,"本地电话机摘机"+vValue);
  367. break;
  368. case BriEvent_PhoneDial:// 只有在本地话机摘机,没有调用软摘机时,检测到DTMF拨号
  369. AppendStatusEx(uID,"本地话机拨号"+vValue);
  370. break;
  371. case BriEvent_PhoneHang:// 本地电话机挂机事件
  372. TV_HangUpCtrl(uID);
  373. AppendStatusEx(uID,"本地电话机挂机"+vValue);
  374. break;
  375. case BriEvent_CallIn:// 外线通道来电响铃事件
  376. AppendStatusEx(uID,"外线通道来电响铃事件"+vValue);
  377. break;
  378. case BriEvent_GetCallID://得到来电号码
  379. AppendStatusEx(uID,"得到来电号码"+vValue);
  380. check_phone(szdata);
  381. break;
  382. case BriEvent_StopCallIn:// 对方停止呼叫(产生一个未接电话)
  383. AppendStatusEx(uID,"对方停止呼叫(产生一个未接电话)"+vValue);
  384. break;
  385. case BriEvent_DialEnd:// 调用开始拨号后,全部号码拨号结束
  386. AppendStatusEx(uID,"调用开始拨号后,全部号码拨号结束"+vValue);
  387. break;
  388. case BriEvent_PlayFileEnd:// 播放文件结束事件
  389. AppendStatusEx(uID,"播放文件结束事件"+vValue);
  390. break;
  391. case BriEvent_PlayMultiFileEnd:// 多文件连播结束事件
  392. AppendStatusEx(uID,"多文件连播结束事件"+vValue);
  393. break;
  394. case BriEvent_PlayStringEnd://播放字符结束
  395. AppendStatusEx(uID,"播放字符结束"+vValue);
  396. break;
  397. case BriEvent_RepeatPlayFile:// 播放文件结束准备重复播放
  398. AppendStatusEx(uID,"播放文件结束准备重复播放"+vValue);
  399. break;
  400. case BriEvent_SendCallIDEnd:// 给本地设备发送震铃信号时发送号码结束
  401. AppendStatusEx(uID,"给本地设备发送震铃信号时发送号码结束"+vValue);
  402. break;
  403. case BriEvent_RingTimeOut://给本地设备发送震铃信号时超时
  404. AppendStatusEx(uID,"给本地设备发送震铃信号时超时"+vValue);
  405. break;
  406. case BriEvent_Ringing://正在内线震铃
  407. AppendStatusEx(uID,"正在内线震铃"+vValue);
  408. break;
  409. case BriEvent_Silence:// 通话时检测到一定时间的静音.默认为5秒
  410. AppendStatusEx(uID,"通话时检测到一定时间的静音"+vValue);
  411. break;
  412. case BriEvent_GetDTMFChar:// 线路接通时收到DTMF码事件
  413. AppendStatusEx(uID,"线路接通时收到DTMF码事件"+vValue);
  414. break;
  415. case BriEvent_RemoteHook:// 拨号后,被叫方摘机事件
  416. AppendStatusEx(uID,"拨号后,被叫方摘机事件"+vValue);
  417. break;
  418. case BriEvent_RemoteHang://对方挂机事件
  419. TV_HangUpCtrl(uID);
  420. AppendStatusEx(uID,"对方挂机事件"+vValue);
  421. break;
  422. case BriEvent_Busy:// 检测到忙音事件,表示PSTN线路已经被断开
  423. AppendStatusEx(uID,"检测到忙音事件,表示PSTN线路已经被断开"+vValue);
  424. break;
  425. case BriEvent_DialTone:// 本地摘机后检测到拨号音
  426. AppendStatusEx(uID,"本地摘机后检测到拨号音"+vValue);
  427. break;
  428. case BriEvent_RingBack:// 电话机拨号结束呼出事件。
  429. AppendStatusEx(uID,"电话机拨号结束呼出事件"+vValue);
  430. break;
  431. case BriEvent_MicIn:// MIC插入状态
  432. AppendStatusEx(uID,"MIC插入状态"+vValue);
  433. break;
  434. case BriEvent_MicOut:// MIC拔出状态
  435. AppendStatusEx(uID,"MIC拔出状态"+vValue);
  436. break;
  437. case BriEvent_FlashEnd:// 拍插簧(Flash)完成事件,拍插簧完成后可以检测拨号音后进行二次拨号
  438. AppendStatusEx(uID,"拍插簧(Flash)完成事件,拍插簧完成后可以检测拨号音后进行二次拨号"+vValue);
  439. break;
  440. case BriEvent_RefuseEnd:// 拒接完成
  441. AppendStatusEx(uID,"拒接完成"+vValue);
  442. break;
  443. case BriEvent_SpeechResult:// 语音识别完成
  444. AppendStatusEx(uID,"语音识别完成"+vValue);
  445. break;
  446. case BriEvent_FaxRecvFinished:// 接收传真完成
  447. AppendStatusEx(uID,"接收传真完成"+vValue);
  448. break;
  449. case BriEvent_FaxRecvFailed:// 接收传真失败
  450. AppendStatusEx(uID,"接收传真失败"+vValue);
  451. break;
  452. case BriEvent_FaxSendFinished:// 发送传真完成
  453. AppendStatusEx(uID,"发送传真完成"+vValue);
  454. break;
  455. case BriEvent_FaxSendFailed:// 发送传真失败
  456. AppendStatusEx(uID,"发送传真失败"+vValue);
  457. break;
  458. case BriEvent_OpenSoundFailed:// 启动声卡失败
  459. AppendStatusEx(uID,"启动声卡失败"+vValue);
  460. break;
  461. case BriEvent_UploadSuccess://远程上传成功
  462. AppendStatusEx(uID,"远程上传成功"+vValue);
  463. break;
  464. case BriEvent_UploadFailed://远程上传失败
  465. AppendStatusEx(uID,"远程上传失败"+vValue);
  466. break;
  467. case BriEvent_EnableHook:// 应用层调用软摘机/软挂机成功事件
  468. AppendStatusEx(uID,"应用层调用软摘机/软挂机成功事件"+vValue);
  469. break;
  470. case BriEvent_EnablePlay:// 喇叭被打开或者/关闭
  471. AppendStatusEx(uID,"喇叭被打开或者/关闭"+vValue);
  472. break;
  473. case BriEvent_EnableMic:// MIC被打开或者关闭
  474. AppendStatusEx(uID,"MIC被打开或者关闭"+vValue);
  475. break;
  476. case BriEvent_EnableSpk:// 耳机被打开或者关闭
  477. AppendStatusEx(uID,"耳机被打开或者关闭"+vValue);
  478. break;
  479. case BriEvent_EnableRing:// 电话机跟电话线(PSTN)断开/接通
  480. AppendStatusEx(uID,"电话机跟电话线(PSTN)断开/接通"+vValue);
  481. break;
  482. case BriEvent_DoRecSource:// 修改录音源
  483. AppendStatusEx(uID,"修改录音源"+vValue);
  484. break;
  485. case BriEvent_DoStartDial:// 开始软件拨号
  486. AppendStatusEx(uID,"开始软件拨号"+vValue);
  487. break;
  488. case BriEvent_RecvedFSK:// 接收到FSK信号,包括通话中FSK/来电号码的FSK
  489. AppendStatusEx(uID,"接收到FSK信号,包括通话中FSK/来电号码的FSK"+vValue);
  490. break;
  491. case BriEvent_PlugOut:
  492. AppendStatusEx(uID,"设备移除");
  493. // alert('设备移除');
  494. break;
  495. case BriEvent_DevErr://设备错误
  496. AppendStatusEx(uID,"设备错误"+ decodeURIComponent(vValue) );
  497. // alert('设备错误');
  498. break;
  499. default:
  500. if(uEventType < BriEvent_EndID)
  501. AppendStatusEx(uID,"忽略其它事件发生:ID=" + uEventType+ vValue);
  502. break;
  503. }
  504. }
  505. //编码问题
  506. var base64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  507. var base64DecodeChars = new Array(
  508. -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  509. -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  510. -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
  511. 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
  512. -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
  513. 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
  514. -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
  515. 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1);
  516. function base64encode(str) {
  517. var out, i, len;
  518. var c1, c2, c3;
  519. len = str.length;
  520. i = 0;
  521. out = "";
  522. while(i < len) {
  523. c1 = str.charCodeAt(i++) & 0xff;
  524. if(i == len)
  525. {
  526. out += base64EncodeChars.charAt(c1 >> 2);
  527. out += base64EncodeChars.charAt((c1 & 0x3) << 4);
  528. out += "==";
  529. break;
  530. }
  531. c2 = str.charCodeAt(i++);
  532. if(i == len)
  533. {
  534. out += base64EncodeChars.charAt(c1 >> 2);
  535. out += base64EncodeChars.charAt(((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4));
  536. out += base64EncodeChars.charAt((c2 & 0xF) << 2);
  537. out += "=";
  538. break;
  539. }
  540. c3 = str.charCodeAt(i++);
  541. out += base64EncodeChars.charAt(c1 >> 2);
  542. out += base64EncodeChars.charAt(((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4));
  543. out += base64EncodeChars.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >>6));
  544. out += base64EncodeChars.charAt(c3 & 0x3F);
  545. }
  546. return out;
  547. }
  548. function base64decode(str) {
  549. var c1, c2, c3, c4;
  550. var i, len, out;
  551. len = str.length;
  552. i = 0;
  553. out = "";
  554. while(i < len) {
  555. /* c1 */
  556. do {
  557. c1 = base64DecodeChars[str.charCodeAt(i++) & 0xff];
  558. } while(i < len && c1 == -1);
  559. if(c1 == -1)
  560. break;
  561. /* c2 */
  562. do {
  563. c2 = base64DecodeChars[str.charCodeAt(i++) & 0xff];
  564. } while(i < len && c2 == -1);
  565. if(c2 == -1)
  566. break;
  567. out += String.fromCharCode((c1 << 2) | ((c2 & 0x30) >> 4));
  568. /* c3 */
  569. do {
  570. c3 = str.charCodeAt(i++) & 0xff;
  571. if(c3 == 61)
  572. return out;
  573. c3 = base64DecodeChars[c3];
  574. } while(i < len && c3 == -1);
  575. if(c3 == -1)
  576. break;
  577. out += String.fromCharCode(((c2 & 0XF) << 4) | ((c3 & 0x3C) >> 2));
  578. /* c4 */
  579. do {
  580. c4 = str.charCodeAt(i++) & 0xff;
  581. if(c4 == 61)
  582. return out;
  583. c4 = base64DecodeChars[c4];
  584. } while(i < len && c4 == -1);
  585. if(c4 == -1)
  586. break;
  587. out += String.fromCharCode(((c3 & 0x03) << 6) | c4);
  588. }
  589. return out;
  590. }
  591. function utf16to8(str) {
  592. var out, i, len, c;
  593. out = "";
  594. len = str.length;
  595. for(i = 0; i < len; i++) {
  596. c = str.charCodeAt(i);
  597. if ((c >= 0x0001) && (c <= 0x007F)) {
  598. out += str.charAt(i);
  599. } else if (c > 0x07FF) {
  600. out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));
  601. out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F));
  602. out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
  603. } else {
  604. out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F));
  605. out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
  606. }
  607. }
  608. return out;
  609. }
  610. function utf8to16(str) {
  611. var out, i, len, c;
  612. var char2, char3;
  613. out = "";
  614. len = str.length;
  615. i = 0;
  616. while(i < len) {
  617. c = str.charCodeAt(i++);
  618. switch(c >> 4)
  619. {
  620. case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
  621. // 0xxxxxxx
  622. out += str.charAt(i-1);
  623. break;
  624. case 12: case 13:
  625. // 110x xxxx  10xx xxxx
  626. char2 = str.charCodeAt(i++);
  627. out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F));
  628. break;
  629. case 14:
  630. // 1110 xxxx 10xx xxxx 10xx xxxx
  631. char2 = str.charCodeAt(i++);
  632. char3 = str.charCodeAt(i++);
  633. out += String.fromCharCode(((c & 0x0F) << 12) |
  634. ((char2 & 0x3F) << 6) |
  635. ((char3 & 0x3F) << 0));
  636. break;
  637. }
  638. }
  639. return out;
  640. }
  641. function getCurrentDate(format) {
  642. var now = new Date();
  643. var year = now.getFullYear(); //得到年份
  644. var month = now.getMonth();//得到月份
  645. var date = now.getDate();//得到日期
  646. var day = now.getDay();//得到周几
  647. var hour = now.getHours();//得到小时
  648. var minu = now.getMinutes();//得到分钟
  649. var sec = now.getSeconds();//得到秒
  650. month = month + 1;
  651. if (month < 10) month = "0" + month;
  652. if (date < 10) date = "0" + date;
  653. if (hour < 10) hour = "0" + hour;
  654. if (minu < 10) minu = "0" + minu;
  655. if (sec < 10) sec = "0" + sec;
  656. var time = "";
  657. //精确到天
  658. if(format==1){
  659. time = year + "-" + month + "-" + date;
  660. }
  661. //精确到分
  662. else if(format==2){
  663. time = year + "-" + month + "-" + date+ " " + hour + ":" + minu + ":" + sec;
  664. }
  665. return time;
  666. }
  667. </script>
  668. {/block}