Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

完全 #1251

Open
wants to merge 51 commits into
base: master
Choose a base branch
from
Open

完全 #1251

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
0029fe5
add form-btn
Aug 23, 2018
da31ff4
修改RELOAD'
Aug 23, 2018
50f2aac
修改form-btn
Aug 24, 2018
8efdfd8
自定义表单测试
Aug 27, 2018
dc01f01
样式上传
Aug 27, 2018
9779d93
生成环境表单修改
Aug 28, 2018
b71afa3
样式修改
Aug 28, 2018
87cbc2d
样式修改
Aug 28, 2018
6d23c9f
样式修改
Aug 28, 2018
d443fbc
修改readme 修改version
Aug 28, 2018
fdb1a44
修改文件错误格式部分
Aug 28, 2018
94d98b7
修改为es5
Aug 28, 2018
52e844b
修改表单数据contenttype
Aug 28, 2018
af746cc
fetch使用自动content-type,并添加cookie传入
Aug 29, 2018
fb9f6ed
验证码表单
Aug 30, 2018
8e046e1
bug修复
Aug 30, 2018
ffce896
bug修复
Aug 30, 2018
2159d4f
bug修复
Aug 30, 2018
4bd0d80
bug修复
Aug 30, 2018
50d8d4d
统一字段返回info
Aug 30, 2018
7102141
提交
Aug 30, 2018
2bd5f4c
提交tool
Aug 30, 2018
71b81af
简单js工具
Aug 30, 2018
12db6d6
简单js工具
Aug 30, 2018
28bfeb1
添加csrf
Sep 6, 2018
4251645
添加csrf
Sep 6, 2018
a03424c
youbao表单
Sep 6, 2018
e367e23
获取短信验证码
Sep 6, 2018
13d2f4e
获取短信验证码
Sep 6, 2018
5ccf2e4
获取短信验证码
Sep 6, 2018
ac65469
表单验证提示
Sep 6, 2018
bbb219c
验证码
Sep 6, 2018
34e6eeb
修改验证事件
Sep 6, 2018
0c803e2
修复radio表单验证bug
Sep 7, 2018
c23a7e9
邮编表单添加xmlHttpRequest头
Sep 10, 2018
05a1c55
添加ajax头
Sep 10, 2018
f6af241
添加ajax头
Sep 10, 2018
41d6dfa
添加ajax头
Sep 10, 2018
38f7657
checkbox表单验证修改
Sep 10, 2018
dc40029
redirect
Sep 10, 2018
c2b28d7
checkbox修改
Sep 10, 2018
9a1bdad
添加fetch include
Sep 11, 2018
ef2a8ea
验证码失败处理
Sep 14, 2018
48b014f
验证码失败处理
Sep 14, 2018
09fb5fc
验证码失败处理
Sep 14, 2018
f266490
验证码失败处理
Sep 14, 2018
37f7a97
验证码失败处理
Sep 14, 2018
9969e20
验证码失败处理
Sep 14, 2018
a79f1fc
验证码失败处理
Sep 14, 2018
511c4d3
验证码失败处理
Sep 14, 2018
64fd90a
验证码失败处理
Sep 14, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions src/mip-258-form-btn/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# mip-258-form-btn ajax请求

ajax请求

标题|内容
----|----
类型|通用
支持布局|N/S
## 示例

### 基本使用

```html
<mip-258-form-btn method="post" url="http://laravel51.com/postData" redirect="" reload="false">
<input type="text" name="user_id" value="1111">
<span class="success" style="display: none;">请求成功,一秒后跳转</span>
<span class="error" style="display: none;">字段格式不正确</span>
<button type="button">确定</button>
</mip-258-form-btn>

```
### url

说明:必须是 HTTP(S) 或 // 开头的地址
必选项: 是

### method

说明:请求方法
必选项: 是

### redirect

说明:必须是 HTTP(S) 或 // 开头的地址
必选项: 否

### reload

说明:boolean值 默认false, 请求成功后是否页面刷新
必选项: 否





50 changes: 50 additions & 0 deletions src/mip-258-form-btn/mip-258-form-btn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

/**
* @file mip-ajax-button 组件
*
* @author chen
* @time 2018.8.21
*/
define(function (require) {
var customElement = require('customElement').create();
var $ = require('zepto');
customElement.prototype.build = function () {
var element = this.element;
var url = $(element).attr('url');
var method = $(element).attr('method');
var button = $(element).find('button');
var reload = $(element).attr('reload');
var redirect = $(element).attr('redirect');
var input = $(element).find('input');
var formData = new FormData();
$.each(input, function (index, item) {
var filed = $(item).attr('name');
var val = $.trim($(item).val());
formData.append(filed, val);
});
button.click(function () {
ajaxBox();
});

// tijiao
function ajaxBox() {
fetch(url, {method: method, mode: 'cors', body: formData}).then(function (res) {
res.json().then(function (data) {
if (data.status === 1) {
$(element).find('span.success').text(data.msg).show();
if (redirect) {
window.top.location.href = redirect;
}
if (reload === 'true') {
window.top.location.reload();
}
} else {
$(element).find('span.error').text(data.msg).show();
}
});
}).catch(function (e) {
});
}
};
return customElement;
});
12 changes: 12 additions & 0 deletions src/mip-258-form-btn/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "mip-258-form-btn",
"version": "1.0.0",
"description":"按钮ajax请求。",
"author": {
"name": "chen",
"email": "[email protected]"
},
"engines": {
"mip": ">=1.0.0"
}
}
113 changes: 113 additions & 0 deletions src/mip-258-form1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# mip-258-form1

mip-258-form1 表单组件

标题|内容
----|----
类型|通用
支持布局|fixed
所需脚本|https://c.mipcdn.com/static/v1/mip-258-form1/mip-258-form1.js

## 示例
### 基本使用

```html
<mip-258-form1 method="get" fetch-url="http://laravel51.com/postData" from="comment" id="test" >
<input type="number" name="mobile" validatetarget="mobile" validatetype="phone" placeholder="电话号码" class="inquiryMobile" value="13950186826">
<div class="btnCode getInquiryCode" btn-url="http://m.258.com/Common/sendMobileCode">获取验证码</div>
<div class='waitInquiryCode hide'><span class='waitInquiry'>59</span>秒后重新获取</div>
<div class="error" target="mobile">请输入正确的电话</div>
<input type="number" validatetarget="age" validatetype="must" name="age" placeholder="年龄" value="123">
<div class="error" target="age">年龄不能为空</div>
<div submit-success>
<template type="mip-mustache">
{{aaa}}
</template>
</div>
<div submit-fail class="error">
<template type="mip-mustache">
{{failinfo}}
</template>
</div>
<div submit-error>
<template type="mip-mustache">
Error!.
</template>
</div>
<input type="submit" class="submit" value="提交">
</mip-258-form1>
```
## 属性

### method

说明:表单提交方法
必选项:是

### controlId

说明:需要控制的id
必选项:否

### from

说明:来自那张表单
必选项:否

### url

说明:必须是 HTTP(S) 或 // 开头的地址
必选项: 是

### validatetarget

说明: 验证提示对应 tag,用于对应错误时的提示显示元素的查找
必选项:否

### validatetype

说明:验证类型, 用于支持简单的验证。目前提供 `email`, `phone`, `idcar`, `custom`。当为 `custom` 时则需要填写 `validatereg`
必选项:否

### validatereg

说明: 自定义验证,补充站长个性化的验证规则。如果 `validatetype` 为 `custom` 时需填写相应验证规则
必选项:否

### fetch-url

说明: 有此属性则可以开启异步请求数据逻辑,组件会并根据数据返回状态来按`submit-success`,`submit-error`块中的模板刷新局部信息。
需要注意的几个点:

- 方法支持。
- 请求结果请返回 JSON 对象。
- 数据状态只有在成功(2xx)的时候触发 `submit-success` 的逻辑,其他的均触发 `submit-error` 逻辑。

必选项:否

### pid

说明: 用来绑定产品id
必选项: 否

### cid

说明: 用来绑定公司id
必选项: 否

- 方法支持。
- 请求结果请返回 JSON 对象。
- 数据状态只有在成功(2xx)的时候触发 `submit-success` 的逻辑,其他的均触发 `submit-error` 逻辑。

必选项:否

### on

说明: 添加事件清空表单
必选项: 否


## 注意事项

1. 表单提交方法如果为 `post`,应使用 HTTPS 地址。避免 MIP-Cache HTTPS 环境提交到 HTTP,导致浏览器报错。
2. 使用 fetch 功能时,请求使用 cors 时不能配置为 *。
Loading