Authored by wuxiao

登录失败提示

推送商品列表刷新指令
... ... @@ -15,7 +15,7 @@ class AjaxController extends BaseController
*/
public function actionPushgoodslog()
{
$log = Yii::$app->redisIm->rpop(Yii::$app->params['cache_prefix'].'room/product/pushlog');
$log = Yii::$app->redisIm->rpop(Yii::$app->params['cache_prefix'].'push_goods_log');
$this->renderJson(Yii::$app->params['success_code'],'',(string)$log);
}
}
... ...
... ... @@ -78,13 +78,17 @@ class SiteController extends BaseController
}
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
return $this->goBack();
} else {
return $this->render('login', [
'model' => $model,
]);
if (Yii::$app->request->isPost){
if ($model->load(Yii::$app->request->post()) && $model->login()) {
return $this->goBack();
} else {
$this->setParam('logon', false);
}
}
return $this->render('login', [
'model' => $model,
]);
}
/**
... ...
... ... @@ -58,8 +58,8 @@ $this->title = $this->params['main_title'].'-'.$this->params['sub_title'];
<td><?=Yii::$app->params['config']['vest'][$model->vest]?></td>
<td><?=Yii::$app->params['config']['room_living'][$model->living]?></td>
<td>
真实:<?=$model->roomNums->online_num ? :0?>,
马甲:<?=$model->roomNums->vest_online_num ? :0?>
真实:<?=@$model->roomNums->online_num ? :0?>,
马甲:<?=@$model->roomNums->vest_online_num ? :0?>
</td>
<td>
... ...
... ... @@ -15,27 +15,15 @@ var room_id = <?=$room->room_id?>;
var interval_handle;
var default_interval = 3;
/**
* 推送商品
* @param {type} product_id
* websocket推送指令
* @returns {undefined}
*/
function sendProduct(product_id){
if (!confirm('将推送该商品,确定?')){
return;
}
i++;
if (i>5){
$('#runtime').html('');
i = 1;
}
consoleLog('');
function callWebsocket(callback){
if (!window.ws || window.ws.readyState === undefined || window.ws.readyState != 1) {
websocket('192.168.102.17',9501,'/',function(){
consoleLog('连接服务器');
_sendProduct(product_id);
callback();
},function(evt){
consoleLog('收到消息: '+evt.data);
data = JSON.parse(evt.data);
... ... @@ -50,40 +38,85 @@ function sendProduct(product_id){
consoleLog('有错误出现');
});
}else{
_sendProduct(product_id);
callback();
}
}
/**
* 推送商品列表刷新指令
* @param {type} product_id
* @returns {undefined}
*/
function refreshProduct(){
if (!confirm('将推送商品列表刷新指令,确定?')){
return;
}
callWebsocket(function(){
consoleLog('');
consoleLog('发起推送商品列表刷新指令');
cmd = {cmd:18,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 _sendProduct(product_id){
consoleLog('发起推送,商品ID: '+product_id);
/**
* 推送商品
* @param {type} product_id
* @returns {undefined}
*/
function sendProduct(product_id){
if (!confirm('将推送该商品,确定?')){
return;
}
cmd = {cmd:10001,room:room_id,skn:product_id};
cmd['secret'] = makeSign(cmd);
delete(cmd['private_key']);
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);
});
cmd = JSON.stringify(cmd);
consoleLog('发送消息: '+cmd);
ws.send(cmd);
//ws.send('{"cmd":"10001","skn":"123","room":"3","secret":"72c1f9eb60b761d3078294e3e8318fc0"}');
//ws.close();
getPushlog(default_interval);
}
/**
*
* 监听推送记录
* @param {type} package
* @returns {unresolved}
*/
function getPushlog(interval){
clearInterval(interval_handle);
interval_handle = setInterval(function(){
$.get('/ajax/pushgoodslog','',function(json){
console.log(json);
if (json.data){
consoleLog('监听到推送记录: '+json.data);
}
},'json');
},interval*1000);
$('#pushlog').text('推送记录监听中...');
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+')');
}
}
/**
* 页面打印发送记录
... ... @@ -170,6 +203,7 @@ $this->registerJs($this->blocks['javascript'],View::POS_END)
<div class="form-group">
<label>
<button type="button" onclick="getPushlog(default_interval)" id="pushlog" class="btn btn-primary">开始监听推送记录</button>
<button type="button" onclick="refreshProduct()" class="btn btn-primary">推送商品列表刷新指令</button>
</label>
</div>
... ...
... ... @@ -15,8 +15,10 @@ $this->title = 'Login';
<img src="/images/logo-primary.png" alt="Chain Logo" >
</div>
<br />
<!--<h4 class="text-center mb5">Already a Member?</h4>-->
<p class="text-center">登录到你的账户</p>
<h4 class="text-center mb5">登录到你的账户</h4>
<?php if (isset($logon) && !$logon):?>
<p class="text-center" style="color:red">登录失败</p>
<?php endif;?>
<div class="mb30"></div>
... ...