Component({
properties: {
imgSrc: {
type: String
},
height: {
type: Number,
value: 200
},
width: {
type: Number,
value: 200
},
min_width: {
type: Number,
value: 100
},
min_height: {
type: Number,
value: 100
},
max_width: {
type: Number,
value: 300
},
max_height: {
type: Number,
value: 300
},
disable_width: {
type: Boolean,
value: !1
},
disable_height: {
type: Boolean,
value: !1
},
disable_ratio: {
type: Boolean,
value: !1
},
export_scale: {
type: Number,
value: 3
},
quality: {
type: Number,
value: 1
},
cut_top: {
type: Number,
value: null
},
cut_left: {
type: Number,
value: null
},
canvas_top: {
type: Number,
value: null
},
canvas_left: {
type: Number,
value: null
},
img_width: {
type: null,
value: null
},
img_height: {
type: null,
value: null
},
scale: {
type: Number,
value: 1
},
angle: {
type: Number,
value: 0
},
min_scale: {
type: Number,
value: .5
},
max_scale: {
type: Number,
value: 2
},
disable_rotate: {
type: Boolean,
value: !1
},
limit_move: {
type: Boolean,
value: !1
}
},
data: {
el: "image-cropper",
info: wx.getSystemInfoSync(),
MOVE_THROTTLE: null,
MOVE_THROTTLE_FLAG: !0,
INIT_IMGWIDTH: 0,
INIT_IMGHEIGHT: 0,
TIME_BG: null,
TIME_CUT_CENTER: null,
_touch_img_relative: [ {
x: 0,
y: 0
} ],
_flag_cut_touch: !1,
_hypotenuse_length: 0,
_flag_img_endtouch: !1,
_flag_bright: !0,
_canvas_overflow: !0,
_canvas_width: 200,
_canvas_height: 200,
origin_x: .5,
origin_y: .5,
_cut_animation: !1,
_img_top: wx.getSystemInfoSync().windowHeight / 2,
_img_left: wx.getSystemInfoSync().windowWidth / 2,
watch: {
width: function(t, a) {
t < a.data.min_width && a.setData({
width: a.data.min_width
}), a._computeCutSize();
},
height: function(t, a) {
t < a.data.min_height && a.setData({
height: a.data.min_height
}), a._computeCutSize();
},
angle: function(t, a) {
a._moveStop(), a.data.limit_move && a.data.angle % 90 && a.setData({
angle: 90 * Math.round(a.data.angle / 90)
});
},
_cut_animation: function(t, a) {
clearTimeout(a.data._cut_animation_time), t && (a.data._cut_animation_time = setTimeout(function() {
a.setData({
_cut_animation: !1
});
}, 300));
},
limit_move: function(t, a) {
t && (a.data.angle % 90 && a.setData({
angle: 90 * Math.round(a.data.angle / 90)
}), a._imgMarginDetectionScale(), !a.data._canvas_overflow && a._draw());
},
canvas_top: function(t, a) {
a._canvasDetectionPosition();
},
canvas_left: function(t, a) {
a._canvasDetectionPosition();
},
imgSrc: function(t, a) {
a.pushImg();
},
cut_top: function(t, a) {
a._cutDetectionPosition(), a.data.limit_move && !a.data._canvas_overflow && a._draw();
},
cut_left: function(t, a) {
a._cutDetectionPosition(), a.data.limit_move && !a.data._canvas_overflow && a._draw();
}
}
},
attached: function() {
this.data.info = wx.getSystemInfoSync(), this._watcher(), this.data.INIT_IMGWIDTH = this.data.img_width,
this.data.INIT_IMGHEIGHT = this.data.img_height, this.setData({
_canvas_height: this.data.height,
_canvas_width: this.data.width
}), this._initCanvas(), this.data.imgSrc && (this.data.imgSrc = this.data.imgSrc),
this._initImageSize(), this._computeCutSize(), this._cutDetectionPosition(), this._canvasDetectionPosition(),
this.triggerEvent("load", {
cropper: this
});
},
methods: {
upload: function() {
var t = this;
wx.chooseImage({
count: 1,
sizeType: [ "original", "compressed" ],
sourceType: [ "album", "camera" ],
success: function(a) {
var i = a.tempFilePaths[0];
t.pushImg(i), wx.showLoading({
title: "加载中..."
});
}
});
},
getImg: function(t) {
var a = this;
this._draw(function() {
wx.canvasToTempFilePath({
width: a.data.width * a.data.export_scale,
height: Math.round(a.data.height * a.data.export_scale),
destWidth: a.data.width * a.data.export_scale,
destHeight: Math.round(a.data.height) * a.data.export_scale,
fileType: "png",
quality: a.data.quality,
canvasId: a.data.el,
success: function(i) {
t({
url: i.tempFilePath,
width: a.data.width * a.data.export_scale,
height: a.data.height * a.data.export_scale
});
}
}, a);
});
},
setTransform: function(t) {
if (t) {
this.data.disable_rotate || this.setData({
angle: t.angle ? this.data.angle + t.angle : this.data.angle
});
var a = this.data.scale;
t.scale && (a = (a = (a = this.data.scale + t.scale) <= this.data.min_scale ? this.data.min_scale : a) >= this.data.max_scale ? this.data.max_scale : a),
this.data.scale = a;
var i = this.data.cut_left, h = this.data.cut_top;
t.cutX && (this.setData({
cut_left: i + t.cutX
}), this.data.watch.cut_left(null, this)), t.cutY && (this.setData({
cut_top: h + t.cutY
}), this.data.watch.cut_top(null, this)), this.data._img_top = t.y ? this.data._img_top + t.y : this.data._img_top,
this.data._img_left = t.x ? this.data._img_left + t.x : this.data._img_left, this._imgMarginDetectionScale(),
this._moveDuring(), this.setData({
scale: this.data.scale,
_img_top: this.data._img_top,
_img_left: this.data._img_left
}), !this.data._canvas_overflow && this._draw(), this._moveStop();
}
},
setCutXY: function(t, a) {
this.setData({
cut_top: a,
cut_left: t
});
},
setCutSize: function(t, a) {
this.setData({
width: t,
没有合适的资源?快使用搜索试试~ 我知道了~
微信头像制作小程序源码 微信流量主系列.rar

共163个文件
png:37个
js:34个
json:27个

1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
24 浏览量
2022-06-23
09:34:40
上传
评论
收藏 1.49MB RAR 举报
微信头像制作小程序源码 微信流量主系列.rar
资源推荐
资源详情
资源评论

















收起资源包目录





































































































共 163 条
- 1
- 2
资源评论

qq_38220914
- 粉丝: 491
- 资源: 4233

上传资源 快速赚钱
我的内容管理 收起
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助

会员权益专享
最新资源
- 3.25-13.30-C++-我的成绩-笔记.pdf
- 基于Java的视频会议系统(程序+论文)
- jdk相关安装包文件可用
- mallet-2.0.8 Gensim LDAMallet Python 文本分类、聚类、主题建模、信息提取
- 新闻资讯行业-富文本解析,折线图,MD5,bluebird源代码【含图文文档教程+源码导入教程+操作界面截图】
- 基于Java的远程视频会议系统(系统+论文)
- 适用于 DJI OcuSync 2.0 的无人机 ID 接收器 追踪定位无人机操控者的位置
- 加人通过率高的高超话术:.exe
- Sileo Demo 1.2.6b2.ipa
- TC(Table Controller)是配合EXCEL实现自动化测试的产品
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
