hookehuyr

✨ feat(上传相关模块): 七牛新增HTTPS地址

1 /* 1 /*
2 * @Date: 2022-05-18 22:56:08 2 * @Date: 2022-05-18 22:56:08
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2022-11-21 17:12:28 4 + * @LastEditTime: 2023-02-10 15:13:01
5 * @FilePath: /data-table/src/api/fn.js 5 * @FilePath: /data-table/src/api/fn.js
6 * @Description: 文件描述 6 * @Description: 文件描述
7 */ 7 */
...@@ -43,7 +43,7 @@ export const fn = (api) => { ...@@ -43,7 +43,7 @@ export const fn = (api) => {
43 export const uploadFn = (api) => { 43 export const uploadFn = (api) => {
44 return api 44 return api
45 .then(res => { 45 .then(res => {
46 - if (res.statusText === 'OK') { 46 + if (res.status === 200) {
47 return res.data || true; 47 return res.data || true;
48 } else { 48 } else {
49 // tslint:disable-next-line: no-console 49 // tslint:disable-next-line: no-console
...@@ -51,7 +51,7 @@ export const uploadFn = (api) => { ...@@ -51,7 +51,7 @@ export const uploadFn = (api) => {
51 if (!res.data.show) return false; 51 if (!res.data.show) return false;
52 Toast({ 52 Toast({
53 icon: 'close', 53 icon: 'close',
54 - message: res.data.msg 54 + message: res.data.msg,
55 }); 55 });
56 return false; 56 return false;
57 } 57 }
......
...@@ -280,8 +280,14 @@ const uploadQiniu = async (file, token, name, md5) => { ...@@ -280,8 +280,14 @@ const uploadQiniu = async (file, token, name, md5) => {
280 headers: { "Content-Type": "multipart/form-data" }, 280 headers: { "Content-Type": "multipart/form-data" },
281 }; 281 };
282 // 自拍文件上传七牛服务器 282 // 自拍文件上传七牛服务器
283 + let qiniuUploadUrl;
284 + if (window.location.protocol === 'https:') {
285 + qiniuUploadUrl = 'https://up.qbox.me';
286 + } else {
287 + qiniuUploadUrl = 'http://upload.qiniu.com';
288 + }
283 const { filekey, hash, image_info } = await qiniuUploadAPI( 289 const { filekey, hash, image_info } = await qiniuUploadAPI(
284 - "http://upload.qiniu.com/", 290 + qiniuUploadUrl,
285 formData, 291 formData,
286 config 292 config
287 ); 293 );
......
...@@ -290,8 +290,14 @@ const uploadQiniu = async (file, token, name, md5) => { ...@@ -290,8 +290,14 @@ const uploadQiniu = async (file, token, name, md5) => {
290 headers: { "Content-Type": "multipart/form-data" }, 290 headers: { "Content-Type": "multipart/form-data" },
291 }; 291 };
292 // 自拍图片上传七牛服务器 292 // 自拍图片上传七牛服务器
293 + let qiniuUploadUrl;
294 + if (window.location.protocol === 'https:') {
295 + qiniuUploadUrl = 'https://up.qbox.me';
296 + } else {
297 + qiniuUploadUrl = 'http://upload.qiniu.com';
298 + }
293 const { filekey, hash, image_info } = await qiniuUploadAPI( 299 const { filekey, hash, image_info } = await qiniuUploadAPI(
294 - "http://upload.qiniu.com/", 300 + qiniuUploadUrl,
295 formData, 301 formData,
296 config 302 config
297 ); 303 );
......
1 <!-- 1 <!--
2 * @Date: 2022-09-06 16:29:31 2 * @Date: 2022-09-06 16:29:31
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2023-02-10 11:28:50 4 + * @LastEditTime: 2023-02-10 15:15:05
5 * @FilePath: /data-table/src/components/SignField/index.vue 5 * @FilePath: /data-table/src/components/SignField/index.vue
6 * @Description: 电子签名控件 6 * @Description: 电子签名控件
7 --> 7 -->
...@@ -129,8 +129,14 @@ const uploadQiniu = async (file, token, filename) => { ...@@ -129,8 +129,14 @@ const uploadQiniu = async (file, token, filename) => {
129 headers: { "Content-Type": "multipart/form-data" }, 129 headers: { "Content-Type": "multipart/form-data" },
130 }; 130 };
131 // 自拍图片上传七牛服务器 131 // 自拍图片上传七牛服务器
132 + let qiniuUploadUrl;
133 + if (window.location.protocol === 'https:') {
134 + qiniuUploadUrl = 'https://up.qbox.me';
135 + } else {
136 + qiniuUploadUrl = 'http://upload.qiniu.com';
137 + }
132 const { filekey, hash, image_info } = await qiniuUploadAPI( 138 const { filekey, hash, image_info } = await qiniuUploadAPI(
133 - "http://upload.qiniu.com/", 139 + qiniuUploadUrl,
134 formData, 140 formData,
135 config 141 config
136 ); 142 );
......