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,
没有合适的资源?快使用搜索试试~ 我知道了~
微信头像制作小程序源码 微信流量主系列.zip
共163个文件
png:37个
js:34个
json:27个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 68 浏览量
2023-01-06
10:11:30
上传
评论
收藏 1.52MB ZIP 举报
温馨提示
纯前端源码,无后端!不需要服务器域名。 源码放到微信开发者工具云函数直接调试!
资源推荐
资源详情
资源评论
收起资源包目录
微信头像制作小程序源码 微信流量主系列.zip (163个子文件)
关注公众号【青衣雅会】.jpg 146KB
封面.jpg 130KB
资料卡.jpg 126KB
职业.jpg 112KB
作品框.jpg 79KB
003.jpg 77KB
002.jpg 70KB
123.jpg 60KB
001.jpg 53KB
1.jpg 52KB
04.jpg 44KB
2.jpg 42KB
3.jpg 37KB
share.jpg 32KB
01.jpg 29KB
03.jpg 19KB
02.jpg 17KB
image-cropper.js 30KB
indexDetail.js 15KB
index.js 15KB
word.js 13KB
signIn.js 13KB
charactor.js 11KB
flower.js 8KB
emojy.js 7KB
mine.js 4KB
detail.js 4KB
colorful.js 3KB
emojy.js 3KB
index.js 3KB
fly.js 3KB
telephone.js 2KB
word.js 2KB
cropper.js 2KB
application.js 2KB
foot-tools.js 2KB
nickname.js 2KB
fly.js 1KB
avatar.js 1KB
cu-custom.js 878B
typeof.js 712B
app.js 690B
article.js 570B
index.js 358B
util.js 343B
config.js 255B
defineProperty.js 200B
index.js 194B
share.js 157B
interopRequireDefault.js 96B
index.js 65B
app.json 2KB
project.config.json 1KB
fly.json 430B
word.json 430B
nickname.json 430B
avatar.json 430B
flower.json 430B
telephone.json 430B
colorful.json 430B
emojy.json 430B
cropper.json 300B
index.json 294B
signIn.json 288B
image-cropper.json 271B
cu-custom.json 271B
application.json 248B
detail.json 248B
index.json 248B
article.json 248B
indexDetail.json 248B
mine.json 248B
sitemap.json 235B
foot-tools.json 229B
sitemap98.json 191B
index.json 166B
index.json 166B
index.json 165B
zhanshang.png 127KB
mine_selected.png 28KB
notice.png 22KB
jinbi.png 20KB
contactus.png 20KB
application_selected.png 19KB
index_selected.png 18KB
mine.png 15KB
hyaline.png 13KB
e.png 10KB
pirze.png 10KB
pirze_selected.png 9KB
backImage.png 9KB
q.png 9KB
w.png 8KB
application.png 7KB
wexin.png 7KB
zanshang.png 7KB
index.png 7KB
微信图片_20210104131754.png 6KB
o.png 5KB
x.png 5KB
共 163 条
- 1
- 2
资源评论
智慧浩海
- 粉丝: 1w+
- 资源: 5103
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功