请求401处理

This commit is contained in:
hxhxhx 2025-05-07 13:42:14 +08:00
parent 5b045fe90b
commit 009da9d985
13 changed files with 377 additions and 620 deletions

View File

@ -390,12 +390,13 @@
this.nowteaminfos = this.aboutObj.teamlist[index]; this.nowteaminfos = this.aboutObj.teamlist[index];
}, },
async getAbouts(){ async getAbouts(){
let res = await axios.get(baseUrl+'api/index/about'); let res = await publikRequesFunction('api/index/about','get',{});
if (res.data.code === 1) { console.log(res,'nowRequest');
this.aboutObj = res.data.data; if (res.code === 1) {
this.aboutObj = res.data;
this.nowteaminfos = this.aboutObj.teamlist[0]; this.nowteaminfos = this.aboutObj.teamlist[0];
} }
} }
} }
}) })
</script> </script>

View File

@ -330,32 +330,21 @@
// 返回格式化后的日期字符串 // 返回格式化后的日期字符串
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}, },
getallorderList(){ async getallorderList(){
this.tableLoading = true; this.tableLoading = true;
let _that = this; let _that = this;
$.ajax({ const params = {
url: `${baseUrl}api/project/getorderlist`, ..._that.orderSearchObj,
type: "get", trade: _that.timeFilter,
data: { state: _that.activeTab
..._that.orderSearchObj, };
trade: _that.timeFilter, let res = await publikRequesFunction('api/project/getorderlist','get',params);
state: _that.activeTab if (res.code === 1) {
}, _that.orderListObj = res.data;
headers: { _that.tableLoading = false;
token: _that.userInfoObj.token } else {
}, _that.$message.error(res.msg)
success(res){ }
if (res.code === 1) {
_that.orderListObj = res.data;
_that.tableLoading = false;
} else {
_that.$message.error(res.msg)
}
},
error(error) {
_that.$message.error(error)
}
})
}, },
changeTab(tab) { changeTab(tab) {
this.activeTab = tab; this.activeTab = tab;
@ -448,7 +437,7 @@
this.orderLoading.close(); this.orderLoading.close();
} }
}, },
submitOrderHash(id,tx){ async submitOrderHash(id,tx){
//求购卖出支付结果api/project/wtbrevpayres //求购卖出支付结果api/project/wtbrevpayres
//买入支付结果api/common/payresult //买入支付结果api/common/payresult
let api = ""; let api = "";
@ -462,28 +451,16 @@
obj = { wtbid: id,tx } obj = { wtbid: id,tx }
} }
try { try {
$.ajax({ let res = await publikRequesFunction(api,'post',obj);
url: `${baseUrl + api}`, if (res.code === 1) {
type: "post", _that.$message.success('success');
data: {...obj}, _that.orderLoading.close();
headers: { setTimeout(()=>{
token: _that.userInfoObj.token _that.getallorderList();
}, },1000);
success(res){ } else {
if (res.code === 1) { _that.$message.error(res.msg)
_that.$message.success('success'); }
_that.orderLoading.close();
setTimeout(()=>{
_that.getallorderList();
},1000);
} else {
_that.$message.error(res.msg)
}
},
error(err) {
_that.$message.error(err)
}
})
} catch (error) { } catch (error) {
_that.$message.error(error) _that.$message.error(error)
} }

View File

@ -293,7 +293,7 @@
}); });
}, },
methods:{ methods:{
sendContact(){ async sendContact(){
let _that = this; let _that = this;
let tipMessage = this.currentLanguage == 'zh' ? '請輸入完整信息' : "Please enter complete information"; let tipMessage = this.currentLanguage == 'zh' ? '請輸入完整信息' : "Please enter complete information";
if(!this.firstName || !this.secondName || !this.contactObj.email || !this.contactObj.contact){ if(!this.firstName || !this.secondName || !this.contactObj.email || !this.contactObj.contact){
@ -301,29 +301,15 @@
return return
} }
this.contactObj.name = this.firstName + this.secondName; this.contactObj.name = this.firstName + this.secondName;
$.ajax({ let res = await publikRequesFunction('api/common/contactus','post',{..._that.contactObj});
url:`${baseUrl}api/common/contactus`, if(res.code === 1){
data:{ _that.firstName = "";
..._that.contactObj _that.secondName = "";
}, _that.contactObj = {};
headers:{ _that.$message.success("success");
token: this.userToken }else{
}, _that.$message.error("failed");
type:"post", }
success(res){
if(res.code === 1){
_that.firstName = "";
_that.secondName = "";
_that.contactObj = {};
_that.$message.success("success");
}else{
_that.$message.error("failed");
}
},
error(err){
_that.$message.error("failed");
}
});
}, },
// <-- -------------------------錢包登錄開始 ---------------------------> // <-- -------------------------錢包登錄開始 --------------------------->
copyText(txt){ copyText(txt){

View File

@ -271,7 +271,6 @@
if (user) { if (user) {
this.userIsLogin = true; this.userIsLogin = true;
} }
this.getgamesInfo();
// 钱包登录开始 // 钱包登录开始
const provider = window.web3?.currentProvider; const provider = window.web3?.currentProvider;
let accounts1 = []; let accounts1 = [];
@ -404,9 +403,9 @@
this.currentLanguage = mobileLang() this.currentLanguage = mobileLang()
}, },
async getgamesInfo(){ async getgamesInfo(){
let res = await axios.get(baseUrl+"api/index/gameinfo"); let res = await publikRequesFunction('api/index/gameinfo','get',{});
if(res.data.code == 1){ if(res.code == 1){
this.gamesinfomation = res.data.data; this.gamesinfomation = res.data;
} }
}, },
} }

View File

@ -573,7 +573,6 @@
downloadObj: {}, downloadObj: {},
pageIngomation: [], pageIngomation: [],
videoList: [], videoList: [],
categoriesTabList: [],
outlookList: [], outlookList: [],
saleList: [],//限時商品列表 saleList: [],//限時商品列表
times: { times: {
@ -609,7 +608,6 @@
} }
this.getDownload(); this.getDownload();
this.getgamesVideo(); this.getgamesVideo();
this.getCategoriestable();
this.getOutlook(); this.getOutlook();
this.loadCloseAuth() this.loadCloseAuth()
this.loadSaleList(); this.loadSaleList();
@ -764,21 +762,11 @@
mobileLang() { mobileLang() {
this.currentLanguage = mobileLang() this.currentLanguage = mobileLang()
}, },
getRoleList() { async getRoleList() {
let _that = this; let res = await publikRequesFunction('api/index/getrole','get',{});
$.ajax({ if (res.code === 1) {
url: baseUrl+"api/index/getrole", this.roleList = res.data;
type: 'get', }
dataType: "json",
success(res) {
if (res.code === 1) {
_that.roleList = res.data;
}
},
error(rej) {
console.log("failed");
}
})
}, },
//新聞詳情 //新聞詳情
toNewDetail() { toNewDetail() {
@ -826,13 +814,8 @@
// this.$message.success('success'); // this.$message.success('success');
}, },
async orderPayResult(id, tx) { async orderPayResult(id, tx) {
let res = await axios.post(baseUrl+'api/common/payresult', { id, tx }, { headers: { 'token': this.token, 'Content-Type': 'application/json' } }); let res = await publikRequesFunction('api/common/payresult','post',{id, tx});
if (res.data.code === 1) { if (res.code != 1) {
// if (this.orderList[this.orderList.length - 1].id == id) {
// this.orderLoading.close();
// }
} else {
// this.orderLoading.close();
this.$message.error('error'); this.$message.error('error');
} }
}, },
@ -845,28 +828,21 @@
} }
this.buy.fromaddress = this.userMoneyAdressAll; this.buy.fromaddress = this.userMoneyAdressAll;
let tipMessage = this.currentLanguage == 'zh' ? '交易中,請勿刷新頁面...' : 'During the transaction, please do not refresh the page'; let tipMessage = this.currentLanguage == 'zh' ? '交易中,請勿刷新頁面...' : 'During the transaction, please do not refresh the page';
// this.orderLoading = this.$loading({ lock: true, text: tipMessage, spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)' }); let res = await publikRequesFunction('api/project/createpurchaseorder','post',{...this.buy});
let res = await axios.post(baseUrl+'api/project/createpurchaseorder', { ...this.buy }, {
headers: {
'token': this.token, // 使用 Bearer 認證方式攜帶 Token
'Content-Type': 'application/json' // 確保發送 JSON 格式的數據
}
})
console.log(res, '订单'); console.log(res, '订单');
if (res.data.code === 1) { if (res.code === 1) {
this.orderList = res.data.data; this.orderList = res.data;
this.buyButtonVisible = false; this.buyButtonVisible = false;
this.websentMoney(); this.websentMoney();
} else { } else {
this.$message.error(res.data.msg); this.$message.error(res.msg);
// this.orderLoading.close();
} }
}, },
//獲取限時折購商品 //獲取限時折購商品
async loadSaleList() { async loadSaleList() {
let res = await axios.get(`${baseUrl}api/index/getpurchase`); let res = await publikRequesFunction('api/index/getpurchase','get',{});
if (res.data.code === 1) { if (res.code === 1) {
this.saleList = res.data.data; this.saleList = res.data;
this.isShowSale = this.saleList.length > 0 this.isShowSale = this.saleList.length > 0
setInterval(() => { setInterval(() => {
if (this.currentSaleIndex === this.saleList.length - 1) { if (this.currentSaleIndex === this.saleList.length - 1) {
@ -885,58 +861,40 @@
window.location.href = 'login.html' window.location.href = 'login.html'
}, },
async getOutlook() { async getOutlook() {
let res = await axios.get(`${baseUrl}api/index/getlist? let res = await publikRequesFunction('api/index/getlist','get',{
cateid=4& cateid:4,
keywordsen=& keywordsen:"",
keywordscn=& keywordscn:"",
page=1& page:1,
listrow=5& listrow:5,
`); });
if (res.data.code === 1) { if (res.code === 1) {
this.outlookList = res.data.data.data; this.outlookList = res.data.data;
}
},
async getCategoriestable() {
let res = await axios.get(`${baseUrl}api/index/getlist?
cateid=1&
keywordsen=&
keywordscn=&
page=1&
listrow=4&
`);
if (res.data.code === 1) {
this.categoriesTabList = res.data.data.data;
} }
}, },
async getgamesVideo() { async getgamesVideo() {
let res = await axios.get(baseUrl+'api/index/getmedia?page=1&listrow=8'); let res = await publikRequesFunction('api/index/getmedia','get',{page:1,listrow:8});
if (res.data.code === 1) { if (res.code === 1) {
this.videoList = res.data.data.data; this.videoList = res.data.data;
console.log(this.videoList,'ssxxx');
} }
}, },
async getDownload() { async getDownload() {
let res = await axios.get(baseUrl+'api/'); let res = await publikRequesFunction('api/','get',{});
if (res.data.code === 1) { if (res.code === 1) {
this.downloadObj = res.data.data; this.downloadObj = res.data;
} }
}, },
async getInfomation() { async getInfomation() {
let res = await axios.get(`${baseUrl}api/index/getlist? let res = await publikRequesFunction('api/index/getlist','get',{
cateid=3& cateid:3,
keywordsen=& keywordsen:"",
keywordscn=& keywordscn:"",
page=1& page:1,
listrow=4& listrow:4,
`); });
if (res.data.code === 1) { if (res.code === 1) {
this.pageIngomation = res.data.data.data; this.pageIngomation = res.data.data;
this.hotnewsindex(0) this.hotnewsindex(0)
// setTimeout(()=>{
// const container = this.$refs.container;
// container.clientHeight > 188 && this.$refs.newsLeft.classList.add('ellipsis');
// },500)
} }
}, },
optionsTemp(timestamp) { optionsTemp(timestamp) {
@ -947,16 +905,15 @@
return Y + M + D; return Y + M + D;
}, },
//请求获取显示抢购弹框关闭按钮权限 //请求获取显示抢购弹框关闭按钮权限
loadCloseAuth() { async loadCloseAuth() {
axios.get(baseUrl+'api/index/getcloseauth').then(res => { let res = await publikRequesFunction('api/index/getcloseauth','get',{});
if (res.data.code === 1) { if (res.code === 1) {
console.log(res.data.data, 6666) console.log(res.data, 6666)
this.isShowClose = Boolean(res.data.data.closeauth) this.isShowClose = Boolean(res.data.closeauth)
this.interval = setInterval(() => { this.interval = setInterval(() => {
this.updateCountdown(res.data.data.purastarttime) this.updateCountdown(res.data.purastarttime)
}, 1000); }, 1000);
} }
})
}, },
// 更新倒計時的函數 // 更新倒計時的函數

View File

@ -384,9 +384,9 @@
this.page = val; this.page = val;
}, },
async getonrules() { async getonrules() {
let res = await axios.get(baseUrl+'api/user/getrewardrule'); let res = await publikRequesFunction('api/user/getrewardrule','get',{});
if (res.data.code == 1) { if (res.code == 1) {
this.rewardRules = res.data.data; this.rewardRules = res.data;
} }
}, },
} }

View File

@ -247,7 +247,6 @@
} }
}); });
this.getReadDetail(); this.getReadDetail();
}, },
methods: { methods: {
// <-- -------------------------钱包登录开始 ---------------------------> // <-- -------------------------钱包登录开始 --------------------------->
@ -358,12 +357,9 @@
return Y + M + D; return Y + M + D;
}, },
async getReadDetail() { async getReadDetail() {
let res = await axios.get(` let res = await publikRequesFunction('api/index/getdetail','get',{id:this.readId});
${baseUrl}api/index/getdetail? if (res.code === 1) {
id=${this.readId} let news = JSON.stringify(res.data);
`);
if (res.data.code === 1) {
let news = JSON.stringify(res.data.data);
news = news.replaceAll('samsar Dao','Samsara Dao').replaceAll('Samsar Dao','Samsara Dao') news = news.replaceAll('samsar Dao','Samsara Dao').replaceAll('Samsar Dao','Samsara Dao')
this.readeDetalObj = JSON.parse(news) this.readeDetalObj = JSON.parse(news)
} }

View File

@ -416,16 +416,16 @@
return Y + M + D; return Y + M + D;
}, },
async getCategoriestable() { async getCategoriestable() {
let res = await axios.get(`${baseUrl}api/index/getlist? let res = await publikRequesFunction('api/index/getlist','get',{
cateid=3& cateid:3,
keywordsen=& keywordsen:"",
keywordscn=& keywordscn:"",
page=${this.page}& page:this.page,
listrow=${this.listrow}& listrow:this.listrow
`); });
if (res.data.code === 1) { if (res.code === 1) {
this.categoriesTabList = res.data.data this.categoriesTabList = res.data
this.categoriesTabList.data = res.data.data.data.map(item=>{ this.categoriesTabList.data = res.data.data.map(item=>{
item.sub_en = item.sub_en.replaceAll('samsar Dao','Samsara Dao').replaceAll('Samsar Dao','Samsara Dao') item.sub_en = item.sub_en.replaceAll('samsar Dao','Samsara Dao').replaceAll('Samsar Dao','Samsara Dao')
item.title_en = item.title_en.replaceAll('samsar Dao','Samsara Dao').replaceAll('Samsar Dao','Samsara Dao') item.title_en = item.title_en.replaceAll('samsar Dao','Samsara Dao').replaceAll('Samsar Dao','Samsara Dao')
item.text_en = item.text_en.replaceAll('samsar Dao','Samsara Dao').replaceAll('Samsar Dao','Samsara Dao') item.text_en = item.text_en.replaceAll('samsar Dao','Samsara Dao').replaceAll('Samsar Dao','Samsara Dao')

232
nft.html
View File

@ -706,43 +706,31 @@
_that.$message("Failed"); _that.$message("Failed");
}); });
}, },
creatRenewalOrder(){ async creatRenewalOrder(){
let _that = this; let _that = this;
let tip = this.currentLanguage == 'zh' ? '提示' : 'tips'; let tip = this.currentLanguage == 'zh' ? '提示' : 'tips';
let confirm = this.currentLanguage == 'zh' ? '確定' : 'confirm'; let confirm = this.currentLanguage == 'zh' ? '確定' : 'confirm';
let cancel = this.currentLanguage == 'zh' ? '取消' : 'cancel'; let cancel = this.currentLanguage == 'zh' ? '取消' : 'cancel';
$.ajax({ let res = await publikRequesFunction('api/project/leasenft','post',{
url: `${baseUrl}api/project/leasenft`, id: _that.nftrenewalInfos.id,
type: "post", fromaddress:_that.userMoneyAdressAll
data: { });
id: _that.nftrenewalInfos.id, if (res.code === 1) {
fromaddress:_that.userMoneyAdressAll let tipmessage = _that.currentLanguage == 'zh' ? `請前往支付<span style="color:red;">續租費${res.data.bnb} BNB(包含GAS費:${res.data.gasfee} BNB)</span>` : `Please go to pay the <span style="color:red;">renewal fee ${res.data.bnb} BNB (including GAS fee: ${res.data.gasfee} BNB)</span>`;
}, _that.$confirm(tipmessage, tip, {
headers:{ confirmButtonText: confirm,
token: _that.userInfos.token cancelButtonText: cancel,
}, dangerouslyUseHTMLString: true
success(res) { }).then(() => {
if (res.code === 1) { let tipMessage1 = _that.currentLanguage == 'zh' ? '交易中,請勿刷新頁面...' : 'During the transaction, please do not refresh the page';
let tipmessage = _that.currentLanguage == 'zh' ? `請前往支付<span style="color:red;">續租費${res.data.bnb} BNB(包含GAS費:${res.data.gasfee} BNB)</span>` : `Please go to pay the <span style="color:red;">renewal fee ${res.data.bnb} BNB (including GAS fee: ${res.data.gasfee} BNB)</span>`; _that.orderLoading = _that.$loading({ lock: true, text: tipMessage1, spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)' });
_that.$confirm(tipmessage, tip, { _that.websentMoney(res.data,'renewal');
confirmButtonText: confirm, }).catch(() => {
cancelButtonText: cancel, _that.$message("Failed");
dangerouslyUseHTMLString: true });
}).then(() => { } else {
let tipMessage1 = _that.currentLanguage == 'zh' ? '交易中,請勿刷新頁面...' : 'During the transaction, please do not refresh the page'; _that.$message.error(res.msg)
_that.orderLoading = _that.$loading({ lock: true, text: tipMessage1, spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)' }); }
_that.websentMoney(res.data,'renewal');
}).catch(() => {
_that.$message("Failed");
});
} else {
_that.$message.error(res.msg)
}
},
error(err) {
_that.$message.error(err)
}
});
}, },
submitNft() { submitNft() {
let _that = this; let _that = this;
@ -763,7 +751,7 @@
_that.creatOrder() _that.creatOrder()
}, },
//創建交易訂單 //創建交易訂單
creatOrder(){ async creatOrder(){
let tip = this.currentLanguage == 'zh' ? '提示' : 'tips'; let tip = this.currentLanguage == 'zh' ? '提示' : 'tips';
let confirm = this.currentLanguage == 'zh' ? '確定' : 'confirm'; let confirm = this.currentLanguage == 'zh' ? '確定' : 'confirm';
let cancel = this.currentLanguage == 'zh' ? '取消' : 'cancel'; let cancel = this.currentLanguage == 'zh' ? '取消' : 'cancel';
@ -787,36 +775,24 @@
} }
apiUrl = "api/project/sale" apiUrl = "api/project/sale"
} }
$.ajax({ let res = await publikRequesFunction(apiUrl,'post',params);
url: baseUrl + apiUrl, if (res.code === 1) {
type: "post", let tipmessage = _that.currentLanguage == 'zh' ? `請前往支付<span style="color:red;">版權費(${res.data.salefee} BNB)</span><br>和墊付<span style="color:red;">GAS費(${res.data.gasfee} BNB)</span>` : `Please go to pay the <span style="color:red;">copyright fee (${res.data.salefee} BNB)</span><br> and advance the <span style="color:red;">GAS fee (${res.data.gasfee} BNB)</span>`;
data: params, _that.$confirm(tipmessage, tip, {
headers: { confirmButtonText: confirm,
token: _that.userInfos.token cancelButtonText: cancel,
}, dangerouslyUseHTMLString: true
success(res) { }).then(() => {
if (res.code === 1) { _that.dialogVisible = false;
let tipmessage = _that.currentLanguage == 'zh' ? `請前往支付<span style="color:red;">版權費(${res.data.salefee} BNB)</span><br>和墊付<span style="color:red;">GAS費(${res.data.gasfee} BNB)</span>` : `Please go to pay the <span style="color:red;">copyright fee (${res.data.salefee} BNB)</span><br> and advance the <span style="color:red;">GAS fee (${res.data.gasfee} BNB)</span>`; let tipMessage = _that.currentLanguage == 'zh' ? '交易中,請勿刷新頁面...' : 'During the transaction, please do not refresh the page';
_that.$confirm(tipmessage, tip, { _that.orderLoading = _that.$loading({ lock: true, text: tipMessage, spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)' });
confirmButtonText: confirm, _that.websentMoney(res.data);
cancelButtonText: cancel, }).catch(() => {
dangerouslyUseHTMLString: true _that.$message("Failed");
}).then(() => { });
_that.dialogVisible = false; } else {
let tipMessage = _that.currentLanguage == 'zh' ? '交易中,請勿刷新頁面...' : 'During the transaction, please do not refresh the page'; _that.$message.error(res.msg)
_that.orderLoading = _that.$loading({ lock: true, text: tipMessage, spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)' }); }
_that.websentMoney(res.data);
}).catch(() => {
_that.$message("Failed");
});
} else {
_that.$message.error(res.msg)
}
},
error(err) {
_that.$message.error(err)
}
});
}, },
//發起版權費+GAS費支付 //發起版權費+GAS費支付
async websentMoney(item,renewalTxt) { async websentMoney(item,renewalTxt) {
@ -859,34 +835,22 @@
} }
}, },
//支付完成提交hash //支付完成提交hash
submitHash(id,tx,renewalTxt){ async submitHash(id,tx,renewalTxt){
let _that = this; let _that = this;
let apiURL = ""; let apiURL = "";
renewalTxt == 'renewal' ? apiURL = 'api/common/payresult' : _that.isLease ? apiURL = "api/project/payedleaseorder" : apiURL = "api/project/payedsaleorder" renewalTxt == 'renewal' ? apiURL = 'api/common/payresult' : _that.isLease ? apiURL = "api/project/payedleaseorder" : apiURL = "api/project/payedsaleorder"
try { try {
$.ajax({ let res = await publikRequesFunction(apiURL,'post',{id,tx});
url: baseUrl + apiURL, if (res.code === 1) {
type: "post", _that.$message.success('success');
data: {id,tx}, _that.orderLoading.close();
headers: { setTimeout(()=>{
token: _that.userInfos.token _that.loadData();
}, },1000)
success(res){ } else {
if (res.code === 1) { _that.$message.error(err)
_that.$message.success('success'); _that.orderLoading.close();
_that.orderLoading.close(); }
setTimeout(()=>{
_that.loadData();
},1000)
} else {
_that.$message.error(err)
_that.orderLoading.close();
}
},
error(err) {
_that.$message.error(err)
}
})
} catch (error) { } catch (error) {
_that.$message.error(error) _that.$message.error(error)
_that.orderLoading.close(); _that.orderLoading.close();
@ -1015,45 +979,38 @@
maskString(str) { maskString(str) {
return str.replace(/^(.{3})(.*)(.{3})$/, function (match, p1, p2, p3) { return p1 + '*'.repeat(p2.length / 2) + p3; }); return str.replace(/^(.{3})(.*)(.{3})$/, function (match, p1, p2, p3) { return p1 + '*'.repeat(p2.length / 2) + p3; });
}, },
loadTopType() { async loadTopType() {
axios.get(baseUrl + '/api/project/gettype', { let res = await publikRequesFunction('api/project/gettype','get',{});
headers: { if(res.code === 1){
token: this.userInfos.token, this.nfttypeList = res.data;
},
}).then(res => {
this.nfttypeList = res.data.data;
this.typeactive = this.nfttypeList[0].id this.typeactive = this.nfttypeList[0].id
this.getnfttypeList() this.getnfttypeList()
}) }
}, },
// 獲取分類 // 獲取分類
getnfttypeList() { async getnfttypeList() {
let _that = this;
this.attrCurrent = [] this.attrCurrent = []
axios.get(baseUrl + '/api/project/gettpllist?typeid=' + this.typeactive + '&showown=1&listrow=500', { let res = await publikRequesFunction('api/project/gettpllist','get',{
headers: { typeid:this.typeactive,showown:1,listrow:500
token: this.userInfos.token, });
}, if(res.code === 1){
}).then(res => { this.attributeList = res.data.data
this.attributeList = res.data.data.data if (_that.attributeList.filter(item => { return item.own > 0 }).length > 0) {
_that.loadData()
if (this.attributeList.filter(item => { return item.own > 0 }).length > 0) {
this.loadData()
} else { } else {
this.attrCurrent = [] this.attrCurrent = []
this.nftList = [] this.nftList = []
this.total = 0 this.total = 0
} }
}) }
.catch(err => {
// console.log(err);
})
}, },
cheangetypeact(tplid) { cheangetypeact(tplid) {
if (tplid == this.typeactive) { return } if (tplid == this.typeactive) { return }
this.typeactive = tplid this.typeactive = tplid
this.getnfttypeList() this.getnfttypeList()
}, },
loadData() { async loadData() {
this.showGoodClass = false this.showGoodClass = false
const loading = this.$loading({ const loading = this.$loading({
lock: true, lock: true,
@ -1067,25 +1024,14 @@
params.tplid = this.attrCurrent.length > 1 ? this.attrCurrent.join(',') : this.attrCurrent[0] params.tplid = this.attrCurrent.length > 1 ? this.attrCurrent.join(',') : this.attrCurrent[0]
params.typeid = 0 params.typeid = 0
} }
axios.get(baseUrl + '/api/user/mynftlist', { let res = await publikRequesFunction('api/user/mynftlist','get',params);
params, loading.close()
headers: { if (res.code == 1) {
token: token, this.total = res.data.total
}, this.nftList = res.data.data
}) } else {
.then(({ data: res }) => { this.$message(res.msg)
loading.close() }
if (res.code == 1) {
this.total = res.data.total
this.nftList = res.data.data
} else {
this.$message(res.msg)
}
})
.catch(err => {
loading.close()
this.$message(err.response.data.msg)
})
}, },
//分頁 //分頁
handlePageChange(page) { handlePageChange(page) {
@ -1139,24 +1085,14 @@
confirmButtonText: confirm, confirmButtonText: confirm,
cancelButtonText: cancel, cancelButtonText: cancel,
type: 'warning' type: 'warning'
}).then(() => { }).then(async () => {
$.ajax({ let res = await publikRequesFunction(apiSelect,'post',{id});
url: baseUrl + apiSelect, if(res.code === 1){
type: 'post', _that.$message.success("success");
data: {id}, setTimeout(()=>{
headers:{token: _that.userInfos.token}, _that.loadData()
success(res){ },1000)
if(res.code === 1){ }
_that.$message.success("success");
setTimeout(()=>{
_that.loadData()
},1000)
}
},
error(error){
_that.$message.error("error");
}
});
}).catch(() => { }).catch(() => {
_that.$message("Failed"); _that.$message("Failed");
}); });

View File

@ -690,9 +690,9 @@
}, },
async getuserInfos(){ async getuserInfos(){
if(!this.userInfos?.token){return} if(!this.userInfos?.token){return}
let res = await axios.post(baseUrl+'api/user/index',{},{headers:{token:this.userInfos?.token}}); let res = await publikRequesFunction('api/user/index','post',{});
if(res.data.code == 1){ if(res.code == 1){
this.userInfos = res.data.data.userinfo; this.userInfos = res.data.userinfo;
this.getonrules(); this.getonrules();
} }
}, },
@ -704,9 +704,9 @@
spinner: 'el-icon-loading', spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)' background: 'rgba(0, 0, 0, 0.7)'
}); });
let res = await axios.get(baseUrl+'api/user/getlogs?type='+this.ifications+'&page='+this.page,{ headers:{token:this.userInfos.token}}); let res = await publikRequesFunction('api/user/getlogs','get',{type:this.ifications,page:this.page});
if(res.data.code == 1){ if(res.code == 1){
this.rewardRules = res.data.data; this.rewardRules = res.data;
} }
loading.close() loading.close()
}, },

View File

@ -17,7 +17,10 @@ if (userInfo) {
document.getElementById('isshouother').style.display = 'none'; document.getElementById('isshouother').style.display = 'none';
} }
if(!userInfo && window.location.pathname != '/login.html' && window.location.pathname != '/signup.html'){ let nowPath = window.location.pathname;
console.log(nowPath,'当前路径');
if(!userInfo && !nowPath.includes('login.html') && !nowPath.includes('signup.html')){
let language = window.localStorage.getItem("languageNow"); let language = window.localStorage.getItem("languageNow");
let message = language == 'zh' ? '請先登入或註冊' : 'Please log in or register first'; let message = language == 'zh' ? '請先登入或註冊' : 'Please log in or register first';
const html ="<div id='customizeBox' class='customize-message-box'><p>" + message + "</p></div>" const html ="<div id='customizeBox' class='customize-message-box'><p>" + message + "</p></div>"
@ -34,6 +37,40 @@ baseUrl = "https://demo.samsaradao.com/"
if(window.location.host === 'www.samsaradao.com'){ if(window.location.host === 'www.samsaradao.com'){
baseUrl = "https://www.samsaradao.com/" baseUrl = "https://www.samsaradao.com/"
} }
function publikRequesFunction(api,type,params){
return new Promise((resolve, reject) => {
$.ajax({
url:baseUrl + api,
type: type,
dataType: "json",
headers:{
token: JSON.parse(window.localStorage.getItem("userInfo")).token,
},
data: params,
success(res) {
resolve(res)
if(res.code === 401){
window.localStorage.clear();
window.location.href = 'login.html'
}else{
resolve(res)
}
},
error(rej){
console.log(rej,'错误请求');
if(rej.status === 401){
window.localStorage.clear();
window.location.href = 'login.html'
}else{
reject("failed")
}
}
});
})
}
function signOutPage(){ function signOutPage(){
$.ajax({ $.ajax({
url:baseUrl+"api/user/logout", url:baseUrl+"api/user/logout",

View File

@ -833,35 +833,22 @@
window.location.href = "all-order.html"; window.location.href = "all-order.html";
} }
}, },
submitPurchFeeHash(wtbid,tx){ async submitPurchFeeHash(wtbid,tx){
let _that = this; let _that = this;
try { try {
$.ajax({ let res = await publikRequesFunction('api/project/wtbrevpayres','post',{wtbid,tx});
url: `${baseUrl}api/project/wtbrevpayres`, if (res.code === 1) {
type: "post", _that.orderLoading.close();
data: {wtbid,tx}, let resultMsg = _that.currentLanguage == 'zh' ? '交易成功' : 'Successful transaction';
headers: { _that.$message.success(resultMsg);
token: _that.userInfos.token setTimeout(()=>{
},
success(res){
if (res.code === 1) {
_that.orderLoading.close();
let resultMsg = _that.currentLanguage == 'zh' ? '交易成功' : 'Successful transaction';
_that.$message.success(resultMsg);
setTimeout(()=>{
window.location.href = "all-order.html";
},1500)
} else {
_that.$message.error(err)
_that.orderLoading.close();
window.location.href = "all-order.html";
}
},
error(err) {
_that.$message.error(err)
window.location.href = "all-order.html"; window.location.href = "all-order.html";
} },1500)
}) } else {
_that.$message.error(err)
_that.orderLoading.close();
window.location.href = "all-order.html";
}
} catch (error) { } catch (error) {
_that.$message.error(error) _that.$message.error(error)
_that.orderLoading.close(); _that.orderLoading.close();
@ -870,25 +857,16 @@
//判断是否有相应的NFT //判断是否有相应的NFT
isHaveNft(){ isHaveNft(){
let _that = this; let _that = this;
return new Promise((resolve, reject) => { return new Promise(async (resolve, reject) => {
$.ajax({ let res = await publikRequesFunction('api/project/wtbsend','post',{
url:`${baseUrl}api/project/wtbsend`, wtbid: _that.nowPurchOrderObj.id,
headers:{token: _that.userInfos.token}, saleaddress: _that.receivAdress
data:{
wtbid: _that.nowPurchOrderObj.id,
saleaddress: _that.receivAdress
},
success(res){
if(res.code === 1){
resolve(res.data)
}else{
resolve(res.msg)
}
},
error(xhr,status,error){
reject(error)
}
}); });
if(res.code === 1){
resolve(res.data)
}else{
resolve(res.msg)
}
}) })
}, },
expirationTimeOp(timestamp){ expirationTimeOp(timestamp){
@ -907,30 +885,19 @@
this.purchSearchObj.page = val; this.purchSearchObj.page = val;
this.getPurchasList(); this.getPurchasList();
}, },
getPurchasList(){ async getPurchasList(){
let _that = this; let _that = this;
_that.orderLoading = _that.$loading({ lock: true, text: 'loading', spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)' }); _that.orderLoading = _that.$loading({ lock: true, text: 'loading', spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)' });
$.ajax({ let res = await publikRequesFunction('api/project/getwtblist','get',{
url: `${baseUrl}api/project/getwtblist`, tid: _that.buySelectEqObj.id,
headers:{ ..._that.purchSearchObj
token: _that.userInfos.token
},
data:{
tid: _that.buySelectEqObj.id,
..._that.purchSearchObj
},
success(res){
if(res.code === 1){
_that.purchTableData = res.data;
_that.orderLoading.close();
}
},
error(err){
console.log(err);
}
}); });
if(res.code === 1){
_that.purchTableData = res.data;
_that.orderLoading.close();
}
}, },
purchaseRequest(){ async purchaseRequest(){
let _that = this; let _that = this;
if(!_that.purchPrice || !_that.setimeCycle){ if(!_that.purchPrice || !_that.setimeCycle){
let inputVality = _that.currentLanguage == 'zh' ? '請輸入完整訊息' : 'Please enter complete information'; let inputVality = _that.currentLanguage == 'zh' ? '請輸入完整訊息' : 'Please enter complete information';
@ -948,39 +915,28 @@
},1000) },1000)
return return
} }
$.ajax({ let res = await publikRequesFunction('api/project/wtbuy','post',{
url: `${baseUrl}api/project/wtbuy`, tid: _that.buySelectEqObj.id,
headers:{ bnb: _that.purchPrice,
token: _that.userInfos.token vaildtime: _that.setimeCycle
},
data:{
tid: _that.buySelectEqObj.id,
bnb: _that.purchPrice,
vaildtime: _that.setimeCycle
},
success(res){
if(res.code === 1){
let tipmessage = _that.currentLanguage == 'zh' ? `請前往支付求購費(${res.data.bnb} BNB)和GAS費(${res.data.gas} BNB)` : `Please go to pay the purchase fee ${res.data.bnb} and the GAS fee ${res.data.gas} BNB`;
_that.$confirm(tipmessage, tip, {
confirmButtonText: confirm,
cancelButtonText: cancel,
type: 'warning'
}).then(() => {
_that.chuDialogVisible = false;
let tipMessage = _that.currentLanguage == 'zh' ? '交易中,請勿刷新頁面...' : 'During the transaction, please do not refresh the page';
_that.orderLoading = _that.$loading({ lock: true, text: tipMessage, spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)' });
_that.payPurchPrice(res.data);
}).catch(() => {
_that.$message("Failed");
});
}else{
_that.$message.error('fail')
}
},
error(err){
console.log(err);
}
}); });
if(res.code === 1){
let tipmessage = _that.currentLanguage == 'zh' ? `請前往支付求購費(${res.data.bnb} BNB)和GAS費(${res.data.gas} BNB)` : `Please go to pay the purchase fee ${res.data.bnb} and the GAS fee ${res.data.gas} BNB`;
_that.$confirm(tipmessage, tip, {
confirmButtonText: confirm,
cancelButtonText: cancel,
type: 'warning'
}).then(() => {
_that.chuDialogVisible = false;
let tipMessage = _that.currentLanguage == 'zh' ? '交易中,請勿刷新頁面...' : 'During the transaction, please do not refresh the page';
_that.orderLoading = _that.$loading({ lock: true, text: tipMessage, spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)' });
_that.payPurchPrice(res.data);
}).catch(() => {
_that.$message("Failed");
});
}else{
_that.$message.error('fail')
}
}, },
async payPurchPrice(item){ async payPurchPrice(item){
let _that = this; let _that = this;
@ -1023,35 +979,23 @@
this.orderLoading.close(); this.orderLoading.close();
} }
}, },
submitPurchHash(id,tx,fromaddress){ async submitPurchHash(id,tx,fromaddress){
console.log('交易ID',id,'交易hash',tx); console.log('交易ID',id,'交易hash',tx);
let _that = this; let _that = this;
try { try {
$.ajax({ let res = await publikRequesFunction('api/project/wtbres','post',{id,tx,fromaddress});
url: `${baseUrl}api/project/wtbres`, if (res.code === 1) {
type: "post", _that.orderLoading.close();
data: {id,tx,fromaddress}, let resultMsg = _that.currentLanguage == 'zh' ? '發布求購成功' : 'Published purchase successfully';
headers: { _that.$message.success(resultMsg);
token: _that.userInfos.token _that.purchPrice = "";
}, setTimeout(()=>{
success(res){ _that.getPurchasList();
if (res.code === 1) { },1000)
_that.orderLoading.close(); } else {
let resultMsg = _that.currentLanguage == 'zh' ? '發布求購成功' : 'Published purchase successfully';
_that.$message.success(resultMsg);
_that.purchPrice = "";
setTimeout(()=>{
_that.getPurchasList();
},1000)
} else {
_that.$message.error(err)
_that.orderLoading.close();
}
},
error(err) {
_that.$message.error(err) _that.$message.error(err)
_that.orderLoading.close();
} }
})
} catch (error) { } catch (error) {
_that.$message.error(error) _that.$message.error(error)
_that.orderLoading.close(); _that.orderLoading.close();
@ -1063,7 +1007,7 @@
this.buySelectEqObj = {...item}; this.buySelectEqObj = {...item};
this.getPurchasList(); this.getPurchasList();
}, },
getNftList(){ async getNftList(){
let _that = this; let _that = this;
let sort = ""; let sort = "";
let desc = ""; let desc = "";
@ -1073,66 +1017,42 @@
let keywords_cn = ""; let keywords_cn = "";
let keywords_en = ""; let keywords_en = "";
this.currentLanguage == 'zh' ? keywords_cn = this.searchNft : keywords_en = this.searchNft this.currentLanguage == 'zh' ? keywords_cn = this.searchNft : keywords_en = this.searchNft
$.ajax({ let res = await publikRequesFunction('api/project/getenbuynftlist','get',{
url:`${baseUrl}api/project/getenbuynftlist`, keywords_cn,
type:'get', keywords_en,
data:{ typeid: _that.nownftId,//分類ID
keywords_cn, page: _that.searchObj.page,
keywords_en, listrow: _that.searchObj.pageSize,
typeid: _that.nownftId,//分類ID tplid: _that.selectEqType,
page: _that.searchObj.page, sort,//排序發佈時間time 價格fee
listrow: _that.searchObj.pageSize, desc//true倒序 false正序
tplid: _that.selectEqType,
sort,//排序發佈時間time 價格fee
desc//true倒序 false正序
},
headers:{
token: _that.userInfos.token
},
success(res){
if(res.code === 1){
_that.topnftInfos = res.data.baseinfo;
_that.transactionList = res.data.list;
_that.orderLoading.close();
}
},
error(err){
console.log(err);
}
}); });
if(res.code === 1){
_that.topnftInfos = res.data.baseinfo;
_that.transactionList = res.data.list;
_that.orderLoading.close();
}
}, },
getLeaseNftList(){ async getLeaseNftList(){
let _that = this; let _that = this;
this.orderLoading = _that.$loading({ lock: true, text: 'loading', spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)' }); this.orderLoading = _that.$loading({ lock: true, text: 'loading', spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)' });
let keywords_cn = ""; let keywords_cn = "";
let keywords_en = ""; let keywords_en = "";
this.currentLanguage == 'zh' ? keywords_cn = this.searchNft : keywords_en = this.searchNft this.currentLanguage == 'zh' ? keywords_cn = this.searchNft : keywords_en = this.searchNft
$.ajax({ let res = await publikRequesFunction('api/project/getenleasenftlist','get',{
url:`${baseUrl}api/project/getenleasenftlist`, keywords_cn,
type:'get', keywords_en,
data:{ typeid: _that.nownftId,
keywords_cn, page: _that.searchObj.page,
keywords_en, listrow: _that.searchObj.pageSize,
typeid: _that.nownftId, tplid: _that.selectEqType,
page: _that.searchObj.page, sort:"",
listrow: _that.searchObj.pageSize, desc: true
tplid: _that.selectEqType,
sort:"",
desc: true
},
headers:{
token: _that.userInfos.token
},
success(res){
if(res.code === 1){
_that.leaseNftData = res.data.list;
_that.orderLoading.close();
}
},
error(err){
console.log(err);
}
}); });
if(res.code === 1){
_that.leaseNftData = res.data.list;
_that.orderLoading.close();
}
}, },
searchEqListLease(id){ searchEqListLease(id){
this.selectEqType = id; this.selectEqType = id;
@ -1142,25 +1062,18 @@
this.selectEqType = id; this.selectEqType = id;
this.getNftList(); this.getNftList();
}, },
getnftTypeList(){ async getnftTypeList(){
let _that = this; let _that = this;
$.ajax({ let res = await publikRequesFunction('api/project/gettpllist','get',{
url:`${baseUrl}api/project/gettpllist?typeid=${this.nownftId}&showown=&listrow=9999`, typeid:this.nownftId,
type:'get', showown:1,
headers:{ listrow:9999
token: _that.userInfos.token
},
success(res){
if(res.code === 1){
_that.equipmentType = res.data.data;
_that.buySelectEqType = _that.equipmentType[0].id;
_that.buySelectEqObj = _that.equipmentType[0];
}
},
error(err){
console.log(err);
}
}); });
if(res.code === 1){
_that.equipmentType = res.data.data;
_that.buySelectEqType = _that.equipmentType[0].id;
_that.buySelectEqObj = _that.equipmentType[0];
}
}, },
toNftDetail(){ toNftDetail(){
window.location.href = "nft-detail.html"; window.location.href = "nft-detail.html";
@ -1180,34 +1093,22 @@
} }
this.creatOrder(); this.creatOrder();
}, },
creatOrder(){ async creatOrder(){
let _that = this; let _that = this;
let apiString = ""; let apiString = "";
_that.activeName == 'first' ? apiString = 'api/project/buynft' : apiString = 'api/project/leasenft' _that.activeName == 'first' ? apiString = 'api/project/buynft' : apiString = 'api/project/leasenft'
$.ajax({ let res = await publikRequesFunction(apiString,'post',{
url: baseUrl + apiString, id: _that.paynftObj.id,
type: "post", fromaddress:_that.userMoneyAdressAll
data: { });
id: _that.paynftObj.id, if (res.code === 1) {
fromaddress:_that.userMoneyAdressAll _that.payNFTDialog = false;
}, let tipMessage = _that.currentLanguage == 'zh' ? '交易中,請勿刷新頁面...' : 'During the transaction, please do not refresh the page';
headers:{ _that.orderLoading = _that.$loading({ lock: true, text: tipMessage, spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)' });
token: _that.userInfos.token _that.websentMoney(res.data);
}, } else {
success(res) { _that.$message.error(res.msg)
if (res.code === 1) { }
_that.payNFTDialog = false;
let tipMessage = _that.currentLanguage == 'zh' ? '交易中,請勿刷新頁面...' : 'During the transaction, please do not refresh the page';
_that.orderLoading = _that.$loading({ lock: true, text: tipMessage, spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)' });
_that.websentMoney(res.data);
} else {
_that.$message.error(res.msg)
}
},
error(err) {
_that.$message.error(err)
}
});
}, },
async websentMoney(item) { async websentMoney(item) {
let _that = this; let _that = this;
@ -1250,35 +1151,21 @@
this.orderLoading.close(); this.orderLoading.close();
} }
}, },
submitHash(id,tx){ async submitHash(id,tx){
let _that = this; let _that = this;
let apiString = ""; let apiString = "";
// _that.activeName == 'first' ? apiString = 'api/common/payresult' : ''
try { try {
$.ajax({ let res = await publikRequesFunction('api/common/payresult','post',{id,tx});
// url: baseUrl + apiString, if (res.code === 1) {
url:`${baseUrl}api/common/payresult`, _that.$message.success('success');
type: "post", _that.orderLoading.close();
data: {id,tx}, setTimeout(()=>{
headers: { _that.activeName == 'first' ? _that.getNftList() : _that.getLeaseNftList()
token: _that.userInfos.token },1000)
}, } else {
success(res){ _that.$message.error(err)
if (res.code === 1) { _that.orderLoading.close();
_that.$message.success('success'); }
_that.orderLoading.close();
setTimeout(()=>{
_that.activeName == 'first' ? _that.getNftList() : _that.getLeaseNftList()
},1000)
} else {
_that.$message.error(err)
_that.orderLoading.close();
}
},
error(err) {
_that.$message.error(err)
}
})
} catch (error) { } catch (error) {
_that.$message.error(error) _that.$message.error(error)
_that.orderLoading.close(); _that.orderLoading.close();

View File

@ -302,31 +302,21 @@
this.getRecentNftList(); this.getRecentNftList();
}, },
methods: { methods: {
getRecentNftList(){ async getRecentNftList(){
let _that = this; let _that = this;
$.ajax({ let res = await publikRequesFunction('api/project/getnftlist','get',{page:1,listrow:5});
url:`${baseUrl}api/project/getnftlist`, if(res.code === 1){
type:"get", _that.recentNftData = res.data.data;
data:{page:1,listrow:5}, }else{
headers:{token:_that.userInfoObj.token}, console.log(err);
success(res){ }
if(res.code === 1){
_that.recentNftData = res.data.data;
}else{
console.log(err);
}
},
error(err){
console.log(err);
}
});
}, },
searchTimeOption(n){ searchTimeOption(n){
const currentTimestamp = Date.now(); const currentTimestamp = Date.now();
const timestampAgo = currentTimestamp - n * 24 * 60 * 60 * 1000; const timestampAgo = currentTimestamp - n * 24 * 60 * 60 * 1000;
return timestampAgo return timestampAgo
}, },
getNfttype(){ async getNfttype(){
let starttime = ""; let starttime = "";
let endtime = ""; let endtime = "";
if(this.popularRadio != 'all'){ if(this.popularRadio != 'all'){
@ -338,24 +328,15 @@
} }
this.orderLoading = this.$loading({ lock: true, text: 'loading...', spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)' }); this.orderLoading = this.$loading({ lock: true, text: 'loading...', spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)' });
let _that = this; let _that = this;
$.ajax({ let res = await publikRequesFunction('api/project/gettype','get',{
url:`${baseUrl}api/project/gettype`, showown:"",
type:"get", starttime,
data:{ endtime,
showown:"",
starttime,
endtime,
},
success(res){
if(res.code === 1){
_that.tableData = res.data;
_that.orderLoading.close();
}
},
error(err){
console.log(err);
}
}); });
if(res.code === 1){
_that.tableData = res.data;
_that.orderLoading.close();
}
}, },
toNftDetail(id,typeId){ toNftDetail(id,typeId){
window.location.href = `trading-detail.html?id=${id}&typeId=${typeId}`; window.location.href = `trading-detail.html?id=${id}&typeId=${typeId}`;