Merge remote-tracking branch 'remotes/origin/wpf' into old
This commit is contained in:
commit
c5749eacd9
27
App.vue
27
App.vue
@ -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 == '') {
|
||||
|
@ -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
54
utils/uniMPevent.js
Normal 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
21
utils/uniMPfunction.js
Normal 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)
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user