doum
2025-09-04 9d901b4215323c97a00a068cd962f5c9c04dadfa
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
<template>
    <view class="tx">
        <view class="tx-content">
            <view class="tx-content-title">可提现余额(元)</view>
            <view class="tx-content-price">
                <text>{{((userInfo.amount|| 0)/100).toFixed(2)}}</text>
                <view class="tx-content-price-btn" @click="jump">余额明细</view>
            </view>
            <view class="content">
                <view class="content-head">
                    <text>提现到账</text>
                    <text>微信零钱</text>
                </view>
                <view class="content-title">真实姓名</view>
                <view class="content-input" style="margin-bottom: 40rpx;"> 
                    <input style="font-weight: 500;" type="text" v-model="name"  @input="changeName" placeholder="微信实名认证姓名" /> 
                </view>
                <view class="content-title">提现金额</view>
                <view class="content-input">
                    <view class="content-input-icon">
                        <image src="/static/icon/ic_money@2x.png" mode="widthFix"></image>
                    </view>
                    <input type="digit" v-model="amount" @input="changeAmount" placeholder="请输入提现金额" />
                    <view class="content-input-btn" @click="inputAll">全部提现</view> 
                </view>
                <view class="content-tips">{{tips}}</view>
                <view class="content-button" @click="submit">2小时到账,确认提现</view>
            </view>
        </view>
    </view>
</template>
 
<script>
    import { mapState } from 'vuex'
    export default {
        computed: {
            ...mapState(['userInfo' ])
        },
        data() {
            return {
                tips:'',//
                wxTips:'',
                canTransfer:false,
                changing1:false,
                amount: null,
                name:''
            };
        },
        onLoad(){
            this.name = this.userInfo.name
            var that =this
            that.canTransfer = false
            if (wx.canIUse('requestMerchantTransfer')) {
                //that.tips='您的微信版本支持该功能'
                that.canTransfer = true
            }else{
                that.tips='您的微信版本过低,请更新至最新版本使用该功能'
                uni.showToast({
                    title:'您的微信版本过低,请更新至最新版本使用该功能。'
                })
            }
            /* wx.ready(function () {
              wx.checkJsApi({
                jsApiList: ['requestMerchantTransfer'],
                success: function (res) {
                  if (res.checkResult['requestMerchantTransfer']) {
                        that.canTransfer = true
                  } else {
                      that.tips='您的微信版本过低,请更新至最新版本使用该功能'
                      uni.showToast({
                          title:'您的微信版本过低,请更新至最新版本使用该功能。'
                      })
                  }
                }
              });
            }); */
        },
        methods: {
            jump() {
                uni.navigateTo({
                    url: '/pages/balance-details/balance-details'
                })
            }, 
            inputAll(){
                this.amount = ((this.userInfo.amount|| 0)/100).toFixed(2)
            },
            changeAmount(){
                this.tips=''
            },
            wxMerchantTransfer(param){    
                wx.requestMerchantTransfer({
                    mchId: param.mchId,
                    appId: param.appId,
                    package: param.packageInfo,
                    success: (res) => {
                      // res.err_msg将在页面展示成功后返回应用时返回ok,并不代表付款成功
                      console.log(res)
                      uni.navigateTo({
                          url: '/packageA/pages/withdrawal-successful/withdrawal-successful'
                      })
                    },
                    fail: (res) => {
                      console.log("22222222222222",res)
                      uni.showToast({
                          title:'对不起,提现失败。',
                        icon: 'none'
                      })
                    },
                  });
                /* WeixinJSBridge.invoke('requestMerchantTransfer',param,
                  function (res) {
                    if (res.err_msg === 'requestMerchantTransfer:ok') {
                      // res.err_msg将在页面展示成功后返回应用时返回success,并不代表付款成功
                      uni.navigateTo({
                          url: '/pages/withdrawal-successful/withdrawal-successful'
                      })
                    }else{ 
                        uni.showToast({
                            title:'对不起,提现失败。'+res.err_msg
                        })
                    }
                  }
                );     */                  
            },
            submit() {
                var that = this;
                  if(!this.canTransfer){
                      uni.showToast({
                          title:'您的微信版本过低,请更新至最新版本使用该功能。'
                      })
                      return;
                  }
                  if(this.changing1){
                        return
                  }
                  this.changing1 = true
                  if(this.amount == null || this.amount<=0){
                      this.tips = '提交金额必须大于0,至少提现0.1元'
                      this.changing1 = false
                      return
                  }
                  if(this.amount *100 > this.userInfo.amount){
                      this.tips = '输入的金额已经超过可提现金额'
                      this.changing1 = false
                      return
                  }
                  uni.requestSubscribeMessage({
                      tmplIds: ['fNJy4545hcrH83bP3a1vszs7XEKWjXMsrfr2XCNsql0'],
                      success(res) {
                          this.changing1 = true
                          var param ={amount:that.amount,name:that.name }
                          that.$u.api.applyWithdrawal(param)
                          .then(res =>{
                            if(res.code ===200){
                                that.wxMerchantTransfer(res.data);
                                // uni.navigateTo({
                                //     url: '/pages/withdrawal-successful/withdrawal-successful'
                                // })
                            } 
                           }).finally(() => {
                            that.changing1 = false
                            that.tips=''
                            that.amount =null
                        })
                      }
                  })
            },
            
        }
    }
</script>
 
<style lang="scss">
    page {
        background-color: $uni-bg-color-grey;
    }
</style>
 
<style lang="scss" scoped>
    .tx {
        width: 100%;
        .tx-content {
            width: 100%;
            height: 240rpx;
            padding: 30rpx 40rpx;
            box-sizing: border-box;
            background: #5BBE38;
            .content {
                width: 100%;
                padding: 60rpx 40rpx;
                box-sizing: border-box;
                background: #FFFFFF;
                box-shadow: 0rpx 2rpx 20rpx 0rpx rgba(0,0,0,0.08);
                border-radius: 20rpx;
                .content-head {
                    width: 100%;
                    display: flex;
                    align-items: center;
                    justify-content: space-between;
                    border-bottom: 1rpx solid #E5E5E5;
                    padding-bottom: 32rpx;
                    box-sizing: border-box;
                    margin-bottom: 30rpx;
                    text {
                        &:nth-child(1) {
                            font-weight: 400;
                            font-size: 30rpx;
                            color: #666666;
                        }
                        &:nth-child(2) {
                            font-weight: 400;
                            font-size: 30rpx;
                            color: #222222;
                        }
                    }
                }
                .content-title {
                    font-weight: 500;
                    font-size: 34rpx;
                    color: #111111;
                }
                .content-input {
                    width: 100%;
                    height: 116rpx;
                    display: flex;
                    align-items: center;
                    border-bottom: 1rpx solid #E5E5E5;
                    .content-input-icon {
                        width: 24rpx;
                        height: 56rpx;
                        flex-shrink: 0;
                        display: flex;
                        align-items: center;
                        justify-content: center;
                        image {
                            width: 100%;
                            height: 100%;
                        }
                    }
                    input {
                        flex: 1;
                        margin: 0 10px;
                        font-weight: 500;
                        font-size: 40rpx;
                        color: #222222;
                    }
                    .content-input-btn {
                        font-weight: 400;
                        font-size: 30rpx;
                        color: #5BBE38;
                    }
                }
                .content-tips {
                    font-weight: 400;
                    font-size: 26rpx;
                    color: #FF0000;
                    margin-top: 30rpx;
                }
                .content-button {
                    width: 100%;
                    height: 88rpx;
                    line-height: 88rpx;
                    text-align: center;
                    background: #5BBE38;
                    box-shadow: 0rpx 8rpx 12rpx 0rpx rgba(91,190,56,0.16);
                    border-radius: 44rpx;
                    font-weight: 500;
                    font-size: 32rpx;
                    color: #FFFFFF;
                    margin-top: 80rpx;
                    box-sizing: border-box;
                }
            }
            .tx-content-title {
                font-weight: 400;
                font-size: 26rpx;
                color: #FFFFFF;
                margin-bottom: 14rpx;
            }
            .tx-content-price {
                width: 100%;
                display: flex;
                align-items: center;
                justify-content: space-between;
                margin-bottom: 32rpx;
                text {
                    font-weight: 600;
                    font-size: 48rpx;
                    color: #FFFFFF;
                }
                .tx-content-price-btn {
                    width: 164rpx;
                    height: 60rpx;
                    line-height: 60rpx;
                    text-align: center;
                    border-radius: 30rpx;
                    font-weight: 400;
                    font-size: 26rpx;
                    color: #FFFFFF;
                    border: 2rpx solid #FFFFFF;
                }
            }
        }
    }
</style>