chenhaozhe
2026-01-19 da32252d08f2a52f1ddcdac62e11febb2be3f711
新增 个推 绑定用户设备码, 接受用户点击任务栏事件的功能
3个文件已修改
66 ■■■■ 已修改文件
App.vue 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/index/login.vue 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
utils/getuiUtils.js 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
App.vue
@@ -50,7 +50,7 @@
            // 监听通知点击事件(热启动:App 后台运行时点击通知)
            plus.push.addEventListener("click", (msg) => {
                let payload = {};
                console.log('payload: ', msg.payload);
                console.log('msg: ', msg);
                // 兼容不同格式的 payload(本地推送 vs 远程推送)
                if (typeof msg.payload === "string") {
                    payload = JSON.parse(msg.payload); // 远程推送可能是字符串,需解析
@@ -59,6 +59,15 @@
                }
                this.handlePushJump(payload); // 处理跳转
            });
            // 个推v1版本只能通过透传传参
            plus.push.addEventListener('receive', (msg) => {
                console.log('收到 V1 版本透传消息:', msg);
                // 仅透传模板需要(通知模板无需处理)
                if (msg.payload) {
                    this.handlePushJump(msg.payload);
                }
            }, false);
            // #endif
        },
        onShow: function() {
pages/index/login.vue
@@ -341,8 +341,7 @@
                                this.CommonUtils.setServerUrl(this.serverUrl)
                                // this.WebSocketServices.createConnect(res.data.data[0].Czybm,res.data.data[0].Czymc);
                                // getuiUtils.getClientID()
                                var clientInfo = plus.push.getClientInfo();
                                console.log('clientInfo: ', clientInfo);
                                getuiUtils.getClientID(res.data.data[0].Czybm,res.data.data[0].Czymc)
                                uni.reLaunch({
                                    url: '/pages/index/index'
                                })
utils/getuiUtils.js
@@ -1,16 +1,58 @@
import {
    CommonUtils
} from "./common";
class getuiInstance {
    constructor() {
        this.cid = ""
    }
    getClientID() {
    getClientID(Userbm, UserName) {
        // #ifdef APP-PLUS
        plus.push.getClientInfoAsync((info) => {
            this.cid = info["clientid"]
            console.log('cid: ', this.cid);
        });
        const info = plus.push.getClientInfo()
        this.cid = info["clientid"]
        console.log('cid: ', this.cid);
        this.setUserClientIDRelative(Userbm, UserName, this.cid, 1)
        // #endif
    };
    async setUserClientIDRelative(Userbm, UserName, ClientID, Online) {
        try {
            let res = await CommonUtils.doRequest2Async({
                url: "/Web/SetGy_UserClientIdConnection",
                method: "POST",
                data: {
                    HUserbm: Userbm,
                    HUserName: UserName,
                    HClientID: ClientID,
                    HOnline: Online
                }
            })
            let {
                data,
                count,
                Message
            } = res.data
            if(count != 1) {
                CommonUtils.showTips({
                    title: "温馨提示",
                    message: Message
                })
            }
        }catch(err) {
            CommonUtils.showTips({
                title: "温馨提示",
                message: err
            })
        }
    }
}
export default new getuiInstance()