知識
不管是網(wǎng)站,軟件還是小程序,都要直接或間接能為您產(chǎn)生價值,我們在追求其視覺表現(xiàn)的同時,更側(cè)重于功能的便捷,營銷的便利,運營的高效,讓網(wǎng)站成為營銷工具,讓軟件能切實提升企業(yè)內(nèi)部管理水平和效率。優(yōu)秀的程序為后期升級提供便捷的支持!
您當(dāng)前位置>首頁 » 新聞資訊 » 小程序相關(guān) >
微信小程序截圖工具
發(fā)表時間:2021-4-22
發(fā)布人:葵宇科技
瀏覽次數(shù):101
welCropper 微信小程序截圖工具
文件目錄結(jié)構(gòu),要在測試機(jī)上運行,工程目錄選擇文件夾project
./
├── documents
│ ├── hierarchy.png
│ ├── result.gif
│ └── screenshot.jpeg
├── project
│ ├── app.js
│ ├── app.json
│ ├── app.wxss
│ ├── pages
│ │ ├── index
│ │ │ ├── index.js
│ │ │ ├── index.json
│ │ │ ├── index.wxml
│ │ │ └── index.wxss
│ │ └── test
│ │ ├── test.js
│ │ ├── test.json
│ │ ├── test.wxml
│ │ └── test.wxss
│ ├── utils
│ │ └── util.js
│ └── welCropper
│ ├── welCropper.js
│ ├── welCropper.wxml
│ └── welCropper.wxss
└── readme.md
- 保證圖片質(zhì)量,也可以選擇壓縮圖
Documents
因為cropper
的數(shù)據(jù)和事件是直接綁定到Page
上的,所以數(shù)據(jù)和事件命名應(yīng)該避免一下名字(之后會想辦法避免這種情況)及其相關(guān)解釋:
data中的名字:
- cropperData
- cropperMovableItems
函數(shù)名:
- showCropper
- hideCropper
- originalChange
- cropImage
- loadImage
- clearCanvas
- drawImage
- drawOriginalImage
- drawLines
- setupMoveItem
- moveEvent
- endEvent
外部只用到showCropper
和hideCropper
/**
inputPath:輸入圖片地址
callback(resPath):點擊“完成”按鈕后毀掉函數(shù),毀掉函數(shù)中會有截圖地址
*/
showCropper(inputPath, callback)
使用
將welCropper
復(fù)制到自己的工程當(dāng)中(以/pages/index/index
為例)
wxml
引入并調(diào)用:
<!-- 引入組件 -->
<import src="https://www.wxapp-union.com/welCropper/welCropper" />
<!-- 調(diào)用組件 -->
<template is="welCropper" data="{{data:cropperData, cropperMovableItems:cropperMovableItems}}"></template>
<!-- 用于選擇圖片,傳入cropper中 -->
<button bindtap='selectTap'>select image</button>
wxss
引入:
@import "/welCropper/welCropper.wxss";
js
引入和使用:
// 獲取顯示區(qū)域長寬
const device = wx.getSystemInfoSync()
const W = device.windowWidth
const H = device.windowHeight - 50
let cropper = require('../../welCropper/welCropper.js');
console.log(device)
Page({
data: {
},
onLoad: function () {
var that = this
// 初始化組件數(shù)據(jù)和綁定事件
cropper.init.apply(that, [W, H]);
},
selectTap() {
var that = this
wx.chooseImage({
count: 1, // 默認(rèn)9
sizeType: ['original', 'compressed'], // 可以指定是原圖還是壓縮圖,默認(rèn)二者都有
sourceType: ['album', 'camera'], // 可以指定來源是相冊還是相機(jī),默認(rèn)二者都有
success(res) {
const tempFilePath = res.tempFilePaths[0]
console.log(tempFilePath)
// 將選取圖片傳入cropper,并顯示cropper
that.showCropper({
src: tempFilePath,
sizeType: ['original', 'compressed'], //'original' | 'compressed'(default)
callback: (resPath) => {
console.log("crop callback:" + resPath)
wx.previewImage({
current: '',
urls: [resPath]
})
// that.hideCropper() //隱藏,我在項目里是點擊完成就上傳,所以如果回調(diào)是上傳,那么隱藏掉就行了,不用previewImage
}
})
}
})
}
相關(guān)案例查看更多
相關(guān)閱讀
- 怎么做網(wǎng)站
- 網(wǎng)站建設(shè)制作
- 云南省住房建設(shè)廳網(wǎng)站
- 云南小程序定制
- 汽車拆解管理系統(tǒng)
- 昆明軟件定制
- 日歷組件
- 網(wǎng)站收錄
- web教程
- 軟件定制
- 云南做百度小程序的公司
- 小程序公司
- 云南網(wǎng)站建設(shè)百度
- 小程序商城
- 報廢車回收管理系統(tǒng)
- 網(wǎng)站建設(shè)公司地址
- 百度小程序
- 云南小程序代建
- 云南網(wǎng)站建設(shè)費用
- 云南建設(shè)廳官方網(wǎng)站
- 百度小程序開發(fā)
- 云南小程序開發(fā)報價
- 云南網(wǎng)頁制作
- 云南省建設(shè)廳官方網(wǎng)站
- 云南網(wǎng)站建設(shè)服務(wù)
- 微信分銷系統(tǒng)
- 云南手機(jī)網(wǎng)站建設(shè)
- 買小程序被騙
- 云南網(wǎng)站建設(shè)價格
- 云南小程序開發(fā)公司推薦