gx
queenwuli
2022-03-23 063571a2da8999709b32d434248c85df8a57724f
gx
3 files modified
50 ■■■■ changed files
src/assets/js/axios.js 2 ●●● patch | view | raw | blame | history
src/pages/index/account.vue 30 ●●●●● patch | view | raw | blame | history
src/pages/index/index.vue 18 ●●●●● patch | view | raw | blame | history
src/assets/js/axios.js
@@ -15,7 +15,7 @@
});
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);
src/pages/index/account.vue
@@ -129,19 +129,43 @@
</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>
src/pages/index/index.vue
@@ -27,7 +27,7 @@
                <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">
@@ -101,6 +101,7 @@
  },
  setup() {
    const { proxy } = getCurrentInstance();
    let accountRef = ref(null);
    let walletAddress = ref('');
    let hasApprove = ref(false);
    let isShowApproveModal = ref(false);
@@ -169,7 +170,8 @@
      
      walletAddress, //地址
      hasApprove, //是否授权
      myAccountInfo: reactive({})
      accountRef
    };
  },
  methods: {
@@ -187,12 +189,12 @@
    },
    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;
@@ -239,7 +241,7 @@
    },
    submitApprove () {
        this.$axios({
          url: '/dapp/common/approve',
          url: '/dapi/common/approve',
          method: 'post',
          data: {
            address: this.walletAddress,
@@ -251,9 +253,11 @@
          }
        })
    },
    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) {