Browse Source

修改

master
vee 4 years ago
parent
commit
d263be9901
  1. 195
      pages/menu/collection/addCollection/index.vue
  2. 182
      pages/menu/collection/collectionDetail/index.vue
  3. 4
      pages/menu/collection/index.vue
  4. 17
      pages/menu/wallet/otherCoin/index.vue
  5. 4
      utils/SystemConfiguration.js
  6. 8
      utils/api.js
  7. 61
      utils/axios.js

195
pages/menu/collection/addCollection/index.vue

@ -1,42 +1,46 @@
<template> <template>
<view class="maintoP"> <view class="maintoP">
<navigation :showBack="false" :bgnum="true" class="aaa"> <navigation :showBack="false" :bgnum="true" class="aaa">
<image src="../../../../static/tongyonh/Vector.png" mode="aspectFit" class="back" @click="back()" ></image> <image src="../../../../static/tongyonh/Vector.png" mode="aspectFit" class="back" @click="back()"></image>
<text class="big_title"> <text class="big_title">
NFT collections NFT collections
</text> </text>
</navigation> </navigation>
<view class="main"> <view class="main">
<view class="main_con"> <view class="main_con">
<view class="flex item"> <view class="flex item">
<view class="imgcon flex2"> <view class="imgcon flex2">
<image :src="wallet.coinList[0].icon" mode="aspectFit" class="img"></image> <image :src="wallet.coinList[0].icon" mode="aspectFit" class="img"></image>
<text class="tex1">{{wallet.coinList[0].name2}}</text> <text class="tex1">{{wallet.coinList[0].name2}}</text>
</view> </view>
<view class="text1"> <view class="text1">
{{wallet.address}} {{wallet.address}}
<image src="../../../../static/tongyonh/chevron_right_24px.png" mode="aspectFit" class="lfetimg"></image> <image src="../../../../static/tongyonh/chevron_right_24px.png" mode="aspectFit"
</view> class="lfetimg"></image>
</view> </view>
<view class="item2"> </view>
<view class="title"> <view class="item2">
Contract address <view class="title">
</view> Contract address
<input type="text" v-model="caddress" value="" class="input" placeholder-style="color:#BEBEBE;fontSize:14px" placeholder="Please enter the contract address"/> </view>
</view> <input type="text" v-model="caddress" value="" class="input"
<view class="item2"> placeholder-style="color:#BEBEBE;fontSize:14px"
<view class="title"> placeholder="Please enter the contract address" />
Token ID </view>
</view> <view class="item2">
<input type="text" v-model="tid" value="" class="input" placeholder-style="color:#BEBEBE;fontSize:14px" placeholder="Please enter token ID"/> <view class="title">
</view> Token ID
<view class="btn" @click="Add"> </view>
Confirm <input type="text" v-model="tid" value="" class="input"
</view> placeholder-style="color:#BEBEBE;fontSize:14px" placeholder="Please enter token ID" />
</view> </view>
<view class="btn" @click="Add">
Confirm
</view>
</view>
</view> </view>
</view> </view>
</template> </template>
@ -46,80 +50,81 @@
export default { export default {
data() { data() {
return { return {
caddress:'', caddress: '',
tid:'', tid: '',
wallet:{}, wallet: {},
nftIndex:0, nftIndex: 0,
nftContrct:[[]], nftContrct: [
walletInfo:{}, []
address:'', ],
proid:'', walletInfo: {},
address: '',
proid: '',
} }
}, },
onLoad() { onLoad() {
if(uni.getStorageSync('wallet')){ if (uni.getStorageSync('wallet')) {
this.address=uni.getStorageSync('wallet').address this.address = uni.getStorageSync('wallet').address
this.wallet=uni.getStorageSync('wallet') this.wallet = uni.getStorageSync('wallet')
this.wallet.address = this.wallet.address.substring(0, 6) + '...' + this.wallet.address this.wallet.address = this.wallet.address.substring(0, 6) + '...' + this.wallet.address
.substring(25, this.wallet.address.length); .substring(25, this.wallet.address.length);
}else{ } else {
this.wallet=uni.getStorageSync('walletInfo').BTC[0] this.wallet = uni.getStorageSync('walletInfo').BTC[0]
this.wallet.address = this.wallet.address.substring(0, 6) + '...' + this.wallet.address this.wallet.address = this.wallet.address.substring(0, 6) + '...' + this.wallet.address
console.log(this.wallet,111) console.log(this.wallet, 111)
} }
}, },
methods: { methods: {
back(){ back() {
uni.reLaunch({ uni.reLaunch({
url:'../collectionDetail/index' url: '../collectionDetail/index'
}) })
}, },
Add(){ async Add() {
this.proid=uni.getStorageSync('proid') this.proid = uni.getStorageSync('proid')
uni.request({ let params = {
header: { address: this.address,
'Content-Type': 'application/x-www-form-urlencoded' contract: this.caddress,
}, tonkenId: this.tid,
url: 'http://wallet-api.weirui0755.com/api/nft/addNftCollection', // nftProjectId: this.proid
method: 'POST', };
data: { const response = await this.$api.addNftCollection(params)
address:this.address,
contract:this.caddress, if (response.code == 200) {
tonkenId:this.tid, uni.showToast({
nftProjectId:this.proid title: 'Successfully',
}, icon: 'success',
dataType:'json', duration: 1500
success: (res) => { })
if(res.data.code==200){ setTimeout(() => {
uni.showToast({ uni.navigateTo({
title: 'Successfully', url: '../collectionDetail/index'
icon: 'success', })
duration: 1500 }, 1500)
}) }else{
setTimeout(()=>{ uni.showToast({
uni.navigateTo({ title: response.msg,
url:'../collectionDetail/index' icon: 'error',
}) duration: 1500
},1500) })
} }
}
}); },
},
} }
}; };
</script> </script>

182
pages/menu/collection/collectionDetail/index.vue

@ -1,29 +1,31 @@
<template> <template>
<view class="maintoP"> <view class="maintoP">
<navigation :showBack="false" :bgnum="true" class="aaa"> <navigation :showBack="false" :bgnum="true" class="aaa">
<image src="../../../../static/tongyonh/Vector.png" mode="aspectFit" class="back" @click="back()" ></image> <image src="../../../../static/tongyonh/Vector.png" mode="aspectFit" class="back" @click="back()"></image>
<image src="../../../../static/tongyonh/IconGroup.png" mode="aspectFit" @click="goAdd" class="renYou2" slot="logo"></image> <image src="../../../../static/tongyonh/IconGroup.png" mode="aspectFit" @click="goAdd" class="renYou2"
<text class="big_title"> slot="logo"></image>
{{item.projectName}} <text class="big_title">
</text> {{item.projectName}}
</text>
</navigation> </navigation>
<view class="main"> <view class="main">
<view class="item" v-for="item,index in result" :key="index"> <view class="item" v-for="item,index in result" :key="index">
<view class="top"> <view class="top">
<image :src="item.chainIconUrl" mode="aspectFit" class="img"></image> <image :src="item.chainIconUrl" mode="aspectFit" class="img"></image>
{{item.address}} {{item.address}}
<image src="../../../../static/tongyonh/[email protected]" mode="aspectFit" class="img lfet" @click="goDetail(index)"></image> <image src="../../../../static/tongyonh/[email protected]" mode="aspectFit" class="img lfet"
@click="goDetail(index)"></image>
</view>
<view class="top">
<text class="textleft">Contracts: </text>{{item.contract}}
</view>
<view class="top">
<text class="textleft texttt">ID: </text>{{item.id}}
</view>
</view>
</view> </view>
<view class="top">
<text class="textleft">Contracts: </text>{{item.contract}}
</view>
<view class="top">
<text class="textleft texttt">ID: </text>{{item.id}}
</view>
</view>
</view>
</view> </view>
</template> </template>
@ -33,90 +35,90 @@
export default { export default {
data() { data() {
return { return {
item:{}, item: {},
wallet:{}, wallet: {},
address:'', address: '',
result:[], result: [],
result2:[], result2: [],
pageSize:10, pageSize: 10,
pageNum:1, pageNum: 1,
} }
}, },
onLoad(option) { onLoad(option) {
if(uni.getStorageSync('wallet')){ if (uni.getStorageSync('wallet')) {
this.address=uni.getStorageSync('wallet').address this.address = uni.getStorageSync('wallet').address
this.wallet=uni.getStorageSync('wallet') this.wallet = uni.getStorageSync('wallet')
this.wallet.address = this.wallet.address.substring(0, 6) + '...' + this.wallet.address this.wallet.address = this.wallet.address.substring(0, 6) + '...' + this.wallet.address
.substring(25, this.wallet.address.length); .substring(25, this.wallet.address.length);
}else{ } else {
this.wallet=uni.getStorageSync('walletInfo').BTC[0] this.wallet = uni.getStorageSync('walletInfo').BTC[0]
this.wallet.address = this.wallet.address.substring(0, 6) + '...' + this.wallet.address.substring(25, this.wallet.address.length); this.wallet.address = this.wallet.address.substring(0, 6) + '...' + this.wallet.address.substring(25, this
console.log(this.wallet,111) .wallet.address.length);
} console.log(this.wallet, 111)
}
this.item=uni.getStorageSync('nftitem')
this.item = uni.getStorageSync('nftitem')
this.getProject()
this.getProject2() this.getProject()
this.getProject2()
}, },
onReachBottom() { onReachBottom() {
this.pageSize+=5 this.pageSize += 5
this.getProject() this.getProject()
this.getProject2() this.getProject2()
}, },
methods: { methods: {
back(){ back() {
uni.reLaunch({ uni.reLaunch({
url:'../index' url: '../index'
}) })
}, },
// http://wallet-api.weirui0755.com/api/nft/getNftCollectionList?nftProjectId=1&address= async getProject() {
getProject(){ let params = {
uni.request({ nftProjectId: this.item.id,
url: 'http://wallet-api.weirui0755.com/api/nft/getNftCollectionList?'+'nftProjectId='+this.item.id+'&'+'address='+this.address+'&'+'pageSize='+this.pageSize+'&'+'pageNum='+this.pageNum, // address: this.address,
header: { pageSize: this.pageSize,
'content-type': 'application/x-www-form-urlencoded', // pageNum: this.pageNum
}, }
success: (res) => { const response = await this.$api.getNftCollectionList(params)
this.result=res.data.data.rows
for(var i =0;i<this.result.length;i++){ this.result = response.data.rows
this.result[i].address = this.result[i].address.substring(0, 6) + '...' + this.result[i].address for (var i = 0; i < this.result.length; i++) {
.substring(25, this.result[i].address.length); this.result[i].address = this.result[i].address.substring(0, 6) + '...' + this.result[i].address
} .substring(25, this.result[i].address.length);
}
}
});
}, },
getProject2(){ async getProject2() {
uni.request({ let params = {
url: 'http://wallet-api.weirui0755.com/api/nft/getNftCollectionList?'+'nftProjectId='+this.item.id+'&'+'address='+this.address+'&'+'pageSize='+this.pageSize+'&'+'pageNum='+this.pageNum, // nftProjectId: this.item.id,
header: { address: this.address,
'content-type': 'application/x-www-form-urlencoded', // pageSize: this.pageSize,
}, pageNum: this.pageNum
success: (res) => { }
this.result2=res.data.data.rows const response = await this.$api.getNftCollectionList(params);
console.log( this.result2,7878) this.result2 = response.data.rows
} console.log(this.result2, 7878)
});
}, },
goAdd(){ goAdd() {
uni.navigateTo({ uni.navigateTo({
url:'../addCollection/index' url: '../addCollection/index'
}) })
}, },
goDetail(index){ goDetail(index) {
console.log(this.result2[index]) console.log(this.result2[index])
uni.setStorageSync('nftOneItem',this.result2[index]) uni.setStorageSync('nftOneItem', this.result2[index])
uni.navigateTo({ uni.navigateTo({
url:'../collectionDetailtrue/index' url: '../collectionDetailtrue/index'
}) })
} }
}, },

4
pages/menu/collection/index.vue

@ -119,8 +119,8 @@
let params = { let params = {
address: this.address address: this.address
} }
const post = await this.$api.getNftProjectList(params) const response = await this.$api.getNftProjectList(params)
this.collectinInfo=post.data this.collectinInfo=response.data
}, },
goDetail2(itemm,index){ goDetail2(itemm,index){

17
pages/menu/wallet/otherCoin/index.vue

@ -134,16 +134,13 @@
}, },
// //
getCoin(){ async getCoin(){
uni.request({ let params = {
url: 'http://wallet-api.weirui0755.com/api/contract/getContractInfoList?chainName='+this.coinType, // chainName: this.coinType
header: { }
'content-type': 'application/x-www-form-urlencoded', // const response = await this.$api.getContractInfoList(params)
}, this.coinInfo=response.data
success: (res) => {
this.coinInfo=res.data.data
}
});
}, },

4
utils/SystemConfiguration.js

@ -2,11 +2,11 @@ let isTest = true;
const constant = isTest ? { const constant = isTest ? {
//服务端连接 //服务端连接
serverUrl: 'http://wallet-api.weirui0755.com/' serverUrl: 'http://wallet-api.weirui0755.com'
} : { } : {
//服务端连接 //服务端连接
serverUrl: 'http://wallet-api.weirui0755.com/' serverUrl: 'http://wallet-api.weirui0755.com'
} }

8
utils/api.js

@ -1,8 +1,14 @@
import Vue from 'vue'; import Vue from 'vue';
import qs from 'qs' import qs from 'qs'
const api = { const api = {
//获取NFT项目列表
getNftProjectList: (params) => Vue.prototype.$axios.get('/api/nft/getNftProjectList?' + qs.stringify(params)), getNftProjectList: (params) => Vue.prototype.$axios.get('/api/nft/getNftProjectList?' + qs.stringify(params)),
//添加NFT收藏品
addNftCollection: (params) => Vue.prototype.$axios.post('/api/nft/addNftCollection', qs.stringify(params)),
getNftCollectionList: (params) => Vue.prototype.$axios.get('/api/nft/getNftCollectionList?' + qs.stringify(
params)),
getContractInfoList: (params) => Vue.prototype.$axios.get('/api/contract/getContractInfoList?' + qs.stringify(
params)),
//--------------------------------- free --------------------------------- //--------------------------------- free ---------------------------------
} }

61
utils/axios.js

@ -69,35 +69,44 @@ service.interceptors.response.use(res => {
}) })
// 在main.js中放入这段自定义适配器的代码,就可以实现uniapp的app和小程序开发中能使用axios进行跨域网络请求,并支持携带cookie // 在main.js中放入这段自定义适配器的代码,就可以实现uniapp的app和小程序开发中能使用axios进行跨域网络请求,并支持携带cookie
axios.defaults.adapter = function(config) {
return new Promise((resolve, reject) => { axios.defaults.adapter = function(config) { //自己定义个适配器,用来适配uniapp的语法
return new Promise((resolve, reject) => {
if(config.baseURL){ if(config.baseURL){
config.url=config.baseURL+'/'+config.url config.url=config.baseURL+'/'+config.url
} }
var settle = require('axios/lib/core/settle'); console.log(config)
var buildURL = require('axios/lib/helpers/buildURL'); var settle = require('axios/lib/core/settle');
uni.request({ var buildURL = require('axios/lib/helpers/buildURL');
method: config.method.toUpperCase(), uni.request({
url: buildURL(config.url, config.params, config.paramsSerializer), method: config.method.toUpperCase(),
header: config.headers, url: config.baseURL + buildURL(config.url, config.params, config.paramsSerializer),
data: config.data, header: config.headers,
dataType: config.dataType, data: config.data,
responseType: config.responseType, dataType: config.dataType,
sslVerify: config.sslVerify, responseType: config.responseType,
complete: function complete(response) { sslVerify: config.sslVerify,
response = { complete: function complete(response) {
data: response.data, console.log("执行完成:",config.baseURL + buildURL(config.url, config.params, config.paramsSerializer),response.data)
status: response.statusCode, response = {
errMsg: response.errMsg, data: response.data,
header: response.header, status: response.statusCode,
config: config errMsg: response.errMsg,
}; header: response.header,
// console.log(response) config: config
settle(resolve, reject, response); };
}
})
})
}
settle(resolve, reject, response);
},
fail:res =>{
uni.showToast({
title: res,
icon:'none',
duration: 1500
})
}
})
})
}
export default service export default service

Loading…
Cancel
Save