Browse Source

修改

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

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

@ -1,7 +1,7 @@
<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>
@ -15,20 +15,24 @@
</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"
class="lfetimg"></image>
</view> </view>
</view> </view>
<view class="item2"> <view class="item2">
<view class="title"> <view class="title">
Contract address Contract address
</view> </view>
<input type="text" v-model="caddress" value="" class="input" placeholder-style="color:#BEBEBE;fontSize:14px" placeholder="Please enter the 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>
<view class="item2"> <view class="item2">
<view class="title"> <view class="title">
Token ID Token ID
</view> </view>
<input type="text" v-model="tid" value="" class="input" placeholder-style="color:#BEBEBE;fontSize:14px" placeholder="Please enter token ID"/> <input type="text" v-model="tid" value="" class="input"
placeholder-style="color:#BEBEBE;fontSize:14px" placeholder="Please enter token ID" />
</view> </view>
<view class="btn" @click="Add"> <view class="btn" @click="Add">
Confirm Confirm
@ -46,70 +50,71 @@
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,
nftProjectId:this.proid
},
dataType:'json',
success: (res) => {
if(res.data.code==200){
uni.showToast({ uni.showToast({
title: 'Successfully', title: 'Successfully',
icon: 'success', icon: 'success',
duration: 1500 duration: 1500
}) })
setTimeout(()=>{ setTimeout(() => {
uni.navigateTo({ uni.navigateTo({
url:'../collectionDetail/index' url: '../collectionDetail/index'
})
}, 1500)
}else{
uni.showToast({
title: response.msg,
icon: 'error',
duration: 1500
}) })
},1500)
} }
}
});
}, },

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

@ -1,8 +1,9 @@
<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"
slot="logo"></image>
<text class="big_title"> <text class="big_title">
{{item.projectName}} {{item.projectName}}
</text> </text>
@ -13,7 +14,8 @@
<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>
<view class="top"> <view class="top">
<text class="textleft">Contracts: </text>{{item.contract}} <text class="textleft">Contracts: </text>{{item.contract}}
@ -33,86 +35,86 @@
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.getProject()
this.getProject2() 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
for (var i = 0; i < this.result.length; i++) {
this.result[i].address = this.result[i].address.substring(0, 6) + '...' + this.result[i].address this.result[i].address = this.result[i].address.substring(0, 6) + '...' + this.result[i].address
.substring(25, this.result[i].address.length); .substring(25, this.result[i].address.length);
} }
}
});
},
getProject2(){
uni.request({
url: 'http://wallet-api.weirui0755.com/api/nft/getNftCollectionList?'+'nftProjectId='+this.item.id+'&'+'address='+this.address+'&'+'pageSize='+this.pageSize+'&'+'pageNum='+this.pageNum, //
header: {
'content-type': 'application/x-www-form-urlencoded', //
}, },
success: (res) => { async getProject2() {
this.result2=res.data.data.rows let params = {
console.log( this.result2,7878) nftProjectId: this.item.id,
address: this.address,
pageSize: this.pageSize,
pageNum: this.pageNum
} }
}); const response = await this.$api.getNftCollectionList(params);
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){

15
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', //
},
success: (res) => {
this.coinInfo=res.data.data
} }
}); const response = await this.$api.getContractInfoList(params)
this.coinInfo=response.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 ---------------------------------
} }

17
utils/axios.js

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