186 lines
7.0 KiB
HTML
186 lines
7.0 KiB
HTML
{extend name="public/base" /}
|
|
{block name="body"}
|
|
<style>
|
|
.clinhei{width:100%;height:25px;}
|
|
.inp{width:200px;}
|
|
.inpdiv{width:25%;}
|
|
.inpdivbut{width:10%;float:left;}
|
|
.so{width:80px;height:34px;border:0;margin-top:25px;text-align:center;line-height:34px;cursor: pointer;}
|
|
.tdinp{width:100%;border:0;}
|
|
.up{border:0;cursor: pointer;}
|
|
</style>
|
|
|
|
<div class="main-box clearfix">
|
|
<header class="main-box-header clearfix">
|
|
<div class="pull-left">
|
|
<h2>继续阅读群发推送</h2>
|
|
</div>
|
|
|
|
</header>
|
|
<div class="main-box-body clearfix">
|
|
|
|
<div class="container">
|
|
<form id="forms" enctype="multipart/form-data">
|
|
|
|
<div class="inpdiv" style="width:800px;">
|
|
<label for="name" style="color: #e84e40;">测试ID 用于测试推送</label>
|
|
<input type="text" class="form-control inp" id="cid">
|
|
</div>
|
|
|
|
<div class="input-group" style="width:200px;margin-top: 20px;">
|
|
<input type="text" class="form-control inp" name="startdata" id="startdata" placeholder="推送时间">
|
|
<span class="input-group-addon"><i class="fa fa-th"></i></span>
|
|
</div>
|
|
|
|
<div class="inpdivbut">
|
|
<div class="btn-danger so" onclick="push()">开始推送</div>
|
|
</div>
|
|
|
|
<div class="inpdivbut">
|
|
<button class="btn btn-primary" type="button" style="margin-top: 25px;" onclick="timepush()">定时推送</button>
|
|
</div>
|
|
</form>
|
|
|
|
</div>
|
|
<div class="clinhei"></div>
|
|
<div id="showweb" style="display: none;">
|
|
<p class="text-warning">记录实时展示 忽略刷新即可 或 跳转页面 发送成功共:<font style="color:seagreen" id="iok"></font> 人 发送失败共:<font style="color: red;" id="ino"></font> 人</p>
|
|
<div id="weblist"></div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
{/block}
|
|
{block name="script"}
|
|
<!-- datepicker statr -->
|
|
<link href="/public/plugs/datepicker/css/foundation-datepicker.min.css" rel="stylesheet" type="text/css">
|
|
<script src="/public/plugs/datepicker/js/foundation-datepicker.js"></script>
|
|
<script src="/public/plugs/datepicker/js/foundation-datepicker.zh-CN.js"></script>
|
|
<script>
|
|
// 时间选择器
|
|
$('#startdata').fdatepicker({
|
|
clearBtn: true,
|
|
todayBtn: true,
|
|
format: 'yyyy-mm-dd h:i',
|
|
pickTime: true
|
|
});
|
|
|
|
// 推送
|
|
function push(){
|
|
var cid = $('#cid').val();
|
|
if(cid==''){
|
|
// 群发推送
|
|
swal({
|
|
title: '确定群发推送?',
|
|
text: "请不要频繁推送 对服务器消耗是巨大的 频繁推送会导致微信封禁",
|
|
type: 'warning',
|
|
buttons:{
|
|
confirm: {
|
|
text : '确认群发',
|
|
className : 'btn btn-success'
|
|
},
|
|
cancel: {
|
|
text : '关闭',
|
|
visible: true,
|
|
className: 'btn btn-danger'
|
|
}
|
|
}
|
|
}).then((Delete) => {
|
|
if (Delete) {
|
|
// 群发
|
|
var ws = new WebSocket("ws://47.96.109.168:9503");
|
|
ws.onopen = function () {
|
|
console.log("连接成功");
|
|
var from={"type":"all"}
|
|
ws.send(JSON.stringify(from));//发送参数
|
|
};
|
|
ws.onmessage = function (evt) {
|
|
var data = JSON.parse(evt.data);
|
|
$('#showweb').show();
|
|
$("#weblist").prepend('<p class="text-success">'+data.text+'</p>');
|
|
$('#iok').text(data.ok);
|
|
$('#ino').text(data.no);
|
|
};
|
|
ws.onclose = function (evt) {
|
|
swal('错误','socket服务已关闭', {icon : "error",buttons:{confirm:{className : 'btn btn-danger'}},});
|
|
};
|
|
} else {
|
|
swal.close();
|
|
}
|
|
});
|
|
}else{
|
|
// 单个测试推送
|
|
var ws = new WebSocket("ws://47.96.109.168:9503");
|
|
ws.onopen = function () {
|
|
console.log("连接成功");
|
|
var from={"uid":cid,"type":"one"}
|
|
ws.send(JSON.stringify(from));//发送参数
|
|
};
|
|
ws.onmessage = function (evt) {
|
|
var data = JSON.parse(evt.data);
|
|
if(data){
|
|
$('#showweb').show();
|
|
$("#weblist").prepend('<p class="text-success">'+data.text+'</p>')
|
|
}
|
|
};
|
|
ws.onclose = function (evt) {
|
|
swal('错误','socket服务已关闭', {icon : "error",buttons:{confirm:{className : 'btn btn-danger'}},});
|
|
};
|
|
}
|
|
}
|
|
|
|
// 定时推送
|
|
function timepush(){
|
|
var t = $('#startdata').val();
|
|
if(t==''){
|
|
swal('错误','时间不能为空', {icon : "error",buttons:{confirm:{className : 'btn btn-danger'}},});
|
|
}else{
|
|
var oldTime = (new Date(t)).getTime()/1000;
|
|
swal({
|
|
title: '确定定时推送?',
|
|
text: "请不要频繁推送 对服务器消耗是巨大的 频繁推送会导致微信封禁",
|
|
type: 'warning',
|
|
buttons:{
|
|
confirm: {
|
|
text : '确认',
|
|
className : 'btn btn-success'
|
|
},
|
|
cancel: {
|
|
text : '关闭',
|
|
visible: true,
|
|
className: 'btn btn-danger'
|
|
}
|
|
}
|
|
}).then((Delete) => {
|
|
if (Delete) {
|
|
// 定时群发
|
|
var ws = new WebSocket("ws://47.96.109.168:9503");
|
|
ws.onopen = function () {
|
|
console.log("连接成功");
|
|
var from={"type":"timing","tasktime":oldTime}
|
|
ws.send(JSON.stringify(from));//发送参数
|
|
};
|
|
ws.onmessage = function (evt) {
|
|
var data = JSON.parse(evt.data);
|
|
if(data.status==1){
|
|
swal('成功',data.reg, {icon : "success",buttons:{confirm:{className : 'btn btn-success'}},});
|
|
}else{
|
|
swal('错误',data.reg, {icon : "error",buttons:{confirm:{className : 'btn btn-danger'}},});
|
|
}
|
|
};
|
|
ws.onclose = function (evt) {
|
|
swal('错误','socket服务已关闭', {icon : "error",buttons:{confirm:{className : 'btn btn-danger'}},});
|
|
};
|
|
} else {
|
|
swal.close();
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
{/block}
|