Commit 8da2d5b2 authored by liwei's avatar liwei

修改了学历认证和工作认证上传

parent 1d0e3882
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
<script> <script>
import ELM from '@/components/elm-toast/index.vue'; import ELM from '@/components/elm-toast/index.vue';
import {updateUser, userDetail} from "../../api/user"; import {updateUser, userDetail} from "../../api/user";
import {getOssUrl} from "../../api/article"; import {getOssUrl, getUploadType} from "../../api/article";
export default { export default {
data() { data() {
return { return {
...@@ -36,7 +36,8 @@ ...@@ -36,7 +36,8 @@
singleNoShow: false, singleNoShow: false,
tipMsg: '', tipMsg: '',
isConfirm: false, isConfirm: false,
educationPictureUrl:null educationPictureUrl:null,
uploadType: 'aliYun_direct'
} }
}, },
components: { components: {
...@@ -44,8 +45,15 @@ ...@@ -44,8 +45,15 @@
}, },
onShow() { onShow() {
this.loadPage(); this.loadPage();
this.getUploadType()
}, },
methods: { methods: {
// 获取上传类型 判断当前是oss上传还是本地上传
getUploadType(){
getUploadType().then( res=>{
this.uploadType = res.data.data
})
},
singleNoClose() { singleNoClose() {
this.singleNoShow = false; this.singleNoShow = false;
}, },
...@@ -73,23 +81,69 @@ ...@@ -73,23 +81,69 @@
uni.showLoading({ uni.showLoading({
title: "图片上传中" title: "图片上传中"
}) })
uni.uploadFile({ if (this.uploadType === 'aliYun_direct'){
url: this.$BASE_URL + '/common/fileUpload', // oss直传
filePath: i, uni.uploadFile({
formData: { // url: 'http://192.168.1.18:8082/common/aliyunOssFileUploadByWx',
file: i, url: this.$BASE_URL + '/common/aliyunOssFileUploadByWx',
temp: 'opmArticle', filePath: i,
bucket:'cust-91isoft' formData: {
}, file: i,//你要传的临时文件
header: { temp: 'opmMember',
Authorization: 'Bearer ' + uni.getStorageSync("token"), },
}, header: {
name: 'file', Authorization: 'Bearer ' + uni.getStorageSync("token"),
success: (uploadFileRes) => { },
let res = JSON.parse(uploadFileRes.data) name: 'file',
this.updateImage(res.data.businessId); success: (res) => {
}, let response = JSON.parse(res.data)
}); const formData = {
key: response.data.url, //上传文件名称
policy: response.data.policy, //表单域
'x-oss-signature-version': response.data.x_oss_signature_version, //指定签名的版本和算法
'x-oss-credential': response.data.x_oss_credential, //指明派生密钥的参数集
'x-oss-date': response.data.x_oss_date, //请求的时间
'x-oss-signature': response.data.signature, //签名认证描述信息
'x-oss-security-token': response.data.security_token, //安全令牌
success_action_status: "200" //上传成功后响应状态码
};
wx.uploadFile({
url: response.data.ossDomainName, // 此域名仅作示例,实际Bucket域名,请替换为您的目标Bucket域名。
filePath: i,
name: 'file', //固定值为file
formData: formData,
success:(res1) =>{
console.log('上传响应:', res1);
this.updateImage(response.data.ossInfoId);
uni.$off('Cropper');// 移除事件监听 否则会叠加调用
},
fail:(err) =>{
console.error('上传失败:', err); // 输出错误信息
wx.showToast({ title: '上传失败,请重试!', icon: 'none' });
}
});
},
});
} else {
// 本地上传 oss服务端上传 minio上传
uni.uploadFile({
// url: 'http://192.168.1.18:8082/common/fileUpload',
url: this.$BASE_URL + '/common/fileUpload',
filePath: i,
formData: {
file: i,//你要传的临时文件
temp: 'opmArticle',
},
header: {
Authorization: 'Bearer ' + uni.getStorageSync("token"),
},
name: 'file',
success: (uploadFileRes) => {
let res = JSON.parse(uploadFileRes.data)
this.updateImage(res.data.businessId);
},
});
}
}); });
} }
}); });
......
...@@ -254,8 +254,8 @@ import {getOssUrl, getUploadType} from "../../api/article"; ...@@ -254,8 +254,8 @@ import {getOssUrl, getUploadType} from "../../api/article";
singleNoShow: false, singleNoShow: false,
singleIndex: 0, singleIndex: 0,
waitApprovedImg: [], waitApprovedImg: [],
// oss上传类型 aliYun local // oss上传类型
uploadType: 'aliYun' uploadType: 'aliYun_direct'
} }
}, },
computed: { computed: {
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
<script> <script>
import ELM from '@/components/elm-toast/index.vue'; import ELM from '@/components/elm-toast/index.vue';
import {updateUser, userDetail} from "../../api/user"; import {updateUser, userDetail} from "../../api/user";
import {getOssUrl} from "../../api/article"; import {getOssUrl, getUploadType} from "../../api/article";
export default { export default {
data() { data() {
return { return {
...@@ -36,16 +36,25 @@ ...@@ -36,16 +36,25 @@
singleNoShow: false, singleNoShow: false,
tipMsg: '', tipMsg: '',
isConfirm: false, isConfirm: false,
educationPictureUrl:null educationPictureUrl:null,
// oss上传类型
uploadType: 'aliYun_direct'
} }
}, },
components: { components: {
ELM ELM
}, },
onShow() { onShow() {
this.loadPage(); this.loadPage()
this.getUploadType()
}, },
methods: { methods: {
// 获取上传类型 判断当前是oss上传还是本地上传
getUploadType(){
getUploadType().then( res=>{
this.uploadType = res.data.data
})
},
singleNoClose() { singleNoClose() {
this.singleNoShow = false; this.singleNoShow = false;
}, },
...@@ -73,23 +82,69 @@ ...@@ -73,23 +82,69 @@
uni.showLoading({ uni.showLoading({
title: "图片上传中" title: "图片上传中"
}) })
uni.uploadFile({ if (this.uploadType === 'aliYun_direct'){
url: this.$BASE_URL + '/common/fileUpload', // oss直传
filePath: i, uni.uploadFile({
formData: { // url: 'http://192.168.1.18:8082/common/aliyunOssFileUploadByWx',
file: i, url: this.$BASE_URL + '/common/aliyunOssFileUploadByWx',
temp: 'opmArticle', filePath: i,
bucket:'cust-91isoft' formData: {
}, file: i,//你要传的临时文件
header: { temp: 'opmMember',
Authorization: 'Bearer ' + uni.getStorageSync("token"), },
}, header: {
name: 'file', Authorization: 'Bearer ' + uni.getStorageSync("token"),
success: (uploadFileRes) => { },
let res = JSON.parse(uploadFileRes.data) name: 'file',
this.updateImage(res.data.businessId); success: (res) => {
}, let response = JSON.parse(res.data)
}); const formData = {
key: response.data.url, //上传文件名称
policy: response.data.policy, //表单域
'x-oss-signature-version': response.data.x_oss_signature_version, //指定签名的版本和算法
'x-oss-credential': response.data.x_oss_credential, //指明派生密钥的参数集
'x-oss-date': response.data.x_oss_date, //请求的时间
'x-oss-signature': response.data.signature, //签名认证描述信息
'x-oss-security-token': response.data.security_token, //安全令牌
success_action_status: "200" //上传成功后响应状态码
};
wx.uploadFile({
url: response.data.ossDomainName, // 此域名仅作示例,实际Bucket域名,请替换为您的目标Bucket域名。
filePath: i,
name: 'file', //固定值为file
formData: formData,
success:(res1) =>{
console.log('上传响应:', res1);
this.updateImage(response.data.ossInfoId);
uni.$off('Cropper');// 移除事件监听 否则会叠加调用
},
fail:(err) =>{
console.error('上传失败:', err); // 输出错误信息
wx.showToast({ title: '上传失败,请重试!', icon: 'none' });
}
});
},
});
} else {
// 本地上传 oss服务端上传 minio上传
uni.uploadFile({
// url: 'http://192.168.1.18:8082/common/fileUpload',
url: this.$BASE_URL + '/common/fileUpload',
filePath: i,
formData: {
file: i,//你要传的临时文件
temp: 'opmArticle',
},
header: {
Authorization: 'Bearer ' + uni.getStorageSync("token"),
},
name: 'file',
success: (uploadFileRes) => {
let res = JSON.parse(uploadFileRes.data)
this.updateImage(res.data.businessId);
},
});
}
}); });
} }
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment