提交 a31a2030 authored 作者: 杨斌基's avatar 杨斌基

feat(上报内容): 调大水印文字大小

上级 af511ab6
......@@ -443,7 +443,7 @@
import { actionsOptions, week } from '@/pages/record-content/mock';
import UploadActionSheet from '@/pages/record-content/UploadActionSheet';
import CertificateTypeActionSheet from '@/pages/record-content/CertificateTypeActionSheet';
import { baseEncode } from '@/utils/util';
import { baseEncode, getImageInfo } from '@/utils/util';
const maxUploadVideoSizeM = 50 // M
const maxUploadVideoSize = maxUploadVideoSizeM * 1000 * 1000 // 单位 B,参考 macOS 用 1000 计算
......@@ -692,7 +692,7 @@ export default {
* @returns {Promise<void>}
*/
async onUpload(item) {
const upLoad = async (file, type = 'image') => {
const upLoad = async (file, type = 'image', tempFilePath) => {
const media = {
id: uni.$u.guid(),
type,
......@@ -713,13 +713,32 @@ export default {
const myDay = `${'拍摄时间:' + ' '}${uni.$u.timeFormat(new Date(), 'yyyy-mm-dd hh:MM:ss')}`;
const { key } = JSON.parse(res);
// 水印文字大小,单位: 缇 ,等于1/20磅,默认值是240缇,参考DPI为72。
// 1px(像素) = 0.75 磅
// 1 / 20 * (1 / .75) * 240 => 16
// 所以 240 缇约等于 16px
// 1px => 15 缇
const isImage = type === 'image'
let scale = 1
if (isImage) {
const { width, height } = await getImageInfo(tempFilePath)
// 拿到短边参考
const ref = Math.min(width, height)
const phoneWidth = 375
const scale = ref / phoneWidth
}
const getRealSize = value => ~~(value * scale)
const fontSize = getRealSize(240 * 2.5)
media.url =
type === 'image'
? `${data.qn_domain}${key}?watermark/3/text/${baseEncode(myAddress)
.replace(/\+/g, '-')
.replace(/\//g, '_')}/font/5b6u6L2v6ZuF6buR/fontsize/240/fill/I0ZGRkZGRg==/dissolve/100/gravity/SouthWest/dx/28/dy/40/text/${baseEncode(myDay)
.replace(/\//g, '_')}/font/5b6u6L2v6ZuF6buR/fontsize/${fontSize}/fill/I0ZGRkZGRg==/dissolve/100/gravity/SouthWest/dx/${getRealSize(28)}/dy/${getRealSize(50)}/text/${baseEncode(myDay)
.replace(/\+/g, '-')
.replace(/\//g, '_')}/font/5b6u6L2v6ZuF6buR/fontsize/240/fill/I0ZGRkZGRg==/dissolve/100/gravity/SouthWest/dx/28/dy/10`
.replace(/\//g, '_')}/font/5b6u6L2v6ZuF6buR/fontsize/${fontSize}/fill/I0ZGRkZGRg==/dissolve/100/gravity/SouthWest/dx/${getRealSize(28)}/dy/${getRealSize(10)}`
: `${data.qn_domain}${key}`;
media.status = 'finish';
......@@ -735,8 +754,9 @@ export default {
case 'image':
uni.chooseImage({
success: (result) => {
result.tempFiles.forEach((value) => {
upLoad(value);
console.log(result, 'result')
result.tempFiles.forEach((value, index) => {
upLoad(value, undefined, result.tempFilePaths[index]);
});
},
fail: (result) => {
......
......@@ -128,4 +128,10 @@ export const baseEncode = (str) => {
return base64_encode(utf16to8(str));
};
export const getImageInfo = src => {
return new Promise((resolve, reject) => {
uni.getImageInfo({ src, success: resolve, fail: reject })
})
}
export default myRequest;
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论