自定义扫码界面

lixuan
xk_guohonglei 5 years ago
parent 9320a99366
commit 679c43a03e
  1. 70
      pages/home/home.vue
  2. 39
      pages/index/index.vue
  3. 8
      pages/login/posLogin/posLogin.vue
  4. 54
      pages/orderList/OrderDetail/OrderDetail.vue
  5. 11
      pages/qrcode/QrCode_xy.vue
  6. 300
      pages/station-info/scan-camera/scan-camera.vue
  7. BIN
      static/img/backBar.png
  8. BIN
      static/img/scanBar.png
  9. BIN
      static/img/yellow-scanBar.png
  10. 6
      utils/request.js

@ -4,6 +4,7 @@
<block slot="content">{{site.oilSiteName?site.oilSiteName:'星油云站'}}</block> <block slot="content">{{site.oilSiteName?site.oilSiteName:'星油云站'}}</block>
</cu-custom> </cu-custom>
<view class="main-money bg-main-oil"> <view class="main-money bg-main-oil">
<view class="padding-xs flex align-center"> <view class="padding-xs flex align-center">
<view class="flex-sub text-center padding-top-lg"> <view class="flex-sub text-center padding-top-lg">
<view class="txet-xxs"> <view class="txet-xxs">
@ -98,14 +99,14 @@
<script> <script>
import cloudSiteApi from '@/api/cloud-site.js' import cloudSiteApi from '@/api/cloud-site.js'
export default { export default {
props:{ props: {
userAccount:{ userAccount: {
type:Object, type: Object,
default(){} default () {}
}, },
site:{ site: {
type:Object, type: Object,
default(){} default () {}
} }
}, },
data() { data() {
@ -172,40 +173,33 @@
} }
}, },
methods: { methods: {
scanQr() { scanQr() {
var that = this var scanUrl
uni.scanCode({ scanUrl = '/pages/station-info/scan-camera/scan-camera'
onlyFromCamera: true, uni.navigateTo({
success: function(res) { url: scanUrl,
console.log('条码类型:' + res.scanType); fail: (err) => {
console.log('条码内容:' + res.result); console.log(err)
uni.setStorageSync('qrCode', res.result) },
uni.navigateTo({ success: (res) => {
url: that.scanUrl, console.log('chengg', res)
fail: (err) => {
console.log(err)
},
success: (res) => {
console.log('chengg', res)
}
})
}, },
// 便
// complete: () => {
// uni.setStorageSync('qrCode', 'XM&1309328197641433088')
// uni.navigateTo({
// url: that.scanUrl,
// fail: (err) => {
// console.log(err)
// },
// success: (res) => {
// console.log('chengg', res)
// }
// })
// }
}) })
// 便
// complete: () => {
// uni.setStorageSync('qrCode', 'XM&1309328197641433088')
// uni.navigateTo({
// url: that.scanUrl,
// fail: (err) => {
// console.log(err)
// },
// success: (res) => {
// console.log('chengg', res)
// }
// })
// }
}, },
// 便 // 便
// scanQr() { // scanQr() {

@ -3,12 +3,6 @@
<home v-if="PageCur=='home'||PageCur=='scan'" :user-account="userAccount" :site="site"></home> <home v-if="PageCur=='home'||PageCur=='scan'" :user-account="userAccount" :site="site"></home>
<setup v-if="PageCur=='setup'"></setup> <setup v-if="PageCur=='setup'"></setup>
<view class="action text-gray add-action" @tap="scanCode1" data-cur="scan">
<button class="cu-btn cuIcon-scan sl shadow" :class="PageCur=='scan'?'bg-main-oil':'bg-gradual-orange'"></button>
<text :class="PageCur=='scan'?'text-red':'text-gray'">
一键扫码
</text>
</view>
<view class="bottom-view"> <view class="bottom-view">
@ -58,6 +52,7 @@
this.getUserInfo() this.getUserInfo()
}, },
onShow() { onShow() {
uni.preloadPage({url: "/pages/station-info/scan-camera/scan-camera"});
const token = uni.getStorageSync('Authorization') const token = uni.getStorageSync('Authorization')
const openid = uni.getStorageSync('device') const openid = uni.getStorageSync('device')
if (token && openid) { if (token && openid) {
@ -83,11 +78,7 @@
} }
}, },
methods: { methods: {
scanCode1(){
uni.navigateTo({
url:'/pages/station-info/scan-camera/scan-camera'
})
},
getSiteInfo() { getSiteInfo() {
cloudSiteApi.getSiteDetail().then(res => { cloudSiteApi.getSiteDetail().then(res => {
if (res.code === 20000) { if (res.code === 20000) {
@ -106,7 +97,6 @@
uni.stopPullDownRefresh(); uni.stopPullDownRefresh();
if (res.code === 20000) { if (res.code === 20000) {
this.userAccount = res.data this.userAccount = res.data
} }
}) })
@ -122,22 +112,15 @@
var scanUrl var scanUrl
this.userMenu.forEach((item, index) => { this.userMenu.forEach((item, index) => {
if (item.name === '扫码加油') { if (item.name === '扫码加油') {
scanUrl = item.path // scanUrl = item.path
uni.scanCode({ scanUrl = '/pages/station-info/scan-camera/scan-camera'
onlyFromCamera: true, uni.navigateTo({
success: function(res) { url: scanUrl,
console.log('条码类型:' + res.scanType); fail: (err) => {
console.log('条码内容:' + res.result); console.log(err)
uni.setStorageSync('qrCode', res.result) },
uni.navigateTo({ success: (res) => {
url: scanUrl, console.log('chengg', res)
fail: (err) => {
console.log(err)
},
success: (res) => {
console.log('chengg', res)
}
})
} }
}) })

@ -36,7 +36,9 @@
<view class="margin-lg padding-lg bottom-bg"> <view class="margin-lg padding-lg bottom-bg">
<button class="bg-main-oil round" v-if="showRandom" @tap="loginRandom">登录</button> <button class="bg-main-oil round" v-if="showRandom" @tap="loginRandom">登录</button>
<button class="bg-main-oil round" v-else @tap="loginPwd">登录</button> <button class="bg-main-oil round" v-else @tap="loginPwd">登录</button>
</view> </view>
<official-account @binderror="bindload" @bindload="binderror"></official-account>
<view class="bottom-part"> <view class="bottom-part">
<service-hotline /> <service-hotline />
</view> </view>
@ -66,6 +68,12 @@
uni.showShareMenu() uni.showShareMenu()
}, },
methods: { methods: {
bindload(){
console.log('组件夹杂')
},
binderror(){
console.log('组件夹杂失败')
},
loginWeixin() { loginWeixin() {
uni.login({ uni.login({
provider: 'weixin', provider: 'weixin',

@ -104,12 +104,12 @@
</view> </view>
<view class="padding-lg padding-top-0 padding-bottom-xl"> <view class="padding-lg padding-top-0 padding-bottom-xl">
<button v-show="formQr" @tap="scanQr" class="bg-main-oil margin-bottom"> <button v-show="formQr" @tap="scanQr" class="bg-main-oil margin-bottom">
<text class="cuIcon-scan padding-right-xs"></text> <text class="cuIcon-scan padding-right-xs"></text>
继续加油</button> 继续加油</button>
<button class="bg-red light margin-bottom" @tap="backHome"> <button class="bg-red light margin-bottom" @tap="backHome">
<text class="cuIcon-home padding-right-xs"></text> <text class="cuIcon-home padding-right-xs"></text>
返回首页</button> 返回首页</button>
</view> </view>
</view> </view>
</template> </template>
@ -120,7 +120,7 @@
return { return {
// orderId:'', // orderId:'',
orderId: uni.getStorageSync('orderId'), orderId: uni.getStorageSync('orderId'),
formQr: uni.getStorageSync('formQr')?true:false, formQr: uni.getStorageSync('formQr') ? true : false,
orderItem: {}, orderItem: {},
baseURL: this.global.baseURL baseURL: this.global.baseURL
} }
@ -128,53 +128,31 @@
created() { created() {
this.getOrderDetail() this.getOrderDetail()
}, },
onHide(){ onHide() {
this.clearStatus() this.clearStatus()
}, },
onUnload() { onUnload() {
this.clearStatus() this.clearStatus()
}, },
methods: { methods: {
clearStatus(){ clearStatus() {
uni.removeStorageSync('formQr') uni.removeStorageSync('formQr')
}, },
scanQr() { scanQr() {
var that = this scanUrl = '/pages/station-info/scan-camera/scan-camera'
uni.scanCode({ uni.navigateTo({
onlyFromCamera: true, url: scanUrl,
success: function(res) { fail: (err) => {
console.log('条码类型:' + res.scanType); console.log(err)
console.log('条码内容:' + res.result);
uni.setStorageSync('qrCode', res.result)
uni.navigateTo({
url: '/pages/stationDetail/stationDetail',
fail: (err) => {
console.log(err)
},
success: (res) => {
console.log('chengg', res)
}
})
}, },
// 便 success: (res) => {
// complete: () => { console.log('chengg', res)
// uni.setStorageSync('qrCode', 'XM&1309328197641433088') }
// uni.navigateTo({
// url: that.scanUrl,
// fail: (err) => {
// console.log(err)
// },
// success: (res) => {
// console.log('chengg', res)
// }
// })
// }
}) })
}, },
backHome(){ backHome() {
uni.navigateBack({ uni.navigateBack({
delta:2 delta: 2
}) })
}, },
copyId(id, name) { copyId(id, name) {

@ -15,13 +15,13 @@
@result="qrR" /> @result="qrR" />
</view> </view>
</view> </view>
<view @tap="refreashQr" class="text-center padding-bottom-xs padding-bottom-xs"> <view @tap="refreashQr" class="text-center padding-top padding-bottom-xs padding-bottom-xs">
<text class="color-999 font-12"> <text class="color-999 font-12">
<text class="cuIcon-refresh padding-right-xs"></text> <text class="cuIcon-refresh padding-right-xs"></text>
<!-- 付款码自动 25s --> <!-- 付款码自动 25s -->
付款码 付款码
<text class="oil-main-color"> <text class="oil-main-color">
刷新 刷新
</text> </text>
</text> </text>
</view> </view>
@ -93,7 +93,7 @@
// //
import QR from "@/utils/wxqrcode.js" // import QR from "@/utils/wxqrcode.js" //
import cloudSiteApi from '@/api/cloud-site.js' import cloudSiteApi from '@/api/cloud-site.js'
import tkiQrcode from "@/components/tki-qrcode/tki-qrcode.vue" import tkiQrcode from "@/components/tki-qrcode/tki-qrcode.vue" //
export default { export default {
components: { components: {
@ -103,6 +103,7 @@
data() { data() {
return { return {
oilList: [], oilList: [],
xkPrice:'',
modalName: 'mod', modalName: 'mod',
oilSiteName: '', oilSiteName: '',
qrImg: "https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=1102530589,2787379918&fm=11&gp=0.jpg", qrImg: "https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=1102530589,2787379918&fm=11&gp=0.jpg",
@ -183,7 +184,7 @@
console.log('5555') console.log('5555')
}, },
qrInit() { qrInit() {
this.qrImg = QR.createQrCodeImg('我是您粑粑', { this.qrImg = QR.createQrCodeImg({
size: parseInt(300) // size: parseInt(300) //
}) })
console.log('this.qrImg', this.qrImg) console.log('this.qrImg', this.qrImg)

@ -1,96 +1,240 @@
<template> <template>
<view> <view class="page-content">
<view class="scan-view"> <cu-custom :isBack="true" class="main-topbar bg-main-oil" bgColor="bg-main-oil">
<view class='scan-border'> <block slot="content">扫描二维码</block>
<camera class='scan-camera' mode="scanCode" binderror="cameraError" bindscancode='scancode' frame-size='large'> <block slot="backText">返回</block>
<cover-image class='cover-corner cover-left-top' src='/images/left-top.png'></cover-image> </cu-custom>
<cover-image class='cover-corner cover-right-top' src='/images/right-top.png'></cover-image> <camera class='scan-camera' :flash="flashValue" mode="scanCode" binderror="cameraError" bindscancode='scancode'
<cover-image class='cover-corner cover-left-bottom' src='/images/left-bottom.png'></cover-image> @scancode="scancode" frame-size='large'>
<cover-image class='cover-corner cover-right-bottom' src='/images/right-bottom.png'></cover-image> <cover-view class='scan-animation' :animation="animationData2"></cover-view>
<cover-view class="cover-aquare">
<!-- <cover-view class='scan-animation' animation="{{animation}}"></cover-view> --> <cover-view class='cover-aquare-inner'></cover-view>
</camera> <cover-view class='cover-corner cover-left-top'>
<!-- 这里可以处理其他内容 --> <cover-view class="w-line"></cover-view>
</view> <cover-view class="h-line"></cover-view>
</view> </cover-view>
<cover-view class='cover-corner cover-right-top'>
<cover-view class="w-line w1-line"></cover-view>
<cover-view class="h-line h1-line"></cover-view>
</cover-view>
<cover-view class='cover-corner cover-left-bottom'>
<cover-view class="h-line"></cover-view>
<cover-view class="w-line"></cover-view>
</cover-view>
<cover-view class='cover-corner cover-right-bottom'>
<cover-view class="h-line h3-line"></cover-view>
<cover-view class="w-line w3-line"></cover-view>
</cover-view>
</cover-view>
<cover-view class="flash text-center">
<cover-view @tap="touchFlash" class=" text-white lg" v-show="flashValue!='on'">
打开手电筒
</cover-view>
<cover-view @tap="touchFlash" class=" text-white lg" v-show="flashValue=='on'">
关闭手电筒
</cover-view>
</cover-view>
</camera>
</view> </view>
</template> </template>
<script> <script>
let diSrc = 'http://downsc.chinaz.net/Files/DownLoad/sound1/201711/9360.mp3'
let innerAudioContext = wx.createInnerAudioContext()
innerAudioContext.src = diSrc
export default { export default {
data() { data() {
return { return {
once: false,
lightOn: false,
animationData2: {},
flashValue: 'auto'
} }
}, },
onShow() {
this.donghua()
setInterval(() => {
this.donghua()
}, 6000);
},
// onShow() {
// this.donghua()
// },
methods: { methods: {
touchFlash() {
if (this.flashValue != 'on') {
this.flashValue = 'on'
} else if (this.flashValue == 'on') {
this.flashValue = 'off'
}
},
donghua() {
var animation2 = uni.createAnimation({
duration: 1000,
timingFunction: 'linear',
})
this.animation2 = animation2
animation2.translateY(235).step({
duration: 3000
})
this.animationData2 = animation2.export()
setTimeout(() => {
animation2.translateY(0).step({
duration: 3000
})
this.animationData2 = animation2.export()
}, 3000)
},
scancode(e) {
if (!this.once) {
var scanUrl = '/pages/stationDetail/stationDetail'
// uni.getStorageSync('scanUrl')
//
innerAudioContext.play()
console.log('play滴~')
//
let res = e.detail.result
console.log(res)
console.log(e)
uni.setStorageSync('qrCode', res)
this.once = true
uni.redirectTo({
url: scanUrl,
fail: (err) => {
console.log(err)
},
success: (res) => {
console.log('chengg', res)
}
})
}
}
} }
} }
</script> </script>
<style scoped> <style scoped>
.scan-view { .page-content {
width: 100%; overflow: hidden;
height: 100%; }
display: flex;
flex-direction: column; .scan-camera {
background-color: #B9BEC4; width: 750upx;
position: fixed; height: 92vh;
align-items: center; border-radius: 6rpx;
justify-content: space-around; }
}
.cover-corner {
.scan-border { position: absolute;
width: 94%; z-index: 2;
height: 94%; }
border: 6rpx solid #08FDFE;
border-radius: 10rpx; .cover-left-top {
display: flex; left: 0upx;
flex-direction: column; top: 0upx;
align-items: center;
} }
.scan-camera { .cover-right-top {
width: 500rpx; right: 0;
height: 500rpx; top: 0;
border-radius: 6rpx;
margin: 30rpx; }
}
.cover-left-bottom {
.cover-corner { left: 0;
width: 80rpx; bottom: 0;
height: 80rpx;
position: absolute; }
}
.cover-right-bottom {
.cover-left-top { right: 0;
left: 0; bottom: 0;
top: 0;
} }
.cover-right-top { .scan-animation {
right: 0; position: absolute;
top: 0; width: 480rpx;
} height: 8rpx;
top: 200upx;
.cover-left-bottom { left: 135upx;
left: 0; background-color: #FE0505;
bottom: 0; border-radius: 50%;
} box-shadow: 5upx 5upx 0 10upx #FE0505;
}
.cover-right-bottom {
right: 0; .cover-aquare-inner {
bottom: 0; position: absolute;
} top: 0;
left: 0;
.scan-animation { right: 0;
position: absolute; bottom: 0;
top: -10rpx; border: 2upx solid #f1f3f7;
left: 10rpx; }
width: 480rpx;
height: 8rpx; .cover-aquare {
background-color: #08FDFE; position: absolute;
border-radius: 50%; width: 500upx;
} height: 500upx;
overflow: inherit;
top: 200upx;
left: 125upx;
/* border: 1px solid #FE0505; */
}
.h-line {
width: 10upx;
height: 20upx;
background-color: #FE0505;
}
.w-line {
width: 30upx;
height: 10upx;
background-color: #FE0505;
}
.h1-line {
width: 10upx;
float: right;
height: 20upx;
}
.w1-line {
width: 30upx;
height: 10upx;
}
.h3-line {
right: -21upx;
position: relative;
z-index: 4;
}
.flash {
position: absolute;
width: 750upx;
top: 800upx;
z-index: 4;
}
.cu-avatar {
text-align: center;
background: transparent;
}
.cu-avatar [class*="cuIcon-"] {
padding-left: 1.5rem;
}
</style> </style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

@ -2,8 +2,12 @@ import axios from 'axios'
import utils from '@/utils/encode' import utils from '@/utils/encode'
const service = axios.create({ const service = axios.create({
// baseURL: 'http://192.168.0.104:48080', // 小杰 // baseURL: 'http://192.168.0.104:48080', // 小杰
baseURL: 'http://a27389c632.qicp.vip', // baseURL: 'http://a27389c632.qicp.vip', // 生产
// baseURL: 'http://121.199.72.230:2333/oil', // 生产,yds测试网关
// baseURL: 'http://192.168.0.112:48080', // 龙龙 // baseURL: 'http://192.168.0.112:48080', // 龙龙
baseURL: 'http://31g4904724.picp.vip', // 龙龙出差
// baseURL:'http://datou.wicp.vip',// 龙龙// 龙龙// 龙龙
// baseURL: 'https://www.51xingka.net/oilApp', // baseURL: 'https://www.51xingka.net/oilApp',
timeout: 5000 timeout: 5000
}) })

Loading…
Cancel
Save