| | |
| | | }); |
| | | service.interceptors.request.use(config => { |
| | | let address = sessionStorage.getItem('address'); |
| | | address && (config.headers.address = address); |
| | | address && (config.headers.token = address); |
| | | return config; |
| | | }, error => { |
| | | return Promise.reject(error); |
| | |
| | | </template> |
| | | |
| | | <script scope> |
| | | import { ref, onMounted, getCurrentInstance, defineComponent} from 'vue'; |
| | | import { ref, reactive, onMounted, getCurrentInstance, defineComponent} from 'vue'; |
| | | export default defineComponent({ |
| | | name: 'account', |
| | | setup() { |
| | | const activeNames = ref(['1']) |
| | | const { proxy } = getCurrentInstance(); |
| | | let myAccountInfo = reactive({}); |
| | | function getWalletInfo(){ |
| | | proxy.$axios({ |
| | | url: '/dapp/member/walletInfo', |
| | | method: 'post' |
| | | }).then((res) => { |
| | | if(res.code == 200) { |
| | | proxy.myAccountInfo = res.data; |
| | | } |
| | | }) |
| | | } |
| | | onMounted(() => { |
| | | |
| | | }) |
| | | return { activeNames }; |
| | | return { |
| | | activeNames, |
| | | myAccountInfo, |
| | | getWalletInfo |
| | | }; |
| | | }, |
| | | methods: { |
| | | |
| | | getWalletInfo(){ |
| | | this.$axios({ |
| | | url: '/dapp/member/walletInfo', |
| | | method: 'post' |
| | | }).then((res) => { |
| | | if(res.code == 200) { |
| | | this.myAccountInfo = res.data; |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | }) |
| | | </script> |
| | |
| | | <OrePool></OrePool> |
| | | </van-tab> |
| | | <van-tab :title='$t("message.Account")'> |
| | | <Account></Account> |
| | | <Account :ref="accountRef"></Account> |
| | | </van-tab> |
| | | </van-tabs> |
| | | <van-overlay :show="isShowApproveModal" @click="isShowApproveModal = false" class="wrapper"> |
| | |
| | | }, |
| | | setup() { |
| | | const { proxy } = getCurrentInstance(); |
| | | let accountRef = ref(null); |
| | | let walletAddress = ref(''); |
| | | let hasApprove = ref(false); |
| | | let isShowApproveModal = ref(false); |
| | |
| | | |
| | | walletAddress, //地址 |
| | | hasApprove, //是否授权 |
| | | myAccountInfo: reactive({}) |
| | | |
| | | accountRef |
| | | }; |
| | | }, |
| | | methods: { |
| | |
| | | }, |
| | | isApprove () { |
| | | this.$axios({ |
| | | url: '/dapp/common/isApprove/' + this.walletAddress, |
| | | url: '/dapi/common/isApprove/' + this.walletAddress, |
| | | method: 'get' |
| | | }).then((res) => { |
| | | if(res.code == 200) { |
| | | this.hasApprove = true; |
| | | this.getWalletInfo() |
| | | this.initAccountData() |
| | | sessionStorage.setItem('address', this.walletAddress); |
| | | }else{ |
| | | this.hasApprove = false; |
| | |
| | | }, |
| | | submitApprove () { |
| | | this.$axios({ |
| | | url: '/dapp/common/approve', |
| | | url: '/dapi/common/approve', |
| | | method: 'post', |
| | | data: { |
| | | address: this.walletAddress, |
| | |
| | | } |
| | | }) |
| | | }, |
| | | getWalletInfo(){ |
| | | initAccountData(){ |
| | | // this.accountRef.value.getWalletInfo(); |
| | | alert(accountRef) |
| | | this.$axios({ |
| | | url: '/dapp/member/walletInfo', |
| | | url: '/dapi/member/walletInfo', |
| | | method: 'post' |
| | | }).then((res) => { |
| | | if(res.code == 200) { |