|
@ -4,16 +4,19 @@ mui.plusReady(function() {
|
4
|
4
|
var list = plus.webview.currentWebview();
|
5
|
5
|
var userId = plus.storage.getItem('userid');
|
6
|
6
|
var Orientation;
|
|
7
|
var angle=0;
|
7
|
8
|
img_obj.setAttribute("src", list.imgurl);
|
8
|
9
|
|
9
|
10
|
canvas_ok.addEventListener("tap", function() {
|
10
|
11
|
save_img();
|
11
|
12
|
imgOk = document.querySelector("#img_base64").value;
|
12
|
13
|
console.log(imgOk)
|
13
|
|
mui.ajax(baseUrl + '/ajax/image/saveHead', {
|
|
14
|
alert(angle)
|
|
15
|
mui.ajax(baseUrl + '/ajax/image/test', {
|
14
|
16
|
data: {
|
15
|
17
|
"id": userId,
|
16
|
18
|
"base64": imgOk,
|
|
19
|
"angle":angle,
|
17
|
20
|
},
|
18
|
21
|
dataType: 'json', //数据格式类型
|
19
|
22
|
type: 'post', //http请求类型
|
|
@ -33,7 +36,7 @@ mui.plusReady(function() {
|
33
|
36
|
mui.fire(Pa, 'photoUser');
|
34
|
37
|
|
35
|
38
|
} else {
|
36
|
|
|
|
39
|
|
37
|
40
|
}
|
38
|
41
|
} else {
|
39
|
42
|
plus.nativeUI.toast("图片上传失败", toastStyle);
|
|
@ -48,7 +51,7 @@ mui.plusReady(function() {
|
48
|
51
|
|
49
|
52
|
})
|
50
|
53
|
|
51
|
|
})
|
|
54
|
|
52
|
55
|
|
53
|
56
|
//获取手机屏幕宽高
|
54
|
57
|
var c_w = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
|
|
@ -58,6 +61,7 @@ var can_obj = document.querySelector("#canvas");
|
58
|
61
|
var img_obj = document.querySelector("#canvas_img");
|
59
|
62
|
var div_obj = document.querySelector("#canvas_div");
|
60
|
63
|
|
|
64
|
|
61
|
65
|
var posX = 0,
|
62
|
66
|
posY = 0; //相对坐标
|
63
|
67
|
var scale = 0; //记录在缩放动作执行前的 缩放值
|
|
@ -75,19 +79,40 @@ img_obj.onload = function() {
|
75
|
79
|
EXIF.getData(img_obj, function() {
|
76
|
80
|
//alert(EXIF.pretty(this));
|
77
|
81
|
EXIF.getAllTags(this);
|
78
|
|
//alert(EXIF.getTag(this, 'Orientation'));
|
|
82
|
alert(EXIF.getTag(this, 'Orientation'));
|
79
|
83
|
Orientation = EXIF.getTag(this, 'Orientation');
|
80
|
84
|
//return;
|
81
|
85
|
if(Orientation == 6) {
|
82
|
86
|
//alert('需要顺时针(向左)90度旋转');
|
|
87
|
angle=90;
|
83
|
88
|
var current = 0;
|
|
89
|
//alert(angle);
|
84
|
90
|
//objImg.rotate(degree);
|
85
|
91
|
current = (current + 90) % 360;
|
86
|
92
|
img_obj.style.transform = 'rotate(' + current + 'deg)';
|
87
|
93
|
can_obj.style.transform = 'rotate(' + current + 'deg)';
|
88
|
|
}else{
|
89
|
|
//alert('需要顺时针(向左)-90度旋转');
|
90
|
94
|
}
|
|
95
|
|
|
96
|
if(Orientation == 3) {
|
|
97
|
//alert('需要顺时针(向左)90度旋转');
|
|
98
|
angle=180;
|
|
99
|
var current = 0;
|
|
100
|
//objImg.rotate(degree);
|
|
101
|
current = (current + 180) % 360;
|
|
102
|
img_obj.style.transform = 'rotate(' + current + 'deg)';
|
|
103
|
can_obj.style.transform = 'rotate(' + current + 'deg)';
|
|
104
|
}
|
|
105
|
|
|
106
|
if(Orientation == 8) {
|
|
107
|
//alert('需要顺时针(向左)90度旋转');
|
|
108
|
angle=-90;
|
|
109
|
var current = 0;
|
|
110
|
//objImg.rotate(degree);
|
|
111
|
current = (current - 90) % 360;
|
|
112
|
img_obj.style.transform = 'rotate(' + current + 'deg)';
|
|
113
|
can_obj.style.transform = 'rotate(' + current + 'deg)';
|
|
114
|
}
|
|
115
|
|
91
|
116
|
});
|
92
|
117
|
|
93
|
118
|
load();
|
|
@ -260,3 +285,4 @@ function autoResizeImage(maxWidth, maxHeight, objImg) {
|
260
|
285
|
//objImg.width = w;
|
261
|
286
|
}
|
262
|
287
|
|
|
288
|
})
|