init
This commit is contained in:
112
components/scan.vue
Normal file
112
components/scan.vue
Normal file
@@ -0,0 +1,112 @@
|
||||
<template>
|
||||
<view>
|
||||
<view id="barcode"></view>
|
||||
<view id="light"></view>
|
||||
<view id="close"></view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var light, close;
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
// #ifdef APP-PLUS
|
||||
barcode: [
|
||||
plus.barcode.QR
|
||||
// plus.barcode.EAN13,
|
||||
// plus.barcode.EAN8,
|
||||
// plus.barcode.UPCA,
|
||||
// plus.barcode.UPCE,
|
||||
// plus.barcode.CODABAR,
|
||||
// plus.barcode.CODE39,
|
||||
// plus.barcode.CODE93,
|
||||
// plus.barcode.CODE128,
|
||||
// plus.barcode.ITF,
|
||||
],//码类型
|
||||
// #endif
|
||||
};
|
||||
},
|
||||
created() {
|
||||
var statusBarHeight = uni.getSystemInfoSync().windowHeight;//状态栏
|
||||
var height = statusBarHeight+'px';
|
||||
var pages = getCurrentPages();
|
||||
var page = pages[pages.length - 1];
|
||||
// #ifdef APP-PLUS
|
||||
var currentWebview = page.$getAppWebview();
|
||||
this.barcode = plus.barcode.create('barcode', this.barcode, {
|
||||
background:'#02c17e',
|
||||
frameColor:'#02c17e',
|
||||
scanbarColor:'#02c17e',
|
||||
top: '0',
|
||||
left: '0px',
|
||||
width: '100%',
|
||||
height: height,//这里可以设置扫码框的高度
|
||||
position: 'static'
|
||||
});
|
||||
|
||||
this.barcode.onmarked = this.onmarked;
|
||||
currentWebview.append(this.barcode);
|
||||
|
||||
const res = uni.getSystemInfoSync();
|
||||
if(res.platform == 'android'){//安卓机
|
||||
// this.barcode.setFlash(true)
|
||||
this.barcode.start();
|
||||
}
|
||||
// #endif
|
||||
var that=this;
|
||||
// light = new plus.nativeObj.View('light',
|
||||
// {bottom:'100px',left:'0px',height:'44px',width:'100%'},
|
||||
// [
|
||||
// {tag:'font',id:'font',text:'轻触照亮',textStyles:{size:'16px',color:"rgba(255,255,255,0.8)"}}
|
||||
// ]);
|
||||
// close = new plus.nativeObj.View('close',
|
||||
// {bottom:'100px',left:'0px',height:'44px',width:'100%'},
|
||||
// [
|
||||
// {tag:'font',id:'font',text:'轻触关闭',textStyles:{size:'16px',color:"rgba(255,255,255,0.8)"}}
|
||||
// ]);
|
||||
// light.show();
|
||||
// light.addEventListener("click", function(){
|
||||
// light.hide();
|
||||
// close.show()
|
||||
// that.barcode.setFlash(true)
|
||||
// }, false);
|
||||
// close.addEventListener("click", function(){
|
||||
// light.show();
|
||||
// close.hide()
|
||||
// that.barcode.setFlash(false)
|
||||
// }, false);
|
||||
},
|
||||
destroyed () {
|
||||
// light.hide()
|
||||
// close.hide()
|
||||
},
|
||||
beforeDestroy() {
|
||||
uni.$off('setShow')
|
||||
},
|
||||
mounted () {
|
||||
uni.$on('setShow', (data) => {
|
||||
console.log(data.bol)
|
||||
if (data.bol) {
|
||||
setTimeout(() => {
|
||||
this.barcode.start();
|
||||
}, 1000)
|
||||
} else {
|
||||
this.barcode.cancel();
|
||||
}
|
||||
})
|
||||
},
|
||||
onUnload() {
|
||||
clearTimeout(this.t);
|
||||
},
|
||||
methods: {
|
||||
onmarked(type, result) {
|
||||
this.$emit('getCode',result);
|
||||
// this.t=setTimeout(() => {
|
||||
// this.barcode.start();
|
||||
// // this.barcode.setFlash(true)
|
||||
// }, 1000)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
54
components/tabbar.vue
Normal file
54
components/tabbar.vue
Normal file
@@ -0,0 +1,54 @@
|
||||
<template>
|
||||
<view>
|
||||
<u-tabbar :value="name" :fixed="true" :border="false" activeColor="#03AE80" zIndex="50" inactiveColor="#999" :safeAreaInsetBottom="true" >
|
||||
<u-tabbar-item :text="item.text" @click="swtichTab(item.path)" :name="item.name" v-for="item in tabList" :key="item.path">
|
||||
<image slot="active-icon" style="width: 40rpx;height: 40rpx;" :src="item.selectIconPath" />
|
||||
<image slot="inactive-icon" style="width: 40rpx;height: 40rpx;" :src="item.iconPath" />
|
||||
</u-tabbar-item>
|
||||
</u-tabbar>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'tabar',
|
||||
props: {
|
||||
name: {
|
||||
type: String,
|
||||
default: 'home'
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
tabList:[
|
||||
{
|
||||
iconPath: '/static/icon/home.png',
|
||||
path: '/pages/index/index',
|
||||
selectIconPath: "/static/icon/home_active.png",
|
||||
text: '首页',
|
||||
name: 'home'
|
||||
},
|
||||
{
|
||||
iconPath: '/static/icon/home.png',
|
||||
path: '/pages/video/video',
|
||||
selectIconPath: "/static/icon/home_active.png",
|
||||
text: '数据',
|
||||
name: 'video'
|
||||
},
|
||||
{
|
||||
iconPath: '/static/icon/mine.png',
|
||||
path: '/pages/mine/mine',
|
||||
selectIconPath: "/static/icon/mine_active.png",
|
||||
text: '我的',
|
||||
name: 'mine'
|
||||
}
|
||||
]
|
||||
};
|
||||
},
|
||||
methods:{
|
||||
swtichTab (url) {
|
||||
uni.reLaunch({ url })
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
Reference in New Issue
Block a user