<template>
<div class="scan">
<div id="bcid">
<p class="tip">...載入中...</p> -->
</div>
<!-- <footer>
<button @click="startRecognize">1.創(chuàng)建控件</button>
<button @click="startScan">2.開始掃描</button>
<button @click="cancelScan">3.結(jié)束掃描</button>
<button @click="closeScan">4.關(guān)閉控件</button>
</footer> -->
</div>
</template>
<script type="text/ecmascript-6">
let scan = null
export default {
data() {
return {
codeUrl: ''
}
},
mounted () {
this.startRecognize()
setTimeout(() => {
this.startScan()
}, 500)
},
methods: {
// 創(chuàng)建掃描控件
startRecognize () {
let that = this
if (!window.plus) return
// scan = new plus.barcode.Barcode('bcid')
scan = plus.barcode.create('bcid', [plus.barcode.QR], {
top:'60px',
left:'0px',
width: '100%',
height: '80%',
position: 'static'
});
plus.webview.currentWebview().append(scan);
// scan.onmarked = onmarked
scan.onmarked = onmarked
function onmarked (type, result, file) {
switch (type) {
case plus.barcode.QR:
type = 'QR'
break
case plus.barcode.EAN13:
type = 'EAN13'
break
case plus.barcode.EAN8:
type = 'EAN8'
break
default:
type = '其它' + type
break
}
result = result.replace(/\n/g, '')
that.codeUrl = result
// alert(result)
that.$message.success("掃碼成功");
that.closeScan()
setTimeout(() => {
that.$parent.onScanClose(that.codeUrl);
}, 500);
}
},
// 開始掃描
startScan () {
if (!window.plus) return
scan.start()
},
// 關(guān)閉掃描
cancelScan () {
if (!window.plus) return
scan.cancel()
},
// 關(guān)閉條碼識別控件
closeScan () {
if (!window.plus) return
scan.close()
},
closeAll(){
this.cancelScan()
this.closeScan()
}
},
destroyed () {
console.log("子組件 destroyed");
this.cancelScan()
this.closeScan()
}
}
</script>
<style lang="scss">
.scan {
height: 100%;
#bcid {
width: 100%;
}
footer {
position: absolute;
left: 0;
bottom: 1rem;
height: 2rem;
line-height: 2rem;
z-index: 2;
}
}
</style>
vue app 拍照掃碼
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
- 文/潘曉璐 我一進店門泪幌,熙熙樓的掌柜王于貴愁眉苦臉地迎上來盲厌,“玉大人署照,你說我怎么就攤上這事÷鸷疲” “怎么了建芙?”我有些...
- 文/不壞的土叔 我叫張陵,是天一觀的道長拓萌。 經(jīng)常有香客問我岁钓,道長升略,這世上最難降的妖魔是什么微王? 我笑而不...
- 正文 為了忘掉前任,我火速辦了婚禮品嚣,結(jié)果婚禮上炕倘,老公的妹妹穿的比我還像新娘。我一直安慰自己翰撑,他們只是感情好罩旋,可當(dāng)我...
- 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著眶诈,像睡著了一般涨醋。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上逝撬,一...
- 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼尽棕!你這毒婦竟也來了喳挑?” 一聲冷哼從身側(cè)響起,我...
- 正文 年R本政府宣布资厉,位于F島的核電站厅缺,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏宴偿。R本人自食惡果不足惜湘捎,卻給世界環(huán)境...
- 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望窄刘。 院中可真熱鬧窥妇,春花似錦、人聲如沸娩践。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽翻伺。三九已至材泄,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間吨岭,已是汗流浹背拉宗。 一陣腳步聲響...
推薦閱讀更多精彩內(nèi)容
- 最近公司開發(fā)了一款app单料,在做推廣的時候遇到了微信掃碼無法直接下載的問題。 最終在參考了眾多資料后点楼,發(fā)現(xiàn)微信內(nèi)置瀏...
- vue項目中實現(xiàn)H5調(diào)取攝像頭掃碼掃一掃功能+生成可識別的條形碼 案例描述:需求是生成條形碼并且在vue項目中實現(xiàn)...
- 掃碼槍 一扫尖、掃碼槍是干什么的? 顧名思義掠廓,它是來掃二維碼的换怖,如下所示,掃碼槍連接電腦蟀瞧,把二維碼的信息讀出條碼自動在...