136 lines
4.2 KiB
JavaScript
Executable File
136 lines
4.2 KiB
JavaScript
Executable File
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 += '<option value="' + this.eAddress + '">' + this.eAddress + '</option>'
|
||
});
|
||
$('#select').html(html);
|
||
}else{
|
||
plus.nativeUI.toast('未设置钱包地址');
|
||
}
|
||
} else {
|
||
// console.log(data.status)
|
||
}
|
||
},
|
||
error: function(xhr, type, errorThrown) { //异常处理;
|
||
// alert(errorThrown);
|
||
}
|
||
});
|
||
|
||
mui.ajax(hyhUrl('app/Ectwallets/index'), {
|
||
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) {
|
||
$('.num p').html(data.data.ectNum);
|
||
} else {
|
||
// console.log(data.status)
|
||
}
|
||
},
|
||
error: function(xhr, type, errorThrown) { //异常处理;
|
||
// alert(errorThrown);
|
||
}
|
||
});
|
||
|
||
mui('body').on('tap', '.btn_ture', function() {
|
||
var eAddress = $('#select').val();
|
||
var ectNum = $('#ectNum').val();
|
||
var payPwd = $('#payPwd').val();
|
||
if(eAddress == '') {
|
||
plus.nativeUI.toast('未选择钱包地址');
|
||
return;
|
||
}
|
||
if(!(ectNum >= 500)) {
|
||
plus.nativeUI.toast('ect数量必须大于500');
|
||
return;
|
||
}
|
||
if(payPwd == '') {
|
||
plus.nativeUI.toast('未填写支付密码');
|
||
return;
|
||
}
|
||
$('.btn_ture').attr('disabled', 'disabled');
|
||
mui.ajax(hyhUrl('app/Ectwallets/withdraw'), {
|
||
headers: {
|
||
"HYH-Token": token
|
||
},
|
||
data: {
|
||
eAddress: eAddress,
|
||
ectNum: ectNum,
|
||
payPwd: payPwd
|
||
},
|
||
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.id)
|
||
|
||
var id = data.data.id;
|
||
// $('.btn_ture').removeAttr('disabled');
|
||
mui.ajax('http://moacapi.heyuanhui.cn/api/ect/ect_transfer', {
|
||
data: {
|
||
id: id
|
||
},
|
||
dataType: 'json', //服务器返回json格式数据
|
||
type: 'post', //HTTP请求类型
|
||
timeout: 10000, //超时时间设置为10秒;
|
||
success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功;
|
||
// console.log(data)
|
||
var data = toJson(data, 1);
|
||
if(data.status == 1) {
|
||
|
||
alert(data.msg);
|
||
mui.fire(plus.webview.getWebviewById('templete/my.html'), 'refresh');
|
||
mui.fire(plus.webview.getWebviewById('ect_index.html'), 'refresh');
|
||
location.reload();
|
||
} else {
|
||
// console.log(data.status)
|
||
}
|
||
$('.btn_ture').removeAttr('disabled');
|
||
},
|
||
error: function(xhr, type, errorThrown) { //异常处理;
|
||
// alert(errorThrown);
|
||
}
|
||
});
|
||
|
||
} else {
|
||
alert(data.msg);
|
||
location.reload();
|
||
$('.btn_ture').removeAttr('disabled');
|
||
|
||
}
|
||
},
|
||
error: function(xhr, type, errorThrown) { //异常处理;
|
||
// alert(errorThrown);
|
||
}
|
||
});
|
||
|
||
})
|
||
|
||
}) |