Authored by 刘传洋

comment

'use strict';
const request = require('request-promise');
const fs = require('fs');
const _ = require('lodash');
const utils = require('../models/utils');
const uploadImg = (req, res, next) => {
let files = req.files && req.files.file || [];
if (!_.isArray(files)) {
files = [files];
}
req.body.files = [];
files.forEach(file => {
req.body.files.push(fs.createReadStream(file.path));
req.body.files.push(file.name);
});
request({
method: 'post',
url: 'http://upload.static.yohobuy.com',
formData: {
fileData: req.body.files,
project: req.body.bucket
},
json: true
}).then(function(result) {
if (result && result.code === 200) {
result.data = result.data || {};
result.data.images = _.map(_.get(result, 'data.imagesList'), (it) => {
return utils.getUploadImgAbsoluteUrl(it, req.body.bucket);
});
}
res.json(result);
}).catch(next);
};
module.exports = {
uploadImg
};
... ...
/**
* common 相关 utils
* @author: 刘传洋<chuanyang.liu@yoho.cn>
* @date: 2016/10/31
*/
/**
* 01=["img10.static.yhbimg.com", "img11.static.yhbimg.com"],
* 02=["img12.static.yhbimg.com", "img13.static.yhbimg.com"]
* 03=["flv01.static.yhbimg.com", "flv01.static.yhbimg.com"]
* @param url
* @param bucket
* @returns {*}
*/
'use strict';
const getUploadImgAbsoluteUrl = (url, bucket) => {
if (!url) {
return null;
}
let urlArr = url.split('/'),
stag = urlArr[urlArr.length - 1].substr(0, 2),
domain = `static.yhbimg.com/${bucket}`;
url = domain + url;
if (stag === '01') {
return `//img11.${url}`;
} else if (stag === '03') {
return `//flv01.${url}`;
} else {
return `//img12.${url}`;
}
};
module.exports = {
getUploadImgAbsoluteUrl
};
... ...
... ... @@ -9,8 +9,14 @@
const router = require('express').Router(); // eslint-disable-line
const cRoot = './controllers';
var multipart = require('connect-multiparty');
var multipartMiddleware = multipart();
const rvCtrl = require(`${cRoot}/recent-view`);
const uploadCtrl = require(`${cRoot}/upload`);
router.get('/recentReview', rvCtrl.index); // 最近浏览
router.post('/upload/image', multipartMiddleware, uploadCtrl.uploadImg);
module.exports = router;
... ...
... ... @@ -19,8 +19,9 @@ exports.index = (req, res, next) => {
// 转string值为bool值
isComment = isComment === 'Y';
// uid = '20000318';
// uid: 20000318 test1
console.log('==> uid: ' + req.user.uid);
// console.log('==> uid: ' + uid);
commentModel.getCommentList(uid, isComment, page)
.then(data => {
... ... @@ -30,36 +31,15 @@ exports.index = (req, res, next) => {
});
res.render('comment', localData);
// res.render('comment', {
//
// });
})
.catch(next);
/* res.render('comment', {
comment: {
orders: [{
orderTime: '2016-10-10',
goods: [{
href: '',
thumb: 'http://img10.static.yhbimg.com/goodsimg/2015/08/05/06/016aeb5985c7e186b5c4e43e165311126d.jpg?imageMogr2/thumbnail/100x100/extent/100x100/background/d2hpdGU=/position/center/quality/70',
name: '阿斯顿发到付',
comments: [{
img: '//img12.static.yhbimg.com/article/2016/10/25/14/02fffad7f7caef65d7acb61a7334ece93a.jpg?imageView2/1/w/360/h/240'
}, {
img: 'http://img10.static.yhbimg.com/goodsimg/2015/08/05/06/016aeb5985c7e186b5c4e43e165311126d.jpg?imageMogr2/thumbnail/100x100/extent/100x100/background/d2hpdGU=/position/center/quality/70'
}]
}]
}]
}
});*/
};
exports.commentList4Order = (req, res, next) => {
let uid = req.user.uid;
let orderId = req.query.orderId;
console.log(uid + '===' + orderId);
commentModel.getCommentList4Order(uid, orderId)
.then(data => {
let result = _.merge({
... ... @@ -86,9 +66,17 @@ exports.saveComment = (req, res, next) => {
content: req.body.content,
goodsId: req.body.goodsId,
orderId: req.body.orderId,
erpSkuId: req.body.erpSkuId
erpSkuId: req.body.erpSkuId,
anonymous: false, // 是否匿名评价
satisfied: Number(req.body.satisfied),
url: req.body.url,
size: req.body.size,
height: req.body.height ? Number(req.body.height) : '',
weight: req.body.weight ? Number(req.body.weight) : ''
};
console.log(JSON.stringify(data));
commentModel.saveShareOrder(data)
.then(result => {
res.json(result);
... ...
... ... @@ -59,7 +59,9 @@ exports.getCommentList = (uid, isComment, page, limit) => {
productSkn: v.productSkn,
productId: v.productId,
goodsId: v.goodsId,
erpSkuId: v.erpSkuId
erpSkuId: v.erpSkuId,
orderId: value.orderId,
orderCode: value.orderCode
};
if (isComment === v.hasOwnProperty('comment')) {
... ... @@ -102,61 +104,57 @@ exports.getCommentList = (uid, isComment, page, limit) => {
exports.getCommentList4Order = (uid, orderId) => {
// limit = limit || 10;
// http://api.yoho.cn/?app_version=5.0.0&client_secret=e8098ddd3129372e8c93daea6600eda4&client_type=android&gender=1%2C3&
// method=show.toShareOrderList&
// orderCode=1617595089&os_version=android6.0.1%3AMI_MAX&screen_size=1080x1920&session_key=
// 720e95e42f9c1edc5940f1d49c34b68e&uid=9963947&v=7&yh_channel=1
const process = function*() {
let result = yield api.post('', {
method: 'web.show.queryOrderProductCommentList',
// method: 'web.show.queryOrderProductCommentList',
method: 'show.toShareOrderList',
uid: uid,
orderId: orderId
orderCode: orderId// ,
// orderId: orderId
});
let isComment = true;
let commentList = {
isComment: isComment,
goodsNum: 0,
orders: []
};
// let pagerObj = {};
// 接口返回成功, 处理数据
if (result.code === 200 && !_.isEmpty(result.data)) {
_.forEach(result.data, (value) => {
let order = {
orderNum: value.orderCode,
orderTime: value.createTime,
orderId: value.orderId,
goods: []
let order = {
// orderNum: value.orderCode,
// orderTime: value.createTime,
orderId: orderId,
goods: []
};
_.forEach(result.data, (v) => {
let cnAlphabet = v.cnAlphabet || '';
let good = {
href: helpers.getUrlBySkc(v.productId, v.goodsId, cnAlphabet),
thumb: imgUtils.getImageUrl(v.imageUrl, 100, 100),
name: v.productName || '',
productSkn: v.productSkn,
productId: v.productId,
goodsId: v.goodsId,
erpSkuId: v.erpSkuId,
orderCode: v.orderCode,
orderId: v.orderId
};
_.forEach(value.orderGoods, (v) => {
let cnAlphabet = v.cnAlphabet || '';
let good = {
href: helpers.getUrlBySkc(v.productId, v.goodsId, cnAlphabet),
thumb: imgUtils.getImageUrl(v.imageUrl, 100, 100),
name: v.productName || '',
productSkn: v.productSkn,
productId: v.productId,
goodsId: v.goodsId,
erpSkuId: v.erpSkuId
};
if (isComment === v.hasOwnProperty('comment')) {
if (isComment) {
good.remark = v.comment;
}
order.goods.push(good);
commentList.goodsNum++;
}
});
order.goods.length && commentList.orders.push(order);
order.goods.push(good);
commentList.goodsNum++;
});
order.goods.length && commentList.orders.push(order);
// let total = commentList.orders.length;
... ... @@ -170,9 +168,9 @@ exports.getCommentList4Order = (uid, orderId) => {
// //page: page
// });
} else {
commentList.empty = isComment ? NO_COMMENTED_GOODS : NO_UNCOMMENT_GOODS; // 空数据 提示文字
commentList.empty = NO_UNCOMMENT_GOODS; // 空数据 提示文字
}
console.log(JSON.stringify(commentList.orders.length));
return {
comment: commentList// ,
// pager: pagerObj
... ...
... ... @@ -126,7 +126,7 @@ router.get('/QRcode', [getCommonHeader, getHomeNav], personalController.QRcode);
// 我的评论
router.get('/comment', [getCommonHeader, getHomeNav], commentController.index);
router.post('/comment/saveComment', commentController.saveComment);
router.get('/comment/');
router.get('/comment/order', [getCommonHeader, getHomeNav], commentController.commentList4Order);
// 我的咨询
router.get('/consult', [getCommonHeader, getHomeNav], consultController.index);
... ...
... ... @@ -52,32 +52,39 @@
<tr data-role="commentAddForm" class="m-hide">
<td colspan="3" class="comment-add">
<div class="arrow"><i></i><em></em></div>
<input type="hidden" name="productSkn" value="{{productSkn}}" />
<input type="hidden" name="productId" value="{{productId}}" />
<input type="hidden" name="goodsId" value="{{goodsId}}" />
<input type="hidden" name="orderCode" value="{{orderCode}}" />
<input type="hidden" name="orderId" value="{{orderId}}" />
<input type="hidden" name="erpSkuId" value="{{erpSkuId}}" />
<div class="row">
<label class="fl-left"><i class="color-warn require-sign">*</i> 商品满意度:</label>
<span class="comment-star editable">
<span class="star-5"></span>
<span class="star-4"></span>
<span class="star-3"></span>
<span class="star-2"></span>
<span class="star-1"></span>
<span class="comment-star editable"data-role="star">
<span class="star-5" data-star="5"></span>
<span class="star-4" data-star="4"></span>
<span class="star-3" data-star="3"></span>
<span class="star-2" data-star="2"></span>
<span class="star-1" data-star="1"></span>
</span>
</div>
<div class="row">
<span class="col btn-group">
<span class="col btn-group" data-role="size">
<label><i class="color-warn require-sign">*</i> 尺码符合度:</label>
<a href="#" class="btn btn-outline">偏小</a>
<a href="#" class="btn btn-outline">合身</a>
<a href="#" class="btn btn-outline">偏大</a>
<a href="javascript:void(0);" class="btn btn-outline" data-size="SMALL">偏小</a>
<a href="javascript:void(0);" class="btn btn-outline" data-size="MIDDLE">合身</a>
<a href="javascript:void(0);" class="btn btn-outline" data-size="BIG">偏大</a>
</span>
<span class="col">
<label>身高:</label>
<span class="color-gray">
<a href="#" class="btn btn-outline disabled">175</a> 厘米
<input class="btn btn-outline disabled s-input" name="height" value="" /> 厘米
</span>
</span>
<span class="col">
<label>体重:</label>
<a href="#" class="btn btn-outline disabled">80</a> 公斤
<input class="btn btn-outline disabled s-input" name="weight" value="" /> 公斤
</span>
</div>
<div class="row textarea" data-role="goodsCommentWrap">
... ... @@ -87,14 +94,15 @@
<div class="row img-list clearfix">
<div class="img-preview">
<img src="" />
<input type="file" id="upload-{{../orderId}}-{{goodsId}}" />
<input type="file" name="file" id="upload-{{../orderId}}-{{goodsId}}" />
<input type="hidden" name="imgUrl" />
<i class="view">查看</i>
<i class="del">删除</i>
</div>
<span class="color-warn">最多上传1张图片</span>
</div>
<div class="btns">
<a href="#" class="btn btn-submit active radius">提交评价</a>
<a href="javascript:void(0);" class="btn btn-submit active radius">提交评价</a>
<span class="color-warn">带*为必填选项</span>
</div>
</td>
... ...
... ... @@ -35,11 +35,12 @@
"body-parser": "^1.15.0",
"captchapng": "0.0.1",
"connect-memcached": "^0.2.0",
"connect-multiparty": "^2.0.0",
"cookie-parser": "^1.4.3",
"express": "^4.13.1",
"handlebars": "^4.0.5",
"express-handlebars": "^3.0.0",
"express-session": "^1.13.0",
"handlebars": "^4.0.5",
"influxdb-winston": "^1.0.1",
"lodash": "^4.13.1",
"md5": "^2.1.0",
... ...
/* eslint-disable */
/**
* Created by chuanyang.liu@yoho.cn on 2016/11/1
*/
var $ = require('yoho-jquery');
jQuery.extend({
createUploadIframe: function(id, uri)
{
//create frame
var frameId = 'jUploadFrame' + id;
var iframeHtml = '<iframe id="' + frameId + '" name="' + frameId + '" style="position:absolute; top:-9999px; left:-9999px"';
if(window.ActiveXObject)
{
if(typeof uri== 'boolean'){
iframeHtml += ' src="' + 'javascript:false' + '"';
}
else if(typeof uri== 'string'){
iframeHtml += ' src="' + uri + '"';
}
}
iframeHtml += ' />';
jQuery(iframeHtml).appendTo(document.body);
return jQuery('#' + frameId).get(0);
},
createUploadForm: function(id, fileElementId, data)
{
//create form
var formId = 'jUploadForm' + id;
var fileId = 'jUploadFile' + id;
var form = jQuery('<form action="" method="POST" name="' + formId + '" id="' + formId + '" enctype="multipart/form-data"></form>');
if(data)
{
for(var i in data)
{
jQuery('<input type="hidden" /> ').attr('name', i).val(data[i]).appendTo(form);
//jQuery('<input type="hidden" name="' + i + '" value="' + data[i] + '" />').appendTo(form);
}
}
//var oldElement = jQuery('#' + fileElementId);
if(jQuery.type(fileElementId) === 'string') {
if(fileElementId.indexOf('#') != 0) {
fileElementId = '#' + fileElementId;
}
}
var oldElement = jQuery(fileElementId);
var newElement = jQuery(oldElement).clone();
jQuery(oldElement).attr('id', fileId);
jQuery(oldElement).before(newElement);
jQuery(oldElement).appendTo(form);
//set attributes
jQuery(form).css('position', 'absolute');
jQuery(form).css('top', '-1200px');
jQuery(form).css('left', '-1200px');
jQuery(form).appendTo('body');
return form;
},
handleError: function( s, xhr, status, e ) {
// If a local callback was specified, fire it
if ( s.error ) {
s.error.call( s.context || s, xhr, status, e );
}
// Fire the global callback
if ( s.global ) {
(s.context ? jQuery(s.context) : jQuery.event).trigger( "ajaxError", [xhr, s, e] );
}
},
ajaxFileUpload: function(s) {
// TODO introduce global settings, allowing the client to modify them for all requests, not only timeout
s = jQuery.extend({}, jQuery.ajaxSettings, s);
var id = new Date().getTime()
var form = jQuery.createUploadForm(id, s.fileElementId, (typeof(s.data)=='undefined'?false:s.data));
var io = jQuery.createUploadIframe(id, s.secureuri);
var frameId = 'jUploadFrame' + id;
var formId = 'jUploadForm' + id;
// Watch for a new set of requests
if ( s.global && ! jQuery.active++ )
{
jQuery.event.trigger( "ajaxStart" );
}
var requestDone = false;
// Create the request object
var xml = {}
if ( s.global )
jQuery.event.trigger("ajaxSend", [xml, s]);
// Wait for a response to come back
var uploadCallback = function(isTimeout)
{
var io = document.getElementById(frameId);
try
{
if(io.contentWindow)
{
xml.responseText = io.contentWindow.document.body?io.contentWindow.document.body.innerText:null;
xml.responseXML = io.contentWindow.document.XMLDocument?io.contentWindow.document.XMLDocument:io.contentWindow.document;
}else if(io.contentDocument)
{
xml.responseText = io.contentDocument.document.body?io.contentDocument.document.body.innerText:null;
xml.responseXML = io.contentDocument.document.XMLDocument?io.contentDocument.document.XMLDocument:io.contentDocument.document;
}
}catch(e)
{
jQuery.handleError(s, xml, null, e);
}
if ( xml || isTimeout == "timeout")
{
requestDone = true;
var status;
try {
status = isTimeout != "timeout" ? "success" : "error";
// Make sure that the request was successful or notmodified
if ( status != "error" )
{
// process the data (runs the xml through httpData regardless of callback)
var data = jQuery.uploadHttpData( xml, s.dataType );
// If a local callback was specified, fire it and pass it the data
if ( s.success )
s.success( data, status );
// Fire the global callback
if( s.global )
jQuery.event.trigger( "ajaxSuccess", [xml, s] );
} else
jQuery.handleError(s, xml, status);
} catch(e)
{
status = "error";
jQuery.handleError(s, xml, status, e);
}
// The request was completed
if( s.global )
jQuery.event.trigger( "ajaxComplete", [xml, s] );
// Handle the global AJAX counter
if ( s.global && ! --jQuery.active )
jQuery.event.trigger( "ajaxStop" );
// Process result
if ( s.complete )
s.complete(xml, status);
jQuery(io).unbind()
setTimeout(function()
{ try
{
jQuery(io).remove();
jQuery(form).remove();
} catch(e)
{
jQuery.handleError(s, xml, null, e);
}
}, 100)
xml = null
}
}
// Timeout checker
if ( s.timeout > 0 )
{
setTimeout(function(){
// Check to see if the request is still happening
if( !requestDone ) uploadCallback( "timeout" );
}, s.timeout);
}
try
{
var form = jQuery('#' + formId);
jQuery(form).attr('action', s.url);
jQuery(form).attr('method', 'POST');
jQuery(form).attr('target', frameId);
if(form.encoding)
{
jQuery(form).attr('encoding', 'multipart/form-data');
}
else
{
jQuery(form).attr('enctype', 'multipart/form-data');
}
jQuery(form).submit();
} catch(e)
{
jQuery.handleError(s, xml, null, e);
}
jQuery('#' + frameId).load(uploadCallback );
return {abort: function () {}};
},
uploadHttpData: function( r, type ) {
var data = !type;
data = type == "xml" || data ? r.responseXML : r.responseText;
// If the type is "script", eval it in global context
if ( type == "script" )
jQuery.globalEval( data );
// Get the JavaScript object, if JSON is used.
if ( type == "json" )
data = JSON.parse(data);
if( type == "string" );
// evaluate scripts within html
if ( type == "html" )
jQuery("<div>").html(data).evalScripts();
return data;
}
})
... ...
/**
* 我的评论
* @author: yyqing<yanqing.yang@yoho.cn>
* @date: 2016/3/1
* @author: liuchuanyang<chuanyang.liu@yoho.cn>
* @date: 2016/10/28
*/
var $ = require('yoho-jquery');
var ImgPreview = require('../common/img-preview');
var $comment = $('.comment-table'),
$remarkBtn = $comment.find('.remark-btn');
var $dialog = $('#comment-dialog-widget'),
$titleBar = $dialog.find('.dialog-titlebar'),
$commentArea = $dialog.find('textarea');
var pageW = $(document).width(),
pageH = $(document).height(),
winH = $(window).height(),
preview = new ImgPreview();
var dialog = {
canmove: false,
offset: {},
maxtop: 0,
maxleft: 0
},
orderInfo = {},
$optDom;
require('../plugins/jquery.qupload');
// 处理订单数据
$remarkBtn.each(function() {
/* var $next = $(this).next(),
data = $next.data(),
key = data.orderid;
orderInfo[key] = {};
orderInfo[key].productSkn = data.productskn;
orderInfo[key].productId = data.productid;
orderInfo[key].goodsId = data.goodsid;
orderInfo[key].orderId = data.orderid;
orderInfo[key].erpSkuId = data.erpskuid;
$next.remove();
$(this).data('code', key);*/
});
$remarkBtn.click(function() {
var scrollTop = $(document).scrollTop();
$optDom = $(this);
$commentArea.val('');
$dialog.removeClass('hide').css({
top: scrollTop + (winH - $dialog.outerHeight()) / 2,
left: (pageW - $dialog.outerWidth()) / 2
});
});
// 评论弹窗
$titleBar.bind('mousedown', function(e) {
if ($(e.target).hasClass('dialog-close-btn')) {
return;
}
dialog.canmove = true;
dialog.offset = {
x: e.offsetX,
y: e.offsetY
var preview = new ImgPreview();
require('../common/ajaxfileupload');
$('.comment-add').on('click', '.btn-submit', function() {
var $f = $(this).closest('.comment-add');
var param = {
productSkn: $f.find('input[name=productSkn]').val(),
productId: $f.find('input[name=productId]').val(),
goodsId: $f.find('input[name=goodsId]').val(),
orderCode: $f.find('input[name=orderCode]').val(),
orderId: $f.find('input[name=orderId]').val(),
erpSkuId: $f.find('input[name=erpSkuId]').val(),
content: $f.find('[name=goodsComment]').val(),
url: $f.find('[name=imgUrl]').val(),
height: $f.find('input[name=height]').val(),
weight: $f.find('input[name=weight]').val(),
satisfied: $f.find('[data-role="star"]').find('.active[data-star]').attr('data-star'),
size: $f.find('[data-role="size"]').find('.active[data-size]').attr('data-size')
};
dialog.maxtop = pageH - $dialog.outerHeight();
dialog.maxleft = pageW - $dialog.outerWidth();
});
$(document).mousemove(function(e) {
var mtop, mleft;
$.ajax({
type: 'POST',
url: '/home/comment/saveComment',
data: param
}).then(function(jsonData) {
if (!dialog.canmove) {
return;
}
if (jsonData.code === 200) {
//console.log(JSON.stringify(jsonData));
mtop = e.pageY - dialog.offset.y;
mleft = e.pageX - dialog.offset.x;
mtop = mtop < dialog.maxtop ? mtop : dialog.maxtop;
mleft = mleft < dialog.maxleft ? mleft : dialog.maxleft;
$dialog.css({
top: mtop > 0 ? mtop : 0,
left: mleft > 0 ? mleft : 0
} else {
alert(jsonData.message);
}
});
}).mouseup(function() {
dialog.canmove = false;
});
$('.img-preview').on('click', 'i.view', function() {
// 图片预览
$('.img-preview').on('click', 'i.view', function(e) {
var url = $(this).closest('.img-preview').find('img').attr('src');
e.stopPropagation();
preview.preview(url);
});
$dialog.on('click', '.dialog-save-btn', function() {
var remark = $.trim($commentArea.val()),
param;
// 图片删除
$('.img-preview').on('click', 'i.del', function(e) {
if (remark === '') {
alert('请添加评论内容');
return;
}
if ($optDom.length) {
param = orderInfo[$optDom.data().code];
param.content = remark;
$.ajax({
type: 'POST',
url: '/home/comment/saveComment',
data: param
}).then(function(jsonData) {
var $par = $optDom.parent();
if (jsonData.code === 200) {
$par.prev().text(remark);
$par.html('<span class="remarked">已评论!</span>');
$optDom.length = 0;
$dialog.addClass('hide');
} else {
alert(jsonData.message);
}
});
}
});
var $p = $(this).closest('.img-preview');
$dialog.on('click', '.dialog-close-btn', function() {
$optDom.length = 0;
$dialog.addClass('hide');
e.stopPropagation();
$p.removeClass('selected');
$p.find('input[name=imgUrl]').val('');
$p.find('img').attr('src', '');
});
$('.comment-add input[type="file"]').each(function(i, it) {
var $this = $(it),
$par = $this.closest('.problem-description');
if (!window.location.origin) {
window.location.origin = window.location.protocol + '//' +
window.location.hostname + (window.location.port ? ':' + window.location.port : '');
}
alert(window.location.origin);
$this.qupload({
button_image_url: '',
upload_url: window.location.origin + '/home/returns/imgUpload',
file_post_name: 'fileData',
button_text: '<span class="btn_upload_text">上传图片</span>',
button_text_style: '.btn_upload_text{color: #ffffff;}',
button_width: 60,
button_height: 60,
button_text_left_padding: 32,
button_text_top_padding: 8,
button_action: window.SWFUpload.BUTTON_ACTION.SELECT_FILE,
file_size_limit: '10240',
file_types: '*.jpg;*.jpeg;*.png;*.bmp',
uploadSuccessed: function(data) {
var $imgList = $par.find('li'),
isShow = false,
img, _html;
img = JSON.parse(data).imgList[0];
_html = '<span class="btn-del" title="删除"></span>' +
'<img src="' + img[0] + '" width="126" height="126">' +
'<input type="hidden" name="imgs" value="' + img.imgRelUrl + '">';
$imgList.each(function() {
if (!isShow && !$(this).find('img').length) {
isShow = true;
$(this).html(_html);
// 图片上传
$('.comment-add').on('change', 'input[type=file]', function() {
var $f = $(this);
var $p = $f.closest('.img-preview');
if ($f.val()) {
$.ajaxFileUpload({
url: '/common/upload/image',
secureuri: false,
fileElementId: $f,
data: {
bucket: 'sns'
},
dataType: 'json',
success: function(data /* , status */) {
var url, relaUrl;
if (data && data.code === 200 && data.data && data.data.images && data.data.images[0]) {
url = data.data.images[0];
relaUrl = data.data.imagesList[0];
$p.find('img').attr('src', url);
$p.find('input[name=imgUrl]').val(relaUrl);
$p.addClass('selected');
}
});
}
});
},
error: function() { /** data, status, e **/
alert('上传失败,请稍后再试!');
},
complete: function() {
$f.clone().replaceAll($f);
}
});
}
});
// comment form
... ...
... ... @@ -27,5 +27,9 @@
.preview-body{
overflow: hidden;
img{
max-width:100%;
}
}
}
... ...
... ... @@ -151,6 +151,9 @@
width:100%;
height:100%;
cursor: pointer;
position:absolute;
left:0;
top:0;
}
i{
display:none;
... ... @@ -160,6 +163,7 @@
text-align:center;
color:#FFF;
background:rgba(0, 0, 0, .5);
cursor: pointer;
&.view {
left: 0;
... ... @@ -169,7 +173,9 @@
}
}
img {
max-width:100%;
min-width:100%;
max-width:200%;
min-height:100%;
}
&.selected {
... ... @@ -223,6 +229,11 @@
}
}
}
.s-input {
width: 25px;
padding-left: 5px;
padding-right: 5px;
}
.textarea{
position:relative;
> textarea{
... ...