新增 个推 绑定用户设备码, 接受用户点击任务栏事件的功能
| | |
| | | // 监听通知点击事件(热启动: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); // 远程推送可能是字符串,需解析 |
| | |
| | | } |
| | | this.handlePushJump(payload); // 处理跳转 |
| | | }); |
| | | |
| | | // 个推v1版本只能通过透传传参 |
| | | plus.push.addEventListener('receive', (msg) => { |
| | | console.log('收到 V1 版本透传消息:', msg); |
| | | // 仅透传模板需要(通知模板无需处理) |
| | | if (msg.payload) { |
| | | this.handlePushJump(msg.payload); |
| | | } |
| | | }, false); |
| | | // #endif |
| | | }, |
| | | onShow: function() { |
| | |
| | | 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' |
| | | }) |
| | |
| | | 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() |