Xiuxiu 组件

import React, { Component } from 'react';

class XiuXiu extends Component {
componentDidMount() {
const {closeModal, imageUrl, uploadUrl, formData} = this.props;
/* 第1个参数是加载编辑器div容器,第2个参数是编辑器类型,第3个参数是div容器宽,第4个参数是div容器高*/
xiuxiu.embedSWF('altContent', 1, '700px', '520px');
// 修改为您自己的图片上传接口
xiuxiu.setUploadURL(uploadUrl);
xiuxiu.setUploadType(2);
xiuxiu.setUploadDataFieldName('file');
xiuxiu.setUploadArgs(formData);
xiuxiu.onInit = function () {
xiuxiu.loadPhoto(imageUrl);
};
xiuxiu.onUploadResponse = function (data) {
closeModal(true);
};
xiuxiu.onBatchUploadComplete = function () {
closeModal(true);
};
xiuxiu.onClose = function(id) {
closeModal(false);
};
xiuxiu.onUpload = function(id) {
closeModal(true);
};
}
render() {
return (
<div id='altContent'>
</div>
);
}
} export default XiuXiu; XiuxiuComponent
class XiuXiuModal extends Component {
state = {
visible: false,
}
showModal = () => {
this.setState({visible: true});
}
closeModal = (isEdit) => {
const {imageUrl} = this.props;
this.props.onClose(imageUrl, isEdit);
this.setState({visible: false});
}
render() {
const {children, policyImage, imagePath} = this.props;
const formData = {
signature: policyImage.signature,
OSSAccessKeyId: policyImage.accessid,
policy: policyImage.policy,
key: imagePath,
success_action_status: '200',
};
return (
<a onClick={this.showModal}>
{children}
{this.state.visible && <Modal wrapClassName='xiuxiu-wrapper' closable={false} width='700px' footer={null} title={null} visible >
<XiuXiu uploadUrl={policyImage.host} formData={formData} closeModal={this.closeModal} {...this.props} />
</Modal>}
</a>
);
}
}

最终引入

import XiuXiu from 'components/XiuXiu';
class ItemBox extends Component {
componentDidMount () {
const {folderFormatType, folderId, actions: {policyActions: {getImagePolicy}, ownActions: {loadMaterial}}} = this.props;
loadMaterial(folderId, undefined, true, folderFormatType);
getImagePolicy();
}
cancelEditImage = (imageUrl, isEdit) => {
const {actions: {ownActions: {editMaterial}}, materials} = this.props;
const item = find(materials, {coverImage: imageUrl});
if(isEdit) {
editMaterial({
id: item.id,
version: item.version + 0.1,
});
}
}
render () {
const {actions: {ownActions: {addMaterial, loadMaterial}},
page, policyImage, materials, folderId, folder, profile} = this.props;
return (
<XiuXiuModal onClose={this.cancelEditImage} imagePath={item.path} policyImage={policyImage} imageUrl={item.url}>
编辑图片
</XiuXiuModal>
);
}
}

  

注意:

1、引入美图秀秀必须加载上传图片接口

2、设置crossdomain.xml

下载crossdomain.xml文件,把解压出来的crossdomain.xml文件放在您保存图片或图片来源的服务器根目录下,
比如: http://example.com.cn,那么crossdomain.xml的路径为:http://example.com.cn/crossdomain.xml。
需要注意的是crossdomain.xml必须部署于站点根目录下才有效, crossdomain.xml的目的是授权来自美图域下的flash向您的站点上传图片或者从您的站点加载图片。
【备注】由于本地测试会被flash安全沙箱拦住,请自行搭建web服务器,在web 环境中测试。


美图秀秀web开发文档的更多相关文章

  1. 美图秀秀 web开发图片编辑器

    美图秀秀web开发平台 http://open.web.meitu.com/wiki/ 1.环境配置 1.1.设置crossdomain.xml 下载crossdomain.xml文件,把解压出来的c ...

  2. web开发文档整理

    django 1.11版中文文档 django 1.11版英文文档 Redis命令参考文档 Axios中文文档 Axios英文官方文档 Django REST Framework官方文档 Vue.js ...

  3. Web图片编辑控件开发文档-Xproer.ImageEditor

    版权所有 2009-2014 荆门泽优软件有限公司 保留所有权利 官方网站:http://www.ncmem.com 产品首页:http://www.ncmem.com/webplug/image-e ...

  4. thinkphp + 美图秀秀api 实现图片裁切上传,带数据库

    思路: 1.数据库 创建test2 创建表img,字段id,url,addtime 2.前台页: 1>我用的是bootstrap 引入必要的js,css 2>引入美图秀秀的js 3.后台: ...

  5. 美图秀秀api实现图片的裁剪及美化

    美图秀秀不仅有PC版.手机版等客户端的软件,还有Web开方接口,可以在web页面上调用美图秀秀的api接口,实现图片的编辑.像淘宝.网易.qq空间.新浪微博等大厂都使用过该接口. 官网地址:http: ...

  6. 简易的美图秀秀利用别人的so库

    在实际开发中,有时候时间短,任务量大,可以查看类似的apk,将行apk反编译,通过看源码分析,用里面的JNI代码! 本案例中用了美图秀秀的JNI.java和jni.so链接库 项目中调用别人写的c代码 ...

  7. C#微信开发文档

    C#微信开发文档 开发前准备 微信公众平台链接: https://mp.weixin.qq.com/cgi-bin/home?t=home/index&lang=zh_CN 开发初期我们使用测 ...

  8. QM项目开发文档整理

    QM项目开发文档整理 前言 在W公司工作4个多月,庆幸接触到的全是"硬"项目,真枪实干,技术.经验.能力都得到了很大提升. QM项目 此项目WEB前端学到的东西很多,对PHP项目的 ...

  9. 美图秀秀DBA谈MySQL运维及优化

    美图秀秀DBA谈MySQL运维及优化 https://mp.weixin.qq.com/s?__biz=MzI4NTA1MDEwNg==&mid=401797597&idx=2& ...

随机推荐

  1. 零拷贝详解 Java NIO学习笔记四(零拷贝详解)

    转 https://blog.csdn.net/u013096088/article/details/79122671 Java NIO学习笔记四(零拷贝详解) 2018年01月21日 20:20:5 ...

  2. python入门:输出1-100之内的所有奇数和偶数

    #!/usr/bin/env python # -*- coding:utf-8 -*- #输出1-100之内的所有奇数和偶数 """ 给start赋值等于1,while ...

  3. Restful API 概念解析

    什么是restful? REST与技术无关,代表的是一种软件架构风格,REST是Representational State Transfer的简称,中文翻译为“表征状态转移”或“表现层状态转化”. ...

  4. PTA 7-1 银行业务队列简单模拟

    用链表实现队列操作,代码如下: #include <iostream> #include <cstdio> #include <algorithm> #includ ...

  5. MySQL安装与配置介绍

    MySQl介绍 官方站点:http://www.mysql.com/ MySQL是一个开放源码的小型关联式数据库管理系统.目前MySQL被广泛地应用在Internet上的中小型网站中.由于其体积小.速 ...

  6. android自动化测试之Monkey--从参数讲解、脚本制作到实战技巧

    视频: http://v.youku.com/v_show/id_XODcyMjM1MDA4.html?from=y1.2-1-87.4.4-1.1-1-2-3 PPT: http://www.doc ...

  7. CDH4 journalnode方式手工安装手册之二

    一.                                Hadoop配置修改 修改core-site.xml文件 <configuration> <property> ...

  8. BZOJ 2217: [Poi2011]Lollipop

    若sum可行 sum-2一定可行 序列和为ans 找出和ans奇偶性不同的最大的ans,即最靠左或最靠右的1的位置 更新答案 有spj #include<cstdio> using nam ...

  9. 《Scrum实战》第1次课课后任务

    1.必做任务:从知行角度总结T平台 从知行角度总结T平台 头(知识,学习) 做得好的 宣贯会 引入敏捷思想 敏捷宣言 敏捷原则 质量风险前移原则 引入最佳实践 包括了XP的大部分实践 不足 项目管理框 ...

  10. 模拟 - BZOJ 1510 [POI2006] Kra-The Disks

    BZOJ 1510 [POI2006] Kra-The Disks 描述 Johnny 在生日时收到了一件特殊的礼物,这件礼物由一个奇形怪状的管子和一些盘子组成. 这个管子是由许多不同直径的圆筒(直径 ...