-
Notifications
You must be signed in to change notification settings - Fork 69
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
[platform] rita_114 提交组件改动:mip-msg #227
Open
mip-audit-platform
wants to merge
1
commit into
master
Choose a base branch
from
dev-platform-0abd0029f26512f11d2d0079885aa603
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# mip-msg | ||
|
||
mip-msg 用于提交联系方式的组件 | ||
|
||
标题|内容 | ||
----|---- | ||
类型|通用 | ||
支持布局|responsive,fixed-height,fill,container,fixed | ||
所需脚本|https://c.mipcdn.com/extensions/platform/v1/mip-msg/mip-msg.js | ||
|
||
## 示例 | ||
|
||
### 基本用法 | ||
|
||
```html | ||
<mip-msg popContact="Mcontact" popTel="Mtel" popInfo="Minfo" popButton="Mbutton" projectId="123"> | ||
<p contenteditable="true" id="Mcontact" placeholder="请输入您的手机号码~" ></p> | ||
<p contenteditable="true" id="Mtel" placeholder="请输入您的姓名~" ></p> | ||
|
||
<p contenteditable="true" id="Minfo" placeholder="请输入您的手机号码~" ></p> | ||
<span id="Mbutton" value="立即提交" ></span> | ||
</mip-msg> | ||
``` | ||
## 属性 | ||
|
||
### {属性名} | ||
|
||
说明:{说明} | ||
必选项:{是|否} | ||
类型:{类型} | ||
取值范围:{取值范围} | ||
单位:{单位} | ||
默认值:{默认值} | ||
|
||
## 注意事项 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/** | ||
* @file mip-vote 组件 | ||
* @author | ||
*/ | ||
|
||
define(function (require) { | ||
// mip 组件开发支持 zepto | ||
var jquery = require('zepto'); | ||
var customElement = require('customElement').create(); | ||
// 第一次进入可视区回调,只会执行一次 | ||
|
||
customElement.prototype.firstInviewCallback = function () { | ||
var element = this.element; | ||
// 姓名Id | ||
var popContact = this.element.getAttribute('popContact'); | ||
// 联系方式ID | ||
var popTel = this.element.getAttribute('popTel'); | ||
// 留言内容id | ||
var popInfo = this.element.getAttribute('popInfo'); | ||
// checkBox | ||
var checkBox = this.element.getAttribute('checkBox'); | ||
// 提交按钮Id | ||
var popButton = this.element.getAttribute('popButton'); | ||
var projectId = this.element.getAttribute('projectId'); | ||
var projectIdValue = ''; | ||
var popTelValue = ''; | ||
var popContactValue = ''; | ||
var popInfoValue = ''; | ||
$('#' + checkBox).click(function () { | ||
if ($(this).attr('checked') === 'checked') { | ||
$(this).attr('checked', false); | ||
$(this).css('background', '#999'); | ||
} else { | ||
$(this).attr('checked', 'checked'); | ||
$(this).css('background', '#33bd57'); | ||
} | ||
}); | ||
// 点击按钮 | ||
$('#' + popButton + '').click(function () { | ||
var tval = $('#' + popTel + '').text(); | ||
var add = true; | ||
var reTel = /^1\d{10}$/; | ||
var reg = /^0\d{2,3}-\d{7,8}(-\d{1,6})?$/; | ||
// 判断名字是否为空 | ||
if (popContact !== '') { | ||
if ($.trim($('#' + popContact + ' ').text()) === '') { | ||
$('#' + popContact + ' ').attr('placeholder', '请输入你的姓名'); | ||
$('#' + popContact + ' ').css('border-color', '#FF0000'); | ||
} | ||
else { | ||
$('#' + popContact + '').css('border-color', '#d2d2d2'); | ||
popContactValue = $.trim($('#' + popContact + '').text()); | ||
$('#' + popContact + '').text(''); | ||
} | ||
} | ||
// 判断联系方式是否为空 | ||
if ($.trim(tval) === ' ') { | ||
$('#' + popTel + '').css('border-color', '#FF0000'); | ||
$('#' + popTel + '').attr('placeholder', '请输入你的手机号码'); | ||
return; | ||
} | ||
else if (reTel.test(tval) === false && reg.test(tval) === false) { | ||
$('#' + popTel + '').css('border-color', '#FF0000'); | ||
$('#' + popTel + '').text(''); | ||
$('#' + popTel + '').attr('placeholder', '输入的联系方式不正确'); | ||
return; | ||
} | ||
else { | ||
$('#' + popTel + '').css('border-color', '#d2d2d2'); | ||
popTelValue = $.trim(tval); | ||
} | ||
if (popInfo !== '') { | ||
popInfoValue = $.trim($('#' + popInfo + '').text()); | ||
$('#' + popInfo + '').text(''); | ||
} | ||
var loginReqbody = { | ||
'tid': projectId, | ||
'type': 'addMsg', | ||
'tel': popTelValue, | ||
'popInfo': popInfoValue, | ||
'popContact': popContactValue | ||
}; | ||
if ($('#' + checkBox).attr('checked') === 'checked') { | ||
$.ajax({ | ||
url: 'https://m.53.com.cn/common/mipwebdo.ashx', | ||
type: 'POST', | ||
async: false, | ||
data: JSON.stringify(loginReqbody), | ||
error: function () { | ||
alert('留言失败2'); | ||
}, | ||
success: function (data, status) { | ||
if (status = 'success' && data !== '') { | ||
alert(data); | ||
$('#' + popTel + '').text(''); | ||
} else { | ||
alert('留言失败3'); | ||
} | ||
} | ||
}); | ||
} | ||
else { | ||
alert('请先同意《53加盟网服务条款》'); | ||
} | ||
}); | ||
}; | ||
return customElement; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "mip-msg", | ||
"version": "1.4.2", | ||
"description": "用来进行提交留言的小组件", | ||
"contributors": [ | ||
{ | ||
"name": "LaoWang", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"engines": { | ||
"mip": ">=1.1.0" | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
提交联系方式可以直接用官方组件 mip-form 来实现,没必要新提交组件。
https://www.mipengine.org/v2/components/dynamic-content/mip-form.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我这也是接手的的别人的项目,他之前这样写的,考虑到如果用mip-form改动比较大,所以就改了一下他原来的组件,就很烦