Authored by xiaofeng.yao@yoho.cn

合并

... ... @@ -9,141 +9,141 @@ $this->title = $this->params['main_title'].'-'.$this->params['sub_title'];
$this->registerJsFile('/js/php.js',array('postion'=>View::POS_END));
?>
<script type="text/javascript">
<?php $this->beginBlock('javascript');?>
var i = 0;
var room_id = <?=$room->room_id?>;
var interval_handle;
var default_interval = 3;
/**
* websocket推送指令
* @returns {undefined}
*/
function callWebsocket(callback){
if (!window.ws || window.ws.readyState === undefined || window.ws.readyState != 1) {
websocket('192.168.102.17',9501,'/',function(){
consoleLog('连接服务器');
callback();
},function(evt){
consoleLog('收到消息: '+evt.data);
data = JSON.parse(evt.data);
if (data.status == 1){
consoleLog('请求推送成功');
}else{
consoleLog('请求推送失败');
}
},function(){
consoleLog('连接已关闭');
},function(){
consoleLog('有错误出现');
});
}else{
<?php $this->beginBlock('javascript');?>
var i = 0;
var room_id = <?=$room->room_id?>;
var interval_handle;
var default_interval = 3;
/**
* websocket推送指令
* @returns {undefined}
*/
function callWebsocket(callback){
if (!window.ws || window.ws.readyState === undefined || window.ws.readyState != 1) {
websocket('192.168.102.17',9501,'/',function(){
consoleLog('连接服务器');
callback();
}
}
/**
* 推送商品列表刷新指令
* @param {type} product_id
* @returns {undefined}
*/
function refreshProduct(){
if (!confirm('将推送商品列表刷新指令,确定?')){
return;
}
callWebsocket(function(){
consoleLog('');
consoleLog('发起推送商品列表刷新指令');
cmd = {cmd:10002,room:room_id,msg:'',refresh:'Y'};
cmd['secret'] = makeSign(cmd);
delete(cmd['private_key']);
cmd = JSON.stringify(cmd);
consoleLog('发送消息: '+cmd);
ws.send(cmd);
getPushlog(default_interval);
},function(evt){
consoleLog('收到消息: '+evt.data);
data = JSON.parse(evt.data);
if (data.status == 1){
consoleLog('请求推送成功');
}else{
consoleLog('请求推送失败');
}
},function(){
consoleLog('连接已关闭');
},function(){
consoleLog('有错误出现');
});
}else{
callback();
}
/**
* 推送商品
* @param {type} product_id
* @returns {undefined}
*/
function sendProduct(product_id){
if (!confirm('将推送该商品,确定?')){
return;
}
i++;
if (i>5){
$('#runtime').html('');
i = 1;
}
callWebsocket(function(){
consoleLog('');
consoleLog('发起推送,商品ID: '+product_id);
cmd = {cmd:10001,room:room_id,skn:product_id};
cmd['secret'] = makeSign(cmd);
delete(cmd['private_key']);
cmd = JSON.stringify(cmd);
consoleLog('发送消息: '+cmd);
ws.send(cmd);
getPushlog(default_interval);
});
}
/**
* 推送商品列表刷新指令
* @param {type} product_id
* @returns {undefined}
*/
function refreshProduct(){
if (!confirm('将推送商品列表刷新指令,确定?')){
return;
}
/**
* 监听推送记录
* @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+')');
}
callWebsocket(function(){
consoleLog('');
consoleLog('发起推送商品列表刷新指令');
cmd = {cmd:10002,room:room_id,msg:'',refresh:'Y'};
cmd['secret'] = makeSign(cmd);
delete(cmd['private_key']);
cmd = JSON.stringify(cmd);
consoleLog('发送消息: '+cmd);
ws.send(cmd);
getPushlog(default_interval);
});
}
/**
* 推送商品
* @param {type} product_id
* @returns {undefined}
*/
function sendProduct(product_id){
if (!confirm('将推送该商品,确定?')){
return;
}
/**
* 页面打印发送记录
* @param {type} msg
* @returns {undefined}
*/
function consoleLog(msg){
$('#runtime').append('&nbsp;'+msg+'<br />');
i++;
if (i>5){
$('#runtime').html('');
i = 1;
}
callWebsocket(function(){
consoleLog('');
consoleLog('发起推送,商品ID: '+product_id);
cmd = {cmd:10001,room:room_id,skn:product_id};
cmd['secret'] = makeSign(cmd);
delete(cmd['private_key']);
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+')');
}
/**
* 密钥生成
* @param {type} package
* @returns {unresolved}
*/
function makeSign(package){
package['private_key'] = 'a85bb0674e08986c6b115d5e3a4884fa';
package = ksort(package);
packageList = [];
for (key in package){
packageList.push(trim(key + '=' + package[key]));
}
return strtolower(md5(implode('&', packageList)));
}
/**
* 页面打印发送记录
* @param {type} msg
* @returns {undefined}
*/
function consoleLog(msg){
$('#runtime').append('&nbsp;'+msg+'<br />');
}
/**
* 密钥生成
* @param {type} package
* @returns {unresolved}
*/
function makeSign(package){
package['private_key'] = 'a85bb0674e08986c6b115d5e3a4884fa';
package = ksort(package);
packageList = [];
for (key in package){
packageList.push(trim(key + '=' + package[key]));
}
<?php
$this->endBlock();
$this->registerJs($this->blocks['javascript'],View::POS_END)
?>
return strtolower(md5(implode('&', packageList)));
}
<?php
$this->endBlock();
$this->registerJs($this->blocks['javascript'],View::POS_END)
?>
</script>
<div class="panel">
... ... @@ -163,17 +163,17 @@ $this->registerJsFile('/js/php.js',array('postion'=>View::POS_END));
<div class="table-responsive">
<table class="table mb30">
<thead>
<tr style="white-space:nowrap">
<th><input type="checkbox" onclick="checkall(this)">选择</th>
<th>商品ID</th>
<th>商品名称</th>
<th>商品销售价</th>
<th>排序</th>
<th>操作</th>
</tr>
<tr style="white-space:nowrap">
<th><input type="checkbox" onclick="checkall(this)">选择</th>
<th>商品ID</th>
<th>商品名称</th>
<th>商品销售价</th>
<th>排序</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<?php foreach ($list as $model):?>
<?php foreach ($list as $model):?>
<tr data-stock="1" data-source="1" data-status="2" data-id="5011880">
<td><input type="checkbox" value="<?=$model->id?>" name="product[]"></td>
<td><?=$model->product_id?></td>
... ... @@ -181,16 +181,16 @@ $this->registerJsFile('/js/php.js',array('postion'=>View::POS_END));
<th><?=$model->sales_price?></th>
<td><?=$model->sort?></td>
<td>
<a href="/product/edit/<?=$model->id?>" class="btn btn-default btn-white">编辑</a>
<a onclick="return confirm('删除该商品?')" href="/product/operate/<?=$model->id?>?type=del" class="btn btn-danger btn-metro">删除</a>
<a onclick="sendProduct(<?=$model->product_id?>)" href="javascript:;" class="btn btn-danger btn-metro">弹框</a>
</td>
</tr>
<?php endforeach;?>
<?php endforeach;?>
</tbody>
</table>
</div>
... ...
... ... @@ -4,12 +4,12 @@ return [
'components' => [
'fileCache' => [
'class' => 'yii\caching\FileCache',
'keyPrefix' => 'YOHOLive',
'keyPrefix' => 'YOHOLive:',
],
'cache' => [
'class' => 'common\components\pagecache\Redis',
'redis' => 'redis',
'keyPrefix' => 'YOHOLive',
'keyPrefix' => 'YOHOLive:',
],
'redis' => [
'class' => 'common\components\caching\RedisCache',
... ...
... ... @@ -91,7 +91,7 @@ class LivingController extends BaseController
}else{
$keys = [];
foreach ($ret as $k=>$row){
$keys[] = sprintf("%s:online_nums_room_%s",Yii::$app->params['cache_prefix'],$row['room_id']);
$keys[] = sprintf("%sonline_nums_room_%s",Yii::$app->params['cache_prefix'],$row['room_id']);
}
$values = $keys ? call_user_func_array(array(Yii::$app->redisIm,'mget'), $keys) : [];
... ...