skycaiji/public/static/js/admin/store.js

12 lines
2.4 KiB
JavaScript

/*
|--------------------------------------------------------------------------
| SkyCaiji (蓝天采集器)
|--------------------------------------------------------------------------
| Copyright (c) 2018 https://www.skycaiji.com All rights reserved.
|--------------------------------------------------------------------------
| 使用协议 https://www.skycaiji.com/licenses
|--------------------------------------------------------------------------
*/
function StoreClass(){}
StoreClass.prototype={constructor:StoreClass,init_iframe:function(){var boxHeight=$(window).height()-$('.main-header').height();$('.content').height(boxHeight+'px');$('#iframe_main').on('load',function(){$('.iframe-loading').remove();$(this).show();if($(this).attr('data-provider-url')){var body=document.getElementsByTagName('body')[0];var script=document.createElement('script');script.src='https://www.skycaiji.com/provider/safe?url='+encodeURIComponent($(this).attr('data-provider-url'));script.type='text/javascript';body.appendChild(script)}})},init_my:function(){$('.store-detail').bind('click',function(){windowStore('详细',$(this).attr('href'));return!1})},init_link:function(){var $_o=this;if(window.site_config.clientinfo){var domain='https://www.skycaiji.com';$('[src^="'+domain+'"]').each(function(){$_o.set_link('src',$(this))});$('[href^="'+domain+'"]').each(function(){$_o.set_link('href',$(this))});$('[action^="'+domain+'"]').each(function(){$_o.set_link('action',$(this))});$('[data-is-store-url]').each(function(){var attrs=new Array('href','src','action');for(var i in attrs){var url=$(this).attr(attrs[i]);if(url){$_o.set_link(attrs[i],$(this))}}})}},set_link:function(type,obj){var url=obj.attr(type);if(type){if(url.indexOf('clientinfo=')<0){url+=(url.indexOf('?')>-1?'&':'?')+'clientinfo='+encodeURIComponent(window.site_config.clientinfo);obj.attr(type,url)}}},is_login:function(func){var cname='store_islogin';var is_login=getCookie(cname);if(!is_login||is_login!='yes'){$.ajax({url:'https://www.skycaiji.com/user/account/is_login',type:'get',dataType:'jsonp',jsonp:'callback',success:function(status){if(status){setCookie(cname,'yes',1);func()}else{setCookie(cname,'no',1);toastr.error('请先登录');windowStore('登录','https://www.skycaiji.com/user/account/login')}}})}else if(is_login=='yes'){func()}}}
var storeClass=new StoreClass();$(document).ready(function(){storeClass.init_link()})