- 移除秒合约页面及UI - 合约页Tab改为Position Held/Transaction Record - 存款/提款/转账页增加BTC/ETH - 资产页重构(用户信息+盈亏+多语言) - 注册页改版(匹配新设计稿) - 日文全面翻译+首页菜单多语言 - 代理专属注册链接支持(?code=) - 10个locale文件同步更新
99 lines
2.0 KiB
JavaScript
99 lines
2.0 KiB
JavaScript
const apiUrl = 'https://jyshd.pp1008.top/api'//项目API接口
|
|
|
|
const req = (url, data, isloading = false) => {
|
|
return new Promise((resolve, reject) => {
|
|
isloading && uni.showLoading({
|
|
// title: '加载中...',
|
|
mask: true
|
|
})
|
|
var lang = 'jp'
|
|
if (uni.getStorageSync('Language')) {
|
|
lang = uni.getStorageSync('Language').toLowerCase()
|
|
}
|
|
if (uni.getStorageSync('token')) {
|
|
data = {
|
|
...data,
|
|
token: uni.getStorageSync('token')
|
|
}
|
|
}
|
|
uni.request({
|
|
url: apiUrl + url + "?lang=" + lang,
|
|
data: data,
|
|
sslVerify: false,
|
|
header: {
|
|
// "Content-Type": "application/json",
|
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
},
|
|
method: 'POST',
|
|
success: function(res) {
|
|
resolve(res.data)
|
|
},
|
|
fail: function(e) {
|
|
reject(e)
|
|
},
|
|
complete(res) {
|
|
// console.log(res)
|
|
isloading && uni.hideLoading()
|
|
if (res.data.code == 0) {
|
|
if (res.data.msg != '') {
|
|
uni.showToast({
|
|
title: res.data.msg,
|
|
icon: "none",
|
|
duration: 2000,
|
|
success() {
|
|
setTimeout(() => {
|
|
uni.hideToast()
|
|
}, 2000)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
if (res.data.code == 401) {
|
|
const hadToken = !!uni.getStorageSync('token')
|
|
// uni.clearStorageSync()
|
|
uni.removeStorageSync('token');
|
|
uni.removeStorageSync('user_id');
|
|
uni.removeStorageSync('userinfo');
|
|
if (hadToken) {
|
|
uni.reLaunch({
|
|
url: "/pages/login/index"
|
|
})
|
|
}
|
|
}
|
|
}
|
|
})
|
|
})
|
|
}
|
|
const req1 = (url, data, isloading = false) => {
|
|
return new Promise((resolve, reject) => {
|
|
isloading && uni.showLoading({
|
|
// title: '加载中...',
|
|
mask: true
|
|
})
|
|
uni.request({
|
|
url: url,
|
|
data: data,
|
|
sslVerify: false,
|
|
header: {
|
|
// "Content-Type": "application/json",
|
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
},
|
|
method: 'GET',
|
|
success: function(res) {
|
|
resolve(res.data)
|
|
},
|
|
fail: function(e) {
|
|
reject(e)
|
|
},
|
|
complete() {
|
|
isloading && uni.hideLoading()
|
|
}
|
|
})
|
|
})
|
|
}
|
|
export {
|
|
req,
|
|
req1,
|
|
apiUrl
|
|
}
|