php后台+微信小程序 列表页面
//php查询数据
static public function selfs($id){
return self::where(\'id\',$id)->first();
}
//内置验证
$this->validate(request(),[
\'username\'=>\'required\',
\'pwd\'=>\'required\'
],[
\'username.min\'=>\'名称过短\'
]);
//登录
$info=Db::table(\'user\')->where(\'username\',$data[\'username\'])->where(\'pwd\',$data[\'pwd\'])->get()->Toarray();
//swoole
<!DOCTYPE html>
<html lang=”en”>
<head>
<meta charset=”UTF-8″>
<title>Title</title>
</head>
<body>
<div style=”display: block” id=”data1″>
<input type=”text” id=”a”>
<button type=”button” onclick=”datas()”>设置姓名</button>
</div>
<div style=”display: none” id=”data2″>
<input type=”text” id=”img”>
<button type=”button” onclick=”datas1()”>发送信息</button>
</div>
<div style=”display: none”>
<input type=”text”>
</div>
<div style=”display:block”>
<div id=”b”></div>
</div>
</body>
</html>
<script src=”https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js”>
</script>
<script>
var wsServer = \’ws://121.4.180.50:9501\’;
var websocket = new WebSocket(wsServer);
websocket.onopen = function (evt) {
console.log(“已连接”)
};
websocket.onclose = function (evt) {
console.log(“Disconnected”);
};
websocket.onmessage = function (evt) {
console.log(“已发送”)
console.log(evt.data);
$(“#b”).append(“<div>”+evt.data+”</div>”)
};
websocket.onerror = function (evt, e) {
console.log(\’Error occured: \’ + evt.data);
};
function datas() {
var name=$(“#a”).val();
if (name=!””){
$(“#data1”).prop(“style”,”display:none”);
$(“#data2”).prop(“style”,”display:block”);
}
}
function datas1() {
var datad=”name”+”:”+$(“#a”).val()+”,”+”img”+”:”+$(“#img”).val();
// console.log(data);
websocket.send(datad);
}
</script>
//js