...
|
...
|
@@ -7,23 +7,20 @@ var cascadingAddress = require('../plugins/cascading-address'); |
|
|
var dialog = require('../plugins/dialog');
|
|
|
var _dialog = dialog.Dialog;
|
|
|
var _alert = dialog.Alert;
|
|
|
var modifyHead = require('./setting/modifyHead');
|
|
|
var tip;
|
|
|
|
|
|
var headHtml = modifyHead.swfobject('head', '600px', '400px', '../../img/me/head.swf?code=' + Math.random() +
|
|
|
'&upload_url=' + encodeURIComponent(location.protocol + '//' +
|
|
|
location.hostname + ':' + location.port + '/me/setting/modifyHead'));
|
|
|
|
|
|
var Bll = {
|
|
|
setIcon: function() {
|
|
|
var html = [];
|
|
|
|
|
|
html.push('<form id="upload_form" method="post" action="" onsubmit="return checkForm()">');
|
|
|
html.push('<div class="post-picture inline-block">');
|
|
|
html.push('<div class="choose-avatar"></div>');
|
|
|
html.push('<div class="post-file"><input id="avatar" name="avatar" type="file" value="点击上传"></div>');
|
|
|
html.push('<p class="post-limit">支持JPG、GIF、PNG、JPEG、BMP格式,文件小于3M</p>');
|
|
|
html.push('</div>');
|
|
|
html.push(' <div class="show-picture inline-block" ><img id="post-picture">');
|
|
|
html.push(' </div>');
|
|
|
html.push('<div class="preview-picture inline-block">');
|
|
|
html.push('<div class="small-preview"></div>');
|
|
|
html.push('<div style="width: 600px;height: 400px">');
|
|
|
html.push(headHtml);
|
|
|
html.push('</div>');
|
|
|
html.push('</form>');
|
|
|
|
|
|
return html.join('');
|
|
|
},
|
...
|
...
|
@@ -63,9 +60,8 @@ $('.user-icon').hover(function() { |
|
|
|
|
|
// 编辑头像打开弹框
|
|
|
$(document).on('click', '.edit-ico', function() {
|
|
|
var tip = new _dialog({
|
|
|
tip = new _dialog({
|
|
|
className: 'settled-success',
|
|
|
title: '自定义头像',
|
|
|
content: Bll.setIcon(),
|
|
|
btns: [
|
|
|
{
|
...
|
...
|
@@ -73,7 +69,7 @@ $(document).on('click', '.edit-ico', function() { |
|
|
btnClass: ['apply'],
|
|
|
name: '保存',
|
|
|
cb: function() {
|
|
|
tip.close();
|
|
|
modifyHead.uploadImage();
|
|
|
}
|
|
|
},
|
|
|
{
|
...
|
...
|
@@ -88,19 +84,21 @@ $(document).on('click', '.edit-ico', function() { |
|
|
}).show();
|
|
|
});
|
|
|
|
|
|
|
|
|
$(document).on('change', '#avatar', function() {
|
|
|
/* var oFile = $("#avatar")[0].files[0];
|
|
|
var oImage = document.getElementById('post-picture');
|
|
|
var oReader = new FileReader();
|
|
|
oReader.onload = function (e) {
|
|
|
oImage.src = e.target.result;
|
|
|
$(".post-picture").hide();
|
|
|
$("#post-picture").show();
|
|
|
};
|
|
|
oReader.readAsDataURL(oFile);*/
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* 头像上传处理
|
|
|
* @param obj
|
|
|
*/
|
|
|
window.receive_image_bytes = function(obj) {
|
|
|
var result = JSON.parse(obj);
|
|
|
|
|
|
if (result.code === 200) {
|
|
|
tip.close();
|
|
|
$('.show-ico img').attr('src', result.data.image_url.split('?')[0]);
|
|
|
} else {
|
|
|
tip.close();
|
|
|
new _alert('头像修改失败!').show();
|
|
|
}
|
|
|
};
|
|
|
|
|
|
$(function() {
|
|
|
var address = cascadingAddress({el: '#address'});
|
...
|
...
|
|