checksaosao(){  //兼容h5的扫码页面/*#ifdef H5*/uni.$u.route(`/pages/my/saoma`)return;/*#endif*/uni.scanCode({success: function (res) {console.log('条码类型:' + res.scanType);console.log('条码内容:' + res.result);let {type,uid,} = JSON.parse(res.result);console.log(type,uid);if(type){//扫码成功跳转输入金额页面uni.$u.route(`/pages/my/amountEntered`, {uid: uid,type:type,})}else{uni.$u.toast('未识别到二维码,请重新尝试!')}}})},

saoma.vue 页面 (这个页面用兼容h5扫码的)

<template><view class="scan size"><u-navbar title="扫码" :autoBack="true" bgColor="black"></u-navbar><view class="sectionview"><view id="qr-reader" style="width:100%;height:100%;"></view></view><view class="footer"><view style="margin-top: 60rpx;" class="btn" @click="getCameras">扫码</view>            </view>  <u-toast ref="uToast" /></view>
</template>
<script>
export default {data() {return {codeUrl: '',cameraId: '',};},mounted() {this.current = this.$route.query.current || 0;this.init();},beforeDestroy() {this.stop();},methods: {//返回结果getCode(res) {let {type,uid,} = JSON.parse(res);console.log(type,uid);if(type){uni.$u.route(`/pages/my/amountEntered`, {uid: uid,type:type,})}else{uni.$u.toast('未识别到二维码,请重新尝试!')}},init() {this.AddJs('https://blog.minhazav.dev/assets/research/html5qrcode/html5-qrcode.min.js');//需要加载时间建议延时一点再获取设备列表setTimeout(() => {this.getCameras();}, 1000);},stop() {this.html5QrCode.stop().then(ignore => {// QR Code scanning is stopped.console.log('QR Code scanning stopped.');}).catch(err => {// Stop failed, handle it.console.log('Unable to stop scanning.');});},start() {this.html5QrCode = new Html5Qrcode('qr-reader');this.html5QrCode.start(this.cameraId, // retreived in the previous step.{fps: 10, // sets the framerate to 10 frame per secondqrbox: 250 // sets only 250 X 250 region of viewfinder to// scannable, rest shaded.},qrCodeMessage => {// do something when code is read. For example:if (qrCodeMessage) {uni.$u.toast('扫码成功')this.getCode(qrCodeMessage);this.stop();}},errorMessage => {// parse error, ideally ignore it. For example:// console.log(`QR Code no longer in front of camera.`);}).catch(err => {// Start failed, handle it. For example,console.log(`Unable to start scanning, error: ${err}`);uni.$u.toast(`扫码失败:${err}`)});},getCameras() {console.log(Html5Qrcode.getCameras());Html5Qrcode.getCameras().then(devices => {/*** devices would be an array of objects of type:* { id: "id", label: "label" }*/if (devices && devices.length) {if (devices.length > 1) {this.cameraId = devices[1].id;} else {this.cameraId = devices[0].id;}console.log(this.cameraId, 'cameraId');this.start();}}).catch(err => {console.log(err)uni.$u.toast(`启用相机失败:${err}`)});},//动态创建script的方法AddJs(url) {//console.log( 'url:',url);return new Promise((resolve, reject) => {const script = document.createElement('script');script.src = url;script.type = 'text/javascript';document.body.appendChild(script);script.onload = () => {resolve();};});}}
};
</script>
<style lang="less">
.scan {width: 100%;display: flex;flex-direction: column;height: 100vh;overflow: hidden;.footer {position: fixed;bottom: 50rpx;width: 100%;display: flex;justify-content: center;}
}
.btn{width: 460upx;height: 80upx;line-height: 80upx;margin: 0 auto;margin-top: 60upx;border-radius: 40upx;border: 0;font-size: 32upx;outline: 0;background:  linear-gradient(to right, #52DB93, #6B81F8, #C668F5) !important;color: #FFFFFF;text-align: center;
}
</style>

还有个二维码页面 receiptPayment.vue

<template><view class="main"><!-- 收付款码 --><u-navbar title="收付款码" :autoBack="true"></u-navbar><!-- #ifdef APP--><view  style="height: 80px;"></view><!-- #endif --><view class="yuanmao_tabs"><u-tabs :current="defaultTab" class="tabs" :list="list1" @click="click"    lineWidth="100rpx" activeStyle="color: white" itemStyle="width:25%;height:100rpx" ></u-tabs></view><view class="container flexColumn flexAiCenter w100p" v-if="selectTabValue==0"><view class="flex flexJcCenter fs24 litit">付款码</view><view class="flex flexJcCenter fs24 litit">暂无付款码</view><!--         <view v-if="inviteLink2" class="qrcode"><tki-qrcoderef="qrcode":val="inviteLink2":size="400":showLoading="true":loadMake="true"background="#FFF"@result="qrR" /></view> -->
<!--             <u--image :src="boardTempPath2" width="590rpx" height="850rpx" :fade="false" @load="onoff='1'"bgColor="#111"></u--image> --><view class="" style="opacity: 0;z-index: -99;"><l-painter style="display: none;" isCanvasToTempFilePath @success="canvasDone2($event)"customStyle="border-radius:30rpx;width:295px;position:fixed;left:0%"><l-painter-view css="width:400px;height:900rpx;background: #222222;border-radius:30rpx;"><l-painter-view><l-painter-image src="/static/haibao.png"css="width:700rpx;height:1100rpx;position:absolute;top:-170rpx;left:50rpx;right:0;"></l-painter-image></l-painter-view><l-painter-qrcode :text="inviteLink2"css="width:270rpx;height:300rpx;color:#fff;position:absolute;left:265rpx;top:350rpx;"></l-painter-qrcode></l-painter-view></l-painter></view><view style="margin-top: 60rpx;" class="btn" @click="savecode(boardTempPath2)">保存二维码</view></view><view class="container flexColumn flexAiCenter w100p" v-if="selectTabValue==1"><view class="flex flexJcCenter fs24 litit">收款码</view><view v-if="inviteLink1" class="qrcode"><tki-qrcoderef="qrcode":val="inviteLink1":size="400":lv="3":showLoading="true":loadMake="true"background="#FFF"@result="qrR1" /></view>
<!--             <u--image  :src="boardTempPath1" width="590rpx" height="850rpx" :fade="false" @load="onoff='1'"bgColor="#111"></u--image> --><view class="" style="opacity: 0;z-index: -99;"><l-painter   isCanvasToTempFilePath @success="canvasDone1($event)"customStyle="border-radius:30rpx;width:295px;position:fixed;left:0%"><l-painter-view css="width:400px;height:900rpx;background: #fff;border-radius:30rpx;"><l-painter-view><l-painter-image src="/static/haibao.png"css="width:700rpx;height:1100rpx;position:absolute;top:-170rpx;left:50rpx;right:0;"></l-painter-image></l-painter-view><l-painter-qrcode :text="inviteLink1"css="width:270rpx;height:300rpx;color:#000;position:absolute;left:265rpx;top:350rpx;"></l-painter-qrcode></l-painter-view></l-painter></view><view style="margin-top: 60rpx;" class="btn" @click="savecode(boardTempPath1)">保存二维码</view></view></view>
</template><script>import tkiQrcode from "@/components/tki-qrcode/tki-qrcode.vue"import config from '@/config.js'export default {components:{tkiQrcode},data() {return {inviteLink1:'',inviteLink2:'',img1:'',img2:'',list1: [// {//     name: '付款码',//     value: 0// },{name: '收款码',value: 1}],defaultTab: 0,selectTabValue: 1,boardTempPath1: '',boardTempPath2: '',}},onLoad() {this.loadSeries();},onShow(){// this.loadSeries();},mounted() {// this.loadSeries();// setInterval(_ => {// this.loadSeries();// }, 30e3)},methods: {canvasDone1(e) {console.log(e,'-------------------------')this.boardTempPath1 = e;// this.loadSeries()},canvasDone2(e) {console.log(e)this.boardTempPath2 = e;// this.loadSeries()},loadSeries() {//type  1-收款码;2-付款码this.$axios.post('/payment/getLink',{type:1}).then(data => {console.log(data)// 绑定银行卡if(data.code==100){uni.showModal({title:"提示",content:"您未绑定银行卡,是否前往绑定?",success:(res)=>{if (res.confirm) {console.log('用户点击确定');uni.navigateTo({url: '/pages/my/bindCard'})} else if (res.cancel) {console.log('用户点击取消');uni.switchTab({url: '/pages/index/index-new'})}}})}data.data.type=1;this.inviteLink1 = JSON.stringify(data.data);console.log(this.inviteLink1)})this.$axios.post('/payment/getLink',{type:2}).then(data => {// 绑定银行卡if(data.code==100){uni.showModal({title:"提示",content:"您未绑定银行卡,是否前往绑定?",success:(res)=>{if (res.confirm) {console.log('用户点击确定');uni.navigateTo({url: '/pages/my/bindCard'})} else if (res.cancel) {console.log('用户点击取消');uni.switchTab({url: '/pages/index/index-new'})}}})}data.data.type=2;this.inviteLink2 = JSON.stringify(data.data);console.log(this.inviteLink2)})setTimeout(_=>{this.loadSeries},30e3)},    copy(){//#ifdef H5//#endif},qrR(e){// console.log(e,'二维码')this.img1=e;},qrR1(e){// console.log(e,'二维码')this.img2=e;},click(item) {console.log('item', item.value);if (this.selectTabValue != item.value)this.selectTabValue = item.value;},//保存图片到相册savecode(path){console.log(`savecode`,path)//#ifdef H5uni.$u.toast(`长按二维码保存`)//#endif//#ifdef APP-PLUSuni.saveImageToPhotosAlbum({filePath:path,success() {uni.$u.toast(`保存成功`)}})//#endif},}}
</script><style lang="scss" scoped>page {padding: 60px 10px;.container {width: 90%;margin: 70rpx auto;background: #222222;border-radius: 20rpx;padding: 20rpx 0rpx 80rpx 0rpx;.qrcode{margin-top: 0px;padding: 10px;background-color: white;}.litit{margin: 30rpx 0;}.btn{width: 260upx;height: 60upx;line-height: 60upx;margin: 0 auto;margin-top: 60upx;border-radius: 40upx;border: 0;font-size: 26upx;outline: 0;background:  linear-gradient(to right, #52DB93, #6B81F8, #C668F5) !important;color: #FFFFFF;text-align: center;}}}.yuanmao_tabs .u-tabs__wrapper__nav__line {background: linear-gradient(to right, #52DB93, #6B81F8, #C668F5) !important;}
</style>

h5 兼容扫码用htm-qrcode的

通过扫码获取到 uid:, type2个字段在传给后端,注意扫码哪个二维码加个白色边距,不然可能会扫码不了

,这个我是h5游览器展示的,实际手机的h5可以扫码的,app端用uniapp的那个官方api的那个

uniapp扫码功能兼容h5相关推荐

  1. 微信扫码 android sdk,H5中js-sdk扫码功能,Android手机微信中无法调用扫码?

    我的H5对接微信JS-SDK中的扫码功能,发现在Android手机微信中无法调用扫码功能,在苹果手机微信中可以使用. 报如下错误: errMsg:scanQRCode:permissi on deni ...

  2. uni-app实现扫码功能

    调用uni-app的扫码 // 允许从相机和相册扫码 uni.scanCode({success: function (res) {console.log('条码类型:' + res.scanType ...

  3. Uniapp实现扫码功能

    写uniapp的时候会遇到扫码功能,下面是在项目中遇到的调试问题,再此记录 <button type="primary" @click="scan3"&g ...

  4. vue3 + uniapp 实现PDA设备的扫码功能

    vue3 + uniapp 实现PDA设备的扫码功能 这里必须要用input 不然输入框不能再次聚焦!!!!!!!! 只有input 默认聚焦状态,扫码枪的数据才会默认填入input <inpu ...

  5. 计算机毕业设计Python+uniapp扫码点餐微信小程序(小程序+源码+LW)

    计算机毕业设计Python+uniapp扫码点餐微信小程序(小程序+源码+LW) 该项目含有源码.文档.程序.数据库.配套开发软件.软件安装教程 项目运行 环境配置: Pychram社区版+ pyth ...

  6. uniapp 扫码、拍照

    uniapp 扫码.拍照 uniapp 功能实现 提示:写完文章后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录 uniapp 扫码.拍照 前言 一.扫码 二.拍照 总结 前言 记录一些u ...

  7. uniapp 扫码识别(一维码、二维码)

    注:需开启扫码功能,首先要在manifest.json配置中打开APP模块配置中 Barcode(扫码).Camera&Gallery(相机和相册) 自带扫码插件:uni.scanCode(O ...

  8. 基于MacOSX平台下的二维码扫码功能

    基于MacOSX平台下的二维码扫码功能 最近项目接受了一个需求,要在macOS的系统上实现一个二维码扫码的功能.通过多方面的学习,最终实现了要求,具体的实现步骤将会在下面展示. 核心功能模块 实现途径 ...

  9. Android 二维码扫码功能实现(Zxing集成,避坑启示)

    这两天想要实现一个能扫码的app,找了一下,发现zxing用的比较多,就在网上找了找怎么用zxing.我主要是按照宇宝守护神的博文"Android 二维码的扫码功能实现(一)"的步 ...

最新文章

  1. 如何使用C#在ASP.NET Core中轻松实现QRCoder
  2. ZOJ 3820 Building Fire Stations
  3. ASP.NET:为 AJAX 请求添加客户端事件
  4. python学会了能做什么-学会Python后都能做什么?介绍五种Python的实用场景
  5. Python itertools库详细教程
  6. OpenCV霍夫直线houghlines点集的实例(附完整代码)
  7. ping 问题网络翻滚问题小结
  8. VS2010 C++下编译调试MongoDB“.NET研究”源码
  9. .NET Core UI框架Avalonia
  10. 配置Ubuntu虚拟环境
  11. ESP32 + ESP-IDF |GPIO 01 - 驱动外部两个LED灯,以每300ms的时间间隔闪烁
  12. 实验六 调用函数 判断素数
  13. Java把日期转为周几
  14. 有关Kubernetes监控的4大常见陷阱,注意避免!
  15. 如何打开.hdx文件
  16. 容安馆札记 588则 笺疏
  17. 紫光同创国产FPGA学习之IP Compiler
  18. 数字化转型常见的5种问题:除了意识和能力问题,还有什么?
  19. AspectJ 切入点表达式
  20. 用c语言实现基本数据结构(哈希表)

热门文章

  1. Python turtle 绘制六角星、多角星、小太阳
  2. 共享打印机错误代码0x0000011b修复
  3. 二、5G无线网络空中接口(1)--老狐笔记
  4. 3D游戏建模师的最低学历要求是什么?
  5. EXCEL 图表相关,如何在一个图表里有2种图形?比如折线+ 柱状图?
  6. 有序序列插入c语言,已有一个排好序的序列,输入一个数插入到该序列中,使其仍然保持有序....
  7. 关于初中物理实验室教学装备配置标准清单
  8. html+css+php+mysql 简单的页面登录与注册(数据库的交互)
  9. Python之OpenGL笔记(37):散射光下的棋盘球体
  10. 当前在大数据和人工智能领域创业能否快速崛起