Browse Source

上传图片时新增加载条

master
liaoxinyu 4 months ago
parent
commit
45c14fbfc8
  1. 3
      i18n/lang/en.json
  2. 3
      i18n/lang/zh-TW.json
  3. 2
      pages/assets/coin-list.vue
  4. 97
      pages/auth/senior.vue

3
i18n/lang/en.json

@ -275,7 +275,8 @@
"d2": "Passport",
"d3": "ID card",
"d4": "Select date",
"d5": "Please select"
"d5": "Please select",
"d6": "The file size is too large to exceed"
},
"exchange": {
"a0": "Spot Trading",

3
i18n/lang/zh-TW.json

@ -275,7 +275,8 @@
"d2": "護照",
"d3": "身份證",
"d4": "選擇日期",
"d5": "請選擇"
"d5": "請選擇",
"d6": "檔案尺寸過大,不得超過"
},
"exchange": {
"a0": "幣幣",

2
pages/assets/coin-list.vue

@ -8,7 +8,7 @@
<view class="layout-main">
<template v-for="item in showList">
<view
v-if="item.coin_name=='USDT'||item.coin_name=='BTC'||item.coin_name=='ETH'"
v-if="item.is_recharge!==0&&item.is_recharge!==null||item.is_withdraw!==0&&item.is_withdraw!==null"
class="p-y-md p-x-xs align-center justify-between d-flex link-active m-x-md border-b"
@click="$emit('input',item.coin_name);$emit('close');$emit('imgs',item)"
>

97
pages/auth/senior.vue

@ -11,11 +11,14 @@
<div
@click="getFile('front_img')"
class="upload-box d-flex justify-center align-center rounded-sm bg-panel-3 box-shadow"
style="position: relative;"
>
<van-icon v-if="!form.front_img" class="color-light fn-30" name="photograph" />
<img v-else :src="form.front_img" alt />
<progress v-if="uploadPercentbol" :percent="uploadPercent" show-info stroke-width="3" style="width: 150px;position: absolute;bottom: -20px;right: 0px;" />
</div>
</div>
</div>
<div class="form-item p-md m-md">
<div class="color-light p-b-xs">2{{$t('auth.b6')}}</div>
@ -26,9 +29,11 @@
<div
@click="getFile('back_img')"
class="upload-box d-flex justify-center align-center rounded-sm bg-panel-3 box-shadow"
style="position: relative;"
>
<van-icon v-if="!form.back_img" class="color-light fn-30" name="photograph" />
<img v-else :src="form.back_img" alt />
<progress v-if="uploadPercentbol1" :percent="uploadPercent1" show-info stroke-width="3" style="width: 150px;position: absolute;bottom: -20px;right: 0px;" />
</div>
</div>
</div>
@ -64,6 +69,10 @@ export default {
data() {
return {
imgBase: undefined,
uploadPercent: 0,
uploadPercentbol:true,
uploadPercentbol1:true,
uploadPercent1: 0,
form: {
hand_img: "",
back_img: "",
@ -76,17 +85,84 @@ export default {
},
methods: {
getFile(name) {
console.log(name)
this.$getFile({count:9}).then((res) => {
this.upLoadImg(res, name);
this.$getFile({count:1}).then((res) => {
const MAX_SIZE = 5 * 1024 * 1024;
if(res.tempFiles[0]&&res.tempFiles[0].size > MAX_SIZE){
this.$toast(this.$t('auth.d6')+'5M');
}else{
this.upLoadImg(res, name);
}
})
},
//
upLoadImg(chooseImageRes, name) {
Member.uploadImage(chooseImageRes).then((res) => {
this.form[name] = res.data.url;
this.$toast.success(this.$t('auth.c1'));
});
upLoadImg(chooseImageRes, name1) {
if(name1=='front_img'){
this.uploadPercent = 0;
this.uploadPercentbol = true;
const uploadTask = uni.uploadFile({
url: 'https://seee.bigtchain.com/api/app/uploadImage',
filePath: chooseImageRes.tempFiles[0].path,
name: 'image',
header: {
'authorization': uni.getStorageSync('token')
},
success: response => {
// console.log('', response)
const img = JSON.parse(response.data);
this.form[name1] = img.data.url
this.uploadPercent = 100
},
fail: err => {
uni.showToast({ title: '上传失败', icon: 'none' })
}
})
uploadTask.onProgressUpdate((res) => {
// console.log('' + res.progress);
this.uploadPercent = res.progress
if(this.uploadPercent==100){
setTimeout(()=>{
this.uploadPercentbol = false
},1000)
}
});
}else{
this.uploadPercent1 = 0;
this.uploadPercentbol1 = true;
const uploadTask = uni.uploadFile({
url: 'https://seee.bigtchain.com/api/app/uploadImage',
filePath: chooseImageRes.tempFiles[0].path,
name: 'image',
header: {
'authorization': uni.getStorageSync('token')
},
success: response => {
// console.log('', response)
const img = JSON.parse(response.data);
this.form[name1] = img.data.url
this.uploadPercent1 = 100
},
fail: err => {
uni.showToast({ title: '上传失败', icon: 'none' })
}
})
uploadTask.onProgressUpdate((res) => {
// console.log('' + res.progress);
this.uploadPercent1 = res.progress
if(this.uploadPercent1==100){
setTimeout(()=>{
this.uploadPercentbol1 = false
},1000)
}
});
}
// Member.uploadImage(chooseImageRes).then((res) => {
// this.form[name] = res.data.url;
// this.$toast.success(this.$t('auth.c1'));
// });
},
//
topAuth() {
@ -132,4 +208,9 @@ export default {
object-fit: cover;
}
}
::v-deep .uni-progress-info{
font-size: 12px;
margin-left: 8px;
}
</style>

Loading…
Cancel
Save