小程序截图分享

如果加水印的话,我是用背景做了个水印截的图

html 复制代码
<content-interface>
    <canvas canvas-id="share" style="position: fixed;top: -1000px;height: 100vh; width: 100%;"></canvas>
    <view class="page-content">
        <view class="page-top draw_canvas">
            <image class="bg_water draw_canvas" src="/images/my/share.png" data-type="image" data-url="/images/my/share.png" />
            <view class="success-state draw_canvas" data-type="text" data-text="{{details.statusDesc || '--'}}">{{details.statusDesc || '--'}}</view>
        </view>
    </view>
 </content-interface>
js 复制代码
import { settlement_order_detail, } from './api';
import Wxml2Canvas from './wxml2canvas.js';
var _img = null;
var drawImage;
var drawImageData = {
  list: [{
      type: 'wxml',
      class: '.page-content .draw_canvas',
      limit: '.page-content',
      x: 0,
      y: 0
  }]
};
Page({
  data: {
    details: {},
    id: null,
    isTransfer: false,
  },
  onLoad(options) {
    drawImage = new Wxml2Canvas({
      element: 'share',  // canvas节点的id,
      obj: this,  // 在组件中使用时,需要传入当前组件的this
      width: 375,   // 宽高
      height: 375 * 3, 
      background: '#fff', // 默认背景色
      progress (percent) {  // 绘制进度
      },
      finish (url) {
        _img = url;
        console.log(_img, '---->>>><<<----------<<<<');
      },
      error (res) {
        console.log(res, '---->>>><<<<<<<');
      }
    });
    this.getDetail(options.id)
  },
  saveImg() {
    console.log(111111111111, '_________________>>>>>');
    drawImage.draw(drawImageData, this);
    setTimeout(() => {
      console.log(_img, '_________________>>>>>');
      wx.showShareImageMenu({
        path: _img,
        success: (res)=>{},
        fail: (err)=> {
          
        }
      })
    }, 300)
  },
  getDetail(id) {
    settlement_order_detail({id: id}).then(res => {
      this.setData({
        details: res.data,
        id: id,
      }, () => {
        drawImage.draw(drawImageData, this);
      })
    })
  },
})
css 复制代码
.page-top{
    color:#fff;
    text-align: center;
    position: relative;
    height: 300rpx;
}
.bg_water {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100vh;
    z-index: 1000;
}
.header {
    height: 80rpx;
}
.success-icon{
    width:120rpx;
    height:120rpx;
    z-index: 100;
    position: absolute;
    z-index: 1000;
    margin: 0 auto;
    left: 0;
    right: 0;
    top: 71rpx;
}
.item-value {
    max-width: 75%;
}
.share-icon {
    position: absolute;
    right: 20rpx;
    top: 20rpx;
    width: 40rpx;
    height: 40rpx;
    z-index: 3000;
}
.success-state{
    font-size: 40rpx;
    font-weight: bold;
    position: absolute;
    z-index: 1000;
    margin: 0 auto;
    left: 0;
    right: 0;
    top: 230rpx;
}

.success-price{
    font-size: 36rpx;
    margin-top: 20rpx;
    position: absolute;
    z-index: 1000;
    margin: 0 auto;
    left: 0;
    right: 0;
    top: 300rpx;
}

.page-info{
    padding: 0 4%;
    position: absolute;
    z-index: 2000;
    width: 92%;
    top: 400rpx;
}

.info-label{
    color: #222;
    font-size: 30rpx;
    font-weight: bold;
    display: flex;
    align-items: center;
    padding-top: 18rpx;
    padding-bottom: 30rpx;
}

.info-label:before{
    content: '';
    display: inline-block;
    width: 6rpx;
    height: 28rpx;
    background: linear-gradient( 135deg, #FF6634 0%, #FF7F57 100%);
    border-radius: 2rpx;
    margin-right: 12rpx;
}

.info-content > .item{
    display: flex;
    justify-content: space-between;
    padding-bottom: 30rpx;
    font-size: 28rpx;
}

.page-tips{
    padding: 30rpx 30rpx 0;
    color: #333;
    font-size: 24rpx;
}
.canvas-img {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
}
相关推荐
说私域6 小时前
人工智能赋能美妆零售数字化转型:基于开源AI大模型的S2B2C商城系统构建
人工智能·小程序·开源·零售
说私域7 小时前
数智化时代下开源AI大模型驱动的新型商业生态构建——基于AI智能名片与S2B2C商城小程序的融合创新研究
人工智能·小程序·开源
MobiCetus8 小时前
有关pip与conda的介绍
linux·windows·python·ubuntu·金融·conda·pip
黑马源码库miui5208612 小时前
心理咨询法律咨询预约咨询微信小程序系统源码独立部署
微信小程序·小程序·uni-app·php·微信公众平台
丑过三八线12 小时前
【Kafka】Kafka4.0在windows上启动
windows·分布式·kafka
钢铁男儿17 小时前
Python 序列构成的数组(对序列使用+和_)
服务器·windows·python
DogDaoDao17 小时前
从零开始:Windows 系统中 PowerShell 配置 FFmpeg 的详细步骤
windows·ffmpeg·音视频·ffplay·powershell·视频直播·ffprobe
sukalot18 小时前
Windows 图形显示驱动开发-WDDM 2.4功能-GPU 半虚拟化(十二)
windows·驱动开发
安 当 加 密21 小时前
如何在Windows服务器上搭建RADIUS认证服务器,有哪些开源方案和付费解决方案
服务器·windows·开源
三体世界1 天前
C++ List的模拟实现
java·c语言·开发语言·数据结构·c++·windows·list