Files
qlg.tsgz.moe/static/app/js/my.js
2019-09-06 23:53:10 +08:00

306 lines
14 KiB
JavaScript
Executable File

mui.plusReady(function() {
var token = localStorage.getItem('token');
// alert(token);
mui.ajax(hyhUrl('app/users/getUserInfo'), { 
headers: { 
"HYH-Token": token
},
data: {},
dataType: 'json', //服务器返回json格式数据  
type: 'post', //HTTP请求类型  
timeout: 10000, //超时时间设置为10秒;  
success: function(data) {           //服务器返回响应,根据响应结果,分析是否登录成功;  
var data = toJson(data, 1);
if(data.status == 1) {
// console.log(data.data.userPhoto)
var imgurl = data.data.userPhoto?hyhImgUrl(data.data.userPhoto):'http://heyuanhui.com.cn/Template/mobile/new/Static/images/user68.png';
var html = '<div class="header clearfix"><div class="seeting">设置</div><div class="share">分享</div></div><div class="con"><img src="' + imgurl + '" /><p>' + data.data.loginName + '</p></div><div class="hyz">惠员值:0</div>';
$('.login').css('display', 'none');
$('.my').html(html);
var htmlmoney = '<div class="moneycon_"><img src="../img/yuan.png"/><p id="userMoney">'+ data.data.userMoney +'</p></div><div class="moneycon_" id="moneycon_"><img src="../img/hui.png"/><p id="userScore">'+ data.data.userScore +'</p></div><div class="moneycon_"><img src="http://img.juzi199.com/upload/sysconfigs/ect.png"/><p id="userEct">'+ data.data.userECT +'</p></div>';
$('.moneycon').html(htmlmoney);
// $('#userMoney').html('¥' + data.data.userMoney)
// $('#userScore').html('¥' + data.data.userScore)
}else{
// console.log(data.status)
}
},
error: function(xhr, type, errorThrown) {           //异常处理;  
// alert(errorThrown);      
}  
}); 
mui.ajax(hyhUrl('app/users/getFavoritesNum'), { 
headers: { 
"HYH-Token": token
},
data: {},
dataType: 'json', //服务器返回json格式数据  
type: 'post', //HTTP请求类型  
timeout: 10000, //超时时间设置为10秒;  
success: function(data) {           //服务器返回响应,根据响应结果,分析是否登录成功;  
// console.log(data.data.goodsFavoritesNum)
var data = toJson(data, 1);
if(data.status == 1) {
// console.log(data.data.goodsFavoritesNum)
var html = '<div class="nblock" data-href="collect_commodity.html"><p>' + data.data.goodsFavoritesNum + '</p><p>收藏夹</p></div><div class="nblock" data-href="collect_store.html"><p>' + data.data.shopFavoritesNum + '</p><p>关注店铺</p></div><div class="nblock" data-href="share_user_list.html"><p>' + data.data.shareNum + '</p><p>我的分享</p></div>';
$('.nav').html(html);
}
},
error: function(xhr, type, errorThrown) {           //异常处理;  
// alert(type);      
}  
}); 
mui.ajax(hyhUrl('app/users/getOrderNum'), { 
headers: { 
"HYH-Token": token
},
data: {},
dataType: 'json', //服务器返回json格式数据  
type: 'post', //HTTP请求类型  
timeout: 10000, //超时时间设置为10秒;  
success: function(data) {           //服务器返回响应,根据响应结果,分析是否登录成功;  
// console.log(data.data.goodsFavoritesNum)
var data = toJson(data, 1);
if(data.status == 1) {
var html = '<div class="order_cb indent_btn" data-href="waitPay"><div class="num">' + data.data.order.waitPay + '</div><img src="../img/1.png" /><p>待付款</p></div><div class="order_cb indent_btn" data-href="waitDeliver"><div class="num">' + data.data.order.waitSend + '</div><img src="../img/2.png" /><p>待发货</p></div><div class="order_cb indent_btn" data-href="waitReceive"><div class="num">' + data.data.order.waitReceive + '</div><img src="../img/3.png" /><p>待收货</p></div><div class="order_cb indent_btn" data-href="waitAppraise"><div class="num">' + data.data.order.waitAppraise + '</div><img src="../img/4.png" /><p>待评价</p></div><div class="order_cb indent_btn" data-href="abnormal"><img src="../img/5.png" /><p>退款/售后</p></div>';
$('.order_con').html(html);
$('.num').each(function() {
if($(this).html() == '0') {
$(this).css('display', 'none');
}
})
}
},
error: function(xhr, type, errorThrown) {           //异常处理;  
// alert(type);      
}  
}); 
window.addEventListener('refresh', function(e) { //执行刷新
location.reload();
});
mui('.my').on('tap', '.seeting', function() {
mui.openWindow({
url: 'setting.html',
id: 'setting.html',
styles: {
top: '0px', //新页面顶部位置
bottom: '0px', //新页面底部位置
width: '100%', //新页面宽度,默认为100%
height: '100%' //新页面高度,默认为100%
},
extras: {
// data_href: data_href
// ..... //自定义扩展参数,可以用来处理页面间传值
},
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('.my').on('tap', '.share', function() {
mui.openWindow({
url: 'share.html',
id: 'share.html',
styles: {
top: '0px', //新页面顶部位置
bottom: '0px', //新页面底部位置
width: '100%', //新页面宽度,默认为100%
height: '100%' //新页面高度,默认为100%
},
extras: {
// data_userId: data_href
// ..... //自定义扩展参数,可以用来处理页面间传值
},
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(".nav").on('tap', '.nblock', function() {
// var tj = plus.webview.create('search.html');
// tj.show();
// alert(e.target.attributes["data-id"].nodeValue);
var data_href = this.attributes["data-href"].nodeValue;
var url = 'collect.html';
if(data_href=='share_user_list.html'){
url = 'share_user_list.html';
}
// console.log(this.attributes["data-id"].nodeValue);
mui.openWindow({
url: url,
id: url,
styles: {
top: '0px', //新页面顶部位置
bottom: '0px', //新页面底部位置
width: '100%', //新页面宽度,默认为100%
height: '100%' //新页面高度,默认为100%
},
extras: {
data_href: data_href
// ..... //自定义扩展参数,可以用来处理页面间传值
},
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('.order').on('tap', '.indent_btn', function() {
var data_href = this.attributes["data-href"].nodeValue;
// console.log(this.attributes["data-id"].nodeValue);
mui.openWindow({
url: 'indent.html',
id: 'indent.html',
styles: {
top: '0px', //新页面顶部位置
bottom: '0px', //新页面底部位置
width: '100%', //新页面宽度,默认为100%
height: '100%' //新页面高度,默认为100%
},
extras: {
data_href: data_href
// ..... //自定义扩展参数,可以用来处理页面间传值
},
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, //等待框背景区域高度,默认根据内容自动计算合适高度
// ......
}
}
})
})
$('.my').on('tap', '.login', function() {
mui.openWindow({
url: 'login.html',
id: 'login.html',
styles: {
top: '0px', //新页面顶部位置
bottom: '0px', //新页面底部位置
width: '100%', //新页面宽度,默认为100%
height: '100%' //新页面高度,默认为100%
},
extras: {
// data_href: data_href
// ..... //自定义扩展参数,可以用来处理页面间传值
},
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, //等待框背景区域高度,默认根据内容自动计算合适高度
// ......
}
}
})
})
//跳转到ect钱包
$('.moneycon').on('tap', '.moneycon_', function() {
if($(this).children('p').attr('id','userEct')){
mui.openWindow({
url: 'ect_index.html',
id: 'ect_index.html',
styles: {
top: '0px', //新页面顶部位置
bottom: '0px', //新页面底部位置
width: '100%', //新页面宽度,默认为100%
height: '100%' //新页面高度,默认为100%
},
extras: {
// data_href: data_href
// ..... //自定义扩展参数,可以用来处理页面间传值
},
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, //等待框背景区域高度,默认根据内容自动计算合适高度
// ......
}
}
})
}
})
})