rt_dream01

10.15
当出入金值发生变化时给全局添加声音
cs界面
//在数据库中取出最后一个出入金的值
public partial class api_info_check_new_cashrecord : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Ari.Fi.CashRecord[] rows = Ari.Fi.CashRecord.LoadAll("TOP 1", "ORDER BY ID DESC");

if (rows.Length > 0)
{
top_cashrecord_id = rows[0].ID;
}
}
}
aspx界面
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="check-new-cashrecord.aspx.cs" Inherits="api_info_check_new_cashrecord" %>
<%= top_cashrecord_id %>
//查看最后一个出入金id是否变换,如果改变了就发出声音
+ <audio src="/ui/4082.wav" preload id="new-cashrecord-alert"></audio>

<% if (Ari.Sys.StaffRole.CheckPoint(this.sessionuser, Protocol.Auth.Privilege.Enums.Fi_Cash_WithdrawApprove)) { %>
setInterval(function () {
$.get(‘/api/info/check-new-cashrecord‘, function (data) {
+ var top_cashrecord_id = data.trim();
+ var local_id = localStorage.getItem("top_cashrecord_id");
+
+ if (!local_id)//false,local_id为string,加“!”后变为false
+ localStorage.setItem("top_cashrecord_id", top_cashrecord_id);
+ else
+ if (local_id != top_cashrecord_id){
+ $(‘#new-cashrecord-alert‘)[0].play();
+ localStorage.setItem("top_cashrecord_id", top_cashrecord_id);
+ }
});
}, 5000);
<% } %>
1
localStorage.setItem("top_cashrecord_id", top_cashrecord_id)//设置top_cashrecord_id的值
localStorage.getItem("top_cashrecord_id")//获取top_cashrecord_id的值
以键值对的方式存储,存储的类型为string类型
2
localStorage - 没有时间限制的数据存储
sessionStorage - 针对一个 session 的数据存储

时间: 2024-10-13 01:04:56

rt_dream01的相关文章