feat: 前端全量更新 - 含所有本次需求
- 移除秒合约页面及UI - 合约页Tab改为Position Held/Transaction Record - 存款/提款/转账页增加BTC/ETH - 资产页重构(用户信息+盈亏+多语言) - 注册页改版(匹配新设计稿) - 日文全面翻译+首页菜单多语言 - 代理专属注册链接支持(?code=) - 10个locale文件同步更新
This commit is contained in:
@@ -0,0 +1,410 @@
|
||||
// 图表库实例化后储存的函数
|
||||
console.log("加载kline")
|
||||
var widget = null
|
||||
// 进入页面 默认展示的产品
|
||||
var index_market = 'btcusdt'
|
||||
// 进入页面 默认展示的产品周期
|
||||
var index_activeCycle = 1
|
||||
// 价格精度 默认4位小数
|
||||
var pricescale = 4
|
||||
|
||||
var bb_type = 1
|
||||
|
||||
var lastminClose = 0
|
||||
|
||||
// window.TradingView.onready 确保在html的dom加载完成后在调用
|
||||
window.TradingView.onready(function() {
|
||||
// chartConfig 在chartConfig.js里面
|
||||
// 给chartConfig添加展示周期
|
||||
chartConfig.interval = index_activeCycle
|
||||
// 给chartConfig添加展示产品
|
||||
chartConfig.symbol = index_market
|
||||
|
||||
// 初始化 TradingView
|
||||
widget = new window.TradingView.widget(chartConfig)
|
||||
|
||||
widget && widget.onChartReady && widget.onChartReady(function() {
|
||||
// 这是k线图 展示的 7日均线和30日均线。
|
||||
widget.chart().createStudy('Moving Average', false, false, [7], null, {
|
||||
'Plot.linewidth': 2,
|
||||
'Plot.color': '#2ba7d6'
|
||||
})
|
||||
widget.chart().createStudy('Moving Average', false, false, [30], null, {
|
||||
'Plot.linewidth': 2,
|
||||
'Plot.color': '#de9f66'
|
||||
})
|
||||
setTimeout(() => {
|
||||
widget.chart().resetData()
|
||||
}, 1000)
|
||||
})
|
||||
})
|
||||
|
||||
let baseUrl = 'https://jyshd.pp1008.top/';
|
||||
|
||||
// 请求封装
|
||||
function http2(url, data, method, token) {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios({
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded"
|
||||
},
|
||||
method: method,
|
||||
url: baseUrl + url,
|
||||
data: Qs.stringify(data)
|
||||
})
|
||||
.then(res => {
|
||||
if (res.status == 200) {
|
||||
resolve(res.data)
|
||||
} else {
|
||||
reject()
|
||||
// alertError('请求超时')
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
// alertError('请求超时')
|
||||
})
|
||||
})
|
||||
}
|
||||
// 弹窗
|
||||
function alertError(title) {
|
||||
document.addEventListener('plusready', function() {
|
||||
console.log('......')
|
||||
})
|
||||
try {
|
||||
plus.nativeUI.toast(title, {
|
||||
// icon:'/static/common/toast-error.png',
|
||||
style: 'inline',
|
||||
verticalAlign: 'top'
|
||||
});
|
||||
} catch (e) {
|
||||
//TODO handle the exception
|
||||
}
|
||||
}
|
||||
var app = new Vue({
|
||||
el: '#app',
|
||||
data: {
|
||||
token: "",
|
||||
Language: '',
|
||||
name_sx: '',
|
||||
symbol: "",
|
||||
newData: {
|
||||
close: 0,
|
||||
},
|
||||
title: "",
|
||||
tab: 1,
|
||||
newDay: {
|
||||
high: 0,
|
||||
low: 0
|
||||
},
|
||||
depth: "",
|
||||
coinInfo: "",
|
||||
period: "1min",
|
||||
coindata: {},
|
||||
exchange_rate: 6,
|
||||
current: 1,
|
||||
buyurl: '',
|
||||
sellurl: '',
|
||||
|
||||
market_jd: 6,
|
||||
price_jd: 4,
|
||||
zhezhaoceng: 1,
|
||||
|
||||
changeflag: true,
|
||||
},
|
||||
created() {
|
||||
|
||||
},
|
||||
mounted() {
|
||||
var that = this
|
||||
var storage = window.localStorage;
|
||||
that.token = storage.getItem("token");
|
||||
that.exchange_rate = storage.getItem("ratenum")
|
||||
that.name_sx = storage.getItem("ratename")
|
||||
that.Language = storage.getItem("Language")
|
||||
console.log('语言为' + that.Language);
|
||||
this.getLanguage()
|
||||
this.getCionInfo()
|
||||
|
||||
Event.on('changeflag', data => {
|
||||
// console.log('分钟线数据',data)
|
||||
this.changeflag = data
|
||||
})
|
||||
Event.on('zhezhaoceng', data => {
|
||||
// console.log('分钟线数据',data)
|
||||
this.zhezhaoceng = data
|
||||
})
|
||||
// 拿到实时数据 在这里画
|
||||
Event.on('newData', data => {
|
||||
// console.log('分钟线数据',data)
|
||||
this.newData = data
|
||||
})
|
||||
|
||||
Event.on('newDay', data => {
|
||||
// console.log('一天的数据',data)
|
||||
this.newDay = data
|
||||
})
|
||||
Event.on('depth', data => {
|
||||
// console.log('深度',data)
|
||||
this.depth = data
|
||||
})
|
||||
Event.on('reconnect', data => {
|
||||
// console.log('reconnect',data)
|
||||
console.log(data)
|
||||
// 如果socket断了重连 需要重新请求aptusdt的历史数据
|
||||
if (bb_type == 2) {
|
||||
// setTimeout( ()=> {
|
||||
// this.getHistory(data)
|
||||
// }, 500)
|
||||
}
|
||||
})
|
||||
},
|
||||
destroyed: function() {
|
||||
// clearInterval(this.alone)
|
||||
},
|
||||
methods: {
|
||||
getexchange() {
|
||||
var that = this
|
||||
http2('api/publics/exchange_list', {}, "POST", this.token).then(res => {
|
||||
if (res.code == 1) {
|
||||
let data = res.data
|
||||
let cha = data.find(item => item.id == 2)
|
||||
|
||||
if (that.Language == 'zh-cn') {
|
||||
// that.exchange_rate=res.data
|
||||
let obj = data.find(item => item.id == 2)
|
||||
if (obj) {
|
||||
that.exchange_rate = obj.exchange
|
||||
that.name_sx = obj.name_sx
|
||||
}
|
||||
}
|
||||
if (that.Language == 'en-us') {
|
||||
// that.exchange_rate=res.data
|
||||
let obj = data.find(item => item.id == 4)
|
||||
if (obj) {
|
||||
that.exchange_rate = obj.exchange
|
||||
that.name_sx = obj.name_sx
|
||||
} else {
|
||||
that.exchange_rate = cha.exchange
|
||||
that.name_sx = cha.name_sx
|
||||
}
|
||||
}
|
||||
if (that.Language == 'mn') {
|
||||
// that.exchange_rate=res.data
|
||||
let obj = data.find(item => item.id == 11)
|
||||
if (obj) {
|
||||
that.exchange_rate = obj.exchange
|
||||
that.name_sx = obj.name_sx
|
||||
} else {
|
||||
that.exchange_rate = cha.exchange
|
||||
that.name_sx = cha.name_sx
|
||||
}
|
||||
}
|
||||
if (that.Language == 'ms') {
|
||||
// that.exchange_rate=res.data
|
||||
let obj = data.find(item => item.id == 5)
|
||||
if (obj) {
|
||||
that.exchange_rate = obj.exchange
|
||||
that.name_sx = obj.name_sx
|
||||
} else {
|
||||
that.exchange_rate = cha.exchange
|
||||
that.name_sx = cha.name_sx
|
||||
}
|
||||
}
|
||||
if (that.Language == 'kr') {
|
||||
// that.exchange_rate=res.data
|
||||
let obj = data.find(item => item.id == 7)
|
||||
if (obj) {
|
||||
that.exchange_rate = obj.exchange
|
||||
that.name_sx = obj.name_sx
|
||||
} else {
|
||||
that.exchange_rate = cha.exchange
|
||||
that.name_sx = cha.name_sx
|
||||
}
|
||||
}
|
||||
if (that.Language == 'fre') {
|
||||
// that.exchange_rate=res.data
|
||||
let obj = data.find(item => item.id == 9)
|
||||
if (obj) {
|
||||
that.exchange_rate = obj.exchange
|
||||
that.name_sx = obj.name_sx
|
||||
} else {
|
||||
that.exchange_rate = cha.exchange
|
||||
that.name_sx = cha.name_sx
|
||||
}
|
||||
}
|
||||
if (that.Language == 'ger') {
|
||||
// that.exchange_rate=res.data
|
||||
let obj = data.find(item => item.id == 3)
|
||||
if (obj) {
|
||||
that.exchange_rate = obj.exchange
|
||||
that.name_sx = obj.name_sx
|
||||
} else {
|
||||
that.exchange_rate = cha.exchange
|
||||
that.name_sx = cha.name_sx
|
||||
}
|
||||
}
|
||||
if (that.Language == 'ily') {
|
||||
// that.exchange_rate=res.data
|
||||
let obj = data.find(item => item.id == 10)
|
||||
if (obj) {
|
||||
that.exchange_rate = obj.exchange
|
||||
that.name_sx = obj.name_sx
|
||||
} else {
|
||||
that.exchange_rate = cha.exchange
|
||||
that.name_sx = cha.name_sx
|
||||
}
|
||||
}
|
||||
if (that.Language == 'jp') {
|
||||
// that.exchange_rate=res.data
|
||||
let obj = data.find(item => item.id == 8)
|
||||
if (obj) {
|
||||
that.exchange_rate = obj.exchange
|
||||
that.name_sx = obj.name_sx
|
||||
} else {
|
||||
that.exchange_rate = cha.exchange
|
||||
that.name_sx = cha.name_sx
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
numFilter(item) {
|
||||
if (item == undefined || item == null) {
|
||||
return 0;
|
||||
} else {
|
||||
if (Number(item) < 10) {
|
||||
return Number(item).toFixed(6);
|
||||
} else if (Number(item) >= 10 && Number(item) < 1000) {
|
||||
return Number(item).toFixed(4);
|
||||
} else if (Number(item) >= 1000 && Number(item) < 1000000) {
|
||||
return (Number(item) / 1000).toFixed(4) + ' K';
|
||||
} else if (Number(item) >= 1000000 && Number(item) < 10000000000) {
|
||||
return (Number(item) / 1000000).toFixed(2) + ' M';
|
||||
} else {
|
||||
return (Number(item) / 10000000000).toFixed(2) + ' B';
|
||||
}
|
||||
}
|
||||
},
|
||||
getCionInfo() {
|
||||
http2('api/Contract/get_curr_con', {
|
||||
symbol: this.symbol
|
||||
}, "POST").then(res => {
|
||||
console.log('币种信息', res)
|
||||
if (res.code == 1) {
|
||||
this.coindata = res.data
|
||||
// this.newData.close = res.data.close
|
||||
// https://h5.apec.io/#/pages/transaction/index
|
||||
this.market_jd = res.data.market_jd
|
||||
pricescale = res.data.price_jd
|
||||
this.price_jd = res.data.price_jd
|
||||
}
|
||||
})
|
||||
},
|
||||
overlay() {
|
||||
var e1 = document.getElementById('modal-overlay');
|
||||
e1.style.visibility = (e1.style.visibility == "visible") ? "hidden" : "visible";
|
||||
},
|
||||
getDay() {
|
||||
http2('api/market/get_day_kline', {
|
||||
symbol: this.symbol
|
||||
}, "POST", this.token).then(res => {
|
||||
console.log('获取一天最高最低', res)
|
||||
if (res.code == 1) {
|
||||
Event.emit('newDay', res.data)
|
||||
setTimeout(() => {
|
||||
this.getDay()
|
||||
}, 10000)
|
||||
}
|
||||
})
|
||||
},
|
||||
getLanguage() {
|
||||
var args = window.location.href.split('?');
|
||||
if (args[0] == window.location.href) {
|
||||
return "";
|
||||
};
|
||||
var arr = args[1].split('&');
|
||||
var obj = {};
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
var arg = arr[i].split('=');
|
||||
obj[arg[0]] = arg[1];
|
||||
}
|
||||
// console.log(obj)
|
||||
this.symbol = obj.symbol
|
||||
this.getDay()
|
||||
bb_type = obj.bb_type
|
||||
console.log('bb_type', bb_type)
|
||||
this.title = obj.title
|
||||
index_market = obj.symbol
|
||||
|
||||
this.buyurl = 'https://' + obj.h5_url + '/#/pages/transaction/index?type=buy&symbol=' + this.symbol
|
||||
this.sellurl = 'https://' + obj.h5_url + '/#/pages/transaction/index?type=sell&symbol=' + this
|
||||
.symbol
|
||||
console.log(this.buyurl)
|
||||
console.log(this.sellurl)
|
||||
|
||||
// 如果是aptusdt币种,进页面先接口请求历史数据
|
||||
if (bb_type == 2) {
|
||||
console.log('进入币币模式')
|
||||
this.changeflag = false
|
||||
setTimeout(() => {
|
||||
this.getHistory()
|
||||
}, 1000)
|
||||
} else {
|
||||
console.log('进入线上模式')
|
||||
}
|
||||
},
|
||||
change(e) {
|
||||
if (!this.changeflag) return
|
||||
// 1 为平均K线; 3 为面积图
|
||||
index_activeCycle = e
|
||||
this.tab = e
|
||||
if (e == 1) {
|
||||
this.period = "1min"
|
||||
} else if (e == 5) {
|
||||
this.period = "5min"
|
||||
} else if (e == 15) {
|
||||
this.period = "15min"
|
||||
} else if (e == 30) {
|
||||
this.period = "30min"
|
||||
} else if (e == 60) {
|
||||
this.period = "60min"
|
||||
} else if (e == '1D') {
|
||||
this.period = "1day"
|
||||
}
|
||||
this.changeflag = false
|
||||
if (bb_type == 2) {
|
||||
widget.chart().setChartType(e == '0' ? 3 : 1)
|
||||
widget.chart().setResolution(e)
|
||||
this.getHistory(this.period)
|
||||
} else {
|
||||
widget.chart().setChartType(e == '0' ? 3 : 1)
|
||||
widget.chart().setResolution(e)
|
||||
}
|
||||
},
|
||||
getHistory(e) {
|
||||
var that = this
|
||||
var period = this.period
|
||||
if (e) {
|
||||
console.log("分钟线", e)
|
||||
period = e
|
||||
}
|
||||
http2('api/market/get_apt_kline', {
|
||||
period: period,
|
||||
symbol: this.symbol
|
||||
}, "POST").then(res => {
|
||||
console.log('历史数据请求', res)
|
||||
if (res.code == 1) {
|
||||
if (period == '1min') {
|
||||
lastminClose = res.data[res.data.length - 1].close
|
||||
that.newData = res.data[res.data.length - 1]
|
||||
Event.emit('data', res.data)
|
||||
} else {
|
||||
res.data[res.data.length - 1].close = lastminClose
|
||||
Event.emit('data', res.data)
|
||||
that.newData.close = lastminClose
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user