common.js 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684
  1. function G(e) {
  2. return document.getElementById(e);
  3. }
  4. function showTip(info) {
  5. G('tips').innerHTML = info;
  6. }
  7. function sendForm(formId, action, response, target, effect) {
  8. // Ajax方式提交表单
  9. if (CheckForm(G(formId), 'ThinkAjaxResult'))
  10. //表单数据验证
  11. {
  12. ThinkAjax.sendForm(formId, action, response);
  13. }
  14. //Form.reset(formId);
  15. }
  16. rowIndex = 0;
  17. function prepareIE(height, overflow) {
  18. bod = document.getElementsByTagName('body')[0];
  19. bod.style.height = height;
  20. //bod.style.overflow = overflow;
  21. htm = document.getElementsByTagName('html')[0];
  22. htm.style.height = height;
  23. //htm.style.overflow = overflow;
  24. }
  25. function hideSelects(visibility) {
  26. selects = document.getElementsByTagName('select');
  27. for (i = 0; i < selects.length; i++) {
  28. selects[i].style.visibility = visibility;
  29. }
  30. }
  31. //document.write('<div id="overlay" class="none"></div><div id="lightbox" class="none"></div>');
  32. // 显示light窗口
  33. function showPopWin(content, width, height) {
  34. // IE
  35. prepareIE('100%', 'hidden');
  36. window.scrollTo(0, 0);
  37. hideSelects('hidden');
  38. //隐藏所有的<select>标记
  39. G('overlay').style.display = 'block';
  40. var arrayPageSize = getPageSize();
  41. var arrayPageScroll = getPageScroll();
  42. G('lightbox').style.display = 'block';
  43. G('lightbox').style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 35 - height) / 2) + 'px');
  44. G('lightbox').style.left = (((arrayPageSize[0] - 25 - width) / 2) + 'px');
  45. G('lightbox').innerHTML = content;
  46. }
  47. function fleshVerify() {
  48. //重载验证码
  49. var timenow = new Date().getTime();
  50. G('verifyImg').src = APP + '/Public/verify/' + timenow;
  51. }
  52. function allSelect() {
  53. var colInputs = document.getElementsByTagName("input");
  54. for (var i = 0; i < colInputs.length; i++)
  55. {
  56. colInputs[i].checked = true;
  57. }
  58. }
  59. function allUnSelect() {
  60. var colInputs = document.getElementsByTagName("input");
  61. for (var i = 0; i < colInputs.length; i++)
  62. {
  63. colInputs[i].checked = false;
  64. }
  65. }
  66. function InverSelect() {
  67. var colInputs = document.getElementsByTagName("input");
  68. for (var i = 0; i < colInputs.length; i++)
  69. {
  70. colInputs[i].checked = !colInputs[i].checked;
  71. }
  72. }
  73. function WriteTo(id) {
  74. var type = $F('outputType');
  75. switch (type)
  76. {
  77. case 'EXCEL':
  78. WriteToExcel(id);
  79. break;
  80. case 'WORD':
  81. WriteToWord(id);
  82. break;
  83. }
  84. return;
  85. }
  86. function build(id) {
  87. window.location = APP + '/Card/batch/type/' + id;
  88. }
  89. function shortcut() {
  90. var name = window.prompt("输入该快捷方式的显示名称", "");
  91. if (name != null)
  92. {
  93. var url = location.href;
  94. ThinkAjax.send(location.protocol + '//' + location.hostname + APP + '/Shortcut/ajaxInsert/', 'ajax=1&name=' + name + '&url=' + url);
  95. }
  96. }
  97. function delcache() {
  98. ThinkAjax.send(location.protocol + '//' + location.hostname + APP + '/Common/clearcache/', 'ajax=1');
  99. window.location.reload();
  100. }
  101. function show() {
  102. if (document.getElementById('menu').style.display != 'none')
  103. {
  104. document.getElementById('menu').style.display = 'none';
  105. document.getElementById('main').className = 'full';
  106. } else {
  107. document.getElementById('menu').style.display = 'inline';
  108. document.getElementById('main').className = 'main';
  109. }
  110. }
  111. function CheckAll(strSection)
  112. {
  113. var i;
  114. var colInputs = document.getElementById(strSection).getElementsByTagName("input");
  115. for (i = 1; i < colInputs.length; i++)
  116. {
  117. colInputs[i].checked = colInputs[0].checked;
  118. }
  119. }
  120. function add(id) {
  121. if (id)
  122. {
  123. location.href = CONTROLLER + "/add/id/" + id;
  124. } else {
  125. location.href = CONTROLLER + "/add/";
  126. }
  127. }
  128. function showHideSearch() {
  129. if (document.getElementById('searchM').style.display == 'inline')
  130. {
  131. document.getElementById('searchM').style.display = 'none';
  132. document.getElementById('showText').value = '高级';
  133. document.getElementById('key').style.display = 'inline';
  134. } else {
  135. document.getElementById('searchM').style.display = 'inline';
  136. document.getElementById('showText').value = '隐藏';
  137. document.getElementById('key').style.display = 'none';
  138. }
  139. }
  140. function top2(id) {
  141. var keyValue;
  142. if (id)
  143. {
  144. keyValue = id;
  145. } else {
  146. keyValue = getSelectCheckboxValues();
  147. }
  148. if (!keyValue)
  149. {
  150. alert('请选择置顶项!');
  151. return false;
  152. }
  153. location.href = CONTROLLER + "/top/id/" + keyValue;
  154. }
  155. function unTop(id) {
  156. var keyValue;
  157. if (id)
  158. {
  159. keyValue = id;
  160. } else {
  161. keyValue = getSelectCheckboxValues();
  162. }
  163. if (!keyValue)
  164. {
  165. alert('请选择置顶项!');
  166. return false;
  167. }
  168. // alert(keyValue);
  169. location.href = CONTROLLER + "/unTop/id/" + keyValue;
  170. }
  171. function sort(id) {
  172. var keyValue;
  173. keyValue = getSelectCheckboxValues();
  174. location.href = CONTROLLER + "/sort/sortId/" + keyValue;
  175. }
  176. function high(id) {
  177. var keyValue;
  178. if (id)
  179. {
  180. keyValue = id;
  181. } else {
  182. keyValue = getSelectCheckboxValues();
  183. }
  184. if (!keyValue)
  185. {
  186. alert('请选择高亮项!');
  187. return false;
  188. }
  189. location.href = CONTROLLER + "/high/id/" + keyValue;
  190. }
  191. function recommend(id) {
  192. var keyValue;
  193. if (id)
  194. {
  195. keyValue = id;
  196. } else {
  197. keyValue = getSelectCheckboxValues();
  198. }
  199. if (!keyValue)
  200. {
  201. alert('请选择推荐项!');
  202. return false;
  203. }
  204. location.href = CONTROLLER + "/recommend/id/" + keyValue;
  205. }
  206. function unrecommend(id) {
  207. var keyValue;
  208. if (id)
  209. {
  210. keyValue = id;
  211. } else {
  212. keyValue = getSelectCheckboxValues();
  213. }
  214. if (!keyValue)
  215. {
  216. alert('请选择项目!');
  217. return false;
  218. }
  219. location.href = CONTROLLER + "/unrecommend/id/" + keyValue;
  220. }
  221. function pass(id) {
  222. var keyValue;
  223. if (id)
  224. {
  225. keyValue = id;
  226. } else {
  227. keyValue = getSelectCheckboxValues();
  228. }
  229. if (!keyValue)
  230. {
  231. alert('请选择审核项!');
  232. return false;
  233. }
  234. if (window.confirm('确实审核通过吗?'))
  235. {
  236. window.location.href = CONTROLLER + '/checkPass/id/' + keyValue;
  237. //ThinkAjax.send(CONTROLLER+"/checkPass/","id="+keyValue+'&ajax=1');
  238. }
  239. }
  240. function passs(id) {
  241. var keyValue;
  242. if (id)
  243. {
  244. keyValue = id;
  245. } else {
  246. keyValue = getSelectCheckboxValues();
  247. }
  248. if (!keyValue)
  249. {
  250. alert('请选择审核项!');
  251. return false;
  252. }
  253. if (window.confirm('确实审核通过吗?'))
  254. {
  255. window.location.href = CONTROLLER + '/checkPasss/id/' + keyValue;
  256. //ThinkAjax.send(CONTROLLER+"/checkPass/","id="+keyValue+'&ajax=1');
  257. }
  258. }
  259. function sortBy(field, sort) {
  260. location.href = "?_order=" + field + "&_sort=" + sort;
  261. }
  262. function cache() {
  263. ThinkAjax.send(CONTROLLER + '/cache', 'ajax=1');
  264. }
  265. function forbid(id) {
  266. location.href = CONTROLLER + "/forbid/id/" + id;
  267. }
  268. function recycle(id) {
  269. var keyValue;
  270. if (id)
  271. {
  272. keyValue = id;
  273. } else {
  274. keyValue = getSelectCheckboxValue();
  275. }
  276. if (!keyValue)
  277. {
  278. alert('请选择要还原的项目!');
  279. return false;
  280. }
  281. location.href = CONTROLLER + "/recycle/id/" + keyValue;
  282. }
  283. function resume(id) {
  284. location.href = CONTROLLER + "/resume/id/" + id;
  285. }
  286. function trace(id) {
  287. location.href = CONTROLLER + "/trace/id/" + id;
  288. }
  289. function output() {
  290. location.href = CONTROLLER + "/output/";
  291. }
  292. function member(id) {
  293. location.href = CONTROLLER + "/../Member/edit/id/" + id;
  294. }
  295. function chat(id) {
  296. location.href = CONTROLLER + "/../Chat/index/girlId/" + id;
  297. }
  298. function login(id) {
  299. location.href = CONTROLLER + "/../Login/index/type/4/id/" + id;
  300. }
  301. function child(id) {
  302. location.href = CONTROLLER + "/index/pid/" + id;
  303. }
  304. function action(id) {
  305. location.href = CONTROLLER + "/action/groupId/" + id;
  306. }
  307. function access(id) {
  308. location.href = CONTROLLER + "/access/id/" + id;
  309. }
  310. function app(id) {
  311. location.href = CONTROLLER + "/app/groupId/" + id;
  312. }
  313. function module(id) {
  314. location.href = CONTROLLER + "/module/groupId/" + id;
  315. }
  316. function addv(id) {
  317. location.href = CONTROLLER + "/addv/id/" + id;
  318. }
  319. function user(id) {
  320. location.href = CONTROLLER + "/user/id/" + id;
  321. }
  322. function addVideo(id) {
  323. window.open("/video/add/course_id/" + id);
  324. }
  325. function selectVideo(id){
  326. location.href = "/video/select/course_id/" + id;
  327. }
  328. function reeditVideo(id){
  329. window.open("/video/add/id/" + id+"?reedit=1");
  330. }
  331. function uploadTryPlayVideo(id){
  332. window.open("/video/uploadTryPlay/id/" + id);
  333. }
  334. function linkVideo(id){
  335. window.open("/video/link/course_id/" + id);
  336. //location.href = "/video/select/course_id/" + id;
  337. }
  338. function addComment(id){
  339. window.open("/comment/add/course_id/" + id);
  340. }
  341. function videoManage(id) {
  342. window.open( "/video/index/course_id/" + id);
  343. }
  344. function previewCourse(id) {
  345. window.open(URL_WWW + "/course/show/id/" + id);
  346. }
  347. function previewVideo(id) {
  348. window.open( "/video/show/id/" + id);
  349. }
  350. function viewComment(course_id){
  351. if(!course_id) return false;
  352. window.open(URL_WWW + "/course/" + course_id+'#homework');
  353. }
  354. function addOldUserBalance(id) {
  355. window.open( "/oldUserBalance/initNewUser?user_id=" + id);
  356. }
  357. function wxpaySendGoods(order_no){
  358. location.href = "/order/query/paymethod/wxpay/order_no/" + order_no;
  359. }
  360. function alipaySendGoods(order_no){
  361. location.href = "/order/query/paymethod/alipay/order_no/" + order_no;
  362. }
  363. function setPassword(id){
  364. //location.href = "/user/setPassword/?id=" + id;
  365. window.open( "/user/setPassword/?id=" + id);
  366. }
  367. function log_request_ip_line(ip,id) {
  368. location.href = CONTROLLER + "/index/?ip=" + ip;
  369. }
  370. function user_view_recharge(openid) {
  371. location.href = "/recharge/index/?type=0&status=2&openid=" + openid;
  372. }
  373. function user_edit(id) {
  374. edit(id)
  375. }
  376. function press_send(id) {
  377. }
  378. //+---------------------------------------------------
  379. //| 打开模式窗口,返回新窗口的操作值
  380. //+---------------------------------------------------
  381. function PopModalWindow(url, width, height)
  382. {
  383. var result = window.showModalDialog(url, "win", "dialogWidth:" + width + "px;dialogHeight:" + height + "px;center:yes;status:no;scroll:no;dialogHide:no;resizable:no;help:no;edge:sunken;");
  384. return result;
  385. }
  386. function read(id) {
  387. var keyValue;
  388. if (id)
  389. {
  390. keyValue = id;
  391. } else {
  392. keyValue = getSelectCheckboxValue();
  393. }
  394. if (!keyValue)
  395. {
  396. alert('请选择编辑项!');
  397. return false;
  398. }
  399. location.href = CONTROLLER + "/read/id/" + keyValue;
  400. }
  401. function getData(){
  402. var data = $('#form').serialize();
  403. if(data){
  404. data += "&ajax=1";
  405. }else{
  406. data = "ajax=1";
  407. }
  408. return data;
  409. }
  410. function save(id){
  411. var url = CONTROLLER+"/save";
  412. var data = getData();
  413. $.post(url,data,function(response){
  414. alert(response.info);
  415. window.location = "/index.php?s=/User/Family/index.html";
  416. })
  417. }
  418. function del(id){
  419. var keyValue;
  420. if (id)
  421. {
  422. keyValue = id;
  423. }else {
  424. keyValue = getSelectCheckboxValues();
  425. }
  426. if (!keyValue)
  427. {
  428. alert('请选择删除项!');
  429. return false;
  430. }
  431. if (window.confirm('确实要删除选择项吗?'))
  432. {
  433. ThinkAjax.send(CONTROLLER+"/delete/","id="+keyValue+'&ajax=1',doDelete);
  434. }
  435. }
  436. function edit(id){
  437. var keyValue;
  438. if (id)
  439. {
  440. keyValue = id;
  441. }else {
  442. keyValue = getSelectCheckboxValue();
  443. }
  444. if (!keyValue)
  445. {
  446. alert('请选择编辑项!');
  447. return false;
  448. }
  449. window.open(CONTROLLER + "/edit/id/" + keyValue);
  450. //location.href = CONTROLLER + "/edit/id/" + keyValue;
  451. //location.href = CONTROLLER+"/edit/id/"+keyValue;
  452. }
  453. function view(id) {
  454. var keyValue;
  455. if (id)
  456. {
  457. keyValue = id;
  458. } else {
  459. keyValue = getSelectCheckboxValue();
  460. }
  461. if (!keyValue)
  462. {
  463. alert('请选择查看项!');
  464. return false;
  465. }
  466. //location.href = CONTROLLER + "/show/id/" + keyValue;
  467. domain = "rrbrr.com";
  468. subdomain = "www.";
  469. location.href = "http://"+subdomain+domain +CONTROLLER+ "/show/id/" + keyValue;
  470. }
  471. function grades(id) {
  472. var keyValue;
  473. if (id)
  474. {
  475. keyValue = id;
  476. } else {
  477. keyValue = getSelectCheckboxValue();
  478. }
  479. if (!keyValue)
  480. {
  481. alert('请选择编辑项!');
  482. return false;
  483. }
  484. location.href = CONTROLLER + "/grades/id/" + keyValue;
  485. }
  486. function addmoney(id) {
  487. location.href = CONTROLLER + "/addmoney/id/" + id;
  488. }
  489. var selectRowIndex = Array();
  490. function del(id) {
  491. var keyValue;
  492. if (id)
  493. {
  494. keyValue = id;
  495. } else {
  496. keyValue = getSelectCheckboxValues();
  497. }
  498. if (!keyValue)
  499. {
  500. alert('请选择删除项!');
  501. return false;
  502. }
  503. if (window.confirm('确实要删除选择项吗?'))
  504. {
  505. ThinkAjax.send(CONTROLLER + "/delete/", "id=" + keyValue + '&ajax=1', doDelete);
  506. }
  507. }
  508. function delcontent(id) {
  509. var keyValue;
  510. if (id)
  511. {
  512. keyValue = id;
  513. } else {
  514. keyValue = getSelectCheckboxValues();
  515. }
  516. if (!keyValue)
  517. {
  518. alert('请选择删除项!');
  519. return false;
  520. }
  521. if (window.confirm('确实要删除选择项吗?'))
  522. {
  523. ThinkAjax.send(CONTROLLER + "/delcontent/", "id=" + keyValue + '&ajax=1', doDelete);
  524. }
  525. }
  526. function delsummary(id) {
  527. var keyValue;
  528. if (id)
  529. {
  530. keyValue = id;
  531. } else {
  532. keyValue = getSelectCheckboxValues();
  533. }
  534. if (!keyValue)
  535. {
  536. alert('请选择删除项!');
  537. return false;
  538. }
  539. if (window.confirm('确实要删除选择项吗?'))
  540. {
  541. ThinkAjax.send(CONTROLLER + "/delsummary/", "id=" + keyValue + '&ajax=1', doDelete);
  542. }
  543. }
  544. function delexamples(id) {
  545. var keyValue;
  546. if (id)
  547. {
  548. keyValue = id;
  549. } else {
  550. keyValue = getSelectCheckboxValues();
  551. }
  552. if (!keyValue)
  553. {
  554. alert('请选择删除项!');
  555. return false;
  556. }
  557. if (window.confirm('确实要删除选择项吗?'))
  558. {
  559. ThinkAjax.send(CONTROLLER + "/delexamples/", "id=" + keyValue + '&ajax=1', doDelete);
  560. }
  561. }
  562. function foreverdel(id) {
  563. var keyValue;
  564. if (id)
  565. {
  566. keyValue = id;
  567. } else {
  568. keyValue = getSelectCheckboxValues();
  569. }
  570. if (!keyValue)
  571. {
  572. alert('请选择删除项!');
  573. return false;
  574. }
  575. if (window.confirm('确实要永久删除选择项吗?'))
  576. {
  577. //ThinkAjax.send(CONTROLLER + "/foreverdelete/", "id=" + keyValue + '&ajax=1', doDelete);
  578. ThinkAjax.send(CONTROLLER + "/foreverdelete/", "id=" + keyValue , doDelete);
  579. }
  580. }
  581. function getTableRowIndex(obj) {
  582. selectRowIndex[0] = obj.parentElement.parentElement.rowIndex;
  583. /*当前行对象*/
  584. }
  585. function doDelete(data, status) {
  586. console.log(data);
  587. if (data.code == 1)
  588. {
  589. alert('删除成功');
  590. window.location.reload();
  591. return;
  592. //删除表格
  593. var Table = G('checkList');
  594. var len = selectRowIndex.length;
  595. if (len == 0) {
  596. window.location.reload();
  597. }
  598. for (var i = len - 1; i >= 0; i--)
  599. {
  600. //删除表格行
  601. Table.deleteRow(selectRowIndex[i]);
  602. }
  603. selectRowIndex = Array();
  604. }else{
  605. alert('删除失败');
  606. }
  607. }
  608. function delAttach(id, showId) {
  609. var keyValue;
  610. if (id)
  611. {
  612. keyValue = id;
  613. } else {
  614. keyValue = getSelectCheckboxValues();
  615. }
  616. if (!keyValue)
  617. {
  618. alert('请选择删除项!');
  619. return false;
  620. }
  621. if (window.confirm('确实要删除选择项吗?'))
  622. {
  623. G('result').style.display = 'block';
  624. ThinkAjax.send(CONTROLLER + "/delAttach/", "id=" + keyValue + '&_AJAX_SUBMIT_=1');
  625. if (showId != undefined)
  626. {
  627. G(showId).innerHTML = '';
  628. }
  629. }
  630. }
  631. function clearData() {
  632. if (window.confirm('确实要清空全部数据吗?'))
  633. {
  634. location.href = CONTROLLER + "/clear/";
  635. }
  636. }
  637. function takeback(id) {
  638. var keyValue;
  639. if (id)
  640. {
  641. keyValue = id;
  642. } else {
  643. keyValue = getSelectCheckboxValues();
  644. }
  645. if (!keyValue)
  646. {
  647. alert('请选择回收项!');
  648. return false;
  649. }
  650. if (window.confirm('确实要回收选择项吗?'))
  651. {
  652. location.href = CONTROLLER + "/takeback/id/" + keyValue;
  653. }
  654. }
  655. function getSelectCheckboxValue() {
  656. var obj = document.getElementsByName('key');
  657. var result = '';
  658. for (var i = 0; i < obj.length; i++)
  659. {
  660. if (obj[i].checked == true)
  661. return obj[i].value;
  662. }
  663. return false;
  664. }
  665. function getSelectCheckboxValues() {
  666. var obj = document.getElementsByName('key');
  667. var result = '';
  668. var j = 0;
  669. for (var i = 0; i < obj.length; i++)
  670. {
  671. if (obj[i].checked == true) {
  672. selectRowIndex[j] = i + 1;
  673. result += obj[i].value + ",";
  674. j++;
  675. }
  676. }
  677. return result.substring(0, result.length - 1);
  678. }
  679. function change(e)
  680. {
  681. if (!document.all)
  682. {
  683. return;
  684. }
  685. var e = e || event;
  686. var oObj = e.srcElement || e.target;
  687. //if(oObj.tagName.toLowerCase() == "td")
  688. // {
  689. /*
  690. var oTable = oObj.parentNode.parentNode;
  691. for(var i=1; i<oTable.rows.length; i++)
  692. {
  693. oTable.rows[i].className = "out";
  694. oTable.rows[i].tag = false;
  695. } */
  696. var obj = document.getElementById('checkList').getElementsByTagName("input");
  697. var oTr = oObj.parentNode;
  698. var row = oObj.parentElement.rowIndex - 1;
  699. if (oTr.className == 'down')
  700. {
  701. oTr.className = 'out';
  702. obj[row].checked = false;
  703. oTr.tag = true;
  704. } else {
  705. oTr.className = 'down';
  706. obj[row].checked = true;
  707. oTr.tag = true;
  708. }
  709. //}
  710. }
  711. function out(e)
  712. {
  713. var e = e || event;
  714. var oObj = e.srcElement || e.target;
  715. var oTr = oObj.parentNode;
  716. if (!oTr.tag)
  717. oTr.className = "out";
  718. }
  719. function over(e)
  720. {
  721. var e = e || event;
  722. var oObj = e.srcElement || e.target;
  723. var oTr = oObj.parentNode;
  724. if (!oTr.tag)
  725. oTr.className = "over";
  726. }
  727. //---------------------------------------------------------------------
  728. // 多选改进方法 by Liu21st at 2005-11-29
  729. //
  730. //
  731. //-------------------------begin---------------------------------------
  732. function searchItem(item) {
  733. for (i = 0; i < selectSource.length; i++)
  734. if (selectSource[i].text.indexOf(item) != -1)
  735. {
  736. selectSource[i].selected = true;
  737. break;
  738. }
  739. }
  740. function addItem() {
  741. for (i = 0; i < selectSource.length; i++)
  742. if (selectSource[i].selected) {
  743. selectTarget.add(new Option(selectSource[i].text, selectSource[i].value));
  744. }
  745. for (i = 0; i < selectTarget.length; i++)
  746. for (j = 0; j < selectSource.length; j++)
  747. if (selectSource[j].text == selectTarget[i].text)
  748. selectSource[j] = null;
  749. }
  750. function delItem() {
  751. for (i = 0; i < selectTarget.length; i++)
  752. if (selectTarget[i].selected) {
  753. selectSource.add(new Option(selectTarget[i].text, selectTarget[i].value));
  754. }
  755. for (i = 0; i < selectSource.length; i++)
  756. for (j = 0; j < selectTarget.length; j++)
  757. if (selectTarget[j].text == selectSource[i].text) selectTarget[j] = null;
  758. }
  759. function delAllItem() {
  760. for (i = 0; i < selectTarget.length; i++) {
  761. selectSource.add(new Option(selectTarget[i].text, selectTarget[i].value));
  762. }
  763. selectTarget.length = 0;
  764. }
  765. function addAllItem() {
  766. for (i = 0; i < selectSource.length; i++) {
  767. selectTarget.add(new Option(selectSource[i].text, selectSource[i].value));
  768. }
  769. selectSource.length = 0;
  770. }
  771. function getReturnValue() {
  772. for (i = 0; i < selectTarget.length; i++) {
  773. selectTarget[i].selected = true;
  774. }
  775. }
  776. function loadBar(fl)
  777. //fl is show/hide flag
  778. {
  779. var x,
  780. y;
  781. if (self.innerHeight)
  782. {
  783. // all except Explorer
  784. x = self.innerWidth;
  785. y = self.innerHeight;
  786. }
  787. else
  788. if (document.documentElement && document.documentElement.clientHeight)
  789. {
  790. // Explorer 6 Strict Mode
  791. x = document.documentElement.clientWidth;
  792. y = document.documentElement.clientHeight;
  793. }
  794. else
  795. if (document.body)
  796. {
  797. // other Explorers
  798. x = document.body.clientWidth;
  799. y = document.body.clientHeight;
  800. }
  801. var el = document.getElementById('loader');
  802. if (null != el)
  803. {
  804. var top = (y / 2) - 50;
  805. var left = (x / 2) - 150;
  806. if (left <= 0) left = 10;
  807. el.style.visibility = (fl == 1) ? 'visible': 'hidden';
  808. el.style.display = (fl == 1) ? 'block': 'none';
  809. el.style.left = left + "px"
  810. el.style.top = top + "px";
  811. el.style.zIndex = 2;
  812. }
  813. }
  814. //选中下拉列表值
  815. function selectByValue(element, v) {
  816. var o = document.getElementById(element).options;
  817. if (o) {
  818. for (var i = 0; i < o.length; i++) {
  819. if (o[i].value == v) {
  820. o[i].selected = true;
  821. }
  822. }
  823. }
  824. }
  825. //设置文本框值
  826. function setValue(id, v) {
  827. document.getElementById(id).value = v;
  828. }
  829. function showProvince(name) {
  830. var i = 0;
  831. data2 = province_node;
  832. for (var k in data2) {
  833. document.getElementById(name).options[i] = new Option(data2[k], data2[k]);
  834. i++;
  835. }
  836. }
  837. function showCity(name, province) {
  838. province = getProvinceKey(province);
  839. document.getElementById(name).options.length = 0;
  840. for (var k in city_node) {
  841. s = k - province;
  842. if (s > 0 && s < 10000) {
  843. document.getElementById(name).options.add(new Option(city_node[k]['title'], city_node[k]['title']));
  844. }
  845. }
  846. }
  847. function getProvinceKey(province) {
  848. for (var k in province_node) {
  849. if (province_node[k] == province)
  850. return k;
  851. }
  852. }
  853. function loadProvinceCicy(province, city) {
  854. showProvince(province);
  855. document.getElementById(province).onchange = function() {
  856. showCity(city, this.value);
  857. }
  858. }
  859. function fileChange(k, obj) {
  860. var imgid = "img_" + k;
  861. var formid = "form_" + k;
  862. document.getElementById(imgid).src = obj.value;
  863. document.getElementById(formid).submit();
  864. }
  865. /**
  866. *将两个层的高度保持一致
  867. */
  868. function equalHight(a, b) {
  869. ah = G(a).offsetHeight;
  870. //alert(G(a).offsetHeight);
  871. bh = G(b).offsetHeight;
  872. if (ah < bh) {
  873. G(a).style.height = bh + "px";
  874. } else {
  875. G(b).style.height = ah + "px";
  876. }
  877. }
  878. function g(name) {
  879. var is = document.getElementsByName(name);
  880. var ids = new Array();
  881. var j = 0;
  882. for (var i = 0; i < is.length; ++i) {
  883. if (is[i].type == 'checkbox' && is[i].checked) {
  884. ids[j++] = is[i].value;
  885. }
  886. }
  887. return ids;
  888. }
  889. function getJoinValue() {
  890. var v = '';
  891. $(":checkbox:checked").each(function() {
  892. if (this.value)
  893. v += this.value + ',';
  894. });
  895. //alert(v.substr(0,v.length-1));
  896. if (v)
  897. return v.substr(0, v.length - 1);
  898. }
  899. function ajaxGet(url, ids) {
  900. if (!ids) {
  901. ids = getJoinValue();
  902. }
  903. url = url + ids + "/ajax/1";
  904. if (ids) {
  905. $.get(url,
  906. function(data) {
  907. d = eval('(' + data + ')');
  908. if (typeof(d) == 'object') {
  909. alert(d.info);
  910. } else {
  911. alert(data);
  912. }
  913. });
  914. } else {
  915. alert('请先选择');
  916. }
  917. }
  918. function chkall(n) {
  919. var l = document.getElementsByName(n);
  920. for (i = 0; i < l.length; i++) {
  921. l[i].checked = true;
  922. }
  923. }
  924. function chkallno(n) {
  925. var l = document.getElementsByName(n);
  926. for (i = 0; i < l.length; i++) {
  927. l[i].checked = false;
  928. }
  929. }
  930. function get(url,param,handler) {
  931. try {
  932. $.ajaxSetup({
  933. error: function (x, e) {
  934. console.log('没有内容');
  935. return false;
  936. }
  937. });
  938. $.getJSON(url,param,handler);
  939. }catch (ex) {
  940. console.log('异常内容');
  941. }
  942. }
  943. function post(url,param,handler) {
  944. try {
  945. $.ajaxSetup({
  946. error: function (x, e) {
  947. console.log('服务器响应错误');
  948. return false;
  949. }
  950. });
  951. $.post(url,param,handler, "json");
  952. }catch (ex) {
  953. //alert(ex.message);
  954. console.log('异常内容');
  955. }
  956. }
  957. function post_cross(url,param,handler) {
  958. try {
  959. param['ret_format'] = 'json';
  960. $.ajax({
  961. type: "POST",
  962. url: url,
  963. data:param,
  964. //dataType: 'json',
  965. xhrFields: {
  966. withCredentials: true
  967. },
  968. crossDomain: true,
  969. success:handler,
  970. /*success:function(){
  971. handler
  972. alert('成功');
  973. },*/
  974. error: function (x, e) {
  975. console.log('服务器响应错误');
  976. return false;
  977. }
  978. });
  979. }catch (ex) {
  980. //alert(ex.message);
  981. console.log('异常内容');
  982. }
  983. }
  984. function checkCode(data) {
  985. console.log(data);
  986. if(data.code == 0){
  987. msg(data.msg);
  988. return false;
  989. }
  990. return true;
  991. }
  992. //ThinkAjax.send(CONTROLLER + "/delcontent/", "id=" + keyValue + '&ajax=1', doDelete);
  993. var ThinkAjax = {
  994. send:function(url,pars,response){
  995. url = url+"?"+pars;
  996. data = {};
  997. $.getJSON(url,data,response);
  998. },
  999. other:function(){}
  1000. }
  1001. function msg(data){
  1002. alert(data);
  1003. }
  1004. //读写cookie函数
  1005. function getCookie(c_name)
  1006. {
  1007. if (document.cookie.length > 0)
  1008. {
  1009. c_start = document.cookie.indexOf(c_name + "=")
  1010. if (c_start != -1)
  1011. {
  1012. c_start = c_start + c_name.length + 1;
  1013. c_end = document.cookie.indexOf(";",c_start);
  1014. if (c_end == -1)
  1015. {
  1016. c_end = document.cookie.length;
  1017. }
  1018. return unescape(document.cookie.substring(c_start,c_end));
  1019. }
  1020. }
  1021. return null
  1022. }
  1023. function setCookie(c_name,value,expiredays)
  1024. {
  1025. var exdate = new Date();
  1026. exdate.setDate(exdate.getDate() + expiredays);
  1027. document.cookie = c_name + "=" +escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString()); //使设置的有效时间正确。增加toGMTString()
  1028. }
  1029. function previewImg(obj,fieldName) {
  1030. url = getObjectURL(obj.files[0]);
  1031. $("#preview_img_"+fieldName+" img").attr("src",url);
  1032. }
  1033. //多图预览
  1034. function previewMultImg2(obj,fieldName) {
  1035. var count = obj.files.length;
  1036. if(count<1) return;
  1037. for(var i = 0; i< count; i++){
  1038. console.log(obj.files);
  1039. url = getObjectURL(obj.files[i]);
  1040. $("#preview_mult_img_"+fieldName).append("<img src='"+url+"'>");
  1041. }
  1042. }
  1043. function toDecimal(x) {
  1044. var f = parseFloat(x);
  1045. if (isNaN(f)) {
  1046. return;
  1047. }
  1048. f = Math.round(x*100)/100;
  1049. return f;
  1050. }
  1051. function getObjectURL(file) {
  1052. var url = null ;
  1053. // 下面函数执行的效果是一样的,只是需要针对不同的浏览器执行不同的 js 函数而已
  1054. if (window.createObjectURL!=undefined) { // basic
  1055. url = window.createObjectURL(file) ;
  1056. } else if (window.URL!=undefined) { // mozilla(firefox)
  1057. url = window.URL.createObjectURL(file) ;
  1058. } else if (window.webkitURL!=undefined) { // webkit or chrome
  1059. url = window.webkitURL.createObjectURL(file) ;
  1060. }
  1061. return url ;
  1062. }
  1063. function detectOS() {
  1064. var sUserAgent = navigator.userAgent;
  1065. var isWin = (navigator.platform == "Win32") || (navigator.platform == "Windows");
  1066. var isMac = (navigator.platform == "Mac68K") || (navigator.platform == "MacPPC") || (navigator.platform == "Macintosh") || (navigator.platform == "MacIntel");
  1067. if (isMac) return "MacOS";
  1068. var isUnix = (navigator.platform == "X11") && !isWin && !isMac;
  1069. if (isUnix) return "Unix";
  1070. var isLinux = (String(navigator.platform).indexOf("Linux") > -1);
  1071. if (isLinux) return "Linux";
  1072. if (isWin) {
  1073. var isWin2K = sUserAgent.indexOf("Windows NT 5.0") > -1 || sUserAgent.indexOf("Windows 2000") > -1;
  1074. if (isWin2K) return "Windows2000";
  1075. var isWinXP = sUserAgent.indexOf("Windows NT 5.1") > -1 || sUserAgent.indexOf("Windows XP") > -1;
  1076. if (isWinXP) return "WindowsXP";
  1077. var isWin2003 = sUserAgent.indexOf("Windows NT 5.2") > -1 || sUserAgent.indexOf("Windows 2003") > -1;
  1078. if (isWin2003) return "Windows2003";
  1079. var isWinVista= sUserAgent.indexOf("Windows NT 6.0") > -1 || sUserAgent.indexOf("Windows Vista") > -1;
  1080. if (isWinVista) return "Windows Vista";
  1081. var isWin7 = sUserAgent.indexOf("Windows NT 6.1") > -1 || sUserAgent.indexOf("Windows 7") > -1;
  1082. if (isWin7) return "Windows7";
  1083. }
  1084. return "other";
  1085. }
  1086. function isIpad(){
  1087. var ua = navigator.userAgent.toLowerCase();
  1088. var s;
  1089. s = ua.match(/iPad/i);
  1090. if(s=="ipad")
  1091. {
  1092. return true;
  1093. }
  1094. else{
  1095. return false;
  1096. }
  1097. }
  1098. //是否是微信浏览
  1099. function isWeixin(){
  1100. var ua = navigator.userAgent.toLowerCase();
  1101. if(ua.match(/MicroMessenger/i)=="micromessenger") {
  1102. return true;
  1103. } else {
  1104. return false;
  1105. }
  1106. }
  1107. //是否支持webp
  1108. function isWebp() {
  1109. var isSupportWebp = !![].map && document.createElement('canvas').toDataURL('image/webp').indexOf('data:image/webp') == 0;
  1110. return isSupportWebp;
  1111. //console.log(isSupportWebp); //
  1112. }
  1113. $.fn.serializeObject = function()
  1114. {
  1115. var o = {};
  1116. var a = this.serializeArray();
  1117. $.each(a, function() {
  1118. if (o[this.name] !== undefined) {
  1119. if (!o[this.name].push) {
  1120. o[this.name] = [o[this.name]];
  1121. }
  1122. o[this.name].push(this.value || '');
  1123. } else {
  1124. o[this.name] = this.value || '';
  1125. }
  1126. });
  1127. return o;
  1128. };
  1129. function goback() {
  1130. //console.log()
  1131. if(history.length>1){
  1132. history.back(-1);
  1133. }else{
  1134. location.href='/';
  1135. }
  1136. return ;
  1137. var ref = $("#hd_referrer").val();
  1138. if (ref != "" && ref != "undefined") {
  1139. location.href = ref;
  1140. }
  1141. else {
  1142. location.href = history.back(-1);
  1143. }
  1144. }
  1145. //wap 返回键
  1146. $(function () {
  1147. $("#hd_referrer").val(document.referrer);
  1148. $('#back').click(function () {
  1149. goback();
  1150. });
  1151. });
  1152. function showBuy() {
  1153. //销毁
  1154. player.dispose();
  1155. $('#J_prismPlayer').empty();
  1156. var course_id=$('#course_id').val();
  1157. var html = '<div class="buy_tip">'+
  1158. '<div class="tip_row1"> 试看结束,购买后查看完整课程。<br /> </div>'+
  1159. '<div class="tip_row2"> <a target="_blank" href="'+URL_USER+'/order/create/course_id/'+course_id+'" class="buy"> 立即购买</a> </div>'+
  1160. '<div class="refresh"><span>购买后刷新页面即可观看</span> <a href="javascript:location.reload();">已购买,立即刷新</a> </div>'+
  1161. '</div>';
  1162. $('#J_prismPlayer').html(html);
  1163. }
  1164. function getPlayTime(){
  1165. var tryPlayTime=video_price;
  1166. var currentTime = player.getCurrentTime();
  1167. //区间
  1168. if(typeof(video_price_start)=="undefined"){
  1169. video_price_start=0;
  1170. }
  1171. //if("undefined" != typeof video_price_start) video_price_start=0;
  1172. thresholdValue = 10;
  1173. if( video_price_start) {
  1174. /*alert(currentTime );
  1175. alert(video_price_start);*/
  1176. /*console.log(currentTime);
  1177. console.log(video_price_start);
  1178. console.log(tryPlayTime);*/
  1179. //合法时间区间
  1180. // 1.小于1秒,用于视频缓冲
  1181. // 2.大于等于开始时间
  1182. if(
  1183. currentTime < 6 ||
  1184. (currentTime >=video_price_start-thresholdValue && currentTime < video_price_start+tryPlayTime)
  1185. ){
  1186. }else{
  1187. showBuy();
  1188. clearTimeout(t1);
  1189. }
  1190. }else{
  1191. if(currentTime>tryPlayTime){
  1192. showBuy();
  1193. clearTimeout(t1);
  1194. }
  1195. }
  1196. //console.log(currentTime);
  1197. }
  1198. function handleReady() {
  1199. var a = player.seek(video_price_start);
  1200. t1 = window.setInterval(getPlayTime,1000);
  1201. }
  1202. function handlePlay(){
  1203. player.seek(video_price_start);
  1204. t1 = window.setInterval(getPlayTime,1000);
  1205. }
  1206. function pullDown(controller,pull_element,vue_element){
  1207. var nowPage=1;
  1208. var totalPages=1;
  1209. var nextPage = 1;
  1210. var isLastPage = false;
  1211. var lastRequestPage = 0;
  1212. var vlist = new Vue({
  1213. el: '#'+vue_element,
  1214. data: {
  1215. list: []
  1216. },
  1217. methods: {
  1218. next: function (me) {
  1219. var str=location.href; //取得整个地址栏
  1220. console.log(str);
  1221. var num=str.indexOf("?");
  1222. if(num==-1){
  1223. str="";
  1224. }
  1225. str=str.substr(num+1);
  1226. console.log(str);
  1227. if(isLastPage){
  1228. // 锁定
  1229. me.lock();
  1230. // 显示无数据
  1231. me.noData();
  1232. console.log('最后一页');
  1233. //$('.dropload-refresh').text('没有了');
  1234. return;
  1235. }
  1236. if(nextPage == lastRequestPage) { //当前主页页面和上次请求页面相同,重复请求了,直接return
  1237. return;
  1238. }
  1239. var url="/"+controller+"/?"+str+"&p="+nextPage+"&ret_format=json";
  1240. lastRequestPage = nextPage;
  1241. console.log(nextPage);
  1242. axios.get(url)
  1243. .then(response => {
  1244. totalPages = response.data.data.totalPages;
  1245. nowPage = response.data.data.nowPage;
  1246. $('#totalRows').text(response.data.data.totalRows);
  1247. if(nowPage < totalPages) {
  1248. nextPage = nowPage+1;
  1249. }else{
  1250. isLastPage = true;
  1251. }
  1252. this.list = this.list.concat(response.data.data.list);
  1253. }
  1254. )
  1255. }
  1256. },
  1257. mounted: function () {
  1258. // this.next();
  1259. },
  1260. filters: {
  1261. course_show: function (value) {
  1262. if (!value) return '';
  1263. return "/course/"+value;
  1264. }
  1265. }
  1266. });
  1267. var dropload = $(pull_element).dropload({
  1268. //scrollArea很关键,要不然加载更多不起作用
  1269. scrollArea : window,
  1270. domUp : {
  1271. domClass : 'dropload-up',
  1272. domRefresh : '<div class="dropload-refresh">↓下拉刷新</div>',
  1273. domUpdate : '<div class="dropload-update">↑释放更新</div>',
  1274. domLoad : '<div class="dropload-load"><span class="loading"></span>加载中...</div>'
  1275. },
  1276. domDown : {
  1277. domClass : 'dropload-down',
  1278. domRefresh : '<div class="dropload-refresh">↑上拉加载更多</div>',
  1279. domLoad : '<div class="dropload-load"><span class="loading"></span>加载中...</div>',
  1280. domNoData : '<div class="dropload-noData">没有数据了</div>'
  1281. },
  1282. loadUpFn : function(me){
  1283. //下拉刷新需要调用的函数
  1284. //alert("下拉刷新需要调用的函数");
  1285. //重置下拉刷新
  1286. me.resetload();
  1287. },
  1288. loadDownFn : function(me){
  1289. //上拉加载更多需要调用的函数
  1290. //alert("上拉加载更多需要调用的函数");
  1291. vlist.next(me);
  1292. //定时器函数,为了看出上拉加载更多效果
  1293. setTimeout(function(){
  1294. // 每次数据加载完,必须重置
  1295. me.resetload();
  1296. },1000);
  1297. }
  1298. });
  1299. }