all.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  1. (function(a,b){$window=a(b),a.fn.lazyload=function(c){function f(){var b=0;d.each(function(){var c=a(this);if(e.skip_invisible&&!c.is(":visible"))return;if(!a.abovethetop(this,e)&&!a.leftofbegin(this,e))if(!a.belowthefold(this,e)&&!a.rightoffold(this,e))c.trigger("appear");else if(++b>e.failure_limit)return!1})}var d=this,e={threshold:0,failure_limit:0,event:"scroll",effect:"show",container:b,data_attribute:"original",skip_invisible:!0,appear:null,load:null};return c&&(undefined!==c.failurelimit&&(c.failure_limit=c.failurelimit,delete c.failurelimit),undefined!==c.effectspeed&&(c.effect_speed=c.effectspeed,delete c.effectspeed),a.extend(e,c)),$container=e.container===undefined||e.container===b?$window:a(e.container),0===e.event.indexOf("scroll")&&$container.bind(e.event,function(a){return f()}),this.each(function(){var b=this,c=a(b);b.loaded=!1,c.one("appear",function(){if(!this.loaded){if(e.appear){var f=d.length;e.appear.call(b,f,e)}a("<img />").bind("load",function(){c.hide().attr("src",c.data(e.data_attribute))[e.effect](e.effect_speed),b.loaded=!0;var f=a.grep(d,function(a){return!a.loaded});d=a(f);if(e.load){var g=d.length;e.load.call(b,g,e)}}).attr("src",c.data(e.data_attribute))}}),0!==e.event.indexOf("scroll")&&c.bind(e.event,function(a){b.loaded||c.trigger("appear")})}),$window.bind("resize",function(a){f()}),f(),this},a.belowthefold=function(c,d){var e;return d.container===undefined||d.container===b?e=$window.height()+$window.scrollTop():e=$container.offset().top+$container.height(),e<=a(c).offset().top-d.threshold},a.rightoffold=function(c,d){var e;return d.container===undefined||d.container===b?e=$window.width()+$window.scrollLeft():e=$container.offset().left+$container.width(),e<=a(c).offset().left-d.threshold},a.abovethetop=function(c,d){var e;return d.container===undefined||d.container===b?e=$window.scrollTop():e=$container.offset().top,e>=a(c).offset().top+d.threshold+a(c).height()},a.leftofbegin=function(c,d){var e;return d.container===undefined||d.container===b?e=$window.scrollLeft():e=$container.offset().left,e>=a(c).offset().left+d.threshold+a(c).width()},a.inviewport=function(b,c){return!a.rightofscreen(b,c)&&!a.leftofscreen(b,c)&&!a.belowthefold(b,c)&&!a.abovethetop(b,c)},a.extend(a.expr[":"],{"below-the-fold":function(c){return a.belowthefold(c,{threshold:0,container:b})},"above-the-top":function(c){return!a.belowthefold(c,{threshold:0,container:b})},"right-of-screen":function(c){return a.rightoffold(c,{threshold:0,container:b})},"left-of-screen":function(c){return!a.rightoffold(c,{threshold:0,container:b})},"in-viewport":function(c){return!a.inviewport(c,{threshold:0,container:b})},"above-the-fold":function(c){return!a.belowthefold(c,{threshold:0,container:b})},"right-of-fold":function(c){return a.rightoffold(c,{threshold:0,container:b})},"left-of-fold":function(c){return!a.rightoffold(c,{threshold:0,container:b})}})})(jQuery,window);
  2. function getBrowser() {
  3. var browser = {msie : false,firefox : false,opera : false,safari : false,chrome : false,netscape : false,appname : '未知',version : ''},
  4. userAgent = window.navigator.userAgent.toLowerCase();
  5. if (/(msie|firefox|opera|chrome|netscape)\D+(\d[\d.]*)/.test(userAgent)) {
  6. browser[RegExp.$1] = true;
  7. browser.appname = RegExp.$1;
  8. browser.version = RegExp.$2;
  9. } else if (/version\D+(\d[\d.]*).*safari/.test(userAgent)) {
  10. browser.safari = true;
  11. browser.appname = 'safari';
  12. browser.version = RegExp.$2;
  13. }
  14. return browser;
  15. }
  16. window.ppAjax = {
  17. alert : function (data) {
  18. window.ppData = data = toJson(data);
  19. if (window.ppExit)
  20. return;
  21. },
  22. submit : function (selector, callback) {
  23. $(selector).submit(function () {
  24. ppAjax.post($(this).attr("action"), $(this).serialize(), callback);
  25. return false;
  26. });
  27. },
  28. post : function (url, param, callback) {
  29. $.ajax({
  30. type : "POST",
  31. cache : false,
  32. url : url,
  33. data : param,
  34. success : callback,
  35. error : function (html) {
  36. layer.alert("提交数据失败,代码:" + html.status + ",请稍候再试", {icon : 0,shade : 0.6});
  37. }
  38. });
  39. }
  40. };
  41. function toJson(data) {
  42. var json = {};
  43. try {
  44. json = eval("(" + data + ")");
  45. if (json.kp_error) {
  46. ppAjax.debug(json);
  47. window.ppExit = true;
  48. } else {
  49. window.ppExit = false;
  50. }
  51. } catch (e) {
  52. alert(data);
  53. }
  54. return json;
  55. }
  56. //jQuery的cookie扩展
  57. $.cookie = function (name, value, options) {
  58. if (typeof value != 'undefined') {
  59. options = options || {};
  60. if (value === null) {
  61. value = '';
  62. options.expires = -1;
  63. }
  64. var expires = '';
  65. if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
  66. var date;
  67. if (typeof options.expires == 'number') {
  68. date = new Date();
  69. date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
  70. } else {
  71. date = options.expires;
  72. }
  73. expires = '; expires=' + date.toUTCString();
  74. }
  75. var path = options.path ? '; path=' + options.path : '';
  76. var domain = options.domain ? '; domain=' + options.domain : '';
  77. var secure = options.secure ? '; secure' : '';
  78. document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
  79. } else {
  80. var cookieValue = null;
  81. if (document.cookie && document.cookie != '') {
  82. var cookies = document.cookie.split(';');
  83. for (var i = 0; i < cookies.length; i++) {
  84. var cookie = jQuery.trim(cookies[i]);
  85. if (cookie.substring(0, name.length + 1) == (name + '=')) {
  86. cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
  87. break;
  88. }
  89. }
  90. }
  91. return cookieValue;
  92. }
  93. };
  94. function blink(selector){
  95. $(selector).fadeOut('slow', function(){
  96. $(this).fadeIn('fast', function(){
  97. blink(this);
  98. });
  99. });
  100. }
  101. //购物车部分
  102. function add_cart(id,uid,sid,type){
  103. var load = layer.load();
  104. if(uid == _uid){
  105. layer.msg('不能购买自己的商品!');
  106. layer.close(load);
  107. return false;
  108. }
  109. ppAjax.post(webdir + "index.php?u=cart-add-ajax-1", {"id":id,"sid":sid,"num":1}, function(data){
  110. ppAjax.alert(data);
  111. if(window.ppData.err==0){
  112. if(type>0){
  113. window.location.href = webdir + "index.php?u=cart-index";
  114. }else{
  115. layer.alert(window.ppData.msg, {btn : ["立即去结算","稍候结算"]},function(){window.location.href= webdir + "index.php?u=cart-index";});
  116. }
  117. }else{
  118. layer.msg(window.ppData.msg);
  119. }
  120. layer.close(load);
  121. });
  122. }
  123. function del_cart(id,sid){
  124. var load = layer.load();
  125. ppAjax.post(webdir + "index.php?u=cart-del-ajax-1", {"id":id}, function(data){
  126. ppAjax.alert(data);
  127. if(window.ppData.err==0){
  128. layer.msg(window.ppData.msg);
  129. $('#li_' + id).remove();
  130. var len = $("#shop_" + sid + " .items").length;
  131. if(len == 0){
  132. $("#shop_" + sid).remove();
  133. }
  134. load_total();
  135. }else{
  136. layer.msg(window.ppData.msg);
  137. }
  138. layer.close(load);
  139. });
  140. }
  141. function show_jifen_form(id,dprice){
  142. var _totaljifen = 0 , user_jifen = $('#top_gold').text() - 0 - $("#_jifen_total").val(),num = $("#num_" + id).val();
  143. if(user_jifen >= dprice * jf_rate*num){
  144. _totaljifen = dprice*jf_rate*num ;
  145. }else{
  146. _totaljifen = parseInt(user_jifen/jf_rate)*jf_rate ;
  147. }
  148. var _content = '\
  149. <div class="input-group">\
  150. <span class="input-group-addon">使用</span>\
  151. <input id="_jifen" value="'+_totaljifen+'" class="form-control" type="text" onchange="change_cart_jifen('+_totaljifen+');" autocomplete="off">\
  152. <span class="input-group-addon">'+jf_name+'可抵 <strong id="_jifen_notice" class="text-danger">'+(_totaljifen/jf_rate)+'</strong> 元</span>\
  153. <span class="input-group-btn"><a href="javascript:;" class="btn btn-info save_cid" onclick="save_cart_jifen('+id+');">保存</a></span>\
  154. <span class="input-group-btn"><a href="javascript:;" class="btn btn-link" onclick="layer.closeAll(\'tips\');"><i class="icon-cancel-circle"></i></a> </span>\
  155. </div>\
  156. ';
  157. var tips = layer.tips(_content, '#jfbtn_' + id,{tips:[1, '#ddd'],time:0,area:'380px',shade: 0.35});
  158. }
  159. function change_cart_jifen(max){
  160. var _jifen = $('#_jifen').val();
  161. var _jifen_m = _jifen/jf_rate;
  162. if(parseInt(_jifen_m)!==_jifen_m){
  163. layer.msg('必须填写'+jf_rate+'的倍数!',function(){});
  164. $('#_jifen').val('0');
  165. return false;
  166. }
  167. if(_jifen > max){
  168. _jifen = max ;
  169. _jifen_m = max/jf_rate;
  170. $('#_jifen').val(_jifen);
  171. }
  172. $('#_jifen_notice').text(_jifen_m);
  173. }
  174. function save_cart_jifen(id){
  175. var _jifen = $('#_jifen').val(),_jifen_m = $('#_jifen_notice').text();
  176. $('#jifen_'+id).val(_jifen);
  177. if(_jifen > 0){
  178. $('#jfbtn_'+id).text('使用'+_jifen+jf_name+'抵价'+_jifen_m+'元');
  179. }else{
  180. $("#jfbtn_" + id).text(jfbtn_text);
  181. }
  182. load_total();
  183. layer.closeAll('tips');
  184. }
  185. function move_fav(id,pid){
  186. var load = layer.load();
  187. ppAjax.post(webdir + "index.php?u=fav-cart_to_fav-ajax-1", {"id":id,"pid":pid}, function(data){
  188. layer.close(load);
  189. ppAjax.alert(data);
  190. if(window.ppData.err==0){
  191. $("#li_" + id).remove();
  192. load_total();
  193. }else{
  194. layer.msg(window.ppData.msg);
  195. }
  196. });
  197. }
  198. function post_buy(id,pid,i){
  199. var err = 0 ;
  200. $.ajax({
  201. type : "POST",
  202. cache : false,
  203. url : webdir + "member/index.php?book-cart_add",
  204. data : {"id" : id,"pid" : pid, "num" : $("#num_" + id).val(), "use_jifen" : $("#jifen_" + id).val(),"first" : i},
  205. async : false,
  206. success : function(data){
  207. ppAjax.alert(data);
  208. if(window.ppData.err==0){
  209. $("#li_" + id).addClass('success');
  210. load_total();
  211. }else{
  212. $("#li_" + id).addClass('danger');
  213. err = 1;
  214. }
  215. }
  216. });
  217. return err;
  218. }
  219. //购物车结束
  220. function add_fav(id,sid){
  221. ppAjax.post(webdir + "index.php?u=fav-add-ajax-1", {"id":id,"sid":sid}, function(data){
  222. ppAjax.alert(data);
  223. if(window.ppData.err==0){
  224. layer.msg(window.ppData.msg);
  225. }else{
  226. layer.msg(window.ppData.msg);
  227. }
  228. });
  229. }
  230. function del_fav(id,sid){
  231. ppAjax.post(webdir + "index.php?u=fav-del-ajax-1", {"id":id,"sid":sid}, function(data){
  232. ppAjax.alert(data);
  233. if(window.ppData.err==0){
  234. layer.msg(window.ppData.msg);
  235. $('#li_' + id).remove();
  236. $('#li_' + sid).remove();
  237. }else{
  238. layer.msg(window.ppData.msg);
  239. }
  240. });
  241. }
  242. function change_jifen(max,price){
  243. var _jifen = $('#_jifen').val();
  244. var _jifen_m = _jifen/jf_rate;
  245. if(parseInt(_jifen_m)!==_jifen_m){
  246. $('#_sorry').text('必须填写'+jf_rate+'的倍数!');
  247. $('#_jifen').val('0');
  248. return false;
  249. }else{
  250. $('#_sorry').text('');
  251. }
  252. if(_jifen > max){
  253. _jifen = max ;
  254. _jifen_m = max/jf_rate;
  255. $('#_jifen').val(_jifen);
  256. }
  257. var _money = $('#book_price').val() * 1 - _jifen_m;
  258. if(_money > price){
  259. $('#_sorry').text('现金不足!');
  260. }else{
  261. $('#_sorry').text('');
  262. }
  263. $('#_xianjin').val(_money);
  264. $('#_jifen_notice').text(_jifen_m);
  265. }
  266. function list_cron(){
  267. $.getScript(webdir+"index.php?u=cron-flag-id-2-ajax-1", function(){});
  268. }
  269. function home_cron(){
  270. $.getScript(webdir+"index.php?u=cron-flag-id-1-ajax-1", function(){});
  271. $.getScript(webdir+"index.php?u=cron-refresh_total-ajax-1", function(){});
  272. }
  273. function qiandao(){
  274. ppAjax.post(memurl + "/index.php?u=index-qiandao-ajax-1", {'rnum':Math.random()}, function(data){
  275. //ppAjax.alert(data);
  276. var res = toJson(data);
  277. if(res.err==0){
  278. layer.tips('签到成功!奖励<b>'+res.msg+'</b>'+jf_name+'<br/>连续签到奖励更多', '#qiandao', {tips: [1, '#00AA88']});
  279. var totalgold = parseInt($('#top_gold').text()) + parseInt(res.msg);
  280. $('#top_gold').text(totalgold);
  281. $('#qd_str').text('已签到');
  282. }else{
  283. layer.tips(res.msg, '#qiandao', {tips: [1, '#00AA88']});
  284. }
  285. });
  286. }
  287. function load_comment(){
  288. var obj = $("#load_more");
  289. var next_url = obj.attr("next_url");
  290. var isnext = obj.attr("isnext");
  291. var no_more = function() {
  292. obj.html("没有了...").addClass('disabled');
  293. if(typeof load_more != "undefined") obj.off("click", load_more);
  294. if(typeof auto_load_more != "undefined") $(window).off("scroll", auto_load_more);
  295. }
  296. if(isnext < 1) { no_more(); return; }
  297. var ppJosnLock = false;
  298. var load_more = function() {
  299. if(!next_url || ppJosnLock) return;
  300. obj.html("加载中...");
  301. var com_load = layer.load();
  302. ppJosnLock = true;
  303. $.getJSON(next_url, function(res) {
  304. if(res.err == 0){
  305. try{
  306. //var json = eval("("+res+")");
  307. var json = res;
  308. next_url = json.next_url;
  309. var s = "";
  310. $.each(json.list_arr, function(i,item){
  311. s += '<li class="media">';
  312. s += '<a class="media-left" href="javascript:;"><img src="'+item.avatar+'" alt="'+item.author+'"></a>';
  313. s += '\
  314. <div class="media-body">\
  315. <p class="media-heading"><span class="text-info">'+item.author+'</span><small class="text-muted">['+item.ip+']</small> '+item.rates+' <small class="pull-right text-muted hidden-xs">'+item.date+'</small></p>\
  316. <p class="text-muted small">'+item.content+'</p>\
  317. </div>\
  318. ';
  319. s += '</div>';
  320. //$("#more_div").before(s);
  321. });
  322. $("#comments_list").html(s);
  323. $('html, body').animate({
  324. scrollTop: $("#comments").offset().top
  325. }, 300);
  326. obj.html("下一页");
  327. layer.close(com_load);
  328. ppJosnLock = false;
  329. if(json.isnext < 1) no_more();
  330. }catch(e){
  331. layer.close(com_load);
  332. }
  333. }else{
  334. layer.msg(res.msg);
  335. layer.close(com_load);
  336. }
  337. });
  338. }
  339. obj.click(load_more);
  340. }
  341. function send_buy(){
  342. var user_price = $('#user_price').val(),totalprice = $('#book_price').val() * 1 , dprice = $('#book_dprice').val() * 1, user_jifen = $('#user_jifen').val() * 1;
  343. var _totaljifen = 0 ;
  344. if(user_jifen >= dprice*jf_rate){
  345. _totalprice = totalprice - dprice ;
  346. _totaljifen = dprice*jf_rate ;
  347. }else{
  348. _totaljifen = parseInt(user_jifen/jf_rate)*jf_rate ;
  349. _totalprice = totalprice - parseInt(user_jifen/jf_rate);
  350. }
  351. var lay_content = "<p class='alert text-danger'>余额不足!<br/>您的现金余额:"+user_price+"元<br/>";
  352. if(_totaljifen > 0){
  353. lay_content += "您的"+jf_name+"余额:"+user_jifen+",最多可抵 "+_totaljifen/jf_rate+" 元<br/>";
  354. }
  355. if((_totalprice*1 > user_price*1)){
  356. layer.open({
  357. type: 1,
  358. title: ['友情提醒', 'font-weight:bold;color:green'],
  359. btn: ['去充值', '取消'],
  360. yes: function(index, layero){
  361. window.location.href = memurl + '/index.php?u=record-order-price-' + (_totalprice-user_price);
  362. },cancel: function(index){
  363. },
  364. shadeClose: true,
  365. content: lay_content + "您至少需充值:"+(_totalprice-user_price)+"元</p>"
  366. });
  367. return false;
  368. }else{
  369. if(dprice > 0){
  370. var _content = '\
  371. <div class="input-group mt10">\
  372. <span class="input-group-addon">支付现金</span>\
  373. <input id="_xianjin" value="'+_totalprice+'" class="form-control" type="text" readonly>\
  374. <span class="input-group-addon">元</span>\
  375. </div>\
  376. <div class="input-group mt10">\
  377. <span class="input-group-addon">使用'+jf_name+'</span>\
  378. <input id="_jifen" value="'+_totaljifen+'" class="form-control" type="text" onchange="change_jifen('+_totaljifen+','+user_price+');">\
  379. <span class="input-group-addon">可抵价<strong id="_jifen_notice" class="text-info">'+(_totaljifen/jf_rate)+'</strong>元</span>\
  380. </div>\
  381. <p class="mt10">当前'+item_name+'最多可使用<span class="text-red">'+dprice*jf_rate+jf_name+'抵价'+dprice+'元</span><br/>您当前现金为:'+user_price+'元,'+jf_name+'为:'+user_jifen+'</p>\
  382. ';
  383. }else{
  384. var _content = '确认后将扣除' + totalprice + '元';
  385. }
  386. _content += '\
  387. <div class="input-group mt10">\
  388. <span class="input-group-addon text-red">支付密码</span>\
  389. <input id="_pinpass" value="" class="form-control" type="password">\
  390. </div>\
  391. ';
  392. if(!_pin){
  393. _content += '<p class="alert alert-waring"><a class="text-red" href="'+memurl+'/index.php?u=index-profile#pinpass_d" target="_blank">尚未设置支付密码,立即去设置</a></p>';
  394. }
  395. _content += '<br/><span id="_sorry" class="text-red"></span>&nbsp;';
  396. layer.open({
  397. title: ['购买确认', 'font-weight:bold;color:green'],
  398. btn:['确认','取消'],
  399. yes:function(index,layero){
  400. var btn = layero.find('.layui-layer-btn'); //按钮组
  401. var body = layero.find('.layui-layer-content'); //内容区
  402. btn.hide();
  403. body.append("<br/>请稍候...若无响应请到<a class='text-info' href='"+memurl+"/index.php?u=book-index' target='_blank'>会员中心</a>查看!");
  404. $.ajax({
  405. type : "POST",
  406. cache : false,
  407. url : $('#order_book').attr("action"),
  408. data : {'pid':$('#book_pid').val(),'cid':$('#book_cid').val(),'use_jifen':$('#_jifen').val(),'pinpass':$('#_pinpass').val()},
  409. success : function(data){
  410. ppAjax.alert(data);
  411. if(window.ppData.err==0){
  412. layer.msg('购买成功,请稍后,即将进入会员中心!', {icon: 1,time: 2000,shade: 0.6}, function(){window.location = memurl+'/index.php?u=book-index';});
  413. }else{
  414. layer.alert(window.ppData.msg, {icon: 5,shade: 0.6}) ;
  415. }
  416. },error : function(html){
  417. layer.alert("提交数据失败,代码:"+ html.status +",请稍候再试", {icon: 0,shade: 0.6}) ;
  418. }
  419. });
  420. },cancel:function(index){
  421. layer.close(index);
  422. },
  423. shadeClose: false,
  424. content: _content
  425. });
  426. }
  427. }
  428. function lxfEndtime(){
  429. $(".time_remark_txt").each(function(){
  430. var endtime = $(this).attr("endTime");
  431. var nowtime = new Date().getTime();
  432. var youtime = endtime - nowtime;
  433. var seconds = youtime/1000;
  434. var minutes = Math.floor(seconds/60);
  435. var hours = Math.floor(minutes/60);
  436. var days = Math.floor(hours/24);
  437. var CDay= days ;
  438. var CHour= hours % 24;
  439. var CMinute= minutes % 60;
  440. var CSecond= Math.floor(seconds%60);
  441. if(endtime>nowtime){
  442. $(this).html("<i class='icon-clock'></i> "+CDay+"天"+CHour+"小时"+CMinute+"分"+CSecond+"秒");
  443. }
  444. });
  445. setTimeout("lxfEndtime()",1000);
  446. }
  447. var History = {
  448. 'Json': '',
  449. 'Display': true,
  450. 'Clear': function() {
  451. $.cookie('NEWZHAN_history', null,{path:'/'});
  452. $('#errshow').html('<tr><td colspan="3" class="text-center text-red">浏览记录已被清空</td></tr>');
  453. },
  454. 'List': function(){
  455. var jsondata = [];
  456. if (this.Json) {
  457. jsondata = this.Json;
  458. } else {
  459. var jsonstr = $.cookie('NEWZHAN_history');
  460. if (jsonstr != undefined) {
  461. jsondata = eval(jsonstr);
  462. }
  463. };
  464. html = '<table class="table table-hover small" id="data-table">';
  465. html += '<tr><th>标题</th><th>价格</th><th>'+jf_name+'抵价</th></tr>';
  466. html += '<tbody id="errshow">';
  467. if (jsondata.length > 0){
  468. for ($i = 0; $i < jsondata.length; $i++) {
  469. var d_price = jsondata[$i].d_price > 0 ? jsondata[$i].d_price : '-';
  470. html += '<tr><td><a href="' + jsondata[$i].url + '">' + jsondata[$i].title + '</a></td><td>' + jsondata[$i].price + '</td><td>' + d_price + '</td></tr>';
  471. }
  472. } else {
  473. html += '<tr><td colspan="3" class="text-center text-red">暂无浏览记录</td></tr>';
  474. };
  475. html += '</tbody>';
  476. html += '<tfoot>';
  477. html += '<tr><td colspan="3" class="text-right"><a onclick="History.Clear();" class="btn btn-danger btn-xs" href="javascript:void(0)"><i class=" icon-bin"></i> 清空所有记录</a></td></tr>';
  478. html += '</tfoot>';
  479. html += '</table>';
  480. layer.open({
  481. type: 1,
  482. title: ['浏览记录', 'font-weight:bold;color:green'],
  483. area:'600px',
  484. shadeClose: true,
  485. content: html,
  486. success: function(layero, index){
  487. //分页
  488. }
  489. });
  490. },
  491. //History.Insert(title, price, d_price, limit, days);
  492. 'Insert': function(title, price, d_price, limit, days){
  493. var jsondata = $.cookie('NEWZHAN_history');
  494. var url = document.URL;
  495. //var url = window.location.href;
  496. if (jsondata != undefined) {
  497. this.Json = eval(jsondata);
  498. jsonstr = '{item:[{"title":"' + title + '","url":"' + url + '","price":"' + price + '","d_price":"' + d_price + '"},';
  499. for ($i = 0; $i <= limit; $i++){
  500. if (this.Json[$i]) {
  501. if (this.Json[$i].url != url) {
  502. jsonstr += '{"title":"' + this.Json[$i].title + '","url":"' + this.Json[$i].url + '","price":"' + this.Json[$i].price + '","d_price":"' + this.Json[$i].d_price + '"},';
  503. }
  504. } else {
  505. break;
  506. }
  507. };
  508. jsonstr = jsonstr.substring(0, jsonstr.lastIndexOf(','));
  509. jsonstr += "]}";
  510. } else {
  511. jsonstr = '{item:[{"title":"' + title + '","url":"' + url + '","price":"' + price + '","d_price":"' + d_price + '"}]}';
  512. };
  513. this.Json = eval(jsonstr);
  514. $.cookie('NEWZHAN_history', jsonstr,{path:'/',expires:days});
  515. }
  516. }
  517. function clear_cookie(){
  518. $("#list_checkbox :checkbox").each(function(){
  519. var _id = $(this).attr('id');
  520. $.cookie(_id, null,{path:'/'});
  521. });
  522. $("a.extlink").each(function(){
  523. var _id = $(this).attr('_cook') ;
  524. $.cookie(_id, null,{path:'/'});
  525. });
  526. $.cookie('order', null,{path:'/'});
  527. }
  528. function search(type){
  529. clear_cookie();
  530. var keyword = $("#search_keyword").val() , mid = $("#search_mid").val(), sid = $("#search_sid").val();
  531. if (!keyword) {
  532. layer.tips('搜索词不能为空!', '#search_keyword',{tips: 3});
  533. return false;
  534. }
  535. if(type == 0 && sid){
  536. $.cookie('search_sid', sid,{path:'/'});
  537. }else{
  538. $.cookie('search_sid', null,{path:'/'});
  539. }
  540. //$("#search_form").submit();
  541. _surl = search_url.replace(/\{mid\}/,mid);
  542. _surl = _surl.replace(/%7Bkeyword%7D/,keyword);
  543. window.location.href = _surl;
  544. return false;
  545. }
  546. $(document).ready(function () {
  547. $('#search_all').click(function(){
  548. search(1);
  549. });
  550. $('#search_shop').click(function(){
  551. search(0);
  552. });
  553. $("a.btn-diy").hover(function(){
  554. var str = $(this).attr("_title");
  555. var color = $(this).attr("color");
  556. var that = this;
  557. layer.tips(str, that, {tips: [1, color]});
  558. },function(){
  559. layer.closeAll('tips');
  560. });
  561. $(".item_list .panel").hover(function(){
  562. $(this).addClass('panel_hover');
  563. var _text = $(this).find('.good_remark_txt').text().trim();
  564. if(_text.length > 0){
  565. $(this).find('.good_remark').slideDown('fast');
  566. }
  567. },function(){
  568. $(this).removeClass('panel_hover');
  569. $(this).find('.good_remark').slideUp('fast');
  570. });
  571. $('#artbody img').addClass('img-responsive center-block');
  572. $('#navbar a').click(function(){
  573. clear_cookie();
  574. });
  575. $('#orderby a').click(function(){
  576. $.cookie('order', $(this).attr('data'),{path:'/'});
  577. window.location.reload();
  578. });
  579. $('#comments_order input').click(function(){
  580. layer.load();
  581. $.cookie('comment_order', $(this).val());
  582. window.location.reload();
  583. });
  584. $('#list_check').click(function(){
  585. $("#list_checkbox :checkbox").each(function(){
  586. var _id = $(this).attr('id');
  587. var _checked = $('#' + _id)[0].checked;
  588. $.cookie(_id, _checked ? 1 : 0,{path:'/'});
  589. });
  590. window.location.reload();
  591. });
  592. $('#list_check_del').click(function(){
  593. $("#list_checkbox :checkbox").each(function(){
  594. var _id = $(this).attr('id');
  595. $.cookie(_id, null,{path:'/'});
  596. });
  597. window.location.reload();
  598. });
  599. $('#sorderby a').click(function(){
  600. $.cookie('sorder', $(this).attr('data'),{path:'/'});
  601. window.location.reload();
  602. });
  603. $('#qiandao').click(function(){
  604. qiandao();
  605. });
  606. $('a.extlink').click(function(){
  607. var name = $(this).attr('_cook') ;
  608. $.cookie(name, $(this).attr('_data'),{path:'/'});
  609. window.location.reload();
  610. });
  611. $('a.extlink2').click(function(){
  612. var name = $(this).attr('_cook') ;
  613. var url = $('#exts').attr('_url') ;
  614. $.cookie(name, $(this).attr('_data'),{path:'/'});
  615. window.location.href = url;
  616. });
  617. $("img[data-original]").lazyload({effect:"fadeIn"});
  618. $('li.dropdown').mouseover(function() {
  619. $(this).addClass('open');
  620. }).mouseout(function() {
  621. $(this).removeClass('open');
  622. });
  623. $(".dropdown-toggle").click(function(){
  624. if($(this).attr('href')) window.location = $(this).attr('href');
  625. });
  626. // 页面浮动面板
  627. $("#totop").click(function(){
  628. $("html,body").animate({scrollTop :0},500);
  629. return false;
  630. });
  631. //pm_count
  632. if(_uid && _uid> 0){
  633. $.getScript(webdir + "index.php?u=pm-index", function(){
  634. if(pm_count){
  635. $("#top_newpm").html('<a href="'+memurl+'/index.php?u=pm-index" onMouseOver="layer.tips(\'有'+pm_count+'条新消息\',this);" class="blink"><i class="icon-commenting"></i></a>');blink('.blink');
  636. }
  637. });
  638. }
  639. blink('.blink');
  640. $("#top_qrcode").click(function(){
  641. layer.open({type: 4,content: ['<div style="padding:30px;text-align:center;"><img src=\''+weburl+'static/img/qrcode.png\'><br/><span class="text-danger mb0"><span class="f24">扫一扫</span><br>或在手机浏览器直接输入本站网址</span></div>', '#top_qrcode'],tips: [1, '#fff'],closeBtn: 0,shadeClose:true});
  642. })
  643. });