Commit 4411d8ab authored by xhx's avatar xhx

调整

parent d76ccc2f
NODE_ENV="development"
VUE_APP_URL="http://172.16.100.59:8000"
VUE_CHAIN_URL="http://172.16.100.59:8801"
\ No newline at end of file
VUE_APP_URL="http://172.16.100.59:8090"
#VUE_APP_CHAIN="http://172.16.100.59:8801"
VUE_APP_CHAIN="https://mainnet.bityuan.com/api"
\ No newline at end of file
NODE_ENV="production"
// VUE_APP_URL="http://"
VUE_CHAIN_URL="http://172.16.100.59:8801"
\ No newline at end of file
VUE_APP_URL="http://47.243.139.223:8000"
VUE_APP_CHAIN="https://mainnet.bityuan.com/api"
\ No newline at end of file
NODE_ENV='development'
VUE_APP_URL="http://172.16.100.59:8090"
VUE_APP_CHAIN="http://172.16.100.59:8801"
\ No newline at end of file
......@@ -3,7 +3,7 @@
"version": "0.1.0",
"private": true,
"scripts": {
"build:test": "vue-cli-service build --mode development",
"build:test": "vue-cli-service build --mode test",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint",
"dev": "vue-cli-service serve"
......@@ -27,7 +27,9 @@
"vue-class-component": "^7.2.3",
"vue-property-decorator": "^9.1.2",
"vue-router": "^3.2.0",
"vuex": "^3.4.0"
"vuex": "^3.4.0",
"terser-webpack-plugin": "^4.2.3",
"compression-webpack-plugin": "^6.1.1"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.18.0",
......
public/favicon.ico

4.19 KB | W: | H:

public/favicon.ico

2.26 KB | W: | H:

public/favicon.ico
public/favicon.ico
public/favicon.ico
public/favicon.ico
  • 2-up
  • Swipe
  • Onion skin
......@@ -9,37 +9,54 @@ import Vue from 'vue'
import { isBind } from '@/service/pool'
import service from '@/service/chain33'
import { closeWebview } from '@/utils/bridge'
// import { getCurrentBTYAddress } from '@/utils/bridge' // 币钱包环境
import { test } from '@/utils/test' // 本地测试
import { getCurrentBTYAddress } from '@/utils/bridge' // 币钱包环境
// import { test } from '@/utils/test' // 本地测试
import { Toast } from 'vant'
export default Vue.extend({
methods: {
// 账号是否能进入挖矿
async hasPoolAddr(addr: string) {
const response = await service.getTicketAddress(addr)
console.log(response)
if (response.data.result?.data) {
isBind(response.data.result?.data).catch((res: any) => {
console.log(res.response)
const walletRes = await service.getWalletAddress(addr)
const _result = response.data.result?.data
console.log('respos', response.data.result?.data)
console.log('wallet', walletRes.data.result?.datas)
if (walletRes.data.result?.datas) {
Toast({
message: '该账户不具备进入条件,将于3秒后退出',
forbidClick: true,
duration: 3000
})
// setTimeout(() => {
// closeWebview()
// }, 3000)
}
if (_result) {
isBind(_result).catch((res: any) => {
console.log('isBind', res.response)
const reason = res.response.data.reason
if (reason) {
Toast('该用户已开启挖矿')
setTimeout(() => {
closeWebview()
}, 1000)
Toast({
message: '该账户不具备进入条件,将于3秒后退出',
forbidClick: true,
duration: 3000
})
// setTimeout(() => {
// closeWebview()
// }, 3000)
}
})
}
}
},
created() {
// getCurrentBTYAddress('',(res: any) => {
// console.log('res', res)
// this.$store.commit('app/SET_ADDRESS', res)
// this.hasPoolAddr(res)
// })
this.$store.commit('app/SET_ADDRESS', test.addr)
this.hasPoolAddr(test.addr)
getCurrentBTYAddress('',(res: any) => {
console.log('res', res)
this.$store.commit('app/SET_ADDRESS', res)
this.hasPoolAddr(res)
})
// this.$store.commit('app/SET_ADDRESS', test.addr)
// this.hasPoolAddr(test.addr)
}
})
</script>
......
......@@ -7,8 +7,8 @@
</div>
<div class="pb-3 flex items-center justify-between">
<div class="px-2 flex flex-col items-start">
<div class="income-count">{{ info.dayRate || 0 }}<span class="text-2xl">%</span></div>
<div class="text-xs text-white2">矿池日收益率</div>
<div class="income-count">{{ info.dayRate || 0 }}</div>
<div class="text-xs text-white2">矿池每票日收益</div>
</div>
<button class="w-24 h-9 rounded-full text-sm text-brown1 text-medium bg-gradient-4" @click="goMining">立即委托</button>
</div>
......@@ -42,7 +42,7 @@ export default Vue.extend({
},
methods: {
goMining() {
this.$emit('goDetails', (this.info as any).id)
this.$emit('goDetails', (this.info as any))
}
}
})
......
// export const TICKET_COUNT = 10000
export const TICKET_COUNT = process.env.NODE_ENV !== 'production' ? 10000 : 3000
......@@ -4,23 +4,14 @@ import './registerServiceWorker'
import router from './router'
import store from './store'
import 'vant/lib/index.css';
import Rpc from '@33cn/chain33-rpc-api'
import { Toast } from 'vant'
import '@/style.css'
import vconsole from 'vconsole'
new vconsole()
Vue.config.productionTip = false
Vue.prototype.$api = new Rpc(process.env.VUE_APP_NODE,function(res:any){
if(res.error){
return Promise.reject(res.error);
}
return res.result
},function(err:any){
Toast(err.message || err);
})
new Vue({
router,
......
......@@ -4,7 +4,7 @@ import { sign } from '@/utils/bridge'
import { rawTransaction } from "@/type/request";
// import { test } from '@/utils/test'
const service = request('http://172.16.100.59:8801')
const service = request(`${process.env.VUE_APP_CHAIN}`)
async function chainRequire(method: string, data: any[], b?: boolean, _this?: any, cb?:any){
const CancelToken = axios.CancelToken;
......@@ -155,7 +155,11 @@ export default {
}) {
return chainRequire('Chain33.CreateRawTxGroup', [data])
},
/**
* 获取绑定的挖矿地址
* @param addr
* @returns
*/
getTicketAddress: function (addr: string) {
return service.request({
data: {
......@@ -170,5 +174,26 @@ export default {
},
method: 'POST'
})
},
/**
* 获取矿工地址的对应的冷钱包地址
* @param addr
* @returns
*/
getWalletAddress: function(addr: string) {
return service.request({
data: {
method: 'Chain33.Query',
params: [{
execer: 'ticket',
funcName: 'MinerSourceList',
payload: {
data: addr
}
}]
},
method: 'POST'
})
}
}
\ No newline at end of file
......@@ -7,6 +7,7 @@
// privateKey: '0xCC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944'
// }
export const test = {
// addr: '1Lm22ZxsCHYE3PNtEnGYZJduJs5KG95GUp',
addr: '16GgdskdRFasxuMdtBaxNS4ZagyZgEUuMs',
// addr: '1LGQLmGVHSNthZcLbGpVfJTDmcicMQprZs',
privateKey: '0xa65b62735022cd47b11c5a88b0caac8d360810257aaf1e14bbc330dee63b35ff'
......
......@@ -9,7 +9,7 @@
</nav-bar>
<DetailsCard :info="info" />
<DetailsList :info="info" />
<DetailsFooter :max="Math.floor(profit/ticketNum)" :min="1" @buy="buy" />
<DetailsFooter :max="Math.floor(profit/ticketNum)" :min="min" @buy="buy" />
</div>
</template>
......@@ -19,7 +19,7 @@ import DetailsCard from '@/views/Details/DetailsCard.vue'
import DetailsList from '@/views/Details/DetailsList.vue'
import DetailsFooter from '@/views/Details/DetailsFooter.vue'
import { NavBar, Toast } from 'vant'
import { TICKET_COUNT } from '@/constance/const'
import service from '@/service/chain33'
import { poolInfo, bindPool, checkBind } from '@/service/pool'
import { signTxGroup } from '@33cn/wallet-api'
......@@ -36,7 +36,8 @@ export default Vue.extend({
fee: 0,
profit: 0,
isBind: false, // 是否初次委托
ticketNum: 10000 // 每票BTY
ticketNum: TICKET_COUNT, // 每票BTY
min: undefined as any
}
},
methods: {
......@@ -54,23 +55,26 @@ export default Vue.extend({
getInfo() {
poolInfo(this.$route.query.id as string).then((res: any) => {
this.info = res.data.data
checkBind(this.$route.query.id as string).then(res => {
if (res.data.data.isSucc) {
this.isBind = true
this.min = 1
}
}).catch(() => {
this.isBind = false
this.min = this.info.minTicket
})
})
},
checkBind() {
checkBind(this.$route.query.id as string).then(res => {
if (res.data.data.isSucc) {
this.isBind = true
}
}).catch(() => {
this.isBind = false
})
},
// checkBind() {
// },
signGroup(txs:Array<string>){
return signTxGroup(txs.join(),'none',-1);
},
async buy(value: string) {
// if (this.profit/this.ticketNum < +this.info.minTicket) {
if (this.profit/this.ticketNum < 1) {
if (this.profit/this.ticketNum < +this.info.minTicket) {
// if (this.profit/this.ticketNum < 1) {
Toast(`您的票数余额为${Math.floor(this.profit/this.ticketNum)}票,不足${this.info.minTicket}票`)
return
}
......@@ -124,9 +128,9 @@ export default Vue.extend({
}
},
created() {
console.log(this.ticketNum)
this.getFee()
this.getInfo()
this.checkBind()
}
})
</script>
......
......@@ -23,7 +23,7 @@
<script lang="ts">
import Vue from 'vue'
import service from '@/service/chain33'
import { userMinedData } from '@/service/pool'
import { TICKET_COUNT } from '@/constance/const'
import { Toast } from 'vant'
import Bus from '@/utils/bus'
export default Vue.extend({
......@@ -38,6 +38,11 @@ export default Vue.extend({
timer: 0
}
},
computed: {
// addr() {
// return this.$store.state.app.address
// }
},
methods: {
waitToPool() {
this.timer = setInterval(() => {
......@@ -47,6 +52,7 @@ export default Vue.extend({
getInfo() {
service.getBalance(this.$store.state.app.address, 'ticket').then((res: any) => {
this.profit = Math.floor((res.data.result as any)[0].balance / 1e8)
this.ticketNum = Math.floor((res.data.result as any)[0].frozen / 1e8 / TICKET_COUNT)
if (this.profit > 3000) {
this.btnClick = true
this.btnText = '等待挖矿'
......@@ -63,11 +69,6 @@ export default Vue.extend({
this.fee = res.data.result.properFee
})
},
getTicket() {
userMinedData().then(res => {
this.ticketNum = res.data.data.tickets
})
},
async getIncome() {
if (!this.profit) {
this.$toast('当前无收益可领')
......@@ -125,12 +126,13 @@ export default Vue.extend({
}
},
created() {
console.log('card', this.$store.state.app.address)
console.log('count', TICKET_COUNT)
this.addr = this.$store.state.app.address
this.getInfo()
this.getFee()
this.getTicket()
Bus.$on('updateMsg', () => {
this.getTicket()
this.getInfo()
})
}
})
......
......@@ -36,7 +36,8 @@ import MiningCard from '@/components/MiningCard.vue'
import Popup from '@/components/Popup.vue'
import constant from '@/constance/Image'
import Bus from '@/utils/bus'
import { invitePool, poolList, checkBind } from '@/service/pool'
import { invitePool, poolList, checkBind, isBind } from '@/service/pool'
import service from '@/service/chain33'
import { PullRefresh, Toast } from 'vant'
export default Vue.extend({
components: {
......@@ -75,8 +76,10 @@ export default Vue.extend({
res.data.data?.list ? this.lists.push(...res.data.data?.list) : this.lists = []
this.count = +res.data.data.count
document.addEventListener('scroll', this.scrollEvent)
Toast.clear()
}).catch(e => {
const err = e.response
Toast.clear()
if (err.data?.code === 406 && err.data?.reason === 'USER_NOT_BIND') {
this.show = true
}
......@@ -108,24 +111,34 @@ export default Vue.extend({
this.onRefresh()
}, this.waiter)
},
goDetails(val: string) {
checkBind(val).then(res => {
if (res.data.data.isSucc) {
this.$router.push({ path: '/details', query: { id: val || '1' }})
goDetails(val: { id: string, minerAddr: string }) {
service.getTicketAddress(this.$store.state.app.address).then(r => {
if (r.data.result?.data) {
checkBind(val.id).then(res => {
if (res.data.data.isSucc) {
Toast.clear()
this.$router.push({ path: '/details', query: { id: val.id || '1' }})
}
}).catch(() => {
Toast('该账号已绑定过矿池')
})
// this.$router.push({ path: '/details', query: { id: val.id || '1' }})
} else {
Toast.clear()
this.$router.push({ path: '/details', query: { id: val.id || '1' }})
}
}).catch(() => {
Toast('该账号已绑定过矿池')
})
},
addInvite(val: string) {
const regexp = /^(1|3)[a-zA-Z\d]{24,33}$/
// const regexp = /^(1|3)[a-zA-Z\d]{24,33}$/
if (!val) {
Toast('请先输入推荐人地址')
return
} else if (!regexp.test(val)) {
Toast('请输入正确的推荐人地址')
return
}
// else if (!regexp.test(val)) {
// Toast('请输入正确的推荐人地址')
// return
// }
invitePool(val).then((res: any) => {
if (res.data.data.isSucc) {
Toast('添加成功')
......@@ -141,6 +154,7 @@ export default Vue.extend({
},
},
created() {
Toast.loading()
this.getList()
this.setTimer()
},
......
......@@ -37,7 +37,7 @@ export default Vue.extend({
lists: [] as any,
isLoading: false,
page: 1,
pageSize: 10,
pageSize: 20,
count: 0,
}
},
......@@ -83,7 +83,7 @@ export default Vue.extend({
},
onRefresh() {
this.page = 1
this.pageSize = 10
this.pageSize = 20
if (this.active === 1) {
this.getNowList()
} else {
......
......@@ -5,21 +5,30 @@ module.exports = {
// ...other vue-cli plugin options...
css: {
loaderOptions: {
less: {
javascriptEnabled: true, // 加载LESS 需要把JS设置一下
}
}
// loaderOptions: {
// less: {
// javascriptEnabled: true, // 加载LESS 需要把JS设置一下
// }
// }
},
devServer: {
proxy: { // 设置代理
'/api': {
target: 'http://172.16.100.59:8090',
target: process.env.VUE_APP_URL,
// target: 'http://172.16.100.59:8090',
changeOrigin: true,
pathRewrite: {
'^/api': ''
}
},
// '/chain': {
// target: process.env.VUE_APP_CHAIN,
// // target: 'http://172.16.100.59:8090',
// changeOrigin: true,
// pathRewrite: {
// '^/api': ''
// }
// },
}
},
// configureWebpack: config => {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment