Commit 51d18a21 by 李洋

update code

parent c84d7474
......@@ -290,6 +290,10 @@ class MessageController extends Controller
Csrf($request);
$map = $request->input('log_id');
$db = DB::connection('message');
$isContainInner = '';
$isContainSMS = '';
$isContainEmail = '';
$isContainWechatNotify = '';
if(!empty($map))
{
......@@ -312,9 +316,15 @@ class MessageController extends Controller
$channel_tpls[$channel_type] = $channel_tpl_obj;
}
$info->channel_tpls = $channel_tpls;
//判断包含的消息渠道(用于展示消息渠道)(利用之前分割字符串得到的数组)
$isContainInner = in_array('1',$tpl_channels_arr);
$isContainSMS = in_array('2',$tpl_channels_arr);
$isContainEmail = in_array('3',$tpl_channels_arr);
$isContainWechatNotify = in_array('4',$tpl_channels_arr);
}
//找出所有模板
//找出所有模板(给选择模板用)
$all_msg_tpl = $db->table('lie_msg_tpl')->select('tpl_id','description')->get();
if(empty($info))
......@@ -346,7 +356,11 @@ class MessageController extends Controller
'id'=>$id,
'info'=>$info,
'msg_type'=>$msg_type,
'all_msg_tpl'=>$all_msg_tpl
'all_msg_tpl'=>$all_msg_tpl,
'isContainInner'=>$isContainInner,
'isContainSMS'=>$isContainSMS,
'isContainEmail'=>$isContainEmail,
'isContainWechatNotify'=>$isContainWechatNotify,
];
return view($viewid, $data);
......
$('#msg_tpl_submit').click(function()
{
//前端校验
//1.消息渠道 和 模板描述
if(!$("input[id='chk-channels-inner']").is(':checked') && !$("input[id='chk-channels-sms']").is(':checked') &&
!$("input[id='chk-channels-email']").is(':checked') && !$("input[id='chk-channels-wechat-notify']").is(':checked'))
{
Prompt('请勾选至少一个消息渠道', 5);
return false;
}
if(!$('#msg-tpl-desc').val())
{
Prompt('请输入模板描述', 5);
return false;
}
//2.渠道模板
//站内信
if($("input[id='chk-channels-inner']").is(':checked'))
{
if($("#inner-tpl-type option:selected").val()==0)
{
Prompt('请选择消息类型', 5);
return false;
}
if(!$('#inner-tpl-title').val())
{
Prompt('请填写消息标题', 5);
return false;
}
var ue = UE.getEditor('inner-tpl-content');
if(!ue.getContent())
{
Prompt('请填写消息内容', 5);
return false;
}
if($("input[id='inner-tpl-op-url']").is(':checked') && !$("#inner-tpl-op-url-text").val())
{
Prompt('请填写要打开的url', 5);
return false;
}
}
//短信
if($("input[id='chk-channels-sms']").is(':checked'))
{
if(!$("#sms-tpl-content").val())
{
Prompt('请填写短信内容', 5);
return false;
}
}
//邮件
if($("input[id='chk-channels-email']").is(':checked'))
{
if(!$("#email-tpl-title").val())
{
Prompt('请填写邮件标题', 5);
return false;
}
var ue = UE.getEditor('email-tpl-content');
if(!ue.getContent())
{
Prompt('请填写邮件内容', 5);
return false;
}
}
//微信通知
if($("input[id='chk-channels-wechat-notify']").is(':checked'))
{
if(!$("#wechat-notify_tpl_title").val())
{
Prompt('请填写微信模板编号', 5);
return false;
}
}
// addTemplate();
})
function addTemplate()
{
$.ajax({
type: 'post',
url: '/msgapi/addTemplate',
timeout : 10000, //超时时间设置,单位毫秒
data: {
spu_id:$('#spu_id').val(),
class_id1:$('#class_id1').val(),
class_id2:$('#class_id2').val(),
class_id3:$('#class_id3').val(),
brand_id:$('#brand_id').val(),
spu_name:$('#spu_name').val(),
status:$("input[name='status']:checked").val(),
images_l:$('#images_l').val(),
images_s:$('#images_s').val(),
encap:$('#encap').val(),
pdf:$('#pdf').val(),
spu_brief:$('#spu_brief').val(),
has_rohs:$("input[name='has_rohs']:checked").val(),
attrs:$('#spu_attrs').val(),
spu_detail:ue.getContent(),
bussiness_area:checkBoxes,
},
dataType: 'json',
success: function(resp){
if(!resp){
Prompt('网络异常,请重试', 5);
return false;
}
if(resp.errcode==0){
Prompt(resp.errmsg, 1);
location.reload();
}else{
Prompt(resp.errmsg, 5);
return false;
}
},
error:function(jqXHR, textStatus, errorThrown){
Prompt("网络异常,请重试",5);
},
});
}
//监听短信内容,计算短信条数
$('#sms-tpl-content').bind('input propertychange', function() {
$('#sms-content-length').html('预计' + Math.ceil($(this).val().length/70) + '条短信');
});
//获取点选了的消息渠道复选框
function getChosenMsgChannels()
{
var chk_values = [];
$('input[name="chk-channels"]:checked').each(function(){
chk_values.push($(this).val());
});
var chk_str = chk_values.join(",");
return chk_str;
}
\ No newline at end of file
......@@ -106,8 +106,11 @@
<div style="margin-left: 40px;">
<div class="col-sm-10 form-inline" style="margin-top: 20px">
<label class="col-sm-2 control-label" id="msg-tpl-channels"><span style="color: red">*</span> 消息渠道:</label>
<div class="col-sm-3">
<label>未填写任何渠道</label>
<div class="col-sm-4">
<input type="checkbox" name="chk-channels" id="chk-channels-inner" value="1"/><label>站内信</label>
<input type="checkbox" name="chk-channels" id="chk-channels-sms" value="2"/><label>短息</label>
<input type="checkbox" name="chk-channels" id="chk-channels-email" value="3"/><label>邮箱</label>
<input type="checkbox" name="chk-channels" id="chk-channels-wechat-notify" value="4"/><label>微信通知</label>
</div>
</div>
......@@ -180,7 +183,7 @@
</div>
<div class="col-sm-10" style="margin-top: 20px">
<label>消息内容:</label>
<label><span style="color: red">*</span>消息内容:</label>
<script type="text/plain" id="inner-tpl-content" name="inner-tpl-content"></script>
<script type="text/javascript">UE.getEditor('inner-tpl-content');</script>
</div>
......@@ -202,7 +205,7 @@
<label class="col-sm-2 control-label"><span style="color: red">*</span> 短信内容:</label>
<div class="col-sm-10">
<textarea rows="2" cols="10" id="sms-tpl-content" class="form-control" placeholder="请输入短信内容"></textarea>
<label>预计1条短信</label>
<label id="sms-content-length">预计1条短信</label>
</div>
</div>
</div>
......@@ -217,7 +220,7 @@
</div>
<div class="col-sm-10" style="margin-top: 20px">
<label>邮件内容:</label>
<label><span style="color: red">*</span>邮件内容:</label>
<script type="text/plain" id="email-tpl-content" name="email-tpl-content"></script>
<script type="text/javascript">UE.getEditor('email-tpl-content');</script>
</div>
......
......@@ -106,8 +106,12 @@
<div style="margin-left: 40px;">
<div class="col-sm-10 form-inline" style="margin-top: 20px">
<label class="col-sm-2 control-label" id="msg-tpl-channels"><span style="color: red">*</span> 消息渠道:</label>
<div class="col-sm-3">
<label>@if(empty($info->channels_str)) 未填写任何渠道 @else {{ $info->channels_str }} @endif</label>
<div class="col-sm-4">
{{--<label>@if(empty($info->channels_str)) 未填写任何渠道 @else {{ $info->channels_str }} @endif</label>--}}
<input type="checkbox" name="chk-channels" id="chk-channels-inner" value="1" @if(!empty($isContainInner)) checked @endif/><label>站内信</label>
<input type="checkbox" name="chk-channels" id="chk-channels-sms" value="2" @if(!empty($isContainSMS)) checked @endif/><label>短息</label>
<input type="checkbox" name="chk-channels" id="chk-channels-email" value="3" @if(!empty($isContainEmail)) checked @endif/><label>邮箱</label>
<input type="checkbox" name="chk-channels" id="chk-channels-wechat-notify" value="4" @if(!empty($isContainWechatNotify)) checked @endif/><label>微信通知</label>
</div>
</div>
......@@ -197,7 +201,7 @@
</div>
<div class="col-sm-10" style="margin-top: 20px">
<label>消息内容:</label>
<label><span style="color: red">*</span>站内信内容:</label>
<script type="text/plain" id="inner-tpl-content" name="inner-tpl-content">@if(!empty($info->channel_tpls['1']->content)) {{ $info->channel_tpls['1']->content }} @endif</script>
<script type="text/javascript">UE.getEditor('inner-tpl-content');</script>
</div>
......@@ -219,7 +223,7 @@
<label class="col-sm-2 control-label"><span style="color: red">*</span> 短信内容:</label>
<div class="col-sm-10">
<textarea rows="2" cols="10" id="sms-tpl-content" class="form-control" placeholder="请输入短信内容">@if(!empty($info->channel_tpls['2'])) {{ $info->channel_tpls['2']->content }} @endif</textarea>
<label>预计1条短信</label>
<label id="sms-content-length">预计1条短信</label>
</div>
</div>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment