262 lines
9.8 KiB
JavaScript
Executable File
262 lines
9.8 KiB
JavaScript
Executable File
jumpPage();
|
||
mui.plusReady(function() {
|
||
var data = '';
|
||
var self = plus.webview.currentWebview();
|
||
var shopId = self.shopId;
|
||
localStorage.setItem('shopId', shopId);
|
||
mui.ajax(hyhUrl('app/Shops/getHome'), {
|
||
data: {
|
||
shopId: shopId
|
||
},
|
||
dataType: 'json', //服务器返回json格式数据
|
||
type: 'post', //HTTP请求类型
|
||
timeout: 10000, //超时时间设置为10秒;
|
||
success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功;
|
||
data = toJson(data);
|
||
data = data.data;
|
||
localStorage.setItem('shop_data', JSON.stringify(data))
|
||
var html = '<div class="search clearfix"><a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a><div class="searchcon clearfix"><input type="search" name="" id="keyword" value="" placeholder="请输入商品名" /><button style="display: none;">搜索</button></div><img style="display:none;" class="classmenu" data-shopid="' + data.shop.shopId + '" src="../img/classmenu.png" /></div><div class="b_title" data-shopid="' + data.shop.shopId + '"><img class="b_img" src="' + hyhImgUrl(data.shop.shopImg) + '"/><p class="storename">' + data.shop.shopName + '</p><p class="time">' + data.shop.scores.totalScore + '分</p><div class="gz_btn">关注</div></div>';
|
||
$('.header').html(html);
|
||
},
|
||
error: function(xhr, type, errorThrown) { //异常处理;
|
||
// alert(type);
|
||
}
|
||
});
|
||
// mui('.footer').on('tap','#dpxq',function(){
|
||
// var w = plus.webview.create('store_info.html');
|
||
// w.show()
|
||
// })
|
||
mui('.search').on('tap', '.classmenu', function() {
|
||
shopId = this.attributes["data-shopid"].nodeValue;
|
||
// console.log(this.attributes["data-id"].nodeValue);
|
||
mui.openWindow({
|
||
url: 'store_class.html',
|
||
id: 'store_class.html',
|
||
styles: {
|
||
top: '0px', //新页面顶部位置
|
||
bottom: '0px', //新页面底部位置
|
||
width: '100%', //新页面宽度,默认为100%
|
||
height: '100%' //新页面高度,默认为100%
|
||
},
|
||
extras: {
|
||
shopId: shopId
|
||
// ..... //自定义扩展参数,可以用来处理页面间传值
|
||
},
|
||
createNew: false, //是否重复创建同样id的webview,默认为false:不重复创建,直接显示
|
||
show: {
|
||
// autoShow: true, //页面loaded事件发生后自动显示,默认为true
|
||
// aniShow: animationType, //页面显示动画,默认为”slide-in-right“;
|
||
// duration: animationTime, //页面动画持续时间,Android平台默认100毫秒,iOS平台默认200毫秒;
|
||
// event: 'titleUpdate', //页面显示时机,默认为titleUpdate事件时显示
|
||
// extras: {} //窗口动画是否使用图片加速
|
||
},
|
||
waiting: {
|
||
autoShow: true, //自动显示等待框,默认为true
|
||
title: '正在加载...', //等待对话框上显示的提示内容
|
||
options: {
|
||
// width: waiting - dialog - widht, //等待框背景区域宽度,默认根据内容自动计算合适宽度
|
||
// height: waiting - dialog - height, //等待框背景区域高度,默认根据内容自动计算合适高度
|
||
// ......
|
||
}
|
||
}
|
||
})
|
||
})
|
||
// mui('.footer').on('tap','#rmfl',function(){
|
||
// $('.rmfl').css('display','block')
|
||
// })
|
||
mui('.header').on('tap', '.gz_btn', function() {
|
||
|
||
var shopId = $(this).parent().attr('data-shopid');
|
||
var that = $(this);
|
||
mui.ajax(hyhUrl('app/Favorites/add'), {
|
||
|
||
data: {
|
||
id: shopId,
|
||
type : 1
|
||
},
|
||
dataType: 'json', //服务器返回json格式数据
|
||
type: 'post', //HTTP请求类型
|
||
timeout: 10000, //超时时间设置为10秒;
|
||
success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功;
|
||
// console.log(data.data.goodsFavoritesNum)
|
||
// console.log(data.data.Rows)
|
||
var data = toJson(data);
|
||
if(data.status == 1) {
|
||
that.html('已关注');
|
||
that.addClass('gz_btn1').removeClass('gz_btn');
|
||
} else {
|
||
//console.log(data.status)
|
||
}
|
||
|
||
},
|
||
error: function(xhr, type, errorThrown) { //异常处理;
|
||
// alert(type);
|
||
}
|
||
});
|
||
|
||
})
|
||
$('.header').on('focus','#keyword', function() {
|
||
$(".searchcon button").css('display', 'block');
|
||
})
|
||
$('.header').on('blur','#keyword', function() {
|
||
$(".searchcon button").css('display', 'none');
|
||
})
|
||
|
||
|
||
|
||
//店铺搜索
|
||
$(".header").on('keypress','#keyword', function(e) {
|
||
var keycode = e.keyCode;
|
||
var searchName = $('#keyword').val();
|
||
if(keycode == '13') {
|
||
// e.preventDefault();
|
||
// console.log(searchName)
|
||
//请求搜索接口
|
||
mui.openWindow({
|
||
url: 'goodsList.html',
|
||
id: 'goodsList.html',
|
||
styles: {
|
||
top: '0px', //新页面顶部位置
|
||
bottom: '0px', //新页面底部位置
|
||
width: '100%', //新页面宽度,默认为100%
|
||
height: '100%' //新页面高度,默认为100%
|
||
},
|
||
extras: {
|
||
data_keyword: searchName
|
||
// ..... //自定义扩展参数,可以用来处理页面间传值
|
||
},
|
||
createNew: false, //是否重复创建同样id的webview,默认为false:不重复创建,直接显示
|
||
show: {
|
||
// autoShow: true, //页面loaded事件发生后自动显示,默认为true
|
||
// aniShow: animationType, //页面显示动画,默认为”slide-in-right“;
|
||
// duration: animationTime, //页面动画持续时间,Android平台默认100毫秒,iOS平台默认200毫秒;
|
||
// event: 'titleUpdate', //页面显示时机,默认为titleUpdate事件时显示
|
||
// extras: {} //窗口动画是否使用图片加速
|
||
},
|
||
waiting: {
|
||
autoShow: true, //自动显示等待框,默认为true
|
||
title: '正在加载...', //等待对话框上显示的提示内容
|
||
options: {
|
||
// width: waiting - dialog - widht, //等待框背景区域宽度,默认根据内容自动计算合适宽度
|
||
// height: waiting - dialog - height, //等待框背景区域高度,默认根据内容自动计算合适高度
|
||
// ......
|
||
}
|
||
}
|
||
})
|
||
|
||
}
|
||
});
|
||
$(".header").on('tap','.searchcon button', function(e) {
|
||
var searchName = $('#keyword').val();
|
||
// e.preventDefault();
|
||
// console.log(searchName)
|
||
//请求搜索接口
|
||
mui.openWindow({
|
||
url: 'goodsList.html',
|
||
id: 'goodsList.html',
|
||
styles: {
|
||
top: '0px', //新页面顶部位置
|
||
bottom: '0px', //新页面底部位置
|
||
width: '100%', //新页面宽度,默认为100%
|
||
height: '100%' //新页面高度,默认为100%
|
||
},
|
||
extras: {
|
||
data_keyword: searchName
|
||
// ..... //自定义扩展参数,可以用来处理页面间传值
|
||
},
|
||
createNew: false, //是否重复创建同样id的webview,默认为false:不重复创建,直接显示
|
||
show: {
|
||
// autoShow: true, //页面loaded事件发生后自动显示,默认为true
|
||
// aniShow: animationType, //页面显示动画,默认为”slide-in-right“;
|
||
// duration: animationTime, //页面动画持续时间,Android平台默认100毫秒,iOS平台默认200毫秒;
|
||
// event: 'titleUpdate', //页面显示时机,默认为titleUpdate事件时显示
|
||
// extras: {} //窗口动画是否使用图片加速
|
||
},
|
||
waiting: {
|
||
autoShow: true, //自动显示等待框,默认为true
|
||
title: '正在加载...', //等待对话框上显示的提示内容
|
||
options: {
|
||
// width: waiting - dialog - widht, //等待框背景区域宽度,默认根据内容自动计算合适宽度
|
||
// height: waiting - dialog - height, //等待框背景区域高度,默认根据内容自动计算合适高度
|
||
// ......
|
||
}
|
||
}
|
||
})
|
||
|
||
});
|
||
|
||
})
|
||
|
||
function jumpPage() {
|
||
//跳转页面
|
||
var subpages = ['store_home.html', 'store_commodity.html', 'store_new.html', 'store_activity.html'];
|
||
var subpage_style = {
|
||
top: '178px',
|
||
bottom: '0',
|
||
scrollIndicator: 'none'
|
||
};
|
||
|
||
var aniShow = {}; //动画显示
|
||
//当前激活选项
|
||
var activeTab = subpages[0];
|
||
//选项卡点击事件
|
||
mui('.nav').on('tap', 'a', function(e) {
|
||
var targetTab = this.getAttribute('href');
|
||
if(targetTab == activeTab) {
|
||
return;
|
||
}
|
||
//显示目标选项卡
|
||
//若为iOS平台或非首次显示,则直接显示
|
||
if(mui.os.ios || aniShow[targetTab]) {
|
||
plus.webview.show(targetTab);
|
||
} else {
|
||
//否则,使用fade-in动画,且保存变量
|
||
var temp = {};
|
||
temp[targetTab] = "true";
|
||
mui.extend(aniShow, temp);
|
||
plus.webview.show(targetTab, "fade-in", 300);
|
||
}
|
||
//隐藏当前;
|
||
plus.webview.hide(activeTab);
|
||
//更改当前活跃的选项卡
|
||
activeTab = targetTab;
|
||
|
||
var html = $(this).html();
|
||
html = html.substring(0, html.indexOf('.png')) + '_on.png">';
|
||
$(this).html(html);
|
||
$(this).addClass('on').siblings().removeClass('on');
|
||
$(this).siblings().each(function() {
|
||
if($(this).html().indexOf('_on') == -1) {
|
||
return
|
||
}
|
||
html = $(this).html().substring(0, $(this).html().indexOf('_on'))
|
||
html = html + '.png">';
|
||
$(this).html(html)
|
||
})
|
||
});
|
||
|
||
//首次启动切滑效果
|
||
|
||
mui.plusReady(function() {
|
||
// launchScreen();
|
||
// plus.navigator.setStatusBarStyle('dark');
|
||
// console.log(plus.navigator.getStatusBarStyle())
|
||
var self = plus.webview.currentWebview();
|
||
shopId = self.shopId;
|
||
//console.log(shopId);
|
||
localStorage.setItem('shopId', shopId);
|
||
|
||
for(var i = 0; i < subpages.length; i++) {
|
||
var temp = {};
|
||
//http://www.html5plus.org/doc/zh_cn/webview.html#plus.webview.create
|
||
var sub = plus.webview.create(subpages[i], subpages[i], subpage_style);
|
||
if(i > 0) {
|
||
sub.hide();
|
||
} else {
|
||
temp[subpages[i]] = "true";
|
||
mui.extend(aniShow, temp); //合并对象
|
||
}
|
||
self.append(sub);
|
||
}
|
||
});
|
||
} |