129 lines
4.8 KiB
JavaScript
Executable File
129 lines
4.8 KiB
JavaScript
Executable File
function classInfo(parentId) {
|
||
mui.ajax(hyhUrl('app/goodscats/getGoodsCat'), {
|
||
data: {
|
||
parentId: parentId
|
||
},
|
||
dataType: 'json', //服务器返回json格式数据
|
||
type: 'post', //HTTP请求类型
|
||
timeout: 10000, //超时时间设置为10秒;
|
||
success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功;
|
||
var data = toJson(data, 1);
|
||
if(data.status == 1) {
|
||
var html1 = '';
|
||
data = data.data;
|
||
$.each(data, function() {
|
||
|
||
html1 += '<div class="r_block clearfix" data-catId="' + this.catId + '"><div class="rb_title">' + this.catName + '</div></div>';
|
||
|
||
});
|
||
$('.con_right .mui-scroll').html(html1);
|
||
|
||
$('.r_block').each(function() {
|
||
var parentId2 = $(this).attr('data-catId');
|
||
var that = $(this);
|
||
mui.ajax(hyhUrl('app/goodscats/getGoodsCat'), {
|
||
data: {
|
||
parentId: parentId2
|
||
},
|
||
dataType: 'json', //服务器返回json格式数据
|
||
type: 'post', //HTTP请求类型
|
||
timeout: 10000, //超时时间设置为10秒;
|
||
success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功;
|
||
var data = toJson(data, 1);
|
||
if(data.status == 1) {
|
||
data = data.data;
|
||
var html2 = '';
|
||
$.each(data, function() {
|
||
html2 += '<div class="rb_block" data-catId="' + this.catId + '"><img src="' + hyhImgUrl(this.catImg) + '" /><p>' + this.catName + '</p></div>';
|
||
});
|
||
|
||
that.append(html2);
|
||
$(this).addClass('on').siblings().removeClass('on');
|
||
$('.rb_block img').height($('.rb_block img').width())
|
||
}
|
||
},
|
||
error: function(xhr, type, errorThrown) { //异常处理;
|
||
// alert(type);
|
||
}
|
||
});
|
||
})
|
||
|
||
}
|
||
},
|
||
error: function(xhr, type, errorThrown) { //异常处理;
|
||
// alert(type);
|
||
}
|
||
});
|
||
}
|
||
mui.plusReady(function() {
|
||
|
||
$('.con_left').on('tap', '.left_row', function() {
|
||
var classify = $(this).attr('data-catId');
|
||
$(this).addClass('on').siblings().removeClass('on');
|
||
$('.rb_block img').height($('.rb_block img').width())
|
||
classInfo(classify)
|
||
})
|
||
|
||
mui.ajax(hyhUrl('app/goodscats/getGoodsCat'), {
|
||
data: {
|
||
parentId: 0
|
||
},
|
||
dataType: 'json', //服务器返回json格式数据
|
||
type: 'post', //HTTP请求类型
|
||
timeout: 10000, //超时时间设置为10秒;
|
||
success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功;
|
||
var data = toJson(data, 1);
|
||
if(data.status == 1) {
|
||
var html = '';
|
||
data = data.data;
|
||
$.each(data, function() {
|
||
html += '<div class="left_row" data-catId="' + this.catId + '">' + this.catName + '</div>'
|
||
|
||
});
|
||
$('.con_left .mui-scroll').html(html);
|
||
document.getElementsByClassName('left_row')[0].className += ' on';
|
||
var parentId1 = document.getElementsByClassName('left_row')[0].attributes["data-catId"].nodeValue;
|
||
classInfo(parentId1)
|
||
}
|
||
},
|
||
error: function(xhr, type, errorThrown) { //异常处理;
|
||
// alert(type);
|
||
}
|
||
});
|
||
|
||
$('.con_right .mui-scroll').on('tap', '.rb_block', function() {
|
||
var catId = $(this).attr('data-catId');
|
||
mui.openWindow({
|
||
url: 'goodsList.html',
|
||
id: 'goodsList.html',
|
||
styles: {
|
||
top: '0px', //新页面顶部位置
|
||
bottom: '0px', //新页面底部位置
|
||
width: '100%', //新页面宽度,默认为100%
|
||
height: '100%' //新页面高度,默认为100%
|
||
},
|
||
extras: {
|
||
data_catId: catId
|
||
// ..... //自定义扩展参数,可以用来处理页面间传值
|
||
},
|
||
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, //等待框背景区域高度,默认根据内容自动计算合适高度
|
||
// ......
|
||
}
|
||
}
|
||
})
|
||
})
|
||
|
||
}) |