uni-push2.0推送

207 阅读1分钟

这个网址是微信小程序的使用地图的 网址:ext.dcloud.net.cn/plugin?id=1…

在APP.vue里面 在onLaunch() { //绑定全局方法 uni.on(getPushClientId,this.getPushClientId);uni.on('getPushClientId', this.getPushClientId); uni.on('setCalllPushBackFun', this.setCalllPushBackFun); } // 客户端启用uni-push2.0 推送 getPushClientId() { uni.getPushClientId({ success(res) { this.push_clientid = res.cid console.log(this.push_clientid, '测试出来的用的ID')

					uni.setStorage({
						key: 'jyJPushUuid',
						data: this.push_clientid
					});
				},
				fail(err) {
					console.log(err)
				}
			});
		},
                    
                    
		// 绑定回调方法 (uni-pushu 和激光的推送的)
		setCalllPushBackFun() {
			let that = this
			uni.getStorage({
				key: 'jyJPushUuid',
				success: function(res) {
					let getpushId = res.data;

					that.util
						.request({
							url: that.api.registrationId,
							method: 'POST',
							data: {
								registrationId: getpushId
							}
						})
						.then(res => {
							console.log(res, '后端的接口')
						});

				}
			});


			let callback = (res) => {
				console.log(res, '你回掉了eeeeee吗?密密麻麻吗吗在这里33写判断')
				this.getNewOrderInfo()
			}
			//启动推送事件监听
			uni.onPushMessage(callback);

		},    
                    

// 在 是否登录里面调用 // 是否登录 IsLogin() { // #ifdef MP-WEIXIN this.setAccount({ isDev: this.globalData.siteInfo.isDev, domainUrl: this.globalData.siteInfo.siteroot.replace('https://', '') }); // #endif uni.getStorage({ key: 'account', complete: res => { console.log(res) if (res.data) { if (!res.data.userId) { var loginUrl = '/yb_shd/my/login' uni.reLaunch({ url: loginUrl }); } else { this.setCalllPushBackFun(); // #ifdef APP-PLUS // 激光绑定回调函数 // this.setCalllBackFun(); //#endif // #ifndef APP-PLUS this.openLoactionUpdate() // #endif } // 获取订单设置 if (res.data.domainUrl) { this.getOrderConfigInfo(); this.getSystem(); this.getbusiinfo() } } else { var loginUrl = '/yb_shd/my/login' uni.reLaunch({ url: loginUrl }); } // #ifndef H5 || MP-WEIXIN setTimeout(() => { plus.navigator.closeSplashscreen(); }, 2500); //#endif } }); },