-
zhangwei
2025-03-24 2d43a1df3f5ba42710e6d21c27d1e13bdb8dfd56
src/pages/wallet/recharge.vue
@@ -33,31 +33,29 @@
   export default {
      data() {
         return {
            money: null,
            balance: null,
            userInfo: {}
            money: null
         }
      },
      computed: {
         ...mapGetters(['userInfo', 'identity']),
         balance() {
            if (this.identity == 'worker') {
               if (this.userInfo.userWorker) {
                  return this.$common.moneySub(this.userInfo.userWorker.tiXianZonge, this.userInfo
                     .userWorker
                     .yiTiXianJine)
               } else {
                  return '0.00'
               }
            // if (this.identity == 'worker') {
            if (this.userInfo.userWorker) {
               return this.$common.moneySub(this.userInfo.userWorker.tiXianZonge, this.userInfo
                  .userWorker
                  .yiTiXianJine)
            } else {
               if (this.userInfo.userCompany) {
                  return this.userInfo.userCompany.chongZhiYue ? this.userInfo.userCompany
                     .chongZhiYue :
                     '0.00'
               } else {
                  return '0.00'
               }
               return '0.00'
            }
            // } else {
            //    if (this.userInfo.userCompany) {
            //       return this.userInfo.userCompany.chongZhiYue ? this.userInfo.userCompany
            //          .chongZhiYue :
            //          '0.00'
            //    } else {
            //       return '0.00'
            //    }
            // }
         }
      },
      onLoad() {},
@@ -65,6 +63,13 @@
         ...mapActions([
            'getUserInfo'
         ]),
         stringToNumber(str) {
            const match = str.match(/[\d.]+/); // 正则表达式匹配数字和点
            if (match) {
               return parseFloat(match[0]); // 使用parseFloat转换
            }
            return 0; // 如果没有匹配到数字,返回NaN
         },
         GetTransferMoney() {
            if (!this.money) {
               this.$util.showToast({
@@ -73,7 +78,14 @@
               });
               return false
            }
            if (this.money > this.balance) {
            if (this.money < 0.3) {
               this.$util.showToast({
                  title: "最低提现0.3元!",
                  icon: 'error'
               });
               return false
            }
            if (this.stringToNumber(this.money) > this.stringToNumber(this.balance)) {
               this.$util.showToast({
                  title: "输入金额大于可提现金额!"
               });
@@ -82,9 +94,11 @@
            this.$api.GetTransferMoney(this.money).then(res => {
               if (res.code == 1) {
                  this.$util.showToast({
                     title: '提现成功!’',
                     title: '提现成功!',
                  });
                  this.money = null
                  this.getUserInfo()
                  uni.navigateBack()
               } else {
                  this.$util.showToast({
                     title: res.error ? res.error : '提现失败!’',