h5拍照添加水印上传

本文介绍如何在H5中实现用户拍照时添加自定义水印,并将带有水印的照片上传到服务器的功能。内容包括使用canvas绘制水印、处理图片文件以及通过AJAX进行文件上传的相关技术。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

/**
 * 可预览图片  ++水印   名字 部门  当前时间
 */
import React, { Component } from 'react';
import { ImagePicker } from 'antd-mobile';
import { Toast } from '@/pages/project/yjpt/components/PandaToast.jsx'
import envconfig from "@/envconfig/envconfig";
import Carousel, { ModalGateway, Modal } from 'react-images'

import './index.less';
import { getUsrInfo } from '@/util/localUitl'
import moment from 'moment';

class PicturePreview extends Component {

  static defaultProps = {
    label: '',
    name: '',
    value: '',
    placeholder: '',
    readOnly: 0
  }

  state = {
    isShowModal: false,
  }

  toggleModal = () => {
    this.setState({
      isShowModal: !this.state.isShowModal,
    })
  }

  mapUrl = (url) => {
    if(url.includes('base64')) {
      return url;
    }
    return `${envconfig.pandaURL}/cityinterface/rest/services/filedownload.svc/download${url}`;
  }

  handleChange = (files, type) => {
    if(type === 'add') {
      const len = files.length;
      const newFile = files[len - 1];
//newFile 就是被上传文件的一些信息  和input 中text=file是一样的道理
      this.changeFileFormat(newFile)
      // this.uploadImage(newFile);
    } else if(type === 'remove') {
      const { value } = this.props;
      const urls = value.split(',');
      const removeUrl = urls.filter(url => !files.find(file => file.url === url));
      if(removeUrl.l
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值