🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# index.php页面内重点 ## 1、 获取支付状态:判断是否支付成功的状态status = success ~~~ <?php $status = ''; if (isset($_GET['status']) && !empty($_GET['status'])) { $status = $_GET['status']; } ?> ~~~ ## 2、页面实现websocket ~~~ var wsServer = 'ws://192.168.33.10:9504';//ip+端口 var websocket = new WebSocket(wsServer); websocket.onopen = function (client) { websocket.send("<?php echo $status?>");//向后端发送是否成功购买的状态 }; websocket.onmessage = function (client) { //接收后端发送过来的数据【已经被购买过数据】 if (client.data) { var data = JSON.parse(client.data); sc.get(data).status('unavailable'); } }; websocket.onclose = function (client) { //是否断开连接 console.log("Disconnected"); }; websocket.onerror = function (client, e) { //错误信息 console.log('Error occured: ' + client.data); }; ~~~