|
@@ -118,7 +118,7 @@
|
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
|
<!-- 培训证明上传区域(学员端 + 进行中) -->
|
|
<!-- 培训证明上传区域(学员端 + 进行中) -->
|
|
|
- <view v-if="userType == 2 && !upType" class="upload-section">
|
|
|
|
|
|
|
+ <view v-if="userType == 2 && !upType && proofRequired" class="upload-section">
|
|
|
<view class="upload-header">
|
|
<view class="upload-header">
|
|
|
<text class="upload-icon">🖼️</text>
|
|
<text class="upload-icon">🖼️</text>
|
|
|
<text class="upload-title">上传培训证明</text>
|
|
<text class="upload-title">上传培训证明</text>
|
|
@@ -127,7 +127,7 @@
|
|
|
<!-- 已选图片预览 -->
|
|
<!-- 已选图片预览 -->
|
|
|
<view class="upload-preview">
|
|
<view class="upload-preview">
|
|
|
<view v-for="(img, idx) in previewImages" :key="idx" class="preview-item">
|
|
<view v-for="(img, idx) in previewImages" :key="idx" class="preview-item">
|
|
|
- <image class="preview-img" :src="img" mode="aspectFill" @click="previewImage(img)"></image>
|
|
|
|
|
|
|
+ <image class="preview-img" :src="baseUrl+img" mode="aspectFill" @click="previewImage(img)"></image>
|
|
|
<view class="preview-del" @click.stop="removeImage(idx)">×</view>
|
|
<view class="preview-del" @click.stop="removeImage(idx)">×</view>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
@@ -217,6 +217,7 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
|
|
+ import { config } from '@/api/request/config.js'
|
|
|
import {
|
|
import {
|
|
|
examElTrainingTaskProgressDetail,examElTrainingTaskSignInList,
|
|
examElTrainingTaskProgressDetail,examElTrainingTaskSignInList,
|
|
|
examUserTrainingDetail,examUserTrainingSignIn,examUserTrainingProofUpload,
|
|
examUserTrainingDetail,examUserTrainingSignIn,examUserTrainingProofUpload,
|
|
@@ -224,6 +225,7 @@
|
|
|
export default {
|
|
export default {
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
|
|
|
+ baseUrl:config.base_url,
|
|
|
id:'',
|
|
id:'',
|
|
|
userType: 0, // 1老师 2学生(后续自行调试切换)
|
|
userType: 0, // 1老师 2学生(后续自行调试切换)
|
|
|
detail: {},
|
|
detail: {},
|
|
@@ -248,6 +250,8 @@
|
|
|
signType:false,
|
|
signType:false,
|
|
|
//上传状态
|
|
//上传状态
|
|
|
upType:false,
|
|
upType:false,
|
|
|
|
|
+ //开启签到上传状态
|
|
|
|
|
+ proofRequired:false,
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
computed: {
|
|
computed: {
|
|
@@ -347,6 +351,7 @@
|
|
|
if (data.code == 200) {
|
|
if (data.code == 200) {
|
|
|
this.$set(this,'signType',data.data.signStatus==1?true:false);
|
|
this.$set(this,'signType',data.data.signStatus==1?true:false);
|
|
|
this.$set(this,'upType',data.data.proofImages[0]?true:false);
|
|
this.$set(this,'upType',data.data.proofImages[0]?true:false);
|
|
|
|
|
+ this.$set(this,'proofRequired',data.data.proofRequired==1?true:false);
|
|
|
this.$set(this,'previewImages',data.data.proofImages);
|
|
this.$set(this,'previewImages',data.data.proofImages);
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -450,6 +455,7 @@
|
|
|
},
|
|
},
|
|
|
// 选择图片
|
|
// 选择图片
|
|
|
chooseImage() {
|
|
chooseImage() {
|
|
|
|
|
+ let self = this;
|
|
|
const remaining = 5 - this.previewImages.length
|
|
const remaining = 5 - this.previewImages.length
|
|
|
if (remaining <= 0) {
|
|
if (remaining <= 0) {
|
|
|
uni.showToast({ title: '最多上传 5 张图片', icon: 'none' })
|
|
uni.showToast({ title: '最多上传 5 张图片', icon: 'none' })
|
|
@@ -466,10 +472,44 @@
|
|
|
uni.showToast({ title: '图片大小不能超过 10MB', icon: 'none' })
|
|
uni.showToast({ title: '图片大小不能超过 10MB', icon: 'none' })
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- this.previewImages = [...this.previewImages, ...res.tempFilePaths]
|
|
|
|
|
|
|
+ let tempFilePaths = res.tempFilePaths[0];
|
|
|
|
|
+ self.uploadImg(tempFilePaths);
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
|
|
+ async uploadImg(tempFilePaths){
|
|
|
|
|
+ let self = this;
|
|
|
|
|
+ uni.showLoading({
|
|
|
|
|
+ title: '上传中',
|
|
|
|
|
+ mask: true
|
|
|
|
|
+ });
|
|
|
|
|
+ uni.uploadFile({
|
|
|
|
|
+ url: config.base_url + '/system/file/upload', //仅为示例,非真实的接口地址
|
|
|
|
|
+ header:{'Authorization':uni.getStorageSync('token')},
|
|
|
|
|
+ filePath: tempFilePaths,
|
|
|
|
|
+ name: 'file',
|
|
|
|
|
+ formData: {
|
|
|
|
|
+ 'user': 'test'
|
|
|
|
|
+ },
|
|
|
|
|
+ success: (uploadFileRes) => {
|
|
|
|
|
+ let res = JSON.parse(uploadFileRes.data);
|
|
|
|
|
+ if(res.code == 200){
|
|
|
|
|
+ this.previewImages.push(res.data.url);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: res.msg,
|
|
|
|
|
+ icon:"none",
|
|
|
|
|
+ mask:true,
|
|
|
|
|
+ duration: 2000
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ fail: err => {},
|
|
|
|
|
+ complete: () => {
|
|
|
|
|
+ uni.hideLoading()
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
// 移除预览图
|
|
// 移除预览图
|
|
|
removeImage(idx) {
|
|
removeImage(idx) {
|
|
|
this.previewImages.splice(idx, 1)
|
|
this.previewImages.splice(idx, 1)
|