center.min.js 26.5 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958
(function() {
	localStorage.setItem('auto', false);

	init_data();

	

	function init_data(response) {
		if (response) {
			$(response).appendTo($('body .mask'));
		}
		// Home模块
		var Home = function(modId) {
			Module.call(this, modId);
		}
		// 继承基础模块
		Core.inherit(Home, Module);

		Home.prototype.bind = function() {
			// 绑定模块事件到section
			var that = this;
			that.$c.on('click', 'label.help, img', function(e) {
				e.preventDefault();
				e.stopPropagation();
				/*
				 * @todo-list bug fixed in android,the click event fired twice!
				 */
				if (Core.cur_mod == 'help')
					return;
				Core.showMod('help');
				return false;
			});

		}

		Core.registerMod('home', Home);

		// 帮助信息模块
		var Help = function(modId) {
			Module.call(this, modId);
		}
		Core.inherit(Help, Module);
		Core.registerMod('help', Help);
		// Mibao模块
		var Mibao = function(modId) {
			Module.call(this, modId);
		}
		// 继承基础模块
		Core.inherit(Mibao, Module);
		Mibao.prototype.bind = function() {
			var that = this;
			that.$c.on('click', '[type=submit]', function(e) {
				e.preventDefault();
				Core.ajax_do(that.$c.find('.ajax'), that.mibao_cb, that);
				return false;
			});
		}
		Mibao.prototype.mibao_cb = function(data) {
			var status_code = data.code;
			var msg = data.msg;
			if (0 == status_code) {
				Core.Data.safe_question = msg.question;
				Core.Data.safe_answer = msg.answer;
			}
			// 显示一个成功信息,并跳转到home
			Core.showTips("成功设置密保!", true);
			Core.showMod('home');
		}
		Core.registerMod('mibao', Mibao);

		// 用户安全菜单模块
		var Sub_menu = function(modId) {
			Module.call(this, modId);
		}
		Core.inherit(Sub_menu, Module);
		Core.registerMod('sub_menu', Sub_menu);
		// var Message_menu = function(modId) {
		// 	Module.call(this, modId);
		// }
		// Core.inherit(Message_menu, Module);
		// Message_menu.prototype.show_after = function(){
		// 	var $badge = this.$c.find('.badge');
		// 	if($badge.length ==0){
		// 		if(Core.Data.msg_count > 0){
		// 			var $btn = this.$c.find('.msg');
		// 			$btn.html('<span class="badge">' + Core.Data.msg_count + '</span>' + $btn.html());
		// 		}
		// 	}
		// }
		// Core.registerMod('message_menu', Message_menu);
		// //找回密码模块
		// var Find_pwd = function(modId){
		// Module.call(this, modId);
		// }
		// Core.inherit(Find_pwd, Module);
		// Find_pwd.prototype.bind = function(){
		// var that = this;
		// that.$c.on('click', '.op-primary', function(e){
		// var $form = that.$c.find('.step-tab
		// input:checked').parent().parent().find('form')
		// e.preventDefault();
		// Core.ajax_do($form, that.findpwd_cb, that);
		// return false;
		// });
		// }
		// Find_pwd.prototype.findpwd_cb = function(data){
		// var code = data.code;
		// var msg = data.msg;
		//			
		// if (0 != code){
		// Core.showTips(msg, false);
		// return;
		// }
		// if(typeof msg == 'object'){
		// //回答密保
		// Core.Data.ans_temp = msg;
		// Core.updateMod('answer_question');
		// } else{
		// //通过邮箱
		// Core.showTips(msg, true);
		// Core.showMod("login");
		// }
		// }
		// Core.registerMod('find_pwd', Find_pwd);

		// Mibao模块
		var Bind = function(modId) {
			Module.call(this, modId);
		}
		// 继承基础模块
		Core.inherit(Bind, Module);
		Bind.prototype.bind = function() {
			var that = this;
			that.$c.on('click', '[type=submit]', function(e) {
				e.preventDefault();
				Core.ajax_do(that.$c.find('.ajax'), that.bind_cb, that);
				return false;
			});
			that.$c.on('click', '#bind-mobile', function(e) {
				e.preventDefault();
				that.$c.find('#bind_phone_form').show();
				return false;
			});
			that.$c.on('click', '#bind-check', function(e){
				e.preventDefault();
				Core.ajax_do($(e.target), that.bind_ch, that);
				return false;
			});
		}
		Bind.prototype.bind_ch = function(data){
			var code = data.code;
			Core.Data.bind_statu = data.msg.bind_statu;
			if(data.msg.bind_statu == 1){
				Core.showTips('电话绑定未成功', false);
			}
			Core.updateMod('bind');
		}
		Bind.prototype.bind_cb = function(data) {
			var code = data.code;
			if (code != 0)
				return;
			$(".bind_phone_tip").html(Core.Data.bind_mobile_tips);
			Core.Data.bind_statu = 1;
			Core.Data.bind_phone = this.$c.find('input[name=mobile]').val();
			this.$c.find('span.text-info').html(this.$c.find('input[name=mobile]').val());
			Core.showTips('通过电话确认后可绑定手机!', true);
			this.$c.find('#bind_phone_form').hide();
			this.isValid = false;
			setTimeout(function() {
				Core.updateMod('bind');
			}, 1000);
		}
		Core.registerMod('bind', Bind);

		// Mail模块
		var Mail = function(modId) {
			Module.call(this, modId);
		}
		// 继承基础模块
		Core.inherit(Mail, Module);
		Mail.prototype.bind = function() {
			var that = this;
			that.$c.on('click', '[type=submit]', function(e) {
				e.preventDefault();
				Core.ajax_do(that.$c.find('.ajax'), that.mail_cb, that);
				return false;
			});
			that.$c.on('click', '#bind-mail', function(e) {
				e.preventDefault();
				that.$c.find('#bind_mail_form').show();
				return false;
			});			
			that.$c.on('click', '.op-primary', function(e) {
				e.preventDefault();
				Core.ajax_do(that.$c.find('.ajax'), that.mail_cb, that);
				return false;
			});
		}
		Mail.prototype.mail_cb = function(data) {
			var code = data.code;
			Core.Data.bind_mail_statu = 1;
			Core.Data.mail = this.$c.find('input[name=email]').val();
			this.$c.find('span.text-info').html(this.$c.find('input[name=email]').val());
			Core.showTips('请登录您的邮箱,完成邮箱认证功能。', true);
			this.$c.find('#bind_mail_form').hide();
			this.isValid = false;
			setTimeout(function() {
				Core.updateMod('mail');
			}, 1000);
		}
		Core.registerMod('mail', Mail);

		// // 重置密码模块
		// var Reset_pwd = function(modId) {
		// 	Module.call(this, modId);
		// }
		// // 继承基础模块
		// Core.inherit(Reset_pwd, Module);

		// Reset_pwd.prototype.bind = function() {
		// 	this.$c.on('click', '.op-primary', function() {
		// 		Core.updateMod("modify_pwd");
		// 	});
		// }
		// Core.registerMod('reset_pwd', Reset_pwd);

		var Modify_pwd = function(modId) {
			Module.call(this, modId);
		}
		Core.inherit(Modify_pwd, Module);

		Modify_pwd.prototype.bind = function() {
			var that = this;
			that.$c.on('click', '[type=submit]', function(e) {
				e.preventDefault();
				Core.ajax_do(that.$c.find('.ajax'), that.modify_cb, that);
				return false;
			});
			
		}
		Modify_pwd.prototype.modify_cb = function(data) {
			var status_code = data.code;
			var msg = data.msg;
			if (status_code == 0) {
				if(Core.Data.is_guest == 1){
					//游客帐号转正
					localStorage.removeItem('guest_n');
					Core.showTips('账号升级成功, 请记住登录名和新密码。', true);
				}else{
					Core.showTips('成功修改密码, 请记住新密码。', true);
				}
				if (!Core.user_names) Core.user_names = {}
				Core.user_names[msg.username] = this.$c.find('input[name=newpwd]').val();
				localStorage.setItem('user_names', JSON.stringify(Core.user_names));
				Core.Data.is_guest = msg.is_guest;
				Core.Data.username = msg.username;
				Core.Data.nickname = msg.nickname;
				// 强制更新显示home模块,模块自刷新
				this.isValid = false;
				Core.updateMod('home');
			} else {
				Core.showTips(msg, false);
			}
		}
		Modify_pwd.prototype.show_after = function(){
			var _des = Core.last_mod ? Core.last_mod : 'home';
			this.$c.find('a.btn.pull-left').attr('href', '#'+_des);
		}
		Core.registerMod('modify_pwd', Modify_pwd);

		/**
		 * 公告活动记录模块
		 */
		var Activity = function(modId) {
			this.myScroll = null;
			this.cur_id = null;
			Module.call(this, modId);
		}
		Core.inherit(Activity, Module);
		Activity.prototype.bind = function() {
			var that = this;
			that.$c.on('click', 'li>a.item', function(e) {
				e.preventDefault();
				/*
				 * @todo-list bug fixed in android,the click event fired twice!
				 */
				if (Core.cur_mod == 'activity_detail')
					return;
				var $e = $(e.target);
				if (!$e.is('a'))
					$e = $e.parent();
				var id = $e.attr('data-id');
				if (id == that.cur_id) {
					Core.Data.activity_update = false;
					Core.showMod('activity_detail');
					return false;
				}
				that.cur_id = id;
				Core.Data.activity_update = true;
				Core.showTips('加载中...', true, 5000);
				$e.data('path', '/sdk/notice/view/?id=' + id);
				Core.load_json($e, function(data){
					Core.Data.activity_detail = data;
					Core.showTips('加载完成!', true, 2000);
					Core.updateMod('activity_detail');
				}, that);
				// $.getJSON('/sdk/notice/view/?id=' + id, function(data) {
				// 	Core.Data.activity_detail = data;
				// 	Core.showTips('加载完成!', true, 2000);
				// 	Core.updateMod('activity_detail');
				// });
				return false;
			});
			that.$c.on('click', 'li.more a', function(e) {
				e.preventDefault();
				Core.load_html($(e.target), that.refresh, that);
				return false;
			});
		}
		Activity.prototype.refresh = function() {
			this.myScroll.refresh();
		}
		Activity.prototype.show_after = function() {
			if (this.$c.find('.activity-list').children().length == 0) {
				Core.load_html(this.$c.find('.activity-list'),
						this.act_cb, this);
			}
			var $badge = this.$c.find('.badge');
			if($badge.length ==0){
				if(Core.Data.msg_count > 0){
					var $btn = this.$c.find('.badge_msg');
					$btn.html('<span class="badge">' + Core.Data.msg_count + '</span>' + $btn.html());
				}
			}
		}
		Activity.prototype.act_cb = function(data) {
			this.myScroll = new iScroll('activity_wrapper');
		}
		Core.registerMod('activity', Activity);

		/**
		 * 公告活动详细模块
		 */
		var Activity_detail = function(modId) {
			this.myScroll = null;
			Module.call(this, modId);
		}
		Core.inherit(Activity_detail, Module);
		Activity_detail.prototype.bind = function() {
			var that = this;
		}
		Activity_detail.prototype.show_after = function() {
			var that = this;
			if (Core.Data.activity_update) {
				console.log('new scroller');
				this.myScroll = new iScroll('detail_scroller');
				that.myScroll.refresh();
				this.$c.find('.scroll img').on('load', function(e){
					console.log('img loaded in scroll');
					that.myScroll.refresh();
				});
			}
		}

		Core.registerMod('activity_detail', Activity_detail);

		/**
		 * 客服问题列表模块
		 */
		var Kefu_list = function(modId) {
			this.myScroll = null;
			this.cur_id = null;
			Module.call(this, modId);
		}
		Core.inherit(Kefu_list, Module);
		Kefu_list.prototype.bind = function() {
			var that = this;
			that.$c.on('click', 'li>a.item', function(e) {
				e.preventDefault();
				e.stopPropagation();
				/*
				 * @todo-list bug fixed in android,the click event fired twice!
				 */
				if (Core.cur_mod == 'question_detail')
					return;
				var $e = $(e.target);
				while (!$e.is('a'))
					$e = $e.parent();
				var id = $e.attr('data-id');
				if (id == that.cur_id) {
					Core.Data.question_update = false;
					Core.showMod('question_detail');
					return false;
				}
				that.cur_id = id;
				Core.Data.question_update = true;
				$e.data('path', '/user/question/view?id=' + id + '&format=json');
				Core.load_json($e, function(data){
					Core.Data.question_detail = data;
					Core.showTips('加载完成!', true, 2000);
					Core.updateMod('question_detail');
				}, that);
				// Core.showTips('加载中...', true, 5000);
				// $.getJSON('/user/question/view?id=' + id + '&format=json',
				// 		function(data) {
				// 			Core.Data.question_detail = data;
				// 			Core.showTips('加载完成!', true, 2000);
				// 			Core.updateMod('question_detail');
				// 		});
				return false;
			});
			that.$c.on('click', 'li.more a', function(e) {
				e.preventDefault();
				Core.load_html($(e.target), that.refresh, that);
				return false;
			});
		}
		Kefu_list.prototype.refresh = function() {
			this.myScroll.refresh();
		}
		Kefu_list.prototype.show_after = function() {
			if (this.$c.find('.kefu-list').children().length == 0) {
				$ol = this.$c.find('.kefu-list');
				if($ol.attr('data-params-url').indexOf('undefined') == -1)
					Core.load_html(this.$c.find('.kefu-list'), this.act_cb,
						this);
			}
		}
		Kefu_list.prototype.act_cb = function(data) {
			this.myScroll = new iScroll('kefu_wrapper');
			
		}
		Core.registerMod('kefu_list', Kefu_list);

		/**
		 * 邀请列表模块
		 */
		var Invite_list = function(modId) {
			this.myScroll = null;
			Module.call(this, modId);
		}
		Core.inherit(Invite_list, Module);
		Invite_list.prototype.bind = function() {
			var that = this;
			that.$c.on('click', 'li.more a', function(e) {
				e.preventDefault();
				Core.load_html($(e.target), that.refresh, that);
				return false;
			});
		}
		Invite_list.prototype.refresh = function() {
			this.myScroll.refresh();
		}
		Invite_list.prototype.show_after = function() {
			if (this.$c.find('.invite-list').children().length == 0) {
				Core.load_html(this.$c.find('.invite-list'), this.act_cb,
						this);
			}
		}
		Invite_list.prototype.act_cb = function(data) {
			this.myScroll = new iScroll('invite_wrapper');
		}
		Core.registerMod('invite_list', Invite_list);

		/**
		 * 消息列表模块
		 */
		var Message = function(modId) {
			this.myScroll = null;
			this.cur_id = null;
			Module.call(this, modId);
		}
		Core.inherit(Message, Module);
		Message.prototype.bind = function() {
			var that = this;
			that.$c.on('click', 'li>a.item', function(e) {
				e.preventDefault();
				e.stopPropagation();
				/*
				 * @todo-list bug fixed in android,the click event fired twice!
				 */
				if (Core.cur_mod == 'message_detail')
					return;
				var $e = $(e.currentTarget);
				var id = $e.attr('data-id');
				if (id == that.cur_id) {
					Core.showMod('message_detail');
					return false;
				}
				that.cur_id = id;
				$e.data('path', '/message/' + id + '.html?format=json');
				Core.load_json($e, function(data){
					Core.Data.message_detail = data;
					Core.showTips('加载完成!', true, 2000);
					Core.updateMod('message_detail');
				}, that);
				return false;
			});
			that.$c.on('click', 'li.more a', function(e) {
				e.preventDefault();
				Core.load_html($(e.target), that.refresh, that);
				return false;
			});
		}
		Message.prototype.refresh = function() {
			this.myScroll.refresh();
		}
		Message.prototype.show_after = function() {
			if (this.$c.find('.message-list').children().length == 0) {
				Core.load_html(this.$c.find('.message-list'), this.act_cb,
						this);
			}
		}
		Message.prototype.act_cb = function(data) {
			this.myScroll = new iScroll('message_wrapper');
		}
		Core.registerMod('message', Message);

		/**
		 * 消息内容详细模块
		 */
		var Message_detail = function(modId) {
			Module.call(this, modId);
		}
		Core.inherit(Message_detail, Module);

		Core.registerMod('message_detail', Message_detail);
		/**
		 * 论坛列表模块
		 */
		var Topic_list = function(modId) {
			this.myScroll = null;
			this.cur_id = null;
			Module.call(this, modId);
		}
		Core.inherit(Topic_list, Module);
		Topic_list.prototype.bind = function() {
			var that = this;
			that.$c.on('click', 'li>a.item', function(e) {
				e.preventDefault();
				e.stopPropagation();
				/*
				 * @todo-list bug fixed in android,the click event fired twice!
				 */
				if (Core.cur_mod == 'topic_detail')
					return;
				var $e = $(e.target);
				while (!$e.is('a'))
					$e = $e.parent();
				var id = $e.attr('data-id');
				if (id == that.cur_id) {
					Core.Data.topic_update = false;
					Core.showMod('topic_detail');
					return false;
				}
				that.cur_id = id;
				Core.Data.topic_update = true;
				Core.Data.topic_id = id;
				$e.data('path', '/topic/view?id=' + id + '&order=recent&format=json');
				Core.load_json($e, function(data){
					Core.Data.topic_detail = data;
					Core.showTips('加载完成!', true, 2000);
					Core.updateMod('topic_detail');
				}, that)
				// Core.showTips('加载中...', true, 5000);
				// $.getJSON('/topic/view?id=' + id + '&order=recent&format=json',
				// 		function(data) {
				// 			Core.Data.topic_detail = data;
				// 			Core.showTips('加载完成!', true, 2000);
				// 			Core.updateMod('topic_detail');
				// 		});
				return false;
			});
			that.$c.on('click', 'li.more a', function(e) {
				e.preventDefault();
				Core.load_html($(e.target), that.refresh, that);
				return false;
			});
		}
		Topic_list.prototype.refresh = function() {
			this.myScroll.refresh();
		}
		Topic_list.prototype.show_after = function() {
			if (this.$c.find('.topic-list').children().length == 0) {
				this.cur_id = null;
				var $ol = this.$c.find('.topic-list');
				if($ol.attr('data-params-url').indexOf('undefined') == -1)
					Core.load_html($ol, this.act_cb,
						this);
			}
		}
		Topic_list.prototype.act_cb = function(data) {
			this.myScroll = new iScroll('topic_wrapper');
		}
		Core.registerMod('topic_list', Topic_list);

		/**
		 * 帖子详细模块
		 */
		var Topic_detail = function(modId) {
			this.myScroll = null;
			Module.call(this, modId);
		}
		Core.inherit(Topic_detail, Module);
		Topic_detail.prototype.bind = function() {
			var that = this;
			that.$c.on('click', 'li.more a', function(e) {
				e.preventDefault();
				Core.load_html($(e.target), that.refresh, that);
				return false;
			});
			that.$c.on('click', '.op-primary', function(e) {
				e.preventDefault();
				Core.updateMod('topic_reply');
				return false;
			});
		}
		Topic_detail.prototype.refresh = function() {
			this.myScroll.refresh();
			var that = this;
			this.$c.find('.scroll img').on("load", function(e){
				that.myScroll.refresh();
			});
		}
		Topic_detail.prototype.show_after = function() {
			if (Core.Data.topic_update) {
				if (this.myScroll)
					this.myScroll.destroy();
				this.myScroll = new iScroll('topic_detail_scroller');
				this.refresh();
			}
		}

		Core.registerMod('topic_detail', Topic_detail);

		/**
		 * 发帖子模块
		 */
		var Topic = function(modId) {
			this.myScroll = null;
			Module.call(this, modId);
		}
		Core.inherit(Topic, Module);
		Topic.prototype.bind = function() {
			var that = this;
			that.$c.on('click', '.op-primary.submit', function(e) {
				e.preventDefault();
				if (that.$c.find('textarea').val() == '') {
					Core.showTips('请填写相应的描述!', false);
					return false;
				}
				/*
				 * if(that.$c.find('textarea').val().length > 150){
				 * Core.showTips('帖子描述超出了150个字符!', false); return false; }
				 */
				Core.ajax_do(that.$c.find('.ajax'), that.sq_cb, that);
				return false;
			});
		}
		Topic.prototype.sq_cb = function(data) {
			if (data.code == 0) {
				Core.showTips(data.msg, true, 3000);
				this.$c.find('input[name=title]').val('');
				this.$c.find('textarea').val('');
				setTimeout(function() {
					Core.updateMod('topic_list');
				}, 2000);
			} else {
				Core.showTips(data.msg, false);
			}
		}

		Core.registerMod('topic', Topic);

		/**
		 * 回复帖子模块
		 */
		var Topic_reply = function(modId) {
			this.myScroll = null;
			Module.call(this, modId);
		}
		Core.inherit(Topic_reply, Module);
		Topic_reply.prototype.bind = function() {
			var that = this;
			that.$c.on('click', '.op-primary.submit', function(e) {
				e.preventDefault();
				if (that.$c.find('textarea').val().length > 150) {
					Core.showTips('帖子描述超出了150个字符!', false);
					return false;
				}
				Core.ajax_do(that.$c.find('.ajax'), that.sq_cb, that);
				return false;
			});
		}
		Topic_reply.prototype.sq_cb = function(data) {
			if (data.code == 0) {
				// 回复成功,跳转回帖子详情页
				var that = this;
				Core.showTips(data.msg, true, 2000);
				var id = Core.Data.topic_id;
				var _$ = that.$c.find('.op-primary.submit');
				_$.data('path', '/topic/view?id=' + id + '&order=recent&format=json');
				Core.load_json(_$, function(data){
					Core.Data.topic_update = true;
					Core.Data.topic_detail = data;
					Core.showTips('回复成功!', true, 2000);
					Core.updateMod('topic_detail');
				}, that);
				// $.getJSON('/topic/view?id=' + id + '&order=recent&format=json',
				// 		function(data) {
				// 			Core.Data.topic_update = true;
				// 			Core.Data.topic_detail = data;
				// 			Core.showTips('回复成功!', true, 2000);
				// 			Core.updateMod('topic_detail');
				// 		});
			} else {
				Core.showTips(data.msg, false);
			}

		}

		Core.registerMod('topic_reply', Topic_reply);
		/**
		 * 奖励列表模块
		 */
		var Prize_list = function(modId) {
			this.myScroll = null;
			this.$e = null;
			Module.call(this, modId);
		}
		Core.inherit(Prize_list, Module);
		Prize_list.prototype.bind = function() {
			var that = this;
			that.$c.on('click', 'li>p>a', function(e) {
				e.preventDefault();
				var $e = $(e.target);
				that.$e = $e;
				Core.ajax_do($e, that.post_cb, that);
				return false;
			});
			that.$c.on('click', 'li.more a', function(e) {
				e.preventDefault();
				Core.load_html($(e.target), that.refresh, that);
				return false;
			});
		}
		Prize_list.prototype.refresh = function() {
			var that = this;
			setTimeout(function() {
				that.myScroll.refresh();
			}, 300);

		}
		Prize_list.prototype.show_after = function() {
			if (this.$c.find('.prize-list').children().length == 0) {
				Core.load_html(this.$c.find('.prize-list'), this.act_cb,
						this);
			}
		}
		Prize_list.prototype.post_cb = function(data) {
			Core.showTips(data.msg.msg, data.code == 0 ? true : false, 2000);
			if (data.code == 0) {
				console.log(this);
				this.$e.replaceWith('<sapn class="pull-right text-info btn-small">已经领取</span>');
			}
		}
		Prize_list.prototype.act_cb = function(data) {
			this.myScroll = new iScroll('prize_wrapper');
		}
		Core.registerMod('prize_list', Prize_list);
		/**
		 * 客服问题详细模块
		 */
		var Question_detail = function(modId) {
			this.myScroll = null;
			this.$score = null;
			Module.call(this, modId);
		}
		Core.inherit(Question_detail, Module);
		Question_detail.prototype.bind = function() {
			var that = this;
			that.$c.on('click', 'li.more a', function(e) {
				e.preventDefault();
				Core.load_html($(e.target), that.refresh, that);
				return false;
			});
			that.$c.on('click', 'li p > a', function(e) {
				e.preventDefault();
				that.$score = $(e.target);
				Core.ajax_do($(e.target), that.jude_cb, that);
				return false;
			})
		}
		Question_detail.prototype.jude_cb = function(data) {
			Core.showTips(data.msg);
			if (data.code == 0) {
				var score = this.$score.html();
				this.$score.parent().empty().html(
						'您的评价:&nbsp;&nbsp;<span class="btn">' + score
								+ '</span>');
			}
		}
		Question_detail.prototype.refresh = function() {
			var that = this;
			setTimeout(function() {
				that.myScroll.refresh();
			}, 300);

		}
		Question_detail.prototype.show_after = function() {
			if (Core.Data.question_update) {
				if (this.myScroll)
					this.myScroll.destory();
				this.myScroll = new iScroll('question_detail_scroller');
			}
		}

		Core.registerMod('question_detail', Question_detail);

		/**
		 * 提问客模块
		 */
		var Submit_question = function(modId) {
			Module.call(this, modId);
		}
		Core.inherit(Submit_question, Module);
		Submit_question.prototype.bind = function() {
			var that = this;
			that.$c.on('click', '.op-primary.submit', function(e) {
				e.preventDefault();
				if (that.$c.find('select').val() == ''
						|| that.$c.find('textarea').val() == '') {
					Core.showTips('请选择问题类型,并填写相应的描述!', false);
					return false;
				}
				if (that.$c.find('textarea').val().length > 150) {
					Core.showTips('问题描述超出了150个字符!', false);
					return false;
				}
				Core.ajax_do(that.$c.find('.ajax'), that.sq_cb, that);
				return false;
			});
		}
		Submit_question.prototype.sq_cb = function(data) {
			Core.showTips(data.msg, true, 2000);
			this.isValid = false;
			Core.updateMod('kefu_list');
		}
		Core.registerMod('submit_question', Submit_question);


		/**
		 * 邀请菜单模块
		 */
		var Invite_menu = function(modId) {
			Module.call(this, modId);
		}
		Core.inherit(Invite_menu, Module);
		Invite_menu.prototype.bind = function() {
			var that = this;
			// that.$c.on('click', 'input[type=submit]', function(e) {
			// 	e.preventDefault();
			// 	Core.ajax_do(that.$c.find('.ajax'), that.if_cb, that);
			// 	return false;
			// });
			that.$c.on('click', '#share a', function(e){
				e.preventDefault();
				var $e = $(e.target);
				var params = [];
				var head = $e.attr('title');
				var url = $e.attr('href');
				var pic = Core.Data.game_icon;
				var targetUrl = Core.Data.invite_url;//'http://www.9133.com/game/' + Core.Data.app_id + '.html'; 
				var title = 'title=' + encodeURIComponent('我在玩' + Core.Data.game_name + ',游戏很棒,一起来玩吧!');
				targetUrl = 'url=' + encodeURIComponent(targetUrl);
				if($e.hasClass('s_tqq')){
					params.push('c=share');
					params.push('a=index');
				}
				if($e.hasClass('s_qzone')){
					pic = 'pics=' + encodeURIComponent(pic);
				} 
				else if($e.hasClass('s_tsina')){
					params.push('searchpic=true');
					params.push('style=number');
					//params.push('mbweb=0');
				}
				else {
					pic = 'pic=' + encodeURIComponent(pic);
				}
				params.push(pic);
				params.push(targetUrl);
				params.push(title);
				var appkey = $e.attr('data-appkey');
				if(appkey){
					appkey = 'appkey=' + appkey;
					params.push(appkey);
				}
				url = url + '?' + params.join('&');
				Core.Data.frame_title = head + '分享';
				Core.Data.frame_src = url;
				Core.updateMod('frame');

			});
		}
		// Invite_menu.prototype.if_cb = function(data) {
		// 	Core.showTips(data.msg, data.code == 0 ? true : false);
		// 	this.$c.find('input[type=email]').val('');
		// }
		Core.registerMod('invite_menu', Invite_menu);

		/**
		 * 平台助手模块
		 */
		var Assistant = function(modId) {
			Module.call(this, modId);
		}
		Core.inherit(Assistant, Module);
		Assistant.prototype.bind = function(){
			var that = this;
			that.$c.on('click', '.go_frame', function(e){
				e.preventDefault();
				var $e = $(e.target);
				var site = $e.attr('data-url');
				var title = $e.attr('data-title');
				Core.Data.frame_title = title;
				Core.Data.frame_src = site;
				Core.updateMod('frame');
			});
		}
		Core.registerMod('assistant', Assistant);

		/**
		 * iframe模块,用于显示外部页面
		 */
		var Frame = function(modId) {
			Module.call(this, modId);
		}
		Core.inherit(Frame, Module);
		Frame.prototype.show_after = function() {
			var that = this;
			var _des = Core.last_mod ? Core.last_mod : 'home';
			this.$c.find('a.btn.pull-left').attr('href', '#' + _des);
			this.$c.find('iframe')[0].onload = function() {
				that.$c.find('#loading_frame').hide();
			}
		}
		Core.registerMod('frame', Frame);

		if (window.isGetData == 1) {
			// 兼容旧版本sdk
			$('#loading').hide();
			Core.init();
		} else {
			window.isGetData = 1;
		}
	}
})();