mui.plusReady(function() {
// function hyhUrl(url) {
// return 'http://192.168.1.101/hyh/' + url;
// }
var token = localStorage.getItem('token');
// alert(token);
mui.ajax(hyhUrl('app/Ectwallets/listQuery'), {
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) {
var html = '';
if(data.data != '') {
$.each(data.data, function() {
html += '
钱包地址 ' + this.eAddress + '
';
});
$('.mui-scroll').html(html);
$('.row').each(function() {
if($(this).children('.r_bottom').attr('data-isDefault') == 1) {
$(this).children('.r_bottom').children('.default').children('.check').addClass('on');
}
})
}
} else {
// console.log(data.status)
}
},
error: function(xhr, type, errorThrown) { //异常处理;
// alert(errorThrown);
}
});
//设为默认
$('.mui-scroll').on('tap', '.default', function() {
if($(this).parent().attr('data-isDefault') == 0) {
if(confirm('设为默认地址?')) {
var eWalletId = $(this).parent().attr('data-eWalletId');
// console.log(eWalletId)
mui.ajax(hyhUrl('app/Ectwallets/setDefault'), {
headers: {
"HYH-Token": token
},
data: {
eWalletId: eWalletId
},
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒;
success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功;
var data = toJson(data, 1);
if(data.status == 1) {
plus.nativeUI.toast(data.msg);
location.reload();
} else {
// console.log(data.status)
}
},
error: function(xhr, type, errorThrown) { //异常处理;
// alert(errorThrown);
}
});
}
}
})
//删除地址
$('.mui-scroll').on('tap', '.del', function() {
if(confirm('删除地址?')) {
var eWalletId = $(this).parent().attr('data-eWalletId');
// console.log(eWalletId)
mui.ajax(hyhUrl('app/Ectwallets/del'), {
headers: {
"HYH-Token": token
},
data: {
eWalletId: eWalletId
},
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒;
success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功;
var data = toJson(data, 1);
if(data.status == 1) {
plus.nativeUI.toast(data.msg);
location.reload();
} else {
// console.log(data.status)
}
},
error: function(xhr, type, errorThrown) { //异常处理;
// alert(errorThrown);
}
});
}
})
//添加地址
$('.add').on('tap', function() {
var eAddress = '';
var eAddress_ = '';
if(eAddress = prompt('请输入钱包地址')) {
if(eAddress.length != 42) {
alert('钱包地址长度必须为42位');
return;
}
// if(eAddress_ = prompt('请再次输入钱包地址')) {
// if(eAddress == eAddress_) {
var isDefault = 0;
if(confirm('是否设为默认地址?')) {
isDefault = 1;
}
mui.ajax(hyhUrl('app/Ectwallets/add'), {
headers: {
"HYH-Token": token
},
data: {
eAddress: eAddress,
isDefault: isDefault
},
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒;
success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功;
var data = toJson(data, 1);
if(data.status == 1) {
plus.nativeUI.toast(data.msg);
location.reload();
} else {
// console.log(data.status)
}
},
error: function(xhr, type, errorThrown) { //异常处理;
// alert(errorThrown);
}
});
// } else {
// alert('两次地址输入不一致!');
// }
// }
}
})
})