;!function(win){
"use strict";
var ytui_cachedScript= new Array();
var ytui= function(){
this.v = '2.5.62'; //版本号
this.shop_info={};
}
ytui.prototype.loadShop=function(callback)
{
var sid=this.getUrlParam('sid');
var ucode=this.getUrlParam('code');
if(!sid){sid=layui.router().search.sid;}
var uid=this.getUrlParam('uid');
$.get('../api/shop.php?cmd=shop_info_get&uid='+uid+'&sid='+sid+'&code='+ucode , function(res){
if(res.js_ver){$.ytui_js_ver=res.js_ver;}//加载模块JS 版本号
$.ytui_js_ver='20032811';//1765382942;
if(res.layui_ver){layui.config({version:res.layui_ver});}//加载 LAYUI版本号
var shop_info={};
shop_info.tel=res.客服电话;
shop_info.shop_code=res.shop_id;
shop_info.shop_name=res.商家名称;
shop_info.shop_class=res.商品分类;
shop_info.qigoujine=res.起购金额;
shop_info.ad1=res.横幅广告1;
shop_info.ad2=res.横幅广告2;
shop_info.ad3=res.横幅广告3;
if(shop_info.ad1){shop_info.ad1=shop_info.ad1;}
if(shop_info.ad2){shop_info.ad2=shop_info.ad2;}
if(shop_info.ad3){shop_info.ad3=shop_info.ad3;}
shop_info['ini']=res['ini'] || {};
if(callback){callback( shop_info);}
},'json');
}
//高亮当前页按钮
var active=function(){
var btn=$('.tab-item');
$('.tab-item').removeClass('active');
$.each(btn, function(index, item){
var tmp=$(item).attr('href');
if(tmp=='#'){$(item).addClass('active');}
});
}
ytui.prototype.touchstart=function(id,ins)
{
if(ins.elemItem.length>1)//大于1幅图片的才开启手势
{
//横幅广告 手势滑动
$(id).on("touchstart", function (e) {
var startX = e.originalEvent.targetTouches[0].pageX;//开始坐标X
$(this).on('touchmove', function (e) {
arguments[0].preventDefault();//阻止手机浏览器默认事件
});
$(this).on('touchend', function (e) {
var endX = e.originalEvent.changedTouches[0].pageX;//结束坐标X
e.stopPropagation();//停止DOM事件逐层往上传播
//alert("开始滑动" + startX + "到" + endX);
if (endX - startX > 30) {
ins.slide("sub"); // alert("向右滑动");
}
else if (startX - endX > 30) {
ins.slide("add"); // alert("向左滑动");
}
$(this).off('touchmove touchend');
});
});
}
}
ytui.prototype.load_js=function(doc)//自动载入JS模块文件
{
$(document).attr("title",this.shop_info.shop_name);
active();//高亮当前页按钮
var url=doc.attr('js-url');
var cache=doc.attr('cache') ;
if(!url){return;}
var r=0;
if(cache==true){
for (var s in ytui_cachedScript) {
//如果某个数组已经下载到了本地
if (ytui_cachedScript[s]==url) {r=1;}
}
}
//console.log(footer.attr('url'));
if( r==0)
{
var options = $.extend(options || {}, {
dataType: "script",
url:url+"?_="+$.ytui_js_ver,
cache:true,
success:function(res){
},
error: function() { }
});
if(cache==true){ytui_cachedScript.push(url); }//将url地址放入script标记数组中
$.ajax(options);
}
}
//数字格式化,保留2位小数
ytui.prototype.Float_to_str=function(value)
{
var $tint= parseFloat(value );
$tint=$tint.toFixed(2);
if (isNaN($tint))
{return '';}
else{ return $tint}
}
//获取地址栏参数值
ytui.prototype.getUrlParam=function(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
var r = window.location.search.substr(1).match(reg); //匹配目标参数
if (r != null) return unescape(r[2]); return ''; //返回参数值
}
//Ajax请求
ytui.prototype.req = function(options){
var that = this
,success = options.success
,error = options.error
,debug = function(){
return setter.debug
? '
URL:' + options.url
: '';
};
options.data = options.data || {};
options.headers = options.headers || {};
delete options.success;
delete options.error;
return $.ajax($.extend({
type: 'get'
,dataType: 'json'
,success: function(res){
typeof success === 'function' && success(res);
//只有 response 的 code 一切正常才执行 done
if(res['code'] ==1) {
typeof options.done === 'function' && options.done(res);
}
//其它异常
else {
layer.msg('