270 lines
7.3 KiB
JavaScript
270 lines
7.3 KiB
JavaScript
import { BlockChain } from "@/components/chain/BlockChain";
|
|
import axios from "axios"
|
|
|
|
|
|
const API_BASE = import.meta.env.VUE_APP_MKT_API
|
|
const API_UAW = import.meta.env.VUE_APP_UAW_API
|
|
const KingSome = import.meta.env.VUE_APP_REWARD_API
|
|
const net_id = import.meta.env.VUE_APP_NET_ID
|
|
|
|
const toJson = res => res.json();
|
|
|
|
const httpPost = async (url, data, token) => {
|
|
token = token || await new BlockChain().token();
|
|
let headers = {"Content-Type": "application/json"};
|
|
// let token = token;
|
|
if (token) {
|
|
headers['Authorization'] = `Bearer ${token}`;
|
|
}
|
|
return fetch(url, {
|
|
method: "POST",
|
|
body: JSON.stringify(data),
|
|
headers
|
|
}).then(toJson);
|
|
}
|
|
|
|
|
|
const httpGet = async (url, data, token) => {
|
|
token = token || await new BlockChain().token();
|
|
let headers = {"Content-Type": "application/json"};
|
|
if (token) {
|
|
headers['Authorization'] = `Bearer ${token}`;
|
|
}
|
|
url = url + (url.indexOf('?') > -1 ? "&" : "?" )+ new URLSearchParams(data).toString()
|
|
return fetch(url, {
|
|
method: "GET",
|
|
headers
|
|
}).then(toJson);
|
|
}
|
|
|
|
|
|
|
|
// 获取市场所有
|
|
export const apiMarketplaceState = async (data) => {
|
|
const url = `${API_BASE}/api/market/product/list/${net_id}`;
|
|
// return httpPost(url, data)
|
|
let res = await axios.post(url,data,
|
|
{ })
|
|
// console.log(res)
|
|
return res.data
|
|
}
|
|
|
|
// 获取nft地板价
|
|
export const apiGetPrice = async (data) => {
|
|
const url = `${API_BASE}/api/market/product/query_price`
|
|
return httpGet(url, data)
|
|
}
|
|
|
|
// 获取我拥有得资产
|
|
export const apiAssetsState = async (account_address, net_id, data, token) => {
|
|
const url = `${API_BASE}/api/asset/${net_id}/${account_address}`
|
|
return httpGet(url, data, token)
|
|
}
|
|
|
|
// 获取上架出售得NFTS
|
|
export const apiHangingState = async (data,account_address) => {
|
|
const url = `${API_BASE}/api/listing/${net_id}/${account_address}`
|
|
return httpGet(url, data)
|
|
}
|
|
|
|
// 账号交易历史
|
|
export const apiHistoryState = async (account_address,data) => {
|
|
const url = `${API_BASE}/api/market/transaction/history/${net_id}/${account_address}`
|
|
return httpGet(url, data)
|
|
}
|
|
|
|
// 账号游戏内资产
|
|
export const apiLockState = async (account_address,data, token) => {
|
|
const url = `${API_BASE}/api/market/product/lock/${net_id}/${account_address}`
|
|
return httpPost(url, data, token)
|
|
}
|
|
|
|
// 详情
|
|
export const apiDetail = async (account_address) => {
|
|
const url = `${API_BASE}/api/market/transaction/history/${net_id}/${account_address}`
|
|
return httpGet(url, {})
|
|
}
|
|
|
|
// 获取购物车列表
|
|
export const apiGetCartList = async () => {
|
|
const url = `${API_BASE}/api/shopcart/list`
|
|
return httpGet(url, {})
|
|
}
|
|
|
|
// 添加购物车
|
|
export const apiAddCartList = async (data) => {
|
|
const url = `${API_BASE}/api/shopcart/add`
|
|
return httpPost(url, data)
|
|
}
|
|
|
|
// 删除购物中nft
|
|
export const apiDelCartList = async (data) => {
|
|
const url = `${API_BASE}/api/shopcart/del`
|
|
return httpPost(url, data)
|
|
}
|
|
|
|
// 清空购物车
|
|
export const apiClearCartList = async () => {
|
|
const url = `${API_BASE}/api/shopcart/clear`
|
|
return httpPost(url, {net_id})
|
|
}
|
|
|
|
export const nftDetail = async(address, tokenId) => {
|
|
const url = `${API_BASE}/api/market/product/goods/${net_id}/${address}/${tokenId}`
|
|
return httpGet(url, {})
|
|
}
|
|
|
|
// UAW查询领取
|
|
export const apiCecInfoAll = async(address,token) => {
|
|
let url = `${API_UAW}/api/cec/info_all/${address}`
|
|
return httpGet(url)
|
|
}
|
|
|
|
// CEC Claim 查询
|
|
export const apiCecInfo = async(address,token) => {
|
|
let url = `${API_UAW}/api/cec/info/${address}`
|
|
return httpGet(url)
|
|
}
|
|
|
|
// CEC Claim 领取
|
|
export const apiCecClaim = async(address,token) => {
|
|
let url = `${API_UAW}/api/cec/claim`
|
|
return httpPost(url,{address: address},token)
|
|
}
|
|
|
|
// 绑定交易所账号
|
|
export const apiBindAccount = async(data, token) => {
|
|
let url = `${API_UAW}/api/cec/bind_account`
|
|
return httpPost(url, data, token)
|
|
}
|
|
|
|
// 获取游戏内资产
|
|
export const apiHeroList = async(data, token) => {
|
|
const url = `${API_BASE}/api/ingame/asset/hero/list`
|
|
return httpPost(url, data, token)
|
|
}
|
|
|
|
export const apiUnlockOrMint = async (data, token) => {
|
|
const url = `${API_BASE}/api/nft/stacking/unlock`
|
|
return httpPost(url, data, token)
|
|
}
|
|
|
|
|
|
export const apiMintNft = async (data, token) => {
|
|
const url = `${API_BASE}/api/ingame/asset/hero/mint`
|
|
return httpPost(url, data, token)
|
|
}
|
|
|
|
// 取每日预期所得
|
|
export const apiExpected = async (account_address) => {
|
|
const url = `${API_BASE}/api/activity/stacking/expected_daily/${account_address}`
|
|
return httpGet(url, {})
|
|
}
|
|
|
|
// 用户信息
|
|
export const apiUserData = async (account_address) => {
|
|
const url = `${API_BASE}/api/user/${account_address}`
|
|
return httpGet(url, {})
|
|
}
|
|
|
|
// 轮询状态
|
|
export const apiTxHash = async (net_id, account_address) => {
|
|
const url = `${API_BASE}/api/chain/txhash/${net_id}/${account_address}`
|
|
return httpGet(url, {})
|
|
}
|
|
|
|
// 活动交易记录
|
|
export const apiActivity = async (data, account_address) => {
|
|
const url = `${API_BASE}/api/chain/event/activity/${account_address}`
|
|
return httpPost(url, data)
|
|
}
|
|
|
|
// 贡献值记录
|
|
export const apiContribution = async (account_address) => {
|
|
// const url = `${API_BASE}/api/activity/stacking/history/${account_address}`
|
|
const url = `${API_BASE}/api/activity/contribution/history/${account_address}`
|
|
return httpGet(url, {})
|
|
}
|
|
|
|
// 充值列表
|
|
export const apiRechargeGoods = async (account_address) => {
|
|
const url = `${API_BASE}/api/recharge/goods`
|
|
return httpGet(url, {net_id, account_address})
|
|
}
|
|
|
|
// 充值记录
|
|
export const apiRechargeHistory = async (account_address) => {
|
|
const url = `${API_BASE}/api/recharge/history/${net_id}/${account_address}`
|
|
return httpPost(url, {})
|
|
}
|
|
|
|
// 消耗记录
|
|
export const apiDiamondHistory = async (account_address) => {
|
|
const url = `${API_BASE}/api/activity/diamond/history/${account_address}`
|
|
return httpGet(url, {})
|
|
}
|
|
|
|
// 充值-购买
|
|
export const apiPreRecharge = async (data, token) => {
|
|
const url = `${API_BASE}/api/recharge/buy`
|
|
return httpPost(url, data, token)
|
|
}
|
|
|
|
// CEC 贡献点活动
|
|
export const apiCecActivity = async (account_address) => {
|
|
const url = `${API_BASE}/api/activity/cec/contribution/${account_address}`
|
|
return httpGet(url)
|
|
}
|
|
|
|
|
|
// 活动开关
|
|
export const apiSwitch = async () => {
|
|
const url = `${API_BASE}/api/server_switch`
|
|
return httpGet(url)
|
|
}
|
|
|
|
|
|
// 充值打点
|
|
export const apiGameLog = async (data) => {
|
|
console.log(data)
|
|
// return
|
|
const url = `https://gamelog-test.kingsome.cn/webapp/index.php?c=GameLog&a=customReport`
|
|
return httpPost(url,data)
|
|
}
|
|
|
|
// 判断是否绑定passport账号
|
|
export const apiVipInfo = async () => {
|
|
const url = `${API_BASE}/api/vip/info`
|
|
return httpGet(url)
|
|
}
|
|
|
|
// 绑定passport账号
|
|
export const apiBindPassport = async (data) => {
|
|
console.log(data)
|
|
const url = `${API_BASE}/api/vip/bind`
|
|
return httpPost(url, data)
|
|
}
|
|
|
|
// 获取vip等级
|
|
export const apiVipDetails = async (data) => {
|
|
const url = `${API_BASE}/api/vip/details`
|
|
return httpGet(url)
|
|
}
|
|
|
|
// 拉力赛列表
|
|
export const apiCircuitRewardHistory = async (data) => {
|
|
const url = `${KingSome}/webapp/index.php?c=OutAppCircuit&a=getCircuitRewardHistory`
|
|
return httpGet(url,data)
|
|
}
|
|
|
|
// 巡回赛周赛
|
|
export const apiCircuitRanking = async (data) => {
|
|
const url = `${API_BASE}/api/circuit_ranking`
|
|
return httpGet(url,data)
|
|
}
|
|
|
|
// 巡回赛总赛
|
|
export const apiPhaseRanking = async (data) => {
|
|
const url = `${API_BASE}/api/circuit_phase_ranking`
|
|
return httpGet(url,data)
|
|
} |