city_card/packagecard/common/corpperimg/cropperimg.js

65 lines
1.7 KiB
JavaScript
Raw Normal View History

2023-07-15 14:25:28 +08:00
getApp();
Page({
data: {
imgSrc: "",
scale: 1,
src: "",
width: 250,
height: 250
},
2023-07-18 16:54:17 +08:00
onLoad: function (e) {
console.log(e.imgSrc)
2023-07-15 14:25:28 +08:00
wx.setNavigationBarTitle({
title: "图片裁剪"
2023-07-18 16:54:17 +08:00
});
this.cropper = this.selectComponent("#image-cropper");
this.setData({
src: e.imgSrc,
scale:e.scale
});
wx.showLoading({
2023-07-15 14:25:28 +08:00
title: "加载中"
});
},
2023-07-18 16:54:17 +08:00
cropperload: function (e) {
2023-07-15 14:25:28 +08:00
console.log("cropper初始化完成");
},
2023-07-18 16:54:17 +08:00
loadimage: function (e) {
console.log("图片加载完成", e.detail);
wx.hideLoading();
this.cropper.imgReset();
2023-07-15 14:25:28 +08:00
},
2023-07-18 16:54:17 +08:00
clickcut: function (e) {
2023-07-15 14:25:28 +08:00
console.log(e.detail);
var t = getCurrentPages();
(t.length >= 2 ? t[t.length - 2] : void 0).setData({
imgTempSrc: e.detail.url
}), wx.navigateBack({});
},
2023-07-18 16:54:17 +08:00
cropperDone: function (e) {
2023-07-15 14:25:28 +08:00
var t = e.detail, o = t.src, a = (t.cropperData, getCurrentPages());
(a.length >= 2 ? a[a.length - 2] : void 0).setData({
imgTempSrc: o
});
},
2023-07-18 16:54:17 +08:00
cropperCancel: function () {
2023-07-15 14:25:28 +08:00
wx.navigateBack({});
},
2023-07-18 16:54:17 +08:00
doCropperDone: function (e) {
2023-07-15 14:25:28 +08:00
var t = getCurrentPages();
(t.length >= 2 ? t[t.length - 2] : void 0).setData({
imgTempSrc: e
}), wx.navigateBack({});
},
2023-07-18 16:54:17 +08:00
cropperFail: function (e) {
2023-07-15 14:25:28 +08:00
e.detail;
console.log(e), wx.showToast({
title: "裁剪失败,请重试",
icon: "none",
2023-07-18 16:54:17 +08:00
success: function () {
2023-07-15 14:25:28 +08:00
wx.navigateBack({});
}
});
}
});