提交 11d2cebc authored 作者: 劳广强's avatar 劳广强

fix: 修复 填写上报内容图片加水印

上级 cc2dc50f
...@@ -353,6 +353,7 @@ ...@@ -353,6 +353,7 @@
import { actionsOptions, week } from '@/pages/record-content/mock'; import { actionsOptions, week } from '@/pages/record-content/mock';
import UploadActionSheet from '@/pages/record-content/UploadActionSheet'; import UploadActionSheet from '@/pages/record-content/UploadActionSheet';
import CertificateTypeActionSheet from '@/pages/record-content/CertificateTypeActionSheet'; import CertificateTypeActionSheet from '@/pages/record-content/CertificateTypeActionSheet';
import { baseEncode } from '@/utils/util';
export default { export default {
components: { CertificateTypeActionSheet, UploadActionSheet }, components: { CertificateTypeActionSheet, UploadActionSheet },
...@@ -473,12 +474,12 @@ export default { ...@@ -473,12 +474,12 @@ export default {
*/ */
async upload() { async upload() {
if (this.address === '' || this.address === '点击授权获取位置信息') { if (this.address === '' || this.address === '点击授权获取位置信息') {
// uni.showModal({ uni.showModal({
// title: '提示', title: '提示',
// content: '请获取拍摄地点后上传照片', content: '请获取地点后上传照片',
// showCancel: false, showCancel: false,
// }); });
// return; return;
} }
this.$refs.uploadActionSheet.show = true; this.$refs.uploadActionSheet.show = true;
}, },
...@@ -505,14 +506,21 @@ export default { ...@@ -505,14 +506,21 @@ export default {
file, file,
}, },
}); });
const myAddress = `${'拍摄地点:' + ' '}${this.address}`;
const myDay = `${'拍摄时间:' + ' '}${uni.$u.timeFormat(new Date(), 'yyyy-mm-dd hh:MM:ss')}`;
const { key } = JSON.parse(res); const { key } = JSON.parse(res);
// this.photoList.push({ media.url =
// id: uni.$u.guid(), type === 'image'
// type, ? `${data.qn_domain}${key}?watermark/3/text/${baseEncode(myAddress)
// url: `${data.qn_domain}${key}`, .replace(/\+/g, '-')
// }); .replace(/\//g, '_')}/font/5b6u6L2v6ZuF6buR/fontsize/240/fill/I0ZGRkZGRg==/dissolve/100/gravity/SouthWest/dx/28/dy/40/text/${baseEncode(myDay)
media.url = `${data.qn_domain}${key}`; .replace(/\+/g, '-')
.replace(/\//g, '_')}/font/5b6u6L2v6ZuF6buR/fontsize/240/fill/I0ZGRkZGRg==/dissolve/100/gravity/SouthWest/dx/28/dy/10`
: `${data.qn_domain}${key}`;
media.status = 'finish'; media.status = 'finish';
if (type === 'video') { if (type === 'video') {
this.photoList = this.photoList.map((value, index) => ({ this.photoList = this.photoList.map((value, index) => ({
...value, ...value,
......
...@@ -49,4 +49,69 @@ export const myRequest = (options) => { ...@@ -49,4 +49,69 @@ export const myRequest = (options) => {
export const getPrice = (value = 0) => Number(value ?? 0) / 100; export const getPrice = (value = 0) => Number(value ?? 0) / 100;
// 图片水印
const base64_encode = (str) => {
// 下面是64个基本的编码
const base64EncodeChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
let out;
let i;
let len;
let c1;
let c2;
let c3;
len = str.length;
i = 0;
out = '';
while (i < len) {
c1 = str.charCodeAt(i++) & 0xff;
if (i == len) {
out += base64EncodeChars.charAt(c1 >> 2);
out += base64EncodeChars.charAt((c1 & 0x3) << 4);
out += '==';
break;
}
c2 = str.charCodeAt(i++);
if (i == len) {
out += base64EncodeChars.charAt(c1 >> 2);
out += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xf0) >> 4));
out += base64EncodeChars.charAt((c2 & 0xf) << 2);
out += '=';
break;
}
c3 = str.charCodeAt(i++);
out += base64EncodeChars.charAt(c1 >> 2);
out += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xf0) >> 4));
out += base64EncodeChars.charAt(((c2 & 0xf) << 2) | ((c3 & 0xc0) >> 6));
out += base64EncodeChars.charAt(c3 & 0x3f);
}
return out;
};
const utf16to8 = (str) => {
let out;
let i;
let len;
let c;
out = '';
len = str.length;
for (i = 0; i < len; i++) {
c = str.charCodeAt(i);
if (c >= 0x0001 && c <= 0x007f) {
out += str.charAt(i);
} else if (c > 0x07ff) {
out += String.fromCharCode(0xe0 | ((c >> 12) & 0x0f));
out += String.fromCharCode(0x80 | ((c >> 6) & 0x3f));
out += String.fromCharCode(0x80 | ((c >> 0) & 0x3f));
} else {
out += String.fromCharCode(0xc0 | ((c >> 6) & 0x1f));
out += String.fromCharCode(0x80 | ((c >> 0) & 0x3f));
}
}
return out;
};
export const baseEncode = (str) => {
return base64_encode(utf16to8(str));
};
export default myRequest; export default myRequest;
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论