From 118a3a985bfb0c315ea52203629f22bc7fd1ded0 Mon Sep 17 00:00:00 2001 From: weipengfei <2187978347@qq.com> Date: Sat, 2 Sep 2023 12:07:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=B0=8F=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 15 +++++++++++++-- config/app.js | 4 ++-- utils/uniMP.js | 7 +++++-- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/App.vue b/App.vue index 98f50c4..05c6e1a 100644 --- a/App.vue +++ b/App.vue @@ -10,6 +10,7 @@ // +---------------------------------------------------------------------- // #ifdef APP-PLUS let jpushModule = uni.requireNativePlugin("JG-JPush"); + const mp = uni.requireNativePlugin('uniMP'); // #endif import { checkLogin @@ -74,7 +75,18 @@ }, onLaunch: function(option) { this.globalData.statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px'; - this.globalData.uid = this.$store.state.app.uid + this.globalData.uid = this.$store.state.app.uid; + + //监听uni小程序发送的事件 + mp.onUniMPEventReceive(ret=>{ + console.log('小程序事件: ', ret); + if(ret.event=='closeApp'){ + mp.closeUniMP(ret.fromAppid, (ret)=>{ + console.log('closeUniMP: '+JSON.stringify(ret)); + }); + } + }); + let that = this; // #ifdef MP if (HTTP_REQUEST_URL == '') { @@ -188,7 +200,6 @@ - }, onShow() { let that = this diff --git a/config/app.js b/config/app.js index d731782..d98a31e 100644 --- a/config/app.js +++ b/config/app.js @@ -9,8 +9,8 @@ let httpApiThree // 网络接口修改此字符 小程序域名要求https // let httpApi = 'http://192.168.31.110:8324' // 测试 if (process.env.NODE_ENV === "development") { - httpApi = 'https://shop.lihaink.cn' // 生产 - // httpApi = "https://crmeb-test.shop.lihaink.cn" + // httpApi = 'https://shop.lihaink.cn' // 生产 + httpApi = "https://crmeb-test.shop.lihaink.cn" // httpApi = "http://192.168.0.222" // httpApi = "http://192.168.0.108:8325" // httpApi = 'http://192.168.0.108:8325' diff --git a/utils/uniMP.js b/utils/uniMP.js index 36c9fb9..3b09d3e 100644 --- a/utils/uniMP.js +++ b/utils/uniMP.js @@ -33,7 +33,7 @@ const loadMP = async (id) => { // return ; mp.getUniMPVersion(id, (ret) => { console.log('当前版本', ret); - if (0!=ret.code||compareVersions(info.data.version, ret.versionInfo.name) == 1) { + if (0!=ret.code||compareVersions(info.data.version, ret.versionInfo.name) == 1||true) { uni.downloadFile({ url: info.data.version_info?.dow_url, success(res) { @@ -100,7 +100,10 @@ const doInstallMP = () => { const open = (id = null) => { mp.openUniMP({ - appid: id || appid + appid: id || appid, + extraData: { + uniMP: true + } }, (ret) => { uni.hideLoading(); if (0 != ret.code) {