Merge remote-tracking branch 'remotes/origin/wpf' into old

This commit is contained in:
jia 2023-09-21 17:18:37 +08:00
commit c5749eacd9
4 changed files with 98 additions and 14 deletions

27
App.vue
View File

@ -10,7 +10,7 @@
// +----------------------------------------------------------------------
// #ifdef APP-PLUS
let jpushModule = uni.requireNativePlugin("JG-JPush");
const mp = uni.requireNativePlugin('uniMP');
import { initEvent } from "@/utils/uniMPevent.js";
// #endif
import {
checkLogin
@ -86,17 +86,24 @@
}
// #ifdef APP-PLUS
//uni
mp.onUniMPEventReceive(ret => {
console.log('小程序事件: ', ret);
if (ret.event == 'closeApp') {
mp.closeUniMP(ret.fromAppid, (ret) => {
console.log('closeUniMP: ' + JSON.stringify(ret));
});
}
});
//uniMP
initEvent();
// #endif
// uni.getLocation({
// type: 'gcj02',
// geocode: true,
// isHighAccuracy: true,
// // altitude: true,
// // accuracy: 'best',
// success: (res)=> {
// console.log(res);
// },
// fail(e) {
// console.log(e);
// }
// });
let that = this;
// #ifdef MP
if (HTTP_REQUEST_URL == '') {

View File

@ -95,8 +95,8 @@
"sdkConfigs" : {
"maps" : {
"amap" : {
"appkey_ios" : "048d9f3f323eea894b49c3a7edbc8d87",
"appkey_android" : "048d9f3f323eea894b49c3a7edbc8d87"
"appkey_ios" : "82af93ec51139c712c4118d84ba684ee",
"appkey_android" : "0799f37420c0784f1e6cba230a68bdb1"
}
},
"payment" : {
@ -113,8 +113,10 @@
}
},
"geolocation" : {
"system" : {
"__platform__" : [ "ios", "android" ]
"amap" : {
"__platform__" : [ "ios", "android" ],
"appkey_ios" : "82af93ec51139c712c4118d84ba684ee",
"appkey_android" : "0799f37420c0784f1e6cba230a68bdb1"
}
},
"oauth" : {},

54
utils/uniMPevent.js Normal file
View File

@ -0,0 +1,54 @@
const mp = uni.requireNativePlugin('uniMP');
import {
uniMPgetLocation,
test
} from "@/utils/uniMPfunction.js"
export const initEvent = () => {
mp.onUniMPEventReceive(async (ret) => {
console.log('小程序事件: ', ret);
if (ret.event == 'closeApp') {
mp.closeUniMP(ret.fromAppid, (ret) => {
console.log('closeUniMP: ' + JSON.stringify(ret));
});
}
if (ret.event == 'getLocation') {
try {
console.log('获取定位');
let res = await uniMPgetLocation();
console.log(res);
// plus.geolocation.getCurrentPosition(function(position) {
// console.log('经度:' + position.coords.longitude);
// console.log('纬度:' + position.coords.latitude);
// // that.markers[1].latitude = position.coords.longitude;
// // that.markers[1].longitude = position.coords.longitude;
// mp.sendUniMPEvent(
// ret.fromAppid,
// 'getLocation', {...position.coords},
// (ret) => {
// console.log('Host sendEvent: ' + JSON.stringify(ret));
// });
// }, function(error) {
// console.error('获取位置失败:', error.message);
// }, {provider:'gps'});
mp.sendUniMPEvent(
ret.fromAppid,
'getLocation', {...res},
(ret) => {
console.log('Host sendEvent: ' + JSON.stringify(ret));
});
} catch (e) {
console.log(e);
}
}
if (ret.event == 'test') {
console.log('测试');
mp.sendUniMPEvent(
ret.fromAppid,
'test', { 'key': 'value', 'name': 'data' },
(ret) => {
console.log('Host sendEvent: ' + JSON.stringify(ret));
});
}
});
}

21
utils/uniMPfunction.js Normal file
View File

@ -0,0 +1,21 @@
export const test = () => {
return '测试'
}
export const uniMPgetLocation = () => {
return new Promise((resolve, reject) => {
uni.getLocation({
type: 'gcj02',
geocode: true,
isHighAccuracy: true,
// altitude: true,
// accuracy: 'best',
success: (res) => {
resolve(res)
},
fail(e) {
resolve(e)
}
});
})
}