Commit 8da2d5b2 authored by liwei's avatar liwei

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

parent 1d0e3882
......@@ -25,7 +25,7 @@
<script>
import ELM from '@/components/elm-toast/index.vue';
import {updateUser, userDetail} from "../../api/user";
import {getOssUrl} from "../../api/article";
import {getOssUrl, getUploadType} from "../../api/article";
export default {
data() {
return {
......@@ -36,7 +36,8 @@
singleNoShow: false,
tipMsg: '',
isConfirm: false,
educationPictureUrl:null
educationPictureUrl:null,
uploadType: 'aliYun_direct'
}
},
components: {
......@@ -44,8 +45,15 @@
},
onShow() {
this.loadPage();
this.getUploadType()
},
methods: {
// 获取上传类型 判断当前是oss上传还是本地上传
getUploadType(){
getUploadType().then( res=>{
this.uploadType = res.data.data
})
},
singleNoClose() {
this.singleNoShow = false;
},
......@@ -73,13 +81,58 @@
uni.showLoading({
title: "图片上传中"
})
if (this.uploadType === 'aliYun_direct'){
// oss直传
uni.uploadFile({
// url: 'http://192.168.1.18:8082/common/aliyunOssFileUploadByWx',
url: this.$BASE_URL + '/common/aliyunOssFileUploadByWx',
filePath: i,
formData: {
file: i,//你要传的临时文件
temp: 'opmMember',
},
header: {
Authorization: 'Bearer ' + uni.getStorageSync("token"),
},
name: 'file',
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,
file: i,//你要传的临时文件
temp: 'opmArticle',
bucket:'cust-91isoft'
},
header: {
Authorization: 'Bearer ' + uni.getStorageSync("token"),
......@@ -90,6 +143,7 @@
this.updateImage(res.data.businessId);
},
});
}
});
}
});
......
......@@ -254,8 +254,8 @@ import {getOssUrl, getUploadType} from "../../api/article";
singleNoShow: false,
singleIndex: 0,
waitApprovedImg: [],
// oss上传类型 aliYun local
uploadType: 'aliYun'
// oss上传类型
uploadType: 'aliYun_direct'
}
},
computed: {
......
......@@ -25,7 +25,7 @@
<script>
import ELM from '@/components/elm-toast/index.vue';
import {updateUser, userDetail} from "../../api/user";
import {getOssUrl} from "../../api/article";
import {getOssUrl, getUploadType} from "../../api/article";
export default {
data() {
return {
......@@ -36,16 +36,25 @@
singleNoShow: false,
tipMsg: '',
isConfirm: false,
educationPictureUrl:null
educationPictureUrl:null,
// oss上传类型
uploadType: 'aliYun_direct'
}
},
components: {
ELM
},
onShow() {
this.loadPage();
this.loadPage()
this.getUploadType()
},
methods: {
// 获取上传类型 判断当前是oss上传还是本地上传
getUploadType(){
getUploadType().then( res=>{
this.uploadType = res.data.data
})
},
singleNoClose() {
this.singleNoShow = false;
},
......@@ -73,13 +82,58 @@
uni.showLoading({
title: "图片上传中"
})
if (this.uploadType === 'aliYun_direct'){
// oss直传
uni.uploadFile({
// url: 'http://192.168.1.18:8082/common/aliyunOssFileUploadByWx',
url: this.$BASE_URL + '/common/aliyunOssFileUploadByWx',
filePath: i,
formData: {
file: i,//你要传的临时文件
temp: 'opmMember',
},
header: {
Authorization: 'Bearer ' + uni.getStorageSync("token"),
},
name: 'file',
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,
file: i,//你要传的临时文件
temp: 'opmArticle',
bucket:'cust-91isoft'
},
header: {
Authorization: 'Bearer ' + uni.getStorageSync("token"),
......@@ -90,6 +144,7 @@
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