|
|
<?php
|
|
|
use yii\web\View;
|
|
|
use yii\helpers\Html;
|
|
|
|
|
|
$this->title = $this->params['main_title'].'-'.$this->params['sub_title'];
|
|
|
?>
|
|
|
|
|
|
<?php echo $this->render('@app/views/layouts/websocket');?>
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
<?php $this->beginBlock('javascript');?>
|
|
|
var i = 0;
|
|
|
var room_id = <?=$room_id?>;
|
|
|
var interval_handle;
|
|
|
var default_interval = 3;
|
|
|
|
|
|
/**
|
|
|
* 推送优惠券刷新指令
|
|
|
* @returns {undefined}
|
|
|
*/
|
|
|
function refreshCoupon(){
|
|
|
if (!confirm('将推送商品列表刷新指令,确定?')){
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
callWebsocket(function(){
|
|
|
consoleLog('');
|
|
|
consoleLog('发起推送商品列表刷新指令');
|
|
|
|
|
|
cmd = {cmd:10003,room:room_id,msg:'',refresh:'Y'};
|
|
|
cmd = makeSign(cmd);
|
|
|
|
|
|
cmd = JSON.stringify(cmd);
|
|
|
consoleLog('发送消息: '+cmd);
|
|
|
ws.send(cmd);
|
|
|
getPushlog(default_interval);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 监听推送记录
|
|
|
* @param {type} package
|
|
|
* @returns {unresolved}
|
|
|
*/
|
|
|
function getPushlog(interval){
|
|
|
clearInterval(interval_handle);
|
|
|
|
|
|
if (interval){
|
|
|
interval_handle = setInterval(function(){
|
|
|
$.get('/ajax/pushgoodslog','',function(json){
|
|
|
console.log(json);
|
|
|
if (json.data){
|
|
|
consoleLog('监听到推送记录: '+json.data);
|
|
|
}
|
|
|
},'json');
|
|
|
},interval*1000);
|
|
|
$('#pushlog').text('推送记录监听中...再次点击停止').attr('onclick','getPushlog(false)');
|
|
|
}else{
|
|
|
$('#pushlog').text('开始监听推送记录').attr('onclick','getPushlog('+default_interval+')');
|
|
|
}
|
|
|
}
|
|
|
//预览优惠券元素
|
|
|
function preview() {
|
|
|
var code = $("input[name=code]").val();
|
|
|
var banner_txt = $("textarea[name=banner_txt]").val();
|
|
|
var find = /#code#/g;
|
|
|
var replace = "<b class='coupon-code'>["+code+"]</b>";
|
|
|
banner_txt = banner_txt.replace(find,replace);
|
|
|
|
|
|
var help_title = $("input[name=help_title]").val();
|
|
|
help_txt = $("textarea[name=help_txt]").val();
|
|
|
help_title = "<h4>"+help_title+"</h4>";
|
|
|
$("#coupon_preview").html(banner_txt+help_title+help_txt);
|
|
|
}
|
|
|
<?php
|
|
|
$this->endBlock();
|
|
|
$this->registerJs($this->blocks['javascript'],View::POS_END)
|
|
|
?>
|
|
|
</script>
|
|
|
<style>
|
|
|
.coupon-code {color: #fcc800}
|
|
|
</style>
|
|
|
<div class="row">
|
|
|
<div class="col-md-6">
|
|
|
<form id="form" method="POST" action="">
|
|
|
<input type="hidden" name="room_id" value="<?=$room_id?>">
|
|
|
<div class="panel panel-default">
|
|
|
<div class="panel-body">
|
|
|
<div class="row">
|
|
|
<div class="form-group">
|
|
|
<label class="col-sm-3 control-label">优惠码(金色字体): </label>
|
|
|
<div class="col-sm-5">
|
|
|
<input type="text" name="code" class="form-control" value="<?=$coupon->code?>">
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="form-group">
|
|
|
<label class="col-sm-3 control-label">固定显示内容: </label>
|
|
|
<div class="col-sm-9">
|
|
|
<textarea name="banner_txt" class="form-control" rows="10" cols="50"><?=$coupon->banner_txt?></textarea>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="form-group">
|
|
|
<label class="col-sm-3 control-label">帮助弹框-标题: </label>
|
|
|
<div class="col-sm-9">
|
|
|
<input type="text" name="help_title" class="form-control" value="<?=$coupon->help_title?>">
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="form-group">
|
|
|
<label class="col-sm-3 control-label">帮助弹框-内容: </label>
|
|
|
<div class="col-sm-9">
|
|
|
<textarea name="help_txt" class="form-control" rows="10" cols="50"><?=$coupon->help_txt?></textarea>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div><!-- row -->
|
|
|
</div><!-- panel-body -->
|
|
|
<div class="panel-footer">
|
|
|
<div class="row">
|
|
|
<div class="col-sm-9 col-sm-offset-3">
|
|
|
<button class="btn btn-primary mr5">保存</button>
|
|
|
<a href="<?=$_refer?>" class="btn btn-dark mr5">取消</a>
|
|
|
<a class="btn btn-dark" onclick="preview()">预览</a>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div><!-- panel-footer -->
|
|
|
</div><!-- panel -->
|
|
|
</form>
|
|
|
|
|
|
</div>
|
|
|
<div class="col-md-6">
|
|
|
<p>Notice:优惠码替换占位符用<code>#code#</code>,换行符用<code><br/></code></p>
|
|
|
<div class="panel panel-default">
|
|
|
<div class="panel-heading">
|
|
|
<h4>预览</h4>
|
|
|
</div>
|
|
|
<div class="panel-body">
|
|
|
<div id="coupon_preview">
|
|
|
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
<div class="form-group">
|
|
|
<label>
|
|
|
<button type="button" onclick="getPushlog(default_interval)" id="pushlog" class="btn btn-primary">开始监听推送记录</button>
|
|
|
</label>
|
|
|
<label>
|
|
|
<button type="button" onclick="refreshCoupon()" class="btn btn-primary">推送优惠码刷新指令</button>
|
|
|
</label>
|
|
|
</div>
|
|
|
|
|
|
<div class="form-group">
|
|
|
<div class="col-sm-6" id="wsRuntime">
|
|
|
</div>
|
|
|
</div> |
...
|
...
|
|