更新记录

1.0.1(2024-09-12) 下载此版本

修复生成的水印图片文字不加粗的bug

1.0.0(2024-09-09) 下载此版本

通过live-pusher组件实现拍照,然后使用webview对照片添加水印


平台兼容性

HbuilderX/cli最低兼容版本
3.1.0

uni-app

Vue2 Vue3
?
app-vue app-nvue app-android app-ios app-harmony
? ? ? ? ?
H5-Safari Android Browser 微信浏览器(Android) QQ浏览器(Android) Chrome IE Edge Firefox PC-Safari
? ? ? ? ? ? ? ? ?
微信小程序 支付宝小程序 百度小程序 字节小程序 QQ小程序 钉钉小程序 快手小程序 飞书小程序 京东小程序
? ? ? ? ? ? ? ? ?
快应用-华为 快应用-联盟
? ?

uni-app x

app-android app-ios
? ?
H5-Safari Android Browser 微信浏览器(Android) QQ浏览器(Android) Chrome IE Edge Firefox PC-Safari
? ? ? ? ? ? ? ? ?

watasi-watermark-camera 水印相机

插件地址:watasi-watermark-camera 水印相机

仅支持nvue页面,仅支持APP

仅支持nvue页面,仅支持APP

仅支持nvue页面,仅支持APP

不支持vue3

使用说明

属性 是否必填 值类型 默认值 说明
watermark Array [] 水印,详情见下
debug Boolean false 是否调试模式,调试模式下onPostMessage不会触发,即接收到不到change事件,但可以输出html内的打印
@ready Function - 初始化完成,返回livePusher的宽高等信息
@snapshot Function - 开始拍照
@change Function - 拍摄完成,返回当前拍摄的base64

watermark

属性 值类型 说明
type String 取值text(文本)image(图片)fillRect(矩形)
x Number x轴坐标
y Number y轴坐标
color String type为textfillRect时有效
text String type为text时有效,文本内容
size String type为text时有效,文本字号
isBold Boolean type为text时有效,是否加粗
w String type为fillRectimage时有效,宽
h String type为fillRectimage时有效,高
url String type为image时有效,图片路径

示例(nvue)

<template>
    <view class="watermark-page">
        <watasi-watermark-camera :watermark="watermark" @ready="ready" @snapshot="snapshot" @change="change" />
    </view>
</template>

<script>
    export default {
        data() {
            return {
                watermark: []
            };
        },

        methods: {
            ready(e) {
                const { height, width } = e
                this.watermark = [{
                    type: 'text',
                    x: uni.upx2px(24),
                    y: height - uni.upx2px(150),
                    color: '#fff',
                    size: uni.upx2px(68),
                    text: "14:04",
                    isBold: true
                }, {
                    type: "fillRect",
                    x: uni.upx2px(232),
                    y: height - uni.upx2px(150),
                    w: uni.upx2px(4),
                    h: uni.upx2px(78),
                    color: "#f60"
                }, {
                    type: 'text',
                    x: uni.upx2px(260),
                    y: height - uni.upx2px(150),
                    color: '#fff',
                    size: uni.upx2px(30),
                    text: "2024-09-09",
                }, {
                    type: 'text',
                    x: uni.upx2px(260),
                    y: height - uni.upx2px(100),
                    color: '#fff',
                    size: uni.upx2px(30),
                    text: "星期一"
                }, {
                    type: 'text',
                    x: uni.upx2px(24),
                    y: height - uni.upx2px(48),
                    color: '#fff',
                    size: uni.upx2px(28),
                    text: '江苏省苏州市科技城软件大厦'
                }, {
                    type: 'image',
                    url: 'https://bpic.588ku.com/element_origin_min_pic/00/15/94/7556aeca8408555.jpg',
                    x: width - uni.upx2px(84),
                    y: height - uni.upx2px(84),
                    w: uni.upx2px(60),
                    h: uni.upx2px(60),
                }]
            },

            snapshot() {
                uni.showLoading({
                    mask: true
                })
            },

            change(base64) {
                console.log(base64);
                console.log("执行上传操作");
                uni.hideLoading()
            }
        }
    }
</script>

<style lang="scss">
    .watermark-page {
        flex: 1;
    }
</style>

其他说明

  • 如果出现image没有成功绘制到照片上的情况,请检查图片是否可以跨域访问
  • 默认打开前置摄像头,如果需要默认打开后置摄像头,可以在ready回调里调用切换前后摄像头方法this.$refs.watermark.switchCamera()

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

许可协议

MIT协议

暂无用户评论。

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问