1
李凌
8 days ago 349c48e168b9f2580334422228acde7d1b21bede
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
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
<template>
  <div id="cryptos">
    <div class="loan-page">
      <assets-head :title="$t('助力贷')">
        <div class="right flex items-center">
          <img src="@/assets/image/loan/rule.png" alt="rule-img" class="head-icon mr-20"
            @click="$router.push('/cryptos/loanRule')" />
          <img src="@/assets/image/loan/history.png" alt="history-img" class="head-icon"
            @click="$router.push('/cryptos/loanHistory')" />
        </div>
      </assets-head>
 
      <div class="loan-body">
        <!-- 额度展示 -->
        <div class="hero-card">
          <div class="hero-badge">{{ $t('最高可借') }}</div>
          <div class="hero-amount">
            <span class="amount-num">{{ formatNum(loanData.maxQuota) }}</span>
            <span class="amount-unit">USDT</span>
          </div>
          <p class="hero-tip">{{ $t('经过平台审核,您可向平台申请一笔借款!') }}</p>
        </div>
 
        <!-- 期限选择 -->
        <div class="section-card">
          <div class="section-title">{{ $t('选择借款期限') }}</div>
          <div class="term-list">
            <div
              v-for="item in loanDeployList"
              :key="item.uuid || item.id || item.term"
              class="term-item"
              :class="{ active: isSamePlan(item) }"
              @click="selectDay(item)"
            >
              <span class="term-days">{{ item.term }}</span>
              <span class="term-unit">{{ $t('天') }}</span>
            </div>
          </div>
        </div>
 
        <!-- 方案详情 -->
        <div class="section-card">
          <div class="section-title">{{ $t('借款方案') }}</div>
          <div class="info-grid">
            <div class="info-row">
              <span class="info-label">{{ $t('期望借款金额') }}</span>
              <span class="info-value highlight">{{ formatNum(loanData.maxQuota) }} USDT</span>
            </div>
            <div class="info-row">
              <span class="info-label">{{ $t('还款周期') }}</span>
              <span class="info-value">{{ loanData.term || 0 }} {{ $t('天') }}</span>
            </div>
            <div class="info-row">
              <span class="info-label">{{ $t('日利率') }}</span>
              <span class="info-value">{{ dailyRatePercent }}%</span>
            </div>
            <div class="info-row">
              <span class="info-label">{{ $t('预计总利息') }}</span>
              <span class="info-value accent">{{ totalInterest }} USDT</span>
            </div>
            <div class="info-row">
              <span class="info-label">{{ $t('还款方式') }}</span>
              <span class="info-value">{{ $t('到期一次还款') }}</span>
            </div>
            <div class="info-row">
              <span class="info-label">{{ $t('放款机构') }}</span>
              <span class="info-value">{{ loanData.lendingName || '-' }}</span>
            </div>
          </div>
        </div>
 
        <!-- 证件上传 -->
        <div class="section-card upload-section">
          <div class="section-title">{{ $t('身份认证') }}</div>
          <p class="upload-tip">{{ $t('信用放款(请确保图片清晰可见)') }}</p>
          <div class="upload-grid">
            <div class="upload-item">
              <div class="upload-wrap">
                <van-uploader
                  v-model="frontFile"
                  multiple
                  :max-count="1"
                  :deletable="!isUpload"
                  :disabled="isUpload"
                  :after-read="afterRead"
                  @click-upload="onClickUpload('frontFile')"
                />
              </div>
              <span class="upload-label">{{ $t('credentFront') }}</span>
            </div>
            <div class="upload-item">
              <div class="upload-wrap">
                <van-uploader
                  v-model="reverseFile"
                  multiple
                  :max-count="1"
                  :deletable="!isUpload"
                  :disabled="isUpload"
                  :after-read="afterRead"
                  @click-upload="onClickUpload('reverseFile')"
                />
              </div>
              <span class="upload-label">{{ $t('credentObverse') }}</span>
            </div>
          </div>
        </div>
      </div>
 
      <div class="submit-bar">
        <button class="submit-btn" :disabled="isUpload" @click="submit">
          {{ $t('提交申请') }}
        </button>
      </div>
    </div>
  </div>
</template>
 
<script>
import AssetsHead from "@/components/Transform/assets-head/index.vue";
import { Uploader, showToast } from "vant";
import { _getLoan, _loanApply } from "@/service/fund.api";
import { _uploadImage } from "@/service/upload.api";
 
export default {
  name: "loanIndex",
  components: {
    AssetsHead,
    [Uploader.name]: Uploader,
  },
  computed: {
    dailyRatePercent() {
      const rate = Number(this.loanData.dailyRate) || 0;
      return (rate * 100).toFixed(2);
    },
    totalInterest() {
      const quota = Number(this.loanData.maxQuota) || 0;
      const rate = Number(this.loanData.dailyRate) || 0;
      const term = Number(this.loanData.term) || 0;
      return (quota * rate * term).toFixed(2);
    },
  },
  methods: {
    formatNum(val) {
      const n = Number(val) || 0;
      return n.toLocaleString(undefined, { maximumFractionDigits: 2 });
    },
    isSamePlan(item) {
      const key = item.uuid || item.id || item.term;
      const cur = this.loanData.uuid || this.loanData.id || this.loanData.term;
      return key === cur;
    },
    getLoan() {
      _getLoan().then(data => {
        this.loanDeployList = (data || []).sort((a, b) => +a.term - +b.term);
        if (this.loanDeployList.length) {
          this.loanData = this.loanDeployList[0];
        }
      });
    },
    submit() {
      if (!this.frontFile.length || !this.reverseFile.length) {
        showToast(this.$t('请上传证件正反面'));
        return;
      }
      if (!this.frontFile[0].resURL || !this.reverseFile[0].resURL) {
        showToast(this.$t('uploading'));
        return;
      }
      _loanApply({
        uuid: this.loanData.uuid || this.loanData.id,
        quota: this.loanData.maxQuota,
        symbol: 'USDT',
        frontFile: this.frontFile[0].resURL,
        reverseFile: this.reverseFile[0].resURL,
      }).then(() => {
        showToast(this.$t('提交成功'));
        this.$router.push('/cryptos/loanHistory');
      }).catch(err => {
        showToast(err.msg || this.$t('提交失败'));
      });
    },
    selectDay(data) {
      this.loanData = data;
    },
    onClickUpload(type) {
      this.curFile = type;
    },
    afterRead(file) {
      file.status = 'uploading';
      file.message = this.$t('uploading');
      this.isUpload = true;
      _uploadImage(file).then(data => {
        file.status = 'success';
        file.message = this.$t('uploadSuccess');
        file.resURL = data;
        if (this.curFile === 'frontFile') {
          this.frontFile = [file];
        } else {
          this.reverseFile = [file];
        }
        this.isUpload = false;
      }).catch(() => {
        file.status = 'failed';
        file.message = this.$t('uploadFailed');
        this.isUpload = false;
      });
    },
  },
  mounted() {
    this.getLoan();
  },
  data() {
    return {
      loanData: {},
      loanDeployList: [],
      frontFile: [],
      reverseFile: [],
      curFile: 'frontFile',
      isUpload: false,
    };
  },
};
</script>
 
<style scoped lang="scss">
@import "@/assets/init.scss";
 
#cryptos {
  .loan-page {
    min-height: 100vh;
    padding-bottom: 160px;
    box-sizing: border-box;
  }
 
  .head-icon {
    width: 50px;
    height: 50px;
  }
 
  .loan-body {
    padding: 24px 32px 0;
  }
 
  .hero-card {
    padding: 40px 36px;
    border-radius: 24px;
    background: linear-gradient(135deg, #1a6dff 0%, #004aee 55%, #0035b8 100%);
    color: #fff;
    box-shadow: 0 16px 40px rgba(0, 74, 238, 0.28);
    margin-bottom: 28px;
  }
 
  .hero-badge {
    display: inline-block;
    padding: 8px 20px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
    font-size: 24px;
    margin-bottom: 24px;
  }
 
  .hero-amount {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 16px;
  }
 
  .amount-num {
    font-size: 72px;
    font-weight: 700;
    line-height: 1;
  }
 
  .amount-unit {
    font-size: 32px;
    font-weight: 600;
    opacity: 0.9;
  }
 
  .hero-tip {
    margin: 0;
    font-size: 26px;
    line-height: 1.5;
    opacity: 0.88;
  }
 
  .section-card {
    padding: 32px 28px;
    border-radius: 20px;
    margin-bottom: 24px;
    @include themify() {
      background: themed("cont_background");
    }
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.04);
  }
 
  .section-title {
    font-size: 32px;
    font-weight: 600;
    margin-bottom: 28px;
    @include themify() {
      color: themed("text_color");
    }
  }
 
  .term-list {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
  }
 
  .term-item {
    min-width: 120px;
    padding: 20px 28px;
    border-radius: 16px;
    text-align: center;
    border: 2px solid transparent;
    transition: all 0.2s;
    @include themify() {
      background: themed("tab_background");
      color: themed("text_color2");
    }
 
    &.active {
      border-color: #004aee;
      background: rgba(0, 74, 238, 0.08);
      color: #004aee;
    }
  }
 
  .term-days {
    font-size: 40px;
    font-weight: 700;
    margin-right: 4px;
  }
 
  .term-unit {
    font-size: 24px;
  }
 
  .info-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
  }
 
  .info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 0;
    border-bottom: 1px solid rgba(134, 142, 155, 0.15);
 
    &:last-child {
      border-bottom: none;
      padding-bottom: 0;
    }
 
    &:first-child {
      padding-top: 0;
    }
  }
 
  .info-label {
    font-size: 28px;
    color: #868e9b;
  }
 
  .info-value {
    font-size: 28px;
    font-weight: 600;
    text-align: right;
    max-width: 55%;
    @include themify() {
      color: themed("text_color");
    }
 
    &.highlight {
      color: #004aee;
      font-size: 30px;
    }
 
    &.accent {
      color: #e35461;
    }
  }
 
  .upload-section {
    margin-bottom: 0;
  }
 
  .upload-tip {
    margin: -12px 0 28px;
    font-size: 26px;
    color: #868e9b;
    line-height: 1.5;
  }
 
  .upload-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
  }
 
  .upload-item {
    display: flex;
    flex-direction: column;
    align-items: center;
  }
 
  .upload-wrap {
    width: 100%;
    height: 220px;
    border-radius: 16px;
    overflow: hidden;
    border: 2px dashed rgba(0, 74, 238, 0.25);
    background: rgba(0, 74, 238, 0.03);
    display: flex;
    align-items: center;
    justify-content: center;
 
    ::v-deep .van-uploader,
    ::v-deep .van-uploader__wrapper,
    ::v-deep .van-uploader__upload,
    ::v-deep .van-uploader__preview,
    ::v-deep .van-uploader__preview-image {
      width: 100% !important;
      height: 220px !important;
      margin: 0 !important;
    }
 
    ::v-deep .van-uploader__upload-icon {
      font-size: 48px;
      color: #004aee;
    }
  }
 
  .upload-label {
    margin-top: 16px;
    font-size: 26px;
    color: #868d9a;
  }
 
  .submit-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 24px 32px calc(24px + env(safe-area-inset-bottom));
    @include themify() {
      background: themed("footer_background");
    }
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06);
    z-index: 20;
  }
 
  .submit-btn {
    width: 100%;
    height: 96px;
    border: none;
    border-radius: 16px;
    background: linear-gradient(90deg, #1a6dff, #004aee);
    color: #fff;
    font-size: 32px;
    font-weight: 600;
 
    &:disabled {
      opacity: 0.6;
    }
  }
}
</style>