liangjin
2021-04-01 ffcc13c38517386aee4f1b629b0be25a951cd2c2
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
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
<!--
 * @Author: 小明丶
 * @Date: 2019-10-24 15:13:33
 * @LastEditors: 小明丶
 * @LastEditTime: 2019-11-08 15:43:18
 * @Description: 
 -->
<template>
  <div class="withdrawals-box">
    <v-navbar title="提现"></v-navbar>
    <div class="zfb-box">
      <div class="left">
        <p>提现到</p>
      </div>
      <div class="middle">
        <i class="iconfont iconzhifubao"></i>
      </div>
      <div class="right">
        <p v-if="sta == 1" style="color:#333333;font-size:14px;margin-bottom:5px;">支付宝账号</p>
        <p
          v-if="sta == 1"
          style="color:#999999;font-size:14px;"
        >{{this.userNumber}}</p>
        <p
          v-if="sta == 2"
          style="color:#999999;font-size:14px;margin-top:10px"
          @click="showPopup"
        >请绑定支付宝账号</p>
      </div>
    </div>
    <van-popup
      v-model="show"
      @close="aferClose"
      class="clearfix"
      style="width:280px;height:280px;"
    >
      <div class="payCode" style="width: 280px;height: 170px;position: relative;">
        <van-icon name="cross" size="20px" style="position: absolute;right:10px;top:10px;color:#cccccc" @click="close" color="#CCCCCC"/>
        <img src="../../../../static/img/back.png" style="width:280px;height:170px">
        <img class="myimg" :src="qrCode" style="width: 110px;height: 110px; position: absolute;
      top: 45px;
      left: 85px;
      z-index: 1000;"/>
      </div>
      <div class="prod" style="width: 280px;height: 110px;text-align: center;background-color: white;z-index: 1000;">
        <p>0.01元</p>
        <p>请使用支付宝扫描并进行支付</p>
        <p>红包金额将提现至该支付宝账户</p>
      </div>
    </van-popup>
    <van-popup
      v-model="showTwo"
      @close="aferClose"
      style="width:200px;height:200px;"
    >
      <van-icon name="cross" size="20px" style="position: absolute;right:10px;top:10px;color:#cccccc" @click="closeTwo" color="#CCCCCC"/>
      <p style="text-align:center;margin-top:55px;"><van-icon name="checked" size="56px" color="#896edb"/></p>
      <p style="font-size:18px;font-weight:550;margin-top:10px;text-align:center">提现成功</p>
    </van-popup>
    <div class="money-box">
      <div class="tit">
        <p>提现金额</p>
      </div>
      <div class="input-box">
        <span>¥</span>
        <van-field
          v-model="value"
          placeholder="请输入提现金额"
          style="width:70%;display:inline-block;margin-left:30px;font-size:16px;"
          :border="false"
          maxlength="10"
        />
        <span @click="allWithd">全部提现</span>
      </div>
      <div class="yue">
        <p>
          <span>账户余额</span>
          <span>¥{{this.balanceAmount}}</span>
          <span>(余额不足10元无法提现)</span>
        </p>
      </div>
    </div>
    <van-button
      v-if="balanceAmount>10"
      round
      type="info"
      color="#896EDB"
      style="width:86%;margin-top:60px;margin-left:7%;background:#896EDB;color:#fff;border: .02rem solid rgb(137, 110, 219);"
      @click="getWidthrawals"
    >立即提现</van-button>
    <van-button
      v-else
      disabled
      round
      type="info"
      color="#896EDB"
      style="width:86%;margin-top:60px;margin-left:7%;background:#896EDB;color:#fff;border: .02rem solid rgb(137, 110, 219);"
      @click="getWidthrawals"
    >立即提现</van-button>
    <p class="notes">注:提现单笔限额为1000元,每日最多可提现3次。</p>
  </div>
</template>
<script>
import Vue from 'vue';
import QRCode from "qrcode";
//import { setInterval } from 'timer';
import { Notify } from 'vant';
import { Icon } from 'vant';
 
Vue.use(Icon);
Vue.use(Notify);
export default {
  data() {
    return {
      qrCode: "",
      params: {}, //路由接收的参数
      show: false, //弹出层控制
      showTwo:false,
      payQrCodeUrl: "",
      value: "",
      aliAccount:'',
      timerTwo:'',//轮训定时器
      balanceAmount:'',
      sta:0,
      userNumber:'',
    };
  },
  created() {
    this.$api.redPacketInit().then((res)=>{
      console.log(res)
      this.balanceAmount = res.body.balanceAmount
      this.userNumber = res.body.aliAccount
      if(res.body.aliAccount){
        this.sta = 1
      }else{
        this.sta = 2
      }
    })
    // this.$api.redPacketBindAliInfo().then(res => {
    //   console.log(1);
    //   this.payQrCodeUrl = res.body.payQrCodeUrl;
    //   let url = res.body.payQrCodeUrl;
    //   console.log(url);
    //   QRCode.toDataURL(
    //     url,
    //     {
    //       margin: 1,
    //       width: 100
    //     },
    //     (err, url) => {
    //       //if (err) console.error(err);
    //       this.qrCode = url;
    //       console.log(this.qrCode);
          
    //     }
    //   );
    // });
  },
  mounted() {
    //console.log(this.$route.params)
    this.params = this.$route.params;
  },
  updated(){
    window.onresize
  },
  beforeDestroy() {
    clearInterval(this.timerTwo);        
    this.timerTwo = null;
  },
  methods: {
    close(){
      clearInterval(this.timerTwo)
      this.timerTwo = ''
      this.show = false;
    },//绑定支付宝弹出层关闭按钮
    closeTwo(){
      this.showTwo = false
    },//提现成功关闭按钮
    aferClose(){
      clearInterval(this.timerTwo)
      this.timerTwo = ''
      this.show = false;
    },//支付宝绑定弹出层关闭后执行的事件
    getWidthrawals() {
      if (this.value <= 10) {
        Notify({ type: "primary", message: "提现金额需大于10元" });
      } else if(this.value >= 1000){
        Notify({ type: "primary", message: "提现金额需小于1000元" });
      }else {
        this.$api
          .redPacketExpend({
            amount: this.value
          })
          .then(res => {
            console.log(res);
            if(res.errMsg=='操作成功'){
              this.showTwo = true
              this.$api.redPacketInit().then((res)=>{
                this.balanceAmount = res.body.balanceAmount
              })
            }
          });
      }
    }, //提现
    allWithd() {
      this.value = this.balanceAmount;
    }, //全部提现
    onClickLeft() {
      this.$router.go(-1);
    }, //返回按钮
    showPopup() {
      this.$api.redPacketBindAliInfo().then(res => {
      console.log(1);
      this.payQrCodeUrl = res.body.payQrCodeUrl;
      let url = res.body.payQrCodeUrl;
      console.log(url);
      QRCode.toDataURL(
        url,
        {
          margin: 1,
          width: 100
        },
        (err, url) => {
          //if (err) console.error(err);
          this.qrCode = url;
          console.log(this.qrCode);
          
        }
      );
    });
      this.show = true;
      this.timerFun();
    }, //弹出层控制
    timerFun(){
      var _this = this
      this.timerTwo = setInterval(()=>{
        _this.$api.redPacketInit().then((res)=>{
          if(res.body.aliAccount){
            clearInterval(_this.timerTwo);
            _this.timerTwo = ''
            _this.show = false 
            Notify({ type: "primary", message: "绑定成功" });
            _this.userNumber = res.body.aliAccount
            _this.sta = 1
            return
          }else{
            console.log('未清除')
            //clearInterval(this.timerTwo);
            //this.show = false
            //Notify({ type: "primary", message: "绑定失败,请稍后再试" });
            //window.location.reload()
          }
        },
        err=>{
          err,clearInterval(_this.timerTwo); 
        })
      },10000)
    },
  }
};
</script>
<style lang="less" scoped>
.withdrawals-box {
  & {
   
    background-color: #f0f1f3;
    height: 100vh;
  }
  .clearfix{
 *zoom: 1;
}
.clearfix:after {
 clear: both;
 display: block;
 visibility: hidden;
 height: 0;
 content: ".";
}
  .zfb-box {
    height: 60px;
    width: 94%;
    background-color: white;
    border-radius: 3px;
    margin-left: 3%;
    margin-top: 20px;
    display: flex;
    .left {
      width: 30%;
      box-sizing: border-box;
      padding: 21px 0 23px 13px;
 
      p {
        color: #333333;
        font-size: 18px;
        font-weight: Bold;
        text-align: left;
      }
    }
    .middle {
      width: 10%;
      box-sizing: border-box;
      padding: 12px 0 12px 0;
      i {
        font-size: 36px;
        color: #00a9f2;
      }
    }
    .right {
      width: 60%;
      box-sizing: border-box;
      padding: 15px 0 0 10px;
    }
  }
  .money-box {
    width: 94%;
    background-color: white;
    margin-left: 3%;
    height: 145px;
    margin-top: 20px;
    border-radius: 3px;
    .tit {
      height: 50px;
      box-sizing: border-box;
      padding: 18px 0 17px 13px;
      p {
        color: #333333;
        font-weight: bold;
        font-size: 16px;
      }
    }
    .input-box {
      border-bottom: 1px solid #eeeeee;
      box-sizing: border-box;
      padding-left: 13px;
      padding-right: 12px;
      vertical-align: middle;
      position: relative;
      span:nth-of-type(1) {
        font-size: 18px;
        display: inline-block;
        position: absolute;
        bottom: 15px;
        z-index: 1000;
      }
      span:nth-of-type(2) {
        font-size: 14px;
        color: #896edb;
        text-decoration: underline;
        position: absolute;
        bottom: 15px;
        z-index: 1000;
      }
    }
    .yue {
      box-sizing: border-box;
      padding-left: 13px;
      padding-top: 16px;
      p {
        span:nth-of-type(1),
        span:nth-of-type(3) {
          font-size: 12px;
          color: #999999;
        }
        span:nth-of-type(2) {
          font-size: 12px;
        }
      }
    }
  }
  .notes {
    font-size: 12px;
    color: #999999;
    text-align: center;
    margin-top: 12px;
  }
  .payCode {
    
    
    
    .myimg {
      position: absolute;
      top: 45px;
      left: 85px;
      z-index: 1000;
    }
  }
  .prod {
    
    
    p:nth-of-type(1) {
      font-size: 18px;
      color: #333333;
      margin-bottom: 20px;
      margin-top: 25px;
    }
    p:nth-of-type(2),
    p:nth-of-type(3) {
      font-size: 12px;
      color: #999999;
      margin-bottom: 5px;
    }
  }
}
</style>