绿满眶商城微信小程序-uniapp
zhanghua
5 天以前 1113721c0e068c57adbc15149cce15563960a7f2
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
124
125
126
127
128
129
130
<template>
  <view>
    <view class="withdrawal-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>{{ distributionData.canRebate | unitPrice }}</span
            >元</view
          >
        </view>
      </view>
    </view>
 
    <view class="submit" @click="cashd">提现</view>
  </view>
</template>
<script>
import '@/components/uview-components/uview-ui';
import { distribution, cash } from "@/api/goods";
export default {
  data() {
    return {
      price: 0,
      distributionData: "",
    };
  },
  mounted() {
    this.init();
  },
  methods: {
    cashd() {
      this.price = this.price + "";
    
 
      if (this.$u.test.amount(parseInt(this.price))) {
        cash({ price: this.price }).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.distributionData.canRebate;
    },
    /**
     * 初始化推广商品
     */
    init() {
      uni.showLoading({
        title: "加载中",
      });
      distribution().then((res) => {
        if (res.data.result) {
          this.distributionData = res.data.result;
        }
         if (this.$store.state.isShowToast){ uni.hideLoading() };
      });
    },
  },
};
</script>
<style lang="scss" scoped>
/deep/ .u-input__input,
.u-input {
  font-size: 80rpx !important;
  height: 102rpx !important;
 
}
/deep/ .u-input__input{
  height: 100%;
   font-size: 80rpx;
}
.content {
  display: flex;
  > .price {
    width: 60%;
    margin: 20rpx 0;
    font-size: 80rpx;
    display: flex;
  }
  > .all {
    justify-content: center;
    width: 40%;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
  }
}
.withdrawal-list {
  margin: 20rpx 0;
  background: #fff;
  padding: 16rpx 32rpx;
}
.title {
  font-size: 35rpx;
}
.submit {
  margin: 80rpx auto;
  width: 94%;
  background: $light-color;
  height: 90rpx;
  color: #fff;
  border-radius: 10rpx;
  text-align: center;
  line-height: 90rpx;
}
</style>