...
|
...
|
@@ -5,48 +5,18 @@ use backend\widgets\LinkPager; |
|
|
|
|
|
$this->title = $this->params['main_title'].'-'.$this->params['sub_title'];
|
|
|
?>
|
|
|
<?php
|
|
|
$this->registerJsFile('/js/php.js',array('postion'=>View::POS_END));
|
|
|
?>
|
|
|
|
|
|
<?php echo $this->render('@app/views/layouts/websocket');?>
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
<?php $this->beginBlock('javascript');?>
|
|
|
var socket_arr = '<?=$wsAddr?>'.split(":");
|
|
|
var wsAddr = socket_arr[0];
|
|
|
var port = socket_arr[1];
|
|
|
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(wsAddr,port,'/',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{
|
|
|
callback();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 推送商品列表刷新指令
|
|
|
* @param {type} product_id
|
|
|
* @returns {undefined}
|
|
|
*/
|
|
|
function refreshProduct(){
|
...
|
...
|
@@ -121,31 +91,6 @@ function getPushlog(interval){ |
|
|
$('#pushlog').text('开始监听推送记录').attr('onclick','getPushlog('+default_interval+')');
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
* 页面打印发送记录
|
|
|
* @param {type} msg
|
|
|
* @returns {undefined}
|
|
|
*/
|
|
|
function consoleLog(msg){
|
|
|
if (msg){
|
|
|
console.log(msg);
|
|
|
}
|
|
|
$('#runtime').append(' '+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]));
|
|
|
}
|
|
|
return strtolower(md5(implode('&', packageList)));
|
|
|
}
|
|
|
<?php
|
|
|
$this->endBlock();
|
|
|
$this->registerJs($this->blocks['javascript'],View::POS_END)
|
...
|
...
|
@@ -214,6 +159,6 @@ $this->registerJs($this->blocks['javascript'],View::POS_END) |
|
|
</div>
|
|
|
|
|
|
<div class="form-group">
|
|
|
<div class="col-sm-6" id="runtime">
|
|
|
<div class="col-sm-6" id="wsRuntime">
|
|
|
</div>
|
|
|
</div><!-- form-group --> |
|
|
\ No newline at end of file |
...
|
...
|
|