绿满眶商城微信小程序-uniapp
xiangpei
6 天以前 70738d032bd80f5b13075f8a13045ff4de57c2c3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<template>
  <view>
    <view class="-list">
      <view class="title">提现类型</view>
      <view class="content">
        <view class="price">
          <u-input disabled :value="type === 'ALI' ? '支付宝' : '微信'" placeholder="" />
        </view>
      </view>
    </view>
    <view class="-list">
      <view class="title">提现金额</view>
      <view class="content">
        <view class="price">
          <span> ¥</span>
          <u-input v-model="price" placeholder="" type="number" />
        </view>
    
        <view class="all">
          <view @click="handleAll" :style="{ color: $mainColor }">全部</view>
          <view style="font-size: 24rpx; color: #999">可提现金额<span>{{ walletNum | unitPrice }}</span>元</view>
        </view>
    
      </view>
      <view class="tips">
        最低提现金额为 {{ minPrice }} 元
      </view>
    </view>
    <view class="-list" v-if="type === 'ALI'">
      <view class="title">真实姓名</view>
      <view class="content">
        <view class="price">
          <u-input v-model="realName" placeholder="" />
        </view>
      </view>
    </view>
    <view class="-list" v-if="type === 'ALI'">
      <view class="title">第三方登录账号</view>
      <view class="content">
        <view class="price">
          <u-input v-model="connectNumber" placeholder="" />
        </view>
      </view>
    </view>
 
    <view class="submit" @click="cashd">提现</view>
  </view>
</template>
<script>
import '@/components/uview-components/uview-ui'
import { getUserWallet, withdrawalApply, withdrawalSettingVO } from "@/api/members";
export default {
  data() {
    return {
      price: 0,
      walletNum: 0,
      minPrice: 0,
      type: '',
      connectNumber: '',
      realName: ''
    };
  },
  async mounted() {
    let result = await getUserWallet(); //预存款
    let res = await withdrawalSettingVO();
    this.walletNum = result.data.result.memberWallet;
    this.minPrice = res.data.result.minPrice;
    this.type = res.data.result.type;
  },
 
  methods: {
    cashd() {
      this.price = this.price + "";
 
      if (this.$u.test.amount(parseInt(this.price))) {
        let params = { price: this.price };
        if (this.type === 'ALI') {
            if (!this.connectNumber || !this.realName) {
                uni.showToast({
                  title: "请输入真实姓名和第三方登录账号",
                  duration: 2000,
                  icon: "none",
                });
                return;
            }
            params.connectNumber = this.connectNumber;
            params.realName = this.realName;
        }
        withdrawalApply(params).then((res) => {
          if (res.data.success) {
            uni.showToast({
              title: "提现成功!",
              duration: 2000,
              icon: "none",
            });
            setTimeout(() => {
              uni.navigateBack({
                delta: 1,
              });
            }, 1000);
          }
        });
      } else {
        uni.showToast({
          title: "请输入正确金额",
          duration: 2000,
          icon: "none",
        });
      }
    },
    handleAll() {
      this.price = this.walletNum;
    },
  },
};
</script>
<style lang="scss" scoped>
@import "./style.scss";
.tips {
  font-size: 24rpx;
  color: #999;
}
</style>