qlg.tsgz.moe/static/app2/js/ect_recharge.js
2019-09-06 23:53:10 +08:00

119 lines
3.7 KiB
JavaScript
Executable File
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var userId = '';
var address = '';
mui.plusReady(function() {
var token = localStorage.getItem('token');
mui.ajax(hgUrl('app/Ectwallets/getEctAddress'), { 
headers: { 
"HYH-Token": token
},
dataType: 'json', //服务器返回json格式数据  
type: 'post', //HTTP请求类型  
timeout: 10000, //超时时间设置为10秒  
success: function(data) {           //服务器返回响应,根据响应结果,分析是否登录成功;  
var data = toJson(data, 1);
if(data.status == 1) {
var html = '';
userId = data.data.userId;
address = data.data.address;
// address = '0x29208ff5719cbd856c2e1ab32b2d3e101da6f721';
// console.log(address)
if(address == null) {
// console.log(1)
mui.ajax('http://moacapi.juzi199.com/api/ect/recharge_token', { 
data:{
userId:userId,
tokenName:'ect'
},
dataType: 'json', //服务器返回json格式数据  
type: 'post', //HTTP请求类型  
timeout: 10000, //超时时间设置为10秒  
success: function(data) {           //服务器返回响应,根据响应结果,分析是否登录成功;  
var data = toJson(data, 1);
if(data.status == 1) {
var html = '';
address = data.data.address;
$('#address').html(address);
var qrcode = new QRCode(document.getElementById("qrcode"), {
width: 118, //设置宽高
height: 118
});
qrcode.makeCode(address);
// console.log(address)
} else {
console.log(data.msg)
}
},
error: function(xhr, type, errorThrown) {           //异常处理;  
// alert(errorThrown);      
}  
}); 
} else {
$('#address').html(address);
var qrcode = new QRCode(document.getElementById("qrcode"), {
width: 118, //设置宽高
height: 118
});
qrcode.makeCode(address);
}
} else {
console.log(data.status)
}
},
error: function(xhr, type, errorThrown) {           //异常处理;  
alert(errorThrown);      
}  
}); 
$('.con').on('tap','#copy_address',function(){
copyShareUrl()
})
$('.header').on('tap','.add',function(){
mui.openWindow({
url: 'ect_recharge_list.html',
id: 'ect_recharge_list.html',
styles: {
top: '0px', //新页面顶部位置
bottom: '0px', //新页面底部位置
},
extras: {
// data_keyword: searchName
// ..... //自定义扩展参数,可以用来处理页面间传值
},
createNew: false, //是否重复创建同样id的webview默认为false:不重复创建,直接显示
show: {},
waiting: {}
})
})
})
function copyShareUrl() {
mui.plusReady(function() {
//复制链接到剪切板
var copy_content = address;
//判断是安卓还是ios
if(mui.os.ios) {
//ios
var UIPasteboard = plus.ios.importClass("UIPasteboard");  
var generalPasteboard = UIPasteboard.generalPasteboard();   //设置/获取文本内容:
  
generalPasteboard.plusCallMethod({    
setValue: copy_content,
    forPasteboardType: "public.utf8-plain-text"  
});  
generalPasteboard.plusCallMethod({    
valueForPasteboardType: "public.utf8-plain-text"  
});
} else {
//安卓
var context = plus.android.importClass("android.content.Context"); 
var main = plus.android.runtimeMainActivity(); 
var clip = main.getSystemService(context.CLIPBOARD_SERVICE); 
plus.android.invoke(clip, "setText", copy_content);
}
plus.nativeUI.toast("复制到剪切板成功 ");
});
}