Commit fc0928a2 by 李洋

update api

parent 6da550cc
......@@ -395,15 +395,21 @@ class MessageController extends Controller
Csrf($request);
$rq_tpl_id = $request->input('tpl_id');
$db = DB::connection('message');
//是否包含某一渠道
$isContainInner = '';
$isContainSMS = '';
$isContainEmail = '';
$isContainWechatNotify = '';
//渠道模板id
$inner_chn_tpl_id = '';
$sms_chn_tpl_id = '';
$email_chn_tpl_id = '';
$wechatNotify_chn_tpl_id = '';
if(!empty($rq_tpl_id))
{
//通过tpl_id找到模板的渠道们 和 描述等
$info = $db->table('lie_msg_tpl')->select('tpl_id','description','channels','msg_type')->where('tpl_id',$rq_tpl_id)->first();
$info = $db->table('lie_msg_tpl')->select('tpl_id','description','channels','msg_type','creater')->where('tpl_id',$rq_tpl_id)->first();
//通过找到的 channels 去渠道模板表里 把每个channel找出来
$tpl_channels_arr = explode(',',$info->channels);
......@@ -412,6 +418,20 @@ class MessageController extends Controller
{
$channel_tpl_obj = $db->table('lie_msg_channel_tpl')->where('tpl_id',$info->tpl_id)->where('channel_type',$channel_type)->first();
$channel_tpls[$channel_type] = $channel_tpl_obj;
//将channel_tpl_id赋给正确的变量中
if($channel_type==1)
{
$inner_chn_tpl_id = $channel_tpl_obj->channel_tpl_id;
}elseif($channel_type==2)
{
$sms_chn_tpl_id = $channel_tpl_obj->channel_tpl_id;
}elseif($channel_type==3)
{
$email_chn_tpl_id = $channel_tpl_obj->channel_tpl_id;
}elseif($channel_type==4)
{
$wechatNotify_chn_tpl_id = $channel_tpl_obj->channel_tpl_id;
}
}
$info->channel_tpls = $channel_tpls;
......@@ -430,6 +450,7 @@ class MessageController extends Controller
$info->channels ='';
$info->channel_tpls = [];
$info->msg_type = '';
$info->creater = '';
}
//消息类型枚举
......@@ -450,6 +471,10 @@ class MessageController extends Controller
'isContainSMS'=>$isContainSMS,
'isContainEmail'=>$isContainEmail,
'isContainWechatNotify'=>$isContainWechatNotify,
'inner_chn_tpl_id'=>$inner_chn_tpl_id,
'sms_chn_tpl_id'=>$sms_chn_tpl_id,
'email_chn_tpl_id'=>$email_chn_tpl_id,
'wechatNotify_chn_tpl_id'=>$wechatNotify_chn_tpl_id,
];
return view($viewid, $data);
......
......@@ -83,31 +83,46 @@ $('#msg_tpl_submit').click(function()
}
}
// addTemplate();
addTemplate();
})
function addTemplate()
{
var ue_inner = UE.getEditor('inner-tpl-content');
var ue_email = UE.getEditor('email-tpl-content');
$.ajax({
type: 'post',
url: '/msgapi/addTemplate',
timeout : 10000, //超时时间设置,单位毫秒
data: {
tpl_id:$('#spu_id').val(),
channels:$('#class_id1').val(),
msg_type:$('#class_id2').val(),
source_type:$('#class_id3').val(),
creater:$('#brand_id').val(),
obj_user:$('#spu_name').val(),
description:$("input[name='status']:checked").val(),
channel_tpl_id:$('#images_l').val(),
channel_type:$('#images_s').val(),
title:$('#encap').val(),
content:$('#pdf').val(),
op_type:$('#spu_brief').val(),
url:$("input[name='has_rohs']:checked").val(),
tpl_id:$('#tpl-id').val(),
channels:getChosenMsgChannels(),
msg_type:$('#inner-tpl-type option:selected').val(),
source_type:1,
creater:$('#creater').val(),
description:$('#msg-tpl-desc').val(),
inner_channel_tpl_id:$('#inner-chn-tpl-id').val(),
inner_channel_type:1,
inner_title:$('#inner-tpl-title').val(),
inner_content:ue_inner.getContent(),
op_type:$("input[name='inner-tpl-op']:checked").val(),
url:$('#inner-tpl-op-url-text').val(),
sms_channel_tpl_id:$('#sms-chn-tpl-id').val(),
sms_channel_type:2,
sms_content:$('#sms-tpl-content').val(),
email_channel_tpl_id:$('#email-chn-tpl-id').val(),
email_channel_type:3,
email_title:$('#email-tpl-title').val(),
email_content:ue_email.getContent(),
wechat_notify_tpl_id:$('#wechatnotify-chn-tpl-id').val(),
wechat_notify_channel_type:4,
wechat_notify_title:$('#wechat-notify_tpl_title').val(),//存放的是微信模板的id
},
dataType: 'json',
success: function(resp){
......
......@@ -77,8 +77,8 @@ $('#msg_tpl_submit').click(function()
Prompt('请填写邮件标题', 5);
return false;
}
var ue = UE.getEditor('email-tpl-content');
if(!ue.getContent())
var uee = UE.getEditor('email-tpl-content');
if(!uee.getContent())
{
Prompt('请填写邮件内容', 5);
return false;
......
......@@ -104,6 +104,9 @@
{{--外部统一模板描述+消息渠道提示--}}
<div style="margin-left: 40px;">
{{--模板iD和创建人--}}
<input id="tpl-id" type="hidden" value="{{ $info->tpl_id }}">
<input id="creater" type="hidden" value="{{ $info->creater }}">
<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-4">
......@@ -161,7 +164,7 @@
<div class="tab-content tabs">
{{--站内信--}}
<div role="tabpanel" class="tab-pane fade in active" id="innner">
<input type="hidden" id="inner-chn-tpl-id" value="{{ $inner_chn_tpl_id }}">
<div class="col-sm-10 form-inline" style="margin-top: 40px">
<label class="col-sm-2 control-label"><span style="color: red">*</span> 站内信类型:</label>
<div class="col-sm-3">
......@@ -182,7 +185,7 @@
<div class="col-sm-10" style="margin-top: 20px">
<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/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>
......@@ -199,6 +202,7 @@
{{--短信--}}
<div role="tabpanel" class="tab-pane fade" id="sms">
<input type="hidden" id="sms-chn-tpl-id" value="{{ $sms_chn_tpl_id }}">
<div class="col-sm-10" style="margin-top: 40px">
<label class="col-sm-2 control-label"><span style="color: red">*</span> 短信内容:</label>
<div class="col-sm-10">
......@@ -210,6 +214,7 @@
{{--邮件--}}
<div role="tabpanel" class="tab-pane fade" id="email">
<input type="hidden" id="email-chn-tpl-id" value="{{ $email_chn_tpl_id }}">
<div class="col-sm-10 form-inline" style="margin-top: 40px">
<label class="col-sm-2 control-label"><span style="color: red">*</span> 邮件标题:</label>
<div class="col-sm-3">
......@@ -219,13 +224,14 @@
<div class="col-sm-10" style="margin-top: 20px">
<label><span style="color: red">*</span>邮件内容:</label>
<script type="text/plain" id="email-tpl-content" name="email-tpl-content">@if(!empty($info->channel_tpls['3']->content)) {{ $info->channel_tpls['3']->content }} @endif</script>
<script type="text/plain" id="email-tpl-content" name="email-tpl-content">@if(!empty($info->channel_tpls['3']->content)) {!! $info->channel_tpls['3']->content !!} @endif</script>
<script type="text/javascript">UE.getEditor('email-tpl-content');</script>
</div>
</div>
{{--微信通知--}}
<div role="tabpanel" class="tab-pane fade" id="wechat-notify">
<input type="hidden" id="wechatnotify-chn-tpl-id" value="{{ $wechatNotify_chn_tpl_id }}">
<div class="col-sm-10 form-inline" style="margin-top: 40px">
<label class="col-sm-2 control-label"><span style="color: red">*</span> 微信模板:</label>
<div class="col-sm-3">
......
......@@ -196,7 +196,7 @@
<div class="col-sm-10" style="margin-top: 20px">
<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/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>
......@@ -233,7 +233,7 @@
<div class="col-sm-10" style="margin-top: 20px">
<label><span style="color: red">*</span>邮件内容:</label>
<script type="text/plain" id="email-tpl-content" name="email-tpl-content">@if(!empty($info->channel_tpls['3']->content)) {{ $info->channel_tpls['3']->content }} @endif</script>
<script type="text/plain" id="email-tpl-content" name="email-tpl-content">@if(!empty($info->channel_tpls['3']->content)) {!! $info->channel_tpls['3']->content !!} @endif</script>
<script type="text/javascript">UE.getEditor('email-tpl-content');</script>
</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