if(typeof(Qibo)=='undefined'){
var Qibo = function () {
//超级链接那里加上 class="_pop" 就可以实现弹窗, 设置 data-width="600" data-height="600" 就可以指定弹窗大小 , 设置 data-title="标题XXX" 就可以设置弹窗标题
var pop = function(){
jQuery(document).delegate('a._pop', 'click', function () {
if((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i))||$("body").width()<1000){
var default_width = "100%";
var default_height = "85%";
var offset = 'b';
}else{
var default_width = "1000px";
var default_height = "650px";
var offset = 'auto';
}
var width = typeof($(this).data('width'))=='undefined'?default_width:$(this).data('width');
var height = typeof($(this).data('height'))=='undefined'?default_height:$(this).data('height');
var title = typeof($(this).data('title'))=='undefined'?'快速操作':$(this).data('title');
layer.open({
type: 2,
offset: offset,
anim: 2,
title: title,
shade: [0.3,'#333'],
area: [width, height],
content: $(this).attr("href"),
end: function(){ //关闭事件
}
});
return false;
});
}
//超级链接那里加上 class="alert" 就可以实现弹窗确认. 设置 data-alert="你确认要修改吗?" 就可以指定提示语,这个参数也可以不设置.
var _confirm = function(){
jQuery(document).delegate('a.alert', 'click', function () {
var url = $(this).attr("href");
var msg = typeof($(this).data('alert'))=='undefined'?'你确认要删除吗?':$(this).data("alert");
var title = typeof($(this).data('title'))=='undefined'?'提示':$(this).data('title');
layer.confirm(msg, {title:title, btn : [ '确定', '取消' ]}, function(index) {
window.location.href="vsm;"
});
return false;
});
}
//配合下面这个方法 _ajaxget 使用
var _ajaxgoto = function(url,id){
var index = layer.load(1,{shade: [0.7, '#393D49']}, {shadeClose: true}); //0代表加载的风格,支持0-2
$.get(url,function(res){
layer.close(index);
if(res.code==0){ //成功提示
layer.msg(res.msg);
setTimeout(function(){
if(res.url){
window.location.href="sft.vsm;"
}else if(typeof(ajax_get)=='function'){
ajax_get(res,id,true);
}else{
window.location.reload();
}
},500);
}else{ //错误提示
if(res.url){
layer.confirm(res.msg, {title:'提示', btn : [ '确定', '取消' ]}, function(index) {
window.location.href="sft.vsm;"
});
}else{
layer.open({title: '提示!',content:res.msg});
if(typeof(ajax_get)=='function'){
ajax_get(res,id,false); //页面里定义的函数
}
}
}
});
}
//超级链接那里加上 class="ajaxget" 就可以实现ajax访问. 设置 data-alert="你确认这么做吗?" 就可以指定提示语,这个参数也可以不设置.
var _ajaxget = function(){
jQuery(document).delegate('a.ajax_get', 'click', function () {
var url = $(this).attr("href");
var msg = $(this).data("alert");
var id = $(this).data("id");
if(typeof(msg)!='undefined'){
layer.confirm(msg, {title:'提醒', btn : [ '确定', '取消' ]}, function(index) {
_ajaxgoto(url,id);
});
}else{
_ajaxgoto(url,id);
}
return false;
});
}
//显示大图片
var showimg = function(){
$("img.showimg").parent().viewer('destroy').viewer({
url: 'big-img',
navbar:true,
title:false,
});
$(".contentinfo").viewer('destroy').viewer({
//url: 'big-img',
navbar:true,
title:false,
});
$(".qb_ui_ShowContent").viewer('destroy').viewer({
//url: 'big-img',
navbar:true,
title:false,
});
/*
$("img.showimg").click(function(){
var url = $(this).attr("src");
$("").attr("src", url).on("load", function () {
var imgw = this.width>$("body").width() ? $("body").width() : this.width ;
var imgh = this.height * imgw/this.width;
layer.open({
type: 1,
title: false,
shadeClose: true,
maxmin: true,
offset: 'auto',
shade: 0.4,
area: [imgw+"px", imgh+"px"],
content: "",
});
});
});
*/
}
var check_back = function(url){
if(typeof(api)=="object"){ //在APP中打开的情况
api.execScript({
//frameName: 'iframe',
name:"main",
script: 'app_back()'
});
}else{
window.location.href="vsm;"
}
}
//直接使用window.history.go(-1) window.history.back() 遇到新开的页面,就导致无法返回, 用这个函数可以给他默认指定一个返回页面
var goBack = function(url) {
if(typeof(api)=='object'){
var frames = api.frames();
if(frames.length==0){
api.historyBack(function(ret, err) {
if (!ret.status) {
var windows = api.windows();
api.closeWin(windows[windows.length-1].name);
}
});
return ;
}
var now_frame_name = frames[frames.length-1].name;
api.historyBack({
frameName:''
}, function(ret, err) {
if (!ret.status) {
if(frames.length>1){
api.closeFrame({name:now_frame_name});
}else if(typeof(bui)=='object'){
bui.back();
}else if(url){
window.location.href="vsm;"
}
}
});
return ;
}
if ((navigator.userAgent.indexOf('MSIE') >= 0) && (navigator.userAgent.indexOf('Opera') < 0)) { // IE
if (history.length > 0) {
window.history.go(-1);
} else {
check_back(url);
//window.opener = null;
//window.close();
}
} else { //非IE浏览器
if (navigator.userAgent.indexOf('Firefox') >= 0 || navigator.userAgent.indexOf('Opera') >= 0 || navigator.userAgent.indexOf('Safari') >= 0 || navigator.userAgent.indexOf('Chrome') >= 0 || navigator.userAgent.indexOf('WebKit') >= 0) {
if (window.history.length > 1) {
window.history.go(-1);
} else {
check_back(url);
//window.opener = null;
//window.close();
}
} else { //未知的浏览器
window.history.go(-1);
}
}
}
//下拉菜单开始
var moreMenu = {
showSonId:null,
showObjWidth:0,
showObjHeight:0,
topObj:null,
init:function(){
oo=document.body.getElementsByClassName("more-menu");
for(var i=0;i';
//objs=obj.getElementsByTagName("TD");
//objs[1].id=DivId;
obj.innerHTML='';
obj.style.zIndex='9990';
obj.style.display='none'; //网速慢的话,就把这行删除掉,直接先显示,再加载其它内容
obj.style.position='absolute';
obj.style.top=position.bottom+'px';
obj.style.left=position.left+'px';
//obj.style.height='100px';
//obj.style.width=moreMenu.width+'px';
document.body.appendChild(obj);
//moreMenu.getparent(DivId).show("slow");
//obj.innerHTML='以下是显示内容...';
if(thisurl.indexOf('<')>-1 || /^([a-z0-9_-]+)$/i.test(thisurl)){
if( thisurl.indexOf('<')>-1 ){
$("#"+DivId).html(thisurl);
}else{
$("#"+DivId).html( $('.'+thisurl).html() );
}
if($(ao).width()>moreMenu.getparent(DivId).width()){
moreMenu.getparent(DivId).css("width",$(ao).width()+"px");
}
moreMenu.getparent(DivId).show();
setTimeout(function(){
moreMenu.getparent(DivId).show(); //避免有时不显示
},100);
moreMenu.autohide(ao);
}else{
$.get(thisurl+(thisurl.indexOf("?")==-1?"?":"&")+Math.random(),function(res){
if(res.code==0){
$("#"+DivId).html(res.data);
if($(ao).width()>moreMenu.getparent(DivId).width()){
moreMenu.getparent(DivId).css("width",$(ao).width()+"px");
}
moreMenu.getparent(DivId).show();
moreMenu.autohide(ao);
}else{
moreMenu.getparent(DivId).hide();
document.body.removeChild(obj);
return ;
}
});
}
}else{
//兼容缩放窗口后,要重新定位
moreMenu.getparent(DivId).css({"left":position.left+'px',"top":position.bottom+'px'});
moreMenu.getparent(DivId).show();
setTimeout(function(){
moreMenu.getparent(DivId).show(); //避免有时不显示
},100);
moreMenu.autohide(ao);
}
setTimeout(function(){
//$("#"+DivId).parent().parent().css({'display':'none'});
},5000);
},
getparent:function(sonId){
parentObj = $("#"+sonId).parent().parent();
return parentObj;
},
cancel:function(sonId){
//moreMenu.getparent(sonId).hide();
$(".more-menu-wap").parent().hide();
},
autohide:function(eObj){
parentObj = moreMenu.getparent(moreMenu.showSonId);
//要提前赋值,不然渐变隐藏或显示,会引起宽高的变化
w1 = $(eObj).width();
w2 = parentObj.width();
moreMenu.showObjWidth = w1>w2 ? w1 : w2;
moreMenu.showObjHeight = parentObj.height();
document.onmousemove = moreMenu.mouseMove; //不想鼠标离开隐藏的话,就把这行删除掉
},
mouseMove:function(ev){
ev = ev || window.event;
var mousePos = moreMenu.mousePosition(ev);
var x = mousePos.x;
var y = mousePos.y;
parentObj = moreMenu.getparent(moreMenu.showSonId);
left1 = parseInt(parentObj.css("left"));
top1 = parseInt(parentObj.css("top"))-$(moreMenu.topObj).height();
left2 = left1 + moreMenu.showObjWidth ;
top2 = top1 + moreMenu.showObjHeight+$(moreMenu.topObj).height();
if ( xleft2 || ytop2){
moreMenu.cancel(moreMenu.showSonId);
//document.title=x+"-"+y+" 横 "+left1+"-"+left2+" 高 "+top1+"-"+top2 + "p高"+ parentObj.height();
}
},
mousePosition:function(ev){ //获取鼠标所在坐标
if(ev.pageX || ev.pageY){ //FF
return {x:ev.pageX, y:ev.pageY};
}
return { //IE
x:ev.clientX + window.document.documentElement.scrollLeft,// - window.document.documentElement.clientLeft,
y:ev.clientY + window.document.documentElement.scrollTop// - window.document.documentElement.clientTop
};
}
}
//下拉菜单结束
var login = function(login_callback){
var in_pc = navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i) ? false : true ;
var url = '/index.php/index/login/index.html?fromurl='+ encodeURIComponent(window.location.href);
in_pc ? pc_login(url) : wap_login(url);
function wap_login(url){
window.location.href="vsm;"
}
function pc_login(url){
var index = layer.open({
type: 2,
title: '用户登录',
shadeClose: true,
shade: false,
maxmin: true, //开启最大化最小化按钮
area: ["750px", "780px"],
content: url+"&type=iframe",
end: function(){
//window.location.reload();
$.get("/index.php/index/wxapp.login/web_login_check.html?" + Math.random(),function(res){
layer.close(index);
if(res.code==0){
layer.msg("登录成功",{time:1500});
}else{
layer.msg("登录失败");
}
if(typeof(login_callback)=='function'){
login_callback(res.code==0?'ok':'fail');
}
});
}
});
}
}
var pay_money = function(money,callback){
jQuery.getScript("/public/static/js/pay.js").done(function() {
}).fail(function() {
layer.msg('public/static/js/pay.js加载失败',{time:800});
});
layer.confirm("是否立即充值 "+money+" 元",{btn:['充值','取消']},function(i){
layer.close(i);
if( navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i) ){
Pay.mobpay( money,'充值',function(type,index){
layer.close(index);
if(type=='ok'){
layer.msg('充值成功');
if( typeof(callback)=='function' ){ //接口回调
callback();
}
}else{
layer.alert('充值失败');
}
});
}else{
Pay.pcpay( money,'充值',function(type,index){
layer.close(index);
if(type=='ok'){
layer.msg('充值成功');
if( typeof(callback)=='function' ){ //接口回调
callback();
}
}else{
layer.alert('充值失败');
}
});
}
});
}
function open(url,title,iframe){
if(typeof(api)=="undefined" || iframe===true){
//layer.open({type: 2,title: false,shadeClose: true,shade: 0.3,area: ['95%', '90%'],content: url,});
bui.load({
url: "public/static/libs/bui/pages/frame/show.html",
param:{
url:url,
title:typeof(title)=="undefined"?'':title,
}
});
}else{
var win_name = iframe?iframe:'iframe'+Math.random();
/*
api.openWin({
name: win_name,
url: url,
allowEdit:true,
reload: true,
bgColor:'#eeeeee',
rect: {
x: 0,
y: 0,
w: api.winWidth,
h: api.winHeight,
},
bounces: false
});
*/
api.openTabLayout({
name: win_name,
url:url,
title: title,
hideTabBar:true,
hideNavigationBar:false,
headers:{INAPI:'1.0'},
scaleEnabled:true,
allowEdit:true,
reload: true,
navigationBar: {
background: '#38A4FF',
color:'#FFFFFF',
rightButtons: url.indexOf('/member.php/')>-1?[{
iconPath: "widget://icon/more.png"
}] : [
{
iconPath: "widget://icon/more.png"
},
{
iconPath: "widget://icon/member.png"
},
],
}
});
}
}
return {
init:function(){
pop();
_confirm();
_ajaxget();
moreMenu.init();
showimg();
},
goBack:function(url){
goBack(url);
},
login:function(login_callback){
login(login_callback);
},
pay:function(money,callback){
pay_money(money,callback);
},
open:function(url,title,iframe){
return open(url,title,iframe);
},
};
}();
$(document).ready(function(){
Qibo.init();
});
}