You need to sign in or sign up before continuing.
提交 d35446c5 编写于 作者: Q qiang

Merge branch 'dev' into alpha

...@@ -36,7 +36,7 @@ module.exports = { ...@@ -36,7 +36,7 @@ module.exports = {
copyOptions.push(path.resolve(__dirname, '../dist/view.css')) copyOptions.push(path.resolve(__dirname, '../dist/view.css'))
copyOptions.push(path.resolve(__dirname, '../dist/view.umd.min.js')) copyOptions.push(path.resolve(__dirname, '../dist/view.umd.min.js'))
// TODO 后续common与v3目录应该合并 // TODO 后续common与v3目录应该合并
copyOptions.push(path.resolve(__dirname, '../template/common')) copyOptions.push(path.resolve(__dirname, process.env.UNI_USING_NVUE_COMPILER ? '../template/common' : '../template/weex'))
copyOptions.push(path.resolve(__dirname, '../template/v3')) copyOptions.push(path.resolve(__dirname, '../template/v3'))
} }
return copyOptions return copyOptions
...@@ -56,4 +56,4 @@ module.exports = { ...@@ -56,4 +56,4 @@ module.exports = {
devtool devtool
} }
} }
} }
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<script>
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)'))
document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')
</script>
<title></title>
<style>
html,
body,
.container {
margin: 0;
padding: 0;
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
background: #ffffff;
}
#map {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 80px;
bottom: calc(80px + constant(safe-area-inset-bottom));
bottom: calc(80px + env(safe-area-inset-bottom));
}
#poi {
position: absolute;
left: 0;
right: 0;
bottom: 0;
bottom: constant(safe-area-inset-bottom);
bottom: env(safe-area-inset-bottom);
height: 80px;
background: #FFFFFF;
}
.poi-info {
width: 100%;
padding: 23px 16px 23px 18px;
box-sizing: border-box;
background: #FFFFFF;
}
.poi-name {
font-size: 17px;
line-height: 17px;
color: #111111;
display: block;
margin-right: 70px;
word-wrap: break-word;
}
.poi-addr {
font-size: 13px;
line-height: 13px;
color: #666666;
display: block;
margin-top: 4px;
margin-right: 70px;
word-wrap: break-word;
}
.poi-nav {
display: block;
position: absolute;
top: 10px;
right: 16px;
width: 60px;
height: 60px;
border-radius: 60px;
overflow: hidden;
}
.poi-nav i,
.poi-nav span {
position: absolute;
top: 0;
width: 100%;
height: 100%;
display: inline-block;
border-radius: 60px;
}
.poi-nav i {
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAACnVBMVEUAAAA9avA+avA9avA/bPE8afA+avM9afA9avA9au9Ac/I+bPQ9avA8a/E8au8+avY9avA9avBAgP88avA9au9AbfFAgP89avA9avBJbf89au88afA8ae88afA8ae9AbO88afA/avE9ae88avBHcfFCcfY+a/H///89afE8afA8avA9afA8afA9a/E9afA9avA8avA8avA9ae////88ae8/a+/+/v77/P5Cbu9jh/I9au9Te/CIo/XY4fuasfbH1PpJc/Dl6/xHce9Cbe9Eb+9FcO/3+f5SevC0xfjh6PygtvdLdPD4+f7e5fytwPj9/f7y9f1agPG6yvlsjvNIcvC8y/lXfvFNdvBZf/HR3PtBbe+DoPTT3fvg5/xWffGyxPh/nPTo7f32+P65yfnBz/n6+/6xw/i+zfmwwvj5+v6Np/WetPdPd/BMdfBOd/BdgvGkufdGce9ghfKnu/deg/F4l/NqjPKAnfS3x/lAbO+KpfVPePBmifKqvviZsPait/fS3PtUe/F6mfT8/f7s8P2Xr/bX4PuWrvbI1fqdtPfq7/3t8f3E0vqCn/RRefCzxPjK1vpwkfPP2vtVfPHR2/tDbu+BnvTr8P3G0/qLpvXW3/uOqPXL1/rf5vyht/eDn/Rzk/OPqfWQqfXZ4vuGovX19/67y/nm7Pymuvc+au9hhfKluvfU3vt3lvO3yPlpjPJykvN2lfNQePB7mfSsv/ju8v18mvTO2fvv8/22x/nr7/2cs/aMpvXn7P3D0fp+nPR5mPTE0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sqmFKDoSTKt5EZHrEnUIiPdSBjDUFalA6KZoZBMB4Yn8iqd41UsyKs8kldBKK8SWF5Fv7zKnHkVdvMvZedfvM//uAL/Axr8j6TwP4RDSM9Xc+woP53TQStOR8v0wZw5XvfDdPTjg4VW+figtVDb8cH/AZ+Eg+9jqX0NAAAAAElFTkSuQmCC) no-repeat;
background-size: 100%;
}
</style>
</head>
<body>
<div id="container" class="container">
<div id="map"></div>
<div id="poi">
<div class="poi-info">
<span class="poi-name"></span>
<span class="poi-addr"></span>
<div class="poi-nav">
<i></i>
<span></span>
</div>
</div>
</div>
</div>
<script>
var loc;
var serviceWebview;
var back = function() {
var webview = plus.webview.currentWebview()
if (webview.__uniapp_statusbar_style === 'light') {
plus.navigator.setStatusBarStyle('light')
}
webview.close('auto');
};
var isIos = !!navigator.userAgent.match(/iPhone|iPad|iPod/i);
document.addEventListener('plusready', function() {
serviceWebview = plus.webview.getWebviewById('__W2A_CONTEXT_') || plus.webview.getLaunchWebview();
plus.key.addEventListener('backbutton', back);
})
/**
* 调用系统第三方程序进行导航
*/
function openSysMap(lat, lng, title) {
/**
* 网页版地图源
*/
var mapsSourceWeb = [
{
title: '腾讯地图网页版',
getUrl: function() {
var url
url = 'https://apis.map.qq.com/uri/v1/routeplan?type=drive' + '&to=' +
encodeURIComponent(title) + '&tocoord=' + encodeURIComponent(lat + ',' + lng) +
'&referer=APP'
return url
}
}
]
/**
* APP版地图源
*/
var mapsSource = [
{
title: '高德地图',
pname: 'com.autonavi.minimap',
action: !isIos ? 'amapuri://' : 'iosamap://',
getUrl: function() {
var url
if (!isIos) {
url = 'amapuri://route/plan/'
} else {
url = 'iosamap://path'
}
url += '?sourceApplication=APP&dname=' + encodeURIComponent(title) + '&dlat=' + lat +
'&dlon=' + lng + '&dev=0'
return url
}
},
{
title: '百度地图',
pname: 'com.baidu.BaiduMap',
action: 'baidumap://',
getUrl: function() {
var url = 'baidumap://map/direction?destination=' + encodeURIComponent('latlng:' + lat +
',' + lng + '|name:' + title) + '&mode=driving&src=APP&coord_type=gcj02'
return url
}
},
{
title: '腾讯地图',
pname: 'com.tencent.map',
action: 'qqmap://',
getUrl: function() {
var url
url = 'qqmap://map/routeplan?type=drive' + (isIos ? ('&from=' + encodeURIComponent(
'我的位置')) : '') + '&to=' + encodeURIComponent(title) + '&tocoord=' +
encodeURIComponent(lat + ',' + lng) + '&referer=APP'
return url
}
}
]
var maps = []
mapsSource.forEach(function(mapsSource) {
var installed = plus.runtime.isApplicationExist({
pname: mapsSource.pname,
action: mapsSource.action,
})
if (installed) {
maps.push(mapsSource)
}
})
if (isIos) {
maps.unshift({
title: 'Apple 地图',
getUrl: function() {
var url
url = 'https://maps.apple.com/?daddr=' + encodeURIComponent(title) + '&sll=' +
encodeURIComponent(lat + ',' + lng)
return url
}
})
}
if (maps.length === 0) {
maps = maps.concat(mapsSourceWeb)
}
plus.nativeUI.actionSheet({
title: '导航方式',
cancel: '取消',
buttons: maps,
}, function(res) {
var index = res.index
var map
if (index > 0) {
map = maps[index - 1]
plus.runtime.openURL(map.getUrl(), function() { }, map.pname)
}
})
}
var ZOOM = 13
window.__openLocation__ = function(params) {
var mapElem = document.getElementById('map');
var poiNameElem = document.querySelector('.poi-name');
var poiAddrElem = document.querySelector('.poi-addr');
var poiNavElem = document.querySelector('.poi-nav');
var latitude = params.latitude;
var longitude = params.longitude;
var scale = params.scale;
var name = params.name;
var address = params.address;
var point = new plus.maps.Point(longitude, latitude);
var map = plus.maps.create('map', {
center: point,
zoom: scale || ZOOM,
top: 0,
left: 0,
width: mapElem.offsetWidth,
height: mapElem.offsetHeight
});
var marker = new plus.maps.Marker(point);
marker.setIcon('__uniappmarker@3x.png');
if (name) {
poiNameElem.innerText = name;
// marker.setLabel(name);
}
if (address) {
poiAddrElem.innerText = address;
// var bubble = new plus.maps.Bubble(address);
// marker.setBubble(bubble);
}
map.addOverlay(marker);
plus.webview.currentWebview().append(map);
var userPoint = false
map.getUserLocation(function(state, point) {
if (state) {
plus.nativeUI.toast('定位失败!');
} else {
userPoint = point;
}
})
poiNavElem.addEventListener('click', function() {
openSysMap(latitude, longitude, name)
});
}
</script>
</body>
</html>
\ No newline at end of file
此差异已折叠。
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<script>
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
CSS.supports(
'top: constant(a)'))
document.write(
'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
(coverSupport ? ', viewport-fit=cover' : '') + '" />')
</script>
<title>扫码</title>
<style>
html,
body,
.container {
margin: 0;
padding: 0;
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
background: #000000;
}
</style>
</head>
<body>
<div id="scan" class="container">
</div>
<script>
var scan;
var lightImg;
var lightView;
var back = function(cancel) {
if (cancel) {
plus.webview.postMessageToUniNView({
type: 'scanCode',
args: {
errMsg: 'cancel'
}
}, '__uniapp__service');
}
lightImg && lightImg.clear();
lightView && lightView.clear();
scan && scan.close();
var webview = plus.webview.currentWebview();
if (webview.__uniapp_dark) {
plus.navigator.setStatusBarStyle('dark');
}
webview.close('auto');
}
/**
* 绘制照亮开关
*/
function drawLight() {
var offImg =
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAABjklEQVRoQ+1ZbVHEQAx9TwE4ABTcOQAknANQAKcAUAAOAAXgAHAACsDCKQiTmbYDzJZtNt2bFrJ/m6+Xl2yyU2LmhzOPH/8PgIjcADirxNyapNoffMwMiMgzgMPBHmyCLySPLCoBwJKtAbJbYaBmD1yRvBwAtBMxl5DF+DZkiwCIyBLAzsgBbki+Wm2WAlCaL6zOMvKnJO+sNksB7ALQbO1ZHfbIv5FUVs2nCIB6EZETALdmj2mFY5I6X8ynGEADQllYmL1+VzBfnV/VvQB0aj45ARyQ/Ci14QLQsOBZLe5JaikWnzEA7AN4L4hgA2Dpyb76dANwsOCq/TZhASAYKGie0a7R1lDPI0ebtF0NUi+4yfdAtxr3PEMnD6BbD0QkNfACQO05EAwMuaBqDrIVycdmTpwDuP4R0OR7QFftVRP0g+49cwOQq4DJMxAAchmofY3m/EcJBQOZbTRKKJeBKKEoIePvpFRJ1VzmciUccyCa+C81cerBkuuB7sGTE/zt+yhN7AnAqxsAvBn06n8CkyPwMZKwm+UAAAAASUVORK5CYII=';
var onImg =
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAB4klEQVRoQ+1ZQU7CUBCdaWVBLFETqUtxB7iQG4hH4AZ4AvUE4gnkBuoJ9AbiDXAhZadby4IQICaS9psqJBVLy5/fkhKHbefPzPvzZv6bgLDmP1zz/OH/ARjZpSYAniVSORQXRt5qyviWrsDQLrUQ8FgmyLK2AsRTzrSqy9p7dgxA5raibFdSgSR7QAi4yu11GlFA/d+lKSTjfBW2JAAj+7Cio7MVZ4KO0AeG+dKW9UkCMHwvNxDhUjZYuL17apjdW1mfJACiX9gef2bbgLgvG3CB/bNhdioUXyQAXqCRXawDaDeUoPNnBLonuXy3RfFFBvADouxx9ogSeHaGMjpjm0LDXrGKQntUAaBn3IPsTveN6kOpAl5QNWkh7gzTqlOTJ0mJ+WAf/WLBmWivskkIEIONjKio3H4sAKhVUOX+7MKUKcQAZLk3Z88VWEQhr0kRYCoN/m5wqe8BvzQOkuDpB+CTB0EPHgOYNnNiTewXaFyBkFGbWAVQE7XNXevhW7X2Sucg8NqfR+p7AADaesateUk7E+0eAH4tLOsAIPSNZQBJT6EoicMV4Ar4OEJZK5lCTCGmkPy/MUGjOTEtxO9A1A1wE3MTp6iJgxaWKAr7F54o27DvsUwhlQRUzzIA1RtUPf8FRKRYQOI+9hQAAAAASUVORK5CYII=';
var onText = '轻触照亮';
var offText = '轻触关闭';
var on = false;
var viewWidth = 48;
var fontSize = 10;
var imgWidth = 26;
function changeType() {
lightView.reset();
lightImg.loadBase64Data(on ? onImg : offImg, function() {
lightView.drawBitmap(lightImg, {}, {
top: 0,
left: (viewWidth - imgWidth) / 2 + 'px',
width: imgWidth + 'px',
height: imgWidth + 'px'
});
});
lightView.drawText(on ? offText : onText, {
top: imgWidth + 'px',
left: '0px',
width: '100%',
height: (fontSize + 2) + 'px'
}, {
color: '#ffffff',
size: fontSize + 'px'
});
scan.setFlash(on);
on = !on;
}
lightImg = new plus.nativeObj.Bitmap('lightImg');
lightView = new plus.nativeObj.View('lightView', {
width: viewWidth + 'px',
height: viewWidth + 'px',
top: window.innerHeight / 2 + 50 + 'px',
left: (window.innerWidth - viewWidth) / 2 + 'px',
position: 'static'
});
lightView.addEventListener('click', function() {
changeType();
});
plus.webview.currentWebview().append(lightView);
changeType();
}
document.addEventListener('plusready', function() {
var serviceWebview = plus.webview.getWebviewById('__W2A_CONTEXT_') || plus.webview.getLaunchWebview();
plus.key.addEventListener('backbutton', function() {
back(true);
});
setTimeout(function() {
var webview = plus.webview.currentWebview();
scan = new plus.barcode.Barcode('scan', webview.__uniapp_scan_type, {
frameColor: '#118CE9',
scanbarColor: '#118CE9'
});
scan.onmarked = function(type, code, file) {
var res = {
type: type,
code: code
};
back()
plus.webview.postMessageToUniNView({
type: 'scanCode',
args: res
}, '__uniapp__service');
};
scan.onerror = function(error) {
back()
plus.webview.postMessageToUniNView({
type: 'scanCode',
args: {
errMsg: error.message + ',错误码:' + error.code
}
}, '__uniapp__service');
};
scan.start();
drawLight();
}, 500)
})
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<script>
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)'))
document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')
</script>
<title></title>
<style>
html,
body,
.container {
margin: 0;
padding: 0;
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
background: #ffffff;
}
#map {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 80px;
bottom: calc(80px + constant(safe-area-inset-bottom));
bottom: calc(80px + env(safe-area-inset-bottom));
}
#poi {
position: absolute;
left: 0;
right: 0;
bottom: 0;
bottom: constant(safe-area-inset-bottom);
bottom: env(safe-area-inset-bottom);
height: 80px;
background: #FFFFFF;
}
.poi-info {
width: 100%;
padding: 23px 16px 23px 18px;
box-sizing: border-box;
background: #FFFFFF;
}
.poi-name {
font-size: 17px;
line-height: 17px;
color: #111111;
display: block;
margin-right: 70px;
word-wrap: break-word;
}
.poi-addr {
font-size: 13px;
line-height: 13px;
color: #666666;
display: block;
margin-top: 4px;
margin-right: 70px;
word-wrap: break-word;
}
.poi-nav {
display: block;
position: absolute;
top: 10px;
right: 16px;
width: 60px;
height: 60px;
border-radius: 60px;
overflow: hidden;
}
.poi-nav i,
.poi-nav span {
position: absolute;
top: 0;
width: 100%;
height: 100%;
display: inline-block;
border-radius: 60px;
}
.poi-nav i {
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAACnVBMVEUAAAA9avA+avA9avA/bPE8afA+avM9afA9avA9au9Ac/I+bPQ9avA8a/E8au8+avY9avA9avBAgP88avA9au9AbfFAgP89avA9avBJbf89au88afA8ae88afA8ae9AbO88afA/avE9ae88avBHcfFCcfY+a/H///89afE8afA8avA9afA8afA9a/E9afA9avA8avA8avA9ae////88ae8/a+/+/v77/P5Cbu9jh/I9au9Te/CIo/XY4fuasfbH1PpJc/Dl6/xHce9Cbe9Eb+9FcO/3+f5SevC0xfjh6PygtvdLdPD4+f7e5fytwPj9/f7y9f1agPG6yvlsjvNIcvC8y/lXfvFNdvBZf/HR3PtBbe+DoPTT3fvg5/xWffGyxPh/nPTo7f32+P65yfnBz/n6+/6xw/i+zfmwwvj5+v6Np/WetPdPd/BMdfBOd/BdgvGkufdGce9ghfKnu/deg/F4l/NqjPKAnfS3x/lAb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3B+tU6elafWITom9XICTshNhb62saR/TjrhNBIcpxrB+R1pLgCAc5O/X40yP9Sxv1yDQie8HGuc8OPVn3YvWnChqRO8NEk5tFuwtLwKqn75taFyba17Wk1ddcupLqy8RyADiMxa5YQXPcW3AvyY9/i1iv2wHBF7OuABVl6AAI7hFFDifFCKjyWpeeT3PxrXl18/eaeoQXqv/oS/EHHD5QrvlHzp73/+dYJMN5bMUGI7JanJnsZt+Y8MjbNQZqu7du0ELzXIhDiakrjWEwMlVa8naVmU4gQdEWMo5Rg6YsqmFKDoSTKt5EZHrEnUIiPdSBjDUFalA6KZoZBMB4Yn8iqd41UsyKs8kldBKK8SWF5Fv7zKnHkVdvMvZedfvM//uAL/Axr8j6TwP4RDSM9Xc+woP53TQStOR8v0wZw5XvfDdPTjg4VW+figtVDb8cH/AZ+Eg+9jqX0NAAAAAElFTkSuQmCC) no-repeat;
background-size: 100%;
}
</style>
</head>
<body>
<div id="container" class="container">
<div id="map"></div>
<div id="poi">
<div class="poi-info">
<span class="poi-name"></span>
<span class="poi-addr"></span>
<div class="poi-nav">
<i></i>
<span></span>
</div>
</div>
</div>
</div>
<script>
var loc;
var serviceWebview;
var back = function() {
var webview = plus.webview.currentWebview()
if (webview.__uniapp_statusbar_style === 'light') {
plus.navigator.setStatusBarStyle('light')
}
webview.close('auto');
};
var isIos = !!navigator.userAgent.match(/iPhone|iPad|iPod/i);
document.addEventListener('plusready', function() {
serviceWebview = plus.webview.getWebviewById('__W2A_CONTEXT_') || plus.webview.getLaunchWebview();
plus.key.addEventListener('backbutton', back);
})
/**
* 调用系统第三方程序进行导航
*/
function openSysMap(lat, lng, title) {
/**
* 网页版地图源
*/
var mapsSourceWeb = [
{
title: '腾讯地图网页版',
getUrl: function() {
var url
url = 'https://apis.map.qq.com/uri/v1/routeplan?type=drive' + '&to=' +
encodeURIComponent(title) + '&tocoord=' + encodeURIComponent(lat + ',' + lng) +
'&referer=APP'
return url
}
}
]
/**
* APP版地图源
*/
var mapsSource = [
{
title: '高德地图',
pname: 'com.autonavi.minimap',
action: !isIos ? 'amapuri://' : 'iosamap://',
getUrl: function() {
var url
if (!isIos) {
url = 'amapuri://route/plan/'
} else {
url = 'iosamap://path'
}
url += '?sourceApplication=APP&dname=' + encodeURIComponent(title) + '&dlat=' + lat +
'&dlon=' + lng + '&dev=0'
return url
}
},
{
title: '百度地图',
pname: 'com.baidu.BaiduMap',
action: 'baidumap://',
getUrl: function() {
var url = 'baidumap://map/direction?destination=' + encodeURIComponent('latlng:' + lat +
',' + lng + '|name:' + title) + '&mode=driving&src=APP&coord_type=gcj02'
return url
}
},
{
title: '腾讯地图',
pname: 'com.tencent.map',
action: 'qqmap://',
getUrl: function() {
var url
url = 'qqmap://map/routeplan?type=drive' + (isIos ? ('&from=' + encodeURIComponent(
'我的位置')) : '') + '&to=' + encodeURIComponent(title) + '&tocoord=' +
encodeURIComponent(lat + ',' + lng) + '&referer=APP'
return url
}
}
]
var maps = []
mapsSource.forEach(function(mapsSource) {
var installed = plus.runtime.isApplicationExist({
pname: mapsSource.pname,
action: mapsSource.action,
})
if (installed) {
maps.push(mapsSource)
}
})
if (isIos) {
maps.unshift({
title: 'Apple 地图',
getUrl: function() {
var url
url = 'https://maps.apple.com/?daddr=' + encodeURIComponent(title) + '&sll=' +
encodeURIComponent(lat + ',' + lng)
return url
}
})
}
if (maps.length === 0) {
maps = maps.concat(mapsSourceWeb)
}
plus.nativeUI.actionSheet({
title: '导航方式',
cancel: '取消',
buttons: maps,
}, function(res) {
var index = res.index
var map
if (index > 0) {
map = maps[index - 1]
plus.runtime.openURL(map.getUrl(), function() { }, map.pname)
}
})
}
var ZOOM = 13
window.__openLocation__ = function(params) {
var mapElem = document.getElementById('map');
var poiNameElem = document.querySelector('.poi-name');
var poiAddrElem = document.querySelector('.poi-addr');
var poiNavElem = document.querySelector('.poi-nav');
var latitude = params.latitude;
var longitude = params.longitude;
var scale = params.scale;
var name = params.name;
var address = params.address;
var point = new plus.maps.Point(longitude, latitude);
var map = plus.maps.create('map', {
center: point,
zoom: scale || ZOOM,
top: 0,
left: 0,
width: mapElem.offsetWidth,
height: mapElem.offsetHeight
});
var marker = new plus.maps.Marker(point);
marker.setIcon('__uniappmarker@3x.png');
if (name) {
poiNameElem.innerText = name;
// marker.setLabel(name);
}
if (address) {
poiAddrElem.innerText = address;
// var bubble = new plus.maps.Bubble(address);
// marker.setBubble(bubble);
}
map.addOverlay(marker);
plus.webview.currentWebview().append(map);
var userPoint = false
map.getUserLocation(function(state, point) {
if (state) {
plus.nativeUI.toast('定位失败!');
} else {
userPoint = point;
}
})
poiNavElem.addEventListener('click', function() {
openSysMap(latitude, longitude, name)
});
}
</script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<script>
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
CSS.supports(
'top: constant(a)'))
document.write(
'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
(coverSupport ? ', viewport-fit=cover' : '') + '" />')
</script>
<title>扫码</title>
<style>
html,
body,
.container {
margin: 0;
padding: 0;
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
background: #000000;
}
</style>
</head>
<body>
<div id="scan" class="container">
</div>
<script>
var scan;
var lightImg;
var lightView;
var back = function(cancel) {
if (cancel) {
plus.webview.postMessageToUniNView({
type: 'scanCode',
args: {
errMsg: 'cancel'
}
}, '__uniapp__service');
}
lightImg && lightImg.clear();
lightView && lightView.clear();
scan && scan.close();
var webview = plus.webview.currentWebview();
if (webview.__uniapp_dark) {
plus.navigator.setStatusBarStyle('dark');
}
webview.close('auto');
}
/**
* 绘制照亮开关
*/
function drawLight() {
var offImg =
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAABjklEQVRoQ+1ZbVHEQAx9TwE4ABTcOQAknANQAKcAUAAOAAXgAHAACsDC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evhW7X2Sucg8NqfR+p7AADaesateUk7E+0eAH4tLOsAIPSNZQBJT6EoicMV4Ar4OEJZK5lCTCGmkPy/MUGjOTEtxO9A1A1wE3MTp6iJgxaWKAr7F54o27DvsUwhlQRUzzIA1RtUPf8FRKRYQOI+9hQAAAAASUVORK5CYII=';
var onText = '轻触照亮';
var offText = '轻触关闭';
var on = false;
var viewWidth = 48;
var fontSize = 10;
var imgWidth = 26;
function changeType() {
lightView.reset();
lightImg.loadBase64Data(on ? onImg : offImg, function() {
lightView.drawBitmap(lightImg, {}, {
top: 0,
left: (viewWidth - imgWidth) / 2 + 'px',
width: imgWidth + 'px',
height: imgWidth + 'px'
});
});
lightView.drawText(on ? offText : onText, {
top: imgWidth + 'px',
left: '0px',
width: '100%',
height: (fontSize + 2) + 'px'
}, {
color: '#ffffff',
size: fontSize + 'px'
});
scan.setFlash(on);
on = !on;
}
lightImg = new plus.nativeObj.Bitmap('lightImg');
lightView = new plus.nativeObj.View('lightView', {
width: viewWidth + 'px',
height: viewWidth + 'px',
top: window.innerHeight / 2 + 50 + 'px',
left: (window.innerWidth - viewWidth) / 2 + 'px',
position: 'static'
});
lightView.addEventListener('click', function() {
changeType();
});
plus.webview.currentWebview().append(lightView);
changeType();
}
document.addEventListener('plusready', function() {
var serviceWebview = plus.webview.getWebviewById('__W2A_CONTEXT_') || plus.webview.getLaunchWebview();
plus.key.addEventListener('backbutton', function() {
back(true);
});
setTimeout(function() {
var webview = plus.webview.currentWebview();
scan = new plus.barcode.Barcode('scan', webview.__uniapp_scan_type, {
frameColor: '#118CE9',
scanbarColor: '#118CE9'
});
scan.onmarked = function(type, code, file) {
var res = {
type: type,
code: code
};
back()
plus.webview.postMessageToUniNView({
type: 'scanCode',
args: res
}, '__uniapp__service');
};
scan.onerror = function(error) {
back()
plus.webview.postMessageToUniNView({
type: 'scanCode',
args: {
errMsg: error.message + ',错误码:' + error.code
}
}, '__uniapp__service');
};
scan.start();
drawLight();
}, 500)
})
</script>
</body>
</html>
...@@ -189,6 +189,11 @@ if (process.env.UNI_USING_NATIVE || process.env.UNI_USING_V3_NATIVE) { ...@@ -189,6 +189,11 @@ if (process.env.UNI_USING_NATIVE || process.env.UNI_USING_V3_NATIVE) {
from: path.resolve(getTemplatePath(), 'common'), from: path.resolve(getTemplatePath(), 'common'),
to: process.env.UNI_OUTPUT_DIR to: process.env.UNI_OUTPUT_DIR
}) })
} else if (process.env.UNI_USING_V3_NATIVE) {
array.push({
from: path.resolve(getTemplatePath(), 'weex'),
to: process.env.UNI_OUTPUT_DIR
})
} else { } else {
let nativeTemplatePath = path.resolve(process.env.UNI_HBUILDERX_PLUGINS, 'weapp-tools/template/v8-native') let nativeTemplatePath = path.resolve(process.env.UNI_HBUILDERX_PLUGINS, 'weapp-tools/template/v8-native')
if (!fs.existsSync(nativeTemplatePath)) { // 兼容旧版本 if (!fs.existsSync(nativeTemplatePath)) { // 兼容旧版本
...@@ -318,4 +323,4 @@ module.exports = function () { ...@@ -318,4 +323,4 @@ module.exports = function () {
zlib: false zlib: false
} }
} }
} }
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
<script> <script>
import { emitter } from 'uni-mixins' import { emitter } from 'uni-mixins'
import { showPage } from './page' import { showPage } from './page'
import * as webview from './webview'
const mode = { const mode = {
SELECTOR: 'selector', SELECTOR: 'selector',
...@@ -152,6 +153,13 @@ export default { ...@@ -152,6 +153,13 @@ export default {
}) })
this._setValueSync() this._setValueSync()
}, },
mounted () {
webview.exists((exists) => {
if (exists) {
webview.initPicker()
}
})
},
beforeDestroy () { beforeDestroy () {
this.$dispatch('Form', 'uni-form-group-update', { this.$dispatch('Form', 'uni-form-group-update', {
type: 'remove', type: 'remove',
...@@ -195,55 +203,72 @@ export default { ...@@ -195,55 +203,72 @@ export default {
}, },
_showPicker (data) { _showPicker (data) {
if ((data.mode === mode.TIME || data.mode === mode.DATE) && !data.fields) { if ((data.mode === mode.TIME || data.mode === mode.DATE) && !data.fields) {
plus.nativeUI[this.mode === mode.TIME ? 'pickTime' : 'pickDate']((res) => { this._showNativePicker(data)
const date = res.date
this.$trigger('change', {}, {
value: this.mode === mode.TIME ? `${padLeft(date.getHours())}:${padLeft(date.getMinutes())}` : `${date.getFullYear()}-${padLeft(date.getMonth() + 1)}-${padLeft(date.getDate())}`
})
}, () => {
this.$trigger('cancel', {}, {})
}, this.mode === mode.TIME ? {
time: getDate(this.value, mode.TIME)
} : {
date: getDate(this.value, mode.DATE),
minDate: getDate(this.start, mode.DATE),
maxDate: getDate(this.end, mode.DATE)
})
} else { } else {
data.fields = Object.values(fields).includes(data.fields) ? data.fields : fields.DAY data.fields = Object.values(fields).includes(data.fields) ? data.fields : fields.DAY
let res = { event: 'cancel' } webview.exists((exists) => {
this.page = showPage({ this[exists ? '_showWebviewPicker' : '_showWeexPicker'](data)
url: '__uniapppicker',
data,
style: {
titleNView: false,
animationType: 'none',
animationDuration: 0,
background: 'rgba(0,0,0,0)',
popGesture: 'none'
},
onMessage: (message) => {
const event = message.event
if (event === 'created') {
this._updatePicker(data)
return
}
if (event === 'columnchange') {
delete message.event
this.$trigger(event, {}, message)
return
}
res = message
},
onClose: () => {
this.page = null
const event = res.event
delete res.event
this.$trigger(event, {}, res)
}
}) })
} }
}, },
_showNativePicker (data) {
plus.nativeUI[this.mode === mode.TIME ? 'pickTime' : 'pickDate']((res) => {
const date = res.date
this.$trigger('change', {}, {
value: this.mode === mode.TIME ? `${padLeft(date.getHours())}:${padLeft(date.getMinutes())}` : `${date.getFullYear()}-${padLeft(date.getMonth() + 1)}-${padLeft(date.getDate())}`
})
}, () => {
this.$trigger('cancel', {}, {})
}, this.mode === mode.TIME ? {
time: getDate(this.value, mode.TIME)
} : {
date: getDate(this.value, mode.DATE),
minDate: getDate(this.start, mode.DATE),
maxDate: getDate(this.end, mode.DATE)
})
},
_showWeexPicker (data) {
let res = { event: 'cancel' }
this.page = showPage({
url: '__uniapppicker',
data,
style: {
titleNView: false,
animationType: 'none',
animationDuration: 0,
background: 'rgba(0,0,0,0)',
popGesture: 'none'
},
onMessage: (message) => {
console.dir(message)
const event = message.event
if (event === 'created') {
this._updatePicker(data)
return
}
if (event === 'columnchange') {
delete message.event
this.$trigger(event, {}, message)
return
}
res = message
},
onClose: () => {
this.page = null
const event = res.event
delete res.event
this.$trigger(event, {}, res)
}
})
},
_showWebviewPicker (data) {
webview.showPicker(data, (res) => {
console.dir(res)
const event = res.event
delete res.event
this.$trigger(event, {}, res)
})
},
_getFormData () { _getFormData () {
return { return {
value: this.valueSync, value: this.valueSync,
...@@ -267,7 +292,13 @@ export default { ...@@ -267,7 +292,13 @@ export default {
} }
}, },
_updatePicker (data) { _updatePicker (data) {
this.page && this.page.sendMessage(data) webview.exists((exists) => {
if (exists) {
webview.updatePicker(data)
} else {
this.page && this.page.sendMessage(data)
}
})
} }
} }
} }
......
const PICKER_ID = '__UNIAPP_PICKER'
export const PICKER_PATH = '_www/__uniapppicker.html'
let pickerWebview = null
let pickerWebviewCreated = false
let _exists = null
let callbacks = null
export function exists (callback) {
if (_exists !== null) {
callback(_exists)
return
}
if (callbacks) {
callbacks.push(callback)
return
}
callbacks = [callback]
function success (exists) {
_exists = exists
callbacks.forEach(callback => callback(exists))
callbacks = null
}
plus.io.resolveLocalFileSystemURL(PICKER_PATH, () => {
success(true)
}, () => {
success(false)
})
}
let _pickerHideCallback
export function initPicker () {
if (pickerWebview) {
return
}
pickerWebview = plus.webview.getWebviewById(PICKER_ID)
if (pickerWebview) {
pickerWebviewCreated = true
} else {
pickerWebview = plus.webview.create(PICKER_PATH, PICKER_ID, {
popGesture: 'none',
background: 'transparent',
backButtonAutoControl: 'hide',
render: 'always',
kernel: 'WKWebview',
bounce: 'none',
cachemode: 'noCache'
})
pickerWebview.addEventListener('hide', () => {
_pickerHideCallback && _pickerHideCallback()
_pickerHideCallback = null
})
window.__pickerCallback = function () {
delete window.__pickerCallback
pickerWebviewCreated = true
}
}
}
export function showPicker (data = {}, callback) {
data.id = plus.webview.currentWebview().id
pickerWebview.show('fade-in')
let res
_pickerHideCallback = function () {
callback(res || {
event: 'cancel'
})
}
window.__pickerCallback = function ({
event = 'cancel',
column,
value = -1
}) {
if (event === 'created' && pickerWebview) {
pickerWebviewCreated = true
pickerWebview.evalJS(`showPicker(${JSON.stringify(data)})`)
return
}
if (event === 'columnchange' && pickerWebview) {
callback({
event,
column,
value
})
}
if (event === 'change' || event === 'cancel') {
// 赋值为空函数避免 picker-webview 产生多余通讯报错
window.__pickerCallback = function () { }
res = {
event,
value
}
pickerWebview.hide('fade-out', 100)
}
}
if (pickerWebviewCreated) {
pickerWebview.evalJS(`showPicker(${JSON.stringify(data)})`)
}
}
export function updatePicker (data) {
if (pickerWebviewCreated) {
pickerWebview.evalJS(`showPicker(${JSON.stringify(data)})`)
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册