Commit 02b6df4c authored by 杨梦雪's avatar 杨梦雪

upload

parent e942d41c
......@@ -965,7 +965,7 @@
/* eslint-disable */
import {delPic, getAccount, getProAndCity, getSchool, setAccount} from "r/index/signUp";
import COS from "cos-js-sdk-v5";
import {cosSignature, getSignature} from "r/index/cosUpload";
import {cosSignature,achievementCallBack} from "r/index/cosUpload";
import validator from "common/validator";
import area from "config/area";
import cueDialog from "c/index/cueDialog";
......@@ -1800,7 +1800,7 @@
async getCosConfigs(image, file) {
console.log(file)
this.loading = true;
await getSignature(1)
await cosSignature({image: image, index: '1'})
.then((res) => {
console.log(res, "开始上传图片");
let resData = res.data.data
......@@ -1809,19 +1809,19 @@
// 必选参数
getAuthorization: (options, callback) => {
callback({
TmpSecretId: resData.credential.credentials.tmpSecretId,
TmpSecretKey: resData.credential.credentials.tmpSecretKey,
XCosSecurityToken: resData.credential.credentials.sessionToken,
StartTime: resData.credential.startTime, // 时间戳,单位秒,如:1580000000
ExpiredTime: resData.credential.expiredTime, // 时间戳,单位秒,如:1580000900
TmpSecretId: resData.credentials.credential.credentials.tmpSecretId,
TmpSecretKey: resData.credentials.credential.credentials.tmpSecretKey,
XCosSecurityToken: resData.credentials.credential.credentials.sessionToken,
StartTime: resData.credentials.credential.startTime, // 时间戳,单位秒,如:1580000000
ExpiredTime: resData.credentials.credential.expiredTime, // 时间戳,单位秒,如:1580000900
});
},
});
console.log(resData)
cos.putObject({
Bucket: resData.bucket,
Region: resData.region,
Key: '111/fg.png',
Bucket: resData.credentials.bucket,
Region: resData.credentials.region,
Key: resData.key,
Body: file,
onProgress: (progressData) => {
console.log("上传进度:" + JSON.stringify(progressData));
......@@ -1835,7 +1835,7 @@
this.$message.error('上传失败!')
} else {
console.log(data);
this.signUploadSuccess('http://' + data.Location, image);
this.signUploadSuccess('http://' + data.Location,resData);
}
}
);
......@@ -1849,8 +1849,8 @@
});
},
// cos上传-告诉后端上传成功
async signUploadSuccess(path, image) {
await cosSignature({image: image, index: '1'}).then(res => {
async signUploadSuccess(path,resData) {
await achievementCallBack({key:resData.key,index:1}).then(res => {
if (res.data.code != 200) {
this.loading = false;
return this.$message.error('上传失败!');
......@@ -1860,7 +1860,7 @@
this.resultPicture = path + "?t=" + Date.parse(new Date());
this.$forceUpdate();
let obj = {
url: res.data.savefile,
url:res.data.picture_path,
};
this.fileList.push(obj);
let code = this.$store.state.indexIdentity;
......
......@@ -17,7 +17,7 @@
// export const SERVER_WS_URL = "wss://apiy.thuers.com"; // websocket
// 测试
export const SERVER_URL = " https://tgwapi.campcenter.cn/modules-campsite"; // 正式环境
export const SERVER_URL = "https://tgwapi.campcenter.cn/modules-campsite"; // 正式环境
export const DEVELOPMENT_SERVER_URL = " https://tgwapi.campcenter.cn/modules-campsite"; //开发环境
export const SERVER_WS_URL = "wss://tgwapi.campcenter.cn"; // websocket
......@@ -7,6 +7,7 @@ export function getSignature(index) {
url: `/web/download/getSignature/${index}`,
})
}
//cos签名-web直传 1-个人信息上传2-作业上传3-银行缴费截图上传
export function cosSignature(data) {
data['identity'] = store.state.indexIdentity;
......@@ -16,3 +17,12 @@ export function cosSignature(data) {
data
})
}
export function achievementCallBack(data) {
data['identity'] = store.state.indexIdentity;
return request({
method: 'post',
url: '/web/notify/achievementCallBack',
data
})
}
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