From 009da9d9856af513dbdec0c223929527c4263f09 Mon Sep 17 00:00:00 2001 From: hxhxhx <2357034401@qq.com> Date: Wed, 7 May 2025 13:42:14 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=B7=E6=B1=82401=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- about.html | 9 +- all-order.html | 71 +++----- contact.html | 34 ++-- game-detail.html | 7 +- index.html | 137 ++++++--------- mechanism.html | 6 +- news-detail.html | 10 +- news.html | 20 +-- nft.html | 232 ++++++++++---------------- profile.html | 12 +- static/js/getIsUser.js | 39 ++++- trading-detail.html | 369 ++++++++++++++--------------------------- trading.html | 51 ++---- 13 files changed, 377 insertions(+), 620 deletions(-) diff --git a/about.html b/about.html index 50165f5..753f516 100644 --- a/about.html +++ b/about.html @@ -390,12 +390,13 @@ this.nowteaminfos = this.aboutObj.teamlist[index]; }, async getAbouts(){ - let res = await axios.get(baseUrl+'api/index/about'); - if (res.data.code === 1) { - this.aboutObj = res.data.data; + let res = await publikRequesFunction('api/index/about','get',{}); + console.log(res,'nowRequest'); + if (res.code === 1) { + this.aboutObj = res.data; this.nowteaminfos = this.aboutObj.teamlist[0]; } - } + } } }) diff --git a/all-order.html b/all-order.html index aab2d0a..c9dfb42 100644 --- a/all-order.html +++ b/all-order.html @@ -330,32 +330,21 @@ // 返回格式化后的日期字符串 return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; }, - getallorderList(){ + async getallorderList(){ this.tableLoading = true; let _that = this; - $.ajax({ - url: `${baseUrl}api/project/getorderlist`, - type: "get", - data: { - ..._that.orderSearchObj, - trade: _that.timeFilter, - state: _that.activeTab - }, - headers: { - token: _that.userInfoObj.token - }, - 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) - } - }) + const params = { + ..._that.orderSearchObj, + trade: _that.timeFilter, + state: _that.activeTab + }; + let res = await publikRequesFunction('api/project/getorderlist','get',params); + if (res.code === 1) { + _that.orderListObj = res.data; + _that.tableLoading = false; + } else { + _that.$message.error(res.msg) + } }, changeTab(tab) { this.activeTab = tab; @@ -448,7 +437,7 @@ this.orderLoading.close(); } }, - submitOrderHash(id,tx){ + async submitOrderHash(id,tx){ //求购卖出支付结果api/project/wtbrevpayres //买入支付结果api/common/payresult let api = ""; @@ -462,28 +451,16 @@ obj = { wtbid: id,tx } } try { - $.ajax({ - url: `${baseUrl + api}`, - type: "post", - data: {...obj}, - headers: { - token: _that.userInfoObj.token - }, - success(res){ - if (res.code === 1) { - _that.$message.success('success'); - _that.orderLoading.close(); - setTimeout(()=>{ - _that.getallorderList(); - },1000); - } else { - _that.$message.error(res.msg) - } - }, - error(err) { - _that.$message.error(err) - } - }) + let res = await publikRequesFunction(api,'post',obj); + if (res.code === 1) { + _that.$message.success('success'); + _that.orderLoading.close(); + setTimeout(()=>{ + _that.getallorderList(); + },1000); + } else { + _that.$message.error(res.msg) + } } catch (error) { _that.$message.error(error) } diff --git a/contact.html b/contact.html index 8d3d8f7..1c9188c 100644 --- a/contact.html +++ b/contact.html @@ -293,7 +293,7 @@ }); }, methods:{ - sendContact(){ + async sendContact(){ let _that = this; let tipMessage = this.currentLanguage == 'zh' ? '請輸入完整信息' : "Please enter complete information"; if(!this.firstName || !this.secondName || !this.contactObj.email || !this.contactObj.contact){ @@ -301,29 +301,15 @@ return } this.contactObj.name = this.firstName + this.secondName; - $.ajax({ - url:`${baseUrl}api/common/contactus`, - data:{ - ..._that.contactObj - }, - headers:{ - token: this.userToken - }, - 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"); - } - }); + let res = await publikRequesFunction('api/common/contactus','post',{..._that.contactObj}); + if(res.code === 1){ + _that.firstName = ""; + _that.secondName = ""; + _that.contactObj = {}; + _that.$message.success("success"); + }else{ + _that.$message.error("failed"); + } }, // <-- -------------------------錢包登錄開始 ---------------------------> copyText(txt){ diff --git a/game-detail.html b/game-detail.html index c439485..4199b2b 100644 --- a/game-detail.html +++ b/game-detail.html @@ -271,7 +271,6 @@ if (user) { this.userIsLogin = true; } - this.getgamesInfo(); // 钱包登录开始 const provider = window.web3?.currentProvider; let accounts1 = []; @@ -404,9 +403,9 @@ this.currentLanguage = mobileLang() }, async getgamesInfo(){ - let res = await axios.get(baseUrl+"api/index/gameinfo"); - if(res.data.code == 1){ - this.gamesinfomation = res.data.data; + let res = await publikRequesFunction('api/index/gameinfo','get',{}); + if(res.code == 1){ + this.gamesinfomation = res.data; } }, } diff --git a/index.html b/index.html index 20ebf00..5fafeb1 100644 --- a/index.html +++ b/index.html @@ -573,7 +573,6 @@ downloadObj: {}, pageIngomation: [], videoList: [], - categoriesTabList: [], outlookList: [], saleList: [],//限時商品列表 times: { @@ -609,7 +608,6 @@ } this.getDownload(); this.getgamesVideo(); - this.getCategoriestable(); this.getOutlook(); this.loadCloseAuth() this.loadSaleList(); @@ -764,21 +762,11 @@ mobileLang() { this.currentLanguage = mobileLang() }, - getRoleList() { - let _that = this; - $.ajax({ - url: baseUrl+"api/index/getrole", - type: 'get', - dataType: "json", - success(res) { - if (res.code === 1) { - _that.roleList = res.data; - } - }, - error(rej) { - console.log("failed"); - } - }) + async getRoleList() { + let res = await publikRequesFunction('api/index/getrole','get',{}); + if (res.code === 1) { + this.roleList = res.data; + } }, //新聞詳情 toNewDetail() { @@ -826,13 +814,8 @@ // this.$message.success('success'); }, async orderPayResult(id, tx) { - let res = await axios.post(baseUrl+'api/common/payresult', { id, tx }, { headers: { 'token': this.token, 'Content-Type': 'application/json' } }); - if (res.data.code === 1) { - // if (this.orderList[this.orderList.length - 1].id == id) { - // this.orderLoading.close(); - // } - } else { - // this.orderLoading.close(); + let res = await publikRequesFunction('api/common/payresult','post',{id, tx}); + if (res.code != 1) { this.$message.error('error'); } }, @@ -845,28 +828,21 @@ } this.buy.fromaddress = this.userMoneyAdressAll; 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 axios.post(baseUrl+'api/project/createpurchaseorder', { ...this.buy }, { - headers: { - 'token': this.token, // 使用 Bearer 認證方式攜帶 Token - 'Content-Type': 'application/json' // 確保發送 JSON 格式的數據 - } - }) + let res = await publikRequesFunction('api/project/createpurchaseorder','post',{...this.buy}); console.log(res, '订单'); - if (res.data.code === 1) { - this.orderList = res.data.data; + if (res.code === 1) { + this.orderList = res.data; this.buyButtonVisible = false; this.websentMoney(); } else { - this.$message.error(res.data.msg); - // this.orderLoading.close(); + this.$message.error(res.msg); } }, //獲取限時折購商品 async loadSaleList() { - let res = await axios.get(`${baseUrl}api/index/getpurchase`); - if (res.data.code === 1) { - this.saleList = res.data.data; + let res = await publikRequesFunction('api/index/getpurchase','get',{}); + if (res.code === 1) { + this.saleList = res.data; this.isShowSale = this.saleList.length > 0 setInterval(() => { if (this.currentSaleIndex === this.saleList.length - 1) { @@ -885,58 +861,40 @@ window.location.href = 'login.html' }, async getOutlook() { - let res = await axios.get(`${baseUrl}api/index/getlist? - cateid=4& - keywordsen=& - keywordscn=& - page=1& - listrow=5& - `); - if (res.data.code === 1) { - this.outlookList = res.data.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; + let res = await publikRequesFunction('api/index/getlist','get',{ + cateid:4, + keywordsen:"", + keywordscn:"", + page:1, + listrow:5, + }); + if (res.code === 1) { + this.outlookList = res.data.data; } }, async getgamesVideo() { - let res = await axios.get(baseUrl+'api/index/getmedia?page=1&listrow=8'); - if (res.data.code === 1) { - this.videoList = res.data.data.data; - console.log(this.videoList,'ssxxx'); - + let res = await publikRequesFunction('api/index/getmedia','get',{page:1,listrow:8}); + if (res.code === 1) { + this.videoList = res.data.data; } }, async getDownload() { - let res = await axios.get(baseUrl+'api/'); - if (res.data.code === 1) { - this.downloadObj = res.data.data; + let res = await publikRequesFunction('api/','get',{}); + if (res.code === 1) { + this.downloadObj = res.data; } }, async getInfomation() { - let res = await axios.get(`${baseUrl}api/index/getlist? - cateid=3& - keywordsen=& - keywordscn=& - page=1& - listrow=4& - `); - if (res.data.code === 1) { - this.pageIngomation = res.data.data.data; + let res = await publikRequesFunction('api/index/getlist','get',{ + cateid:3, + keywordsen:"", + keywordscn:"", + page:1, + listrow:4, + }); + if (res.code === 1) { + this.pageIngomation = res.data.data; this.hotnewsindex(0) - // setTimeout(()=>{ - // const container = this.$refs.container; - // container.clientHeight > 188 && this.$refs.newsLeft.classList.add('ellipsis'); - // },500) } }, optionsTemp(timestamp) { @@ -947,16 +905,15 @@ return Y + M + D; }, //请求获取显示抢购弹框关闭按钮权限 - loadCloseAuth() { - axios.get(baseUrl+'api/index/getcloseauth').then(res => { - if (res.data.code === 1) { - console.log(res.data.data, 6666) - this.isShowClose = Boolean(res.data.data.closeauth) - this.interval = setInterval(() => { - this.updateCountdown(res.data.data.purastarttime) - }, 1000); - } - }) + async loadCloseAuth() { + let res = await publikRequesFunction('api/index/getcloseauth','get',{}); + if (res.code === 1) { + console.log(res.data, 6666) + this.isShowClose = Boolean(res.data.closeauth) + this.interval = setInterval(() => { + this.updateCountdown(res.data.purastarttime) + }, 1000); + } }, // 更新倒計時的函數 diff --git a/mechanism.html b/mechanism.html index 761758e..54d5e5c 100644 --- a/mechanism.html +++ b/mechanism.html @@ -384,9 +384,9 @@ this.page = val; }, async getonrules() { - let res = await axios.get(baseUrl+'api/user/getrewardrule'); - if (res.data.code == 1) { - this.rewardRules = res.data.data; + let res = await publikRequesFunction('api/user/getrewardrule','get',{}); + if (res.code == 1) { + this.rewardRules = res.data; } }, } diff --git a/news-detail.html b/news-detail.html index 322b1f5..c520b78 100644 --- a/news-detail.html +++ b/news-detail.html @@ -247,7 +247,6 @@ } }); this.getReadDetail(); - }, methods: { // <-- -------------------------钱包登录开始 ---------------------------> @@ -358,12 +357,9 @@ return Y + M + D; }, async getReadDetail() { - let res = await axios.get(` - ${baseUrl}api/index/getdetail? - id=${this.readId} - `); - if (res.data.code === 1) { - let news = JSON.stringify(res.data.data); + let res = await publikRequesFunction('api/index/getdetail','get',{id:this.readId}); + if (res.code === 1) { + let news = JSON.stringify(res.data); news = news.replaceAll('samsar Dao','Samsara Dao').replaceAll('Samsar Dao','Samsara Dao') this.readeDetalObj = JSON.parse(news) } diff --git a/news.html b/news.html index 5c921bb..5ce76e3 100644 --- a/news.html +++ b/news.html @@ -416,16 +416,16 @@ return Y + M + D; }, async getCategoriestable() { - let res = await axios.get(`${baseUrl}api/index/getlist? - cateid=3& - keywordsen=& - keywordscn=& - page=${this.page}& - listrow=${this.listrow}& - `); - if (res.data.code === 1) { - this.categoriesTabList = res.data.data - this.categoriesTabList.data = res.data.data.data.map(item=>{ + let res = await publikRequesFunction('api/index/getlist','get',{ + cateid:3, + keywordsen:"", + keywordscn:"", + page:this.page, + listrow:this.listrow + }); + if (res.code === 1) { + this.categoriesTabList = res.data + 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.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') diff --git a/nft.html b/nft.html index 11793fa..1d545d3 100644 --- a/nft.html +++ b/nft.html @@ -706,43 +706,31 @@ _that.$message("Failed"); }); }, - creatRenewalOrder(){ + async creatRenewalOrder(){ let _that = this; let tip = this.currentLanguage == 'zh' ? '提示' : 'tips'; let confirm = this.currentLanguage == 'zh' ? '確定' : 'confirm'; let cancel = this.currentLanguage == 'zh' ? '取消' : 'cancel'; - $.ajax({ - url: `${baseUrl}api/project/leasenft`, - type: "post", - data: { - id: _that.nftrenewalInfos.id, - fromaddress:_that.userMoneyAdressAll - }, - headers:{ - token: _that.userInfos.token - }, - success(res) { - if (res.code === 1) { - let tipmessage = _that.currentLanguage == 'zh' ? `請前往支付續租費${res.data.bnb} BNB(包含GAS費:${res.data.gasfee} BNB)` : `Please go to pay the renewal fee ${res.data.bnb} BNB (including GAS fee: ${res.data.gasfee} BNB)`; - _that.$confirm(tipmessage, tip, { - confirmButtonText: confirm, - cancelButtonText: cancel, - dangerouslyUseHTMLString: true - }).then(() => { - let tipMessage1 = _that.currentLanguage == 'zh' ? '交易中,請勿刷新頁面...' : 'During the transaction, please do not refresh the page'; - _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) - } - }); + let res = await publikRequesFunction('api/project/leasenft','post',{ + id: _that.nftrenewalInfos.id, + fromaddress:_that.userMoneyAdressAll + }); + if (res.code === 1) { + let tipmessage = _that.currentLanguage == 'zh' ? `請前往支付續租費${res.data.bnb} BNB(包含GAS費:${res.data.gasfee} BNB)` : `Please go to pay the renewal fee ${res.data.bnb} BNB (including GAS fee: ${res.data.gasfee} BNB)`; + _that.$confirm(tipmessage, tip, { + confirmButtonText: confirm, + cancelButtonText: cancel, + dangerouslyUseHTMLString: true + }).then(() => { + let tipMessage1 = _that.currentLanguage == 'zh' ? '交易中,請勿刷新頁面...' : 'During the transaction, please do not refresh the page'; + _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) + } }, submitNft() { let _that = this; @@ -763,7 +751,7 @@ _that.creatOrder() }, //創建交易訂單 - creatOrder(){ + async creatOrder(){ let tip = this.currentLanguage == 'zh' ? '提示' : 'tips'; let confirm = this.currentLanguage == 'zh' ? '確定' : 'confirm'; let cancel = this.currentLanguage == 'zh' ? '取消' : 'cancel'; @@ -787,36 +775,24 @@ } apiUrl = "api/project/sale" } - $.ajax({ - url: baseUrl + apiUrl, - type: "post", - data: params, - headers: { - token: _that.userInfos.token - }, - success(res) { - if (res.code === 1) { - let tipmessage = _that.currentLanguage == 'zh' ? `請前往支付版權費(${res.data.salefee} BNB)
和墊付GAS費(${res.data.gasfee} BNB)` : `Please go to pay the copyright fee (${res.data.salefee} BNB)
and advance the GAS fee (${res.data.gasfee} BNB)`; - _that.$confirm(tipmessage, tip, { - confirmButtonText: confirm, - cancelButtonText: cancel, - dangerouslyUseHTMLString: true - }).then(() => { - _that.dialogVisible = 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); - }).catch(() => { - _that.$message("Failed"); - }); - } else { - _that.$message.error(res.msg) - } - }, - error(err) { - _that.$message.error(err) - } - }); + let res = await publikRequesFunction(apiUrl,'post',params); + if (res.code === 1) { + let tipmessage = _that.currentLanguage == 'zh' ? `請前往支付版權費(${res.data.salefee} BNB)
和墊付GAS費(${res.data.gasfee} BNB)` : `Please go to pay the copyright fee (${res.data.salefee} BNB)
and advance the GAS fee (${res.data.gasfee} BNB)`; + _that.$confirm(tipmessage, tip, { + confirmButtonText: confirm, + cancelButtonText: cancel, + dangerouslyUseHTMLString: true + }).then(() => { + _that.dialogVisible = 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); + }).catch(() => { + _that.$message("Failed"); + }); + } else { + _that.$message.error(res.msg) + } }, //發起版權費+GAS費支付 async websentMoney(item,renewalTxt) { @@ -859,34 +835,22 @@ } }, //支付完成提交hash - submitHash(id,tx,renewalTxt){ + async submitHash(id,tx,renewalTxt){ let _that = this; let apiURL = ""; renewalTxt == 'renewal' ? apiURL = 'api/common/payresult' : _that.isLease ? apiURL = "api/project/payedleaseorder" : apiURL = "api/project/payedsaleorder" try { - $.ajax({ - url: baseUrl + apiURL, - type: "post", - data: {id,tx}, - headers: { - token: _that.userInfos.token - }, - success(res){ - if (res.code === 1) { - _that.$message.success('success'); - _that.orderLoading.close(); - setTimeout(()=>{ - _that.loadData(); - },1000) - } else { - _that.$message.error(err) - _that.orderLoading.close(); - } - }, - error(err) { - _that.$message.error(err) - } - }) + let res = await publikRequesFunction(apiURL,'post',{id,tx}); + if (res.code === 1) { + _that.$message.success('success'); + _that.orderLoading.close(); + setTimeout(()=>{ + _that.loadData(); + },1000) + } else { + _that.$message.error(err) + _that.orderLoading.close(); + } } catch (error) { _that.$message.error(error) _that.orderLoading.close(); @@ -1015,45 +979,38 @@ maskString(str) { return str.replace(/^(.{3})(.*)(.{3})$/, function (match, p1, p2, p3) { return p1 + '*'.repeat(p2.length / 2) + p3; }); }, - loadTopType() { - axios.get(baseUrl + '/api/project/gettype', { - headers: { - token: this.userInfos.token, - }, - }).then(res => { - this.nfttypeList = res.data.data; + async loadTopType() { + let res = await publikRequesFunction('api/project/gettype','get',{}); + if(res.code === 1){ + this.nfttypeList = res.data; this.typeactive = this.nfttypeList[0].id this.getnfttypeList() - }) + } }, // 獲取分類 - getnfttypeList() { + async getnfttypeList() { + let _that = this; this.attrCurrent = [] - axios.get(baseUrl + '/api/project/gettpllist?typeid=' + this.typeactive + '&showown=1&listrow=500', { - headers: { - token: this.userInfos.token, - }, - }).then(res => { - this.attributeList = res.data.data.data - - if (this.attributeList.filter(item => { return item.own > 0 }).length > 0) { - this.loadData() + let res = await publikRequesFunction('api/project/gettpllist','get',{ + typeid:this.typeactive,showown:1,listrow:500 + }); + if(res.code === 1){ + this.attributeList = res.data.data + if (_that.attributeList.filter(item => { return item.own > 0 }).length > 0) { + _that.loadData() } else { this.attrCurrent = [] this.nftList = [] this.total = 0 } - }) - .catch(err => { - // console.log(err); - }) + } }, cheangetypeact(tplid) { if (tplid == this.typeactive) { return } this.typeactive = tplid this.getnfttypeList() }, - loadData() { + async loadData() { this.showGoodClass = false const loading = this.$loading({ lock: true, @@ -1067,25 +1024,14 @@ params.tplid = this.attrCurrent.length > 1 ? this.attrCurrent.join(',') : this.attrCurrent[0] params.typeid = 0 } - axios.get(baseUrl + '/api/user/mynftlist', { - params, - headers: { - token: token, - }, - }) - .then(({ data: res }) => { - 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) - }) + let res = await publikRequesFunction('api/user/mynftlist','get',params); + loading.close() + if (res.code == 1) { + this.total = res.data.total + this.nftList = res.data.data + } else { + this.$message(res.msg) + } }, //分頁 handlePageChange(page) { @@ -1139,24 +1085,14 @@ confirmButtonText: confirm, cancelButtonText: cancel, type: 'warning' - }).then(() => { - $.ajax({ - url: baseUrl + apiSelect, - type: 'post', - data: {id}, - headers:{token: _that.userInfos.token}, - success(res){ - if(res.code === 1){ - _that.$message.success("success"); - setTimeout(()=>{ - _that.loadData() - },1000) - } - }, - error(error){ - _that.$message.error("error"); - } - }); + }).then(async () => { + let res = await publikRequesFunction(apiSelect,'post',{id}); + if(res.code === 1){ + _that.$message.success("success"); + setTimeout(()=>{ + _that.loadData() + },1000) + } }).catch(() => { _that.$message("Failed"); }); diff --git a/profile.html b/profile.html index 8700f68..4ab31d9 100644 --- a/profile.html +++ b/profile.html @@ -690,9 +690,9 @@ }, async getuserInfos(){ if(!this.userInfos?.token){return} - let res = await axios.post(baseUrl+'api/user/index',{},{headers:{token:this.userInfos?.token}}); - if(res.data.code == 1){ - this.userInfos = res.data.data.userinfo; + let res = await publikRequesFunction('api/user/index','post',{}); + if(res.code == 1){ + this.userInfos = res.data.userinfo; this.getonrules(); } }, @@ -704,9 +704,9 @@ spinner: 'el-icon-loading', 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}}); - if(res.data.code == 1){ - this.rewardRules = res.data.data; + let res = await publikRequesFunction('api/user/getlogs','get',{type:this.ifications,page:this.page}); + if(res.code == 1){ + this.rewardRules = res.data; } loading.close() }, diff --git a/static/js/getIsUser.js b/static/js/getIsUser.js index cf34b81..ac245ad 100644 --- a/static/js/getIsUser.js +++ b/static/js/getIsUser.js @@ -17,7 +17,10 @@ if (userInfo) { 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 message = language == 'zh' ? '請先登入或註冊' : 'Please log in or register first'; const html ="

" + message + "

" @@ -34,6 +37,40 @@ baseUrl = "https://demo.samsaradao.com/" if(window.location.host === '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(){ $.ajax({ url:baseUrl+"api/user/logout", diff --git a/trading-detail.html b/trading-detail.html index f285889..3327cb4 100644 --- a/trading-detail.html +++ b/trading-detail.html @@ -833,35 +833,22 @@ window.location.href = "all-order.html"; } }, - submitPurchFeeHash(wtbid,tx){ + async submitPurchFeeHash(wtbid,tx){ let _that = this; try { - $.ajax({ - url: `${baseUrl}api/project/wtbrevpayres`, - type: "post", - data: {wtbid,tx}, - headers: { - token: _that.userInfos.token - }, - 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) + let res = await publikRequesFunction('api/project/wtbrevpayres','post',{wtbid,tx}); + 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"; + } } catch (error) { _that.$message.error(error) _that.orderLoading.close(); @@ -870,25 +857,16 @@ //判断是否有相应的NFT isHaveNft(){ let _that = this; - return new Promise((resolve, reject) => { - $.ajax({ - url:`${baseUrl}api/project/wtbsend`, - headers:{token: _that.userInfos.token}, - 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) - } + return new Promise(async (resolve, reject) => { + let res = await publikRequesFunction('api/project/wtbsend','post',{ + wtbid: _that.nowPurchOrderObj.id, + saleaddress: _that.receivAdress }); + if(res.code === 1){ + resolve(res.data) + }else{ + resolve(res.msg) + } }) }, expirationTimeOp(timestamp){ @@ -907,30 +885,19 @@ this.purchSearchObj.page = val; this.getPurchasList(); }, - getPurchasList(){ + async getPurchasList(){ let _that = this; _that.orderLoading = _that.$loading({ lock: true, text: 'loading', spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)' }); - $.ajax({ - url: `${baseUrl}api/project/getwtblist`, - headers:{ - 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); - } + let res = await publikRequesFunction('api/project/getwtblist','get',{ + tid: _that.buySelectEqObj.id, + ..._that.purchSearchObj }); + if(res.code === 1){ + _that.purchTableData = res.data; + _that.orderLoading.close(); + } }, - purchaseRequest(){ + async purchaseRequest(){ let _that = this; if(!_that.purchPrice || !_that.setimeCycle){ let inputVality = _that.currentLanguage == 'zh' ? '請輸入完整訊息' : 'Please enter complete information'; @@ -948,39 +915,28 @@ },1000) return } - $.ajax({ - url: `${baseUrl}api/project/wtbuy`, - headers:{ - token: _that.userInfos.token - }, - 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); - } + let res = await publikRequesFunction('api/project/wtbuy','post',{ + tid: _that.buySelectEqObj.id, + bnb: _that.purchPrice, + vaildtime: _that.setimeCycle }); + 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){ let _that = this; @@ -1023,35 +979,23 @@ this.orderLoading.close(); } }, - submitPurchHash(id,tx,fromaddress){ + async submitPurchHash(id,tx,fromaddress){ console.log('交易ID:',id,'交易hash:',tx); let _that = this; try { - $.ajax({ - url: `${baseUrl}api/project/wtbres`, - type: "post", - data: {id,tx,fromaddress}, - headers: { - token: _that.userInfos.token - }, - success(res){ - if (res.code === 1) { - _that.orderLoading.close(); - 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) { + let res = await publikRequesFunction('api/project/wtbres','post',{id,tx,fromaddress}); + if (res.code === 1) { + _that.orderLoading.close(); + 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(); } - }) } catch (error) { _that.$message.error(error) _that.orderLoading.close(); @@ -1063,7 +1007,7 @@ this.buySelectEqObj = {...item}; this.getPurchasList(); }, - getNftList(){ + async getNftList(){ let _that = this; let sort = ""; let desc = ""; @@ -1073,66 +1017,42 @@ let keywords_cn = ""; let keywords_en = ""; this.currentLanguage == 'zh' ? keywords_cn = this.searchNft : keywords_en = this.searchNft - $.ajax({ - url:`${baseUrl}api/project/getenbuynftlist`, - type:'get', - data:{ - keywords_cn, - keywords_en, - typeid: _that.nownftId,//分類ID - page: _that.searchObj.page, - listrow: _that.searchObj.pageSize, - 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); - } + let res = await publikRequesFunction('api/project/getenbuynftlist','get',{ + keywords_cn, + keywords_en, + typeid: _that.nownftId,//分類ID + page: _that.searchObj.page, + listrow: _that.searchObj.pageSize, + tplid: _that.selectEqType, + sort,//排序:發佈時間time 價格fee + desc//true倒序 false正序 }); + if(res.code === 1){ + _that.topnftInfos = res.data.baseinfo; + _that.transactionList = res.data.list; + _that.orderLoading.close(); + } }, - getLeaseNftList(){ + async getLeaseNftList(){ let _that = this; this.orderLoading = _that.$loading({ lock: true, text: 'loading', spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)' }); let keywords_cn = ""; let keywords_en = ""; this.currentLanguage == 'zh' ? keywords_cn = this.searchNft : keywords_en = this.searchNft - $.ajax({ - url:`${baseUrl}api/project/getenleasenftlist`, - type:'get', - data:{ - keywords_cn, - keywords_en, - typeid: _that.nownftId, - page: _that.searchObj.page, - listrow: _that.searchObj.pageSize, - 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); - } + let res = await publikRequesFunction('api/project/getenleasenftlist','get',{ + keywords_cn, + keywords_en, + typeid: _that.nownftId, + page: _that.searchObj.page, + listrow: _that.searchObj.pageSize, + tplid: _that.selectEqType, + sort:"", + desc: true }); + if(res.code === 1){ + _that.leaseNftData = res.data.list; + _that.orderLoading.close(); + } }, searchEqListLease(id){ this.selectEqType = id; @@ -1142,25 +1062,18 @@ this.selectEqType = id; this.getNftList(); }, - getnftTypeList(){ + async getnftTypeList(){ let _that = this; - $.ajax({ - url:`${baseUrl}api/project/gettpllist?typeid=${this.nownftId}&showown=&listrow=9999`, - type:'get', - headers:{ - 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); - } + let res = await publikRequesFunction('api/project/gettpllist','get',{ + typeid:this.nownftId, + showown:1, + listrow:9999 }); + if(res.code === 1){ + _that.equipmentType = res.data.data; + _that.buySelectEqType = _that.equipmentType[0].id; + _that.buySelectEqObj = _that.equipmentType[0]; + } }, toNftDetail(){ window.location.href = "nft-detail.html"; @@ -1180,34 +1093,22 @@ } this.creatOrder(); }, - creatOrder(){ + async creatOrder(){ let _that = this; let apiString = ""; _that.activeName == 'first' ? apiString = 'api/project/buynft' : apiString = 'api/project/leasenft' - $.ajax({ - url: baseUrl + apiString, - type: "post", - data: { - id: _that.paynftObj.id, - fromaddress:_that.userMoneyAdressAll - }, - headers:{ - token: _that.userInfos.token - }, - success(res) { - 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) - } - }); + let res = await publikRequesFunction(apiString,'post',{ + id: _that.paynftObj.id, + fromaddress:_that.userMoneyAdressAll + }); + 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) + } }, async websentMoney(item) { let _that = this; @@ -1250,35 +1151,21 @@ this.orderLoading.close(); } }, - submitHash(id,tx){ + async submitHash(id,tx){ let _that = this; let apiString = ""; - // _that.activeName == 'first' ? apiString = 'api/common/payresult' : '' try { - $.ajax({ - // url: baseUrl + apiString, - url:`${baseUrl}api/common/payresult`, - type: "post", - data: {id,tx}, - headers: { - token: _that.userInfos.token - }, - success(res){ - if (res.code === 1) { - _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) - } - }) + let res = await publikRequesFunction('api/common/payresult','post',{id,tx}); + if (res.code === 1) { + _that.$message.success('success'); + _that.orderLoading.close(); + setTimeout(()=>{ + _that.activeName == 'first' ? _that.getNftList() : _that.getLeaseNftList() + },1000) + } else { + _that.$message.error(err) + _that.orderLoading.close(); + } } catch (error) { _that.$message.error(error) _that.orderLoading.close(); diff --git a/trading.html b/trading.html index cf2dc39..61d17b8 100644 --- a/trading.html +++ b/trading.html @@ -302,31 +302,21 @@ this.getRecentNftList(); }, methods: { - getRecentNftList(){ + async getRecentNftList(){ let _that = this; - $.ajax({ - url:`${baseUrl}api/project/getnftlist`, - type:"get", - data:{page:1,listrow:5}, - headers:{token:_that.userInfoObj.token}, - success(res){ - if(res.code === 1){ - _that.recentNftData = res.data.data; - }else{ - console.log(err); - } - }, - error(err){ - console.log(err); - } - }); + let res = await publikRequesFunction('api/project/getnftlist','get',{page:1,listrow:5}); + if(res.code === 1){ + _that.recentNftData = res.data.data; + }else{ + console.log(err); + } }, searchTimeOption(n){ const currentTimestamp = Date.now(); const timestampAgo = currentTimestamp - n * 24 * 60 * 60 * 1000; return timestampAgo }, - getNfttype(){ + async getNfttype(){ let starttime = ""; let endtime = ""; 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)' }); let _that = this; - $.ajax({ - url:`${baseUrl}api/project/gettype`, - type:"get", - data:{ - showown:"", - starttime, - endtime, - }, - success(res){ - if(res.code === 1){ - _that.tableData = res.data; - _that.orderLoading.close(); - } - }, - error(err){ - console.log(err); - } + let res = await publikRequesFunction('api/project/gettype','get',{ + showown:"", + starttime, + endtime, }); + if(res.code === 1){ + _that.tableData = res.data; + _that.orderLoading.close(); + } }, toNftDetail(id,typeId){ window.location.href = `trading-detail.html?id=${id}&typeId=${typeId}`;