-
Notifications
You must be signed in to change notification settings - Fork 0
/
setting-image.html
136 lines (124 loc) · 5.41 KB
/
setting-image.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>nav</title>
<link href="css/icon-svg.css" rel="stylesheet">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/edit.css" rel="stylesheet">
<link href="css/setting-detail.css" rel="stylesheet">
<link rel="stylesheet" href="less-css/public.css" />
<script src="js/vue.js"></script>
<script src="js/fastclick.js"></script>
<script>
if ('addEventListener' in document) {
document.addEventListener('DOMContentLoaded', function() {
FastClick.attach(document.body);
}, false);
}
</script>
</head>
<body>
<div id="body-container"></div>
<div id="wrap" class="container-fluid">
<header id="header">
<button class="goback close glyphicon glyphicon-close" @click="close" key="save"></button>
</header>
<div class="row clear_margin_right" id="_EDIT_WRAP">
<div class="col-xs-12">
<button type="button" v-if="uploadimage == null" class="publish-btn btn not-active">提交</button>
<button type="button" v-else class="publish-btn btn" @click="upload">提交</button>
<h4 class="tx-nav">EDIT</h4>
<small class="tx-inform">修改图片</small>
</div>
<div class="col-xs-12 _EDIT_CONTAINER" id="_EDIT_CONTAINER" @click="galleryImg">
<div class="user-image" v-bind:style="uploadimage" id="_IMAGES"></div>
</div>
</div>
</div>
<div id="map"></div>
<script src="js/renyi.js"></script>
<script src="js/ready-pubilc.js"></script>
<script>
var _IMAGES = document.getElementById('_IMAGES');
new Vue({
el: '#header',
data: {
nav : false
},
methods : {
close : function () {
var w = plus.webview.currentWebview();//获取我这个窗口
plus.webview.close(w ,'slide-out-right' ,300);
}
}
});
var EDIT = new Vue({
el: '#_EDIT_WRAP',
data: {
uploadimage : null,//本地图片地址
src : null
},
methods : {
//选择图片
galleryImg : function () {
var self = this;
// 从相册中选择图片
//console.log("从相册中选择图片:");
plus.gallery.pick( function(path){
self.uploadimage = { backgroundImage : 'url('+path+')'};
self.src = path;
}, function ( e ) {
//alert( "取消选择图片" );
}, {filter:"image"} );
},
upload : function () {
var self = this;
plus.nativeUI.actionSheet( {title:"确认提交修改",cancel:"取消",buttons:[{title:"保存"}]}, function(e){
if( e.index == 1 ) {
self.createUpload();
}
});
},
createUpload : function () {
var self = this;
//如果有图片
if(this.src != null) {
var task = plus.uploader.createUpload( "http://clevok.cn/other/renyi/uploadUserImage.php",
{ method:"POST",blocksize:204800,priority:100 },
function ( t, status ) {
// 上传完成
if ( status == 200 ) {
var _JSON = null;
if(typeof t.responseText != 'object') {
_JSON = JSON.parse(t.responseText);
}else {
_JSON = t.responseText;
}
plus.nativeUI.closeWaiting();//关闭等待
plus.nativeUI.toast( _JSON['msg'] );
if(_JSON['static'] == 0) {
window.localStorage.setItem('userImage', _JSON['pic']);
var w = plus.webview.currentWebview();//获取我这个窗口
plus.webview.close(w ,'slide-out-right' ,300);
}
} else {
alert( "Upload failed: " + status );
plus.nativeUI.closeWaiting();//关闭等待
}
}
);
task.addFile( this.src, {key:"images"} );//上传文件
task.addData( "userImage", window.localStorage.getItem('userImage') );//发送数据,后台根据$_POST['missionImage']获取
task.addData( "userId", window.localStorage.getItem('userId') );
//task.addEventListener( "statechanged", onStateChanged, false );
task.start();//开始上传
plus.nativeUI.showWaiting( "上传图片中..." );
}
}
}
});
</script>
</body>
</html>