更新
This commit is contained in:
@@ -1,27 +1,19 @@
|
||||
<template>
|
||||
<!-- 三个最近的油站弹窗 -->
|
||||
<!-- 三个最近的油站弹窗 -->
|
||||
<view>
|
||||
<view class="cu-modal" :class="showThreeSites?'show':''">
|
||||
<view class="cu-modal" :class="showThreeSites?'show':''" @touchmove.stop>
|
||||
<view class="cu-dialog">
|
||||
<view class="cu-bar bg-white justify-end">
|
||||
<view class="content">选择油站</view>
|
||||
<view class="action" @tap="hideModal('sites')">
|
||||
<!-- <view class="content">选择油站</view> -->
|
||||
<view class="action" @tap="hideModal">
|
||||
<text class="cuIcon-close text-red"></text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="padding-xl bg-white">
|
||||
<view class="" v-if="siteList.length>0">
|
||||
<three-item v-for="(item,index) in siteList" :key="item.id" :site-item="item" :first="index==0"
|
||||
class="cu-list menu-avatar cu-item " @tap="toDetail(item)">
|
||||
</three-item>
|
||||
</view>
|
||||
<view class="" v-else>
|
||||
<my-empty></my-empty>
|
||||
</view>
|
||||
<view class="btn-box padding-top">
|
||||
<button @tap="toSitePage" class="cu-tn bg-red round margin-bottom lg" color="#3982F6"
|
||||
size="large">前往油站列表查找
|
||||
</button>
|
||||
<view class="bg-white pb30">
|
||||
<tki-qrcode ref="qrcode" cid="2" :val="qrcodeText" :size="400" :isHaveBg="true" pdground="#000"
|
||||
foreground="#000" background="#fff" onval showLoading loadMake />
|
||||
<view class="text-center padding-top text-sm margin-bottom">
|
||||
提示:该二维码每隔<text style="color: #ff0000;">3分钟</text>自动刷新一次
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -31,11 +23,13 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import oilSiteApi from '@/api/oil-site.js'
|
||||
import threeItem from './three-item.vue'
|
||||
import serve from '@/api/oil-site.js'
|
||||
import accountApi from '@/api/account.js'
|
||||
|
||||
import tkiQrcode from '@/components/tki-qrcode/tki-qrcode.vue'
|
||||
export default {
|
||||
components: {
|
||||
threeItem
|
||||
tkiQrcode
|
||||
},
|
||||
props: {
|
||||
showThreeSites: {
|
||||
@@ -45,91 +39,63 @@
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
siteList: [],
|
||||
imgURL: this.global.baseURL,
|
||||
qrcodeText: '',
|
||||
user: uni.getStorageSync('user'),
|
||||
timerInstance: null
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getSiteList()
|
||||
},
|
||||
watch:{
|
||||
showThreeSites:{
|
||||
handler(newval){
|
||||
if(newval==true){
|
||||
this.getSiteList()
|
||||
|
||||
watch: {
|
||||
showThreeSites: {
|
||||
handler(newval) {
|
||||
if (newval) {
|
||||
this.initQRCode()
|
||||
}
|
||||
}
|
||||
},
|
||||
immediate: true
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
toSitePage(){
|
||||
// uni.setStorageSync('activeCur','station')
|
||||
uni.switchTab({
|
||||
url: '/pages/tabbar/station/stationList'
|
||||
});
|
||||
},
|
||||
refreshLocation(){
|
||||
uni.getLocation({
|
||||
type: 'wgs84',
|
||||
success: function (res) {
|
||||
uni.setStorageSync('location',res)
|
||||
}
|
||||
});
|
||||
},
|
||||
getSiteList() {
|
||||
this.refreshLocation()
|
||||
let data1 = {
|
||||
currentPage: 1,
|
||||
pageSize: 3,
|
||||
params: { //类型:Object 必有字段 备注:// 筛选对象
|
||||
sort: "juli", //类型:String 必有字段 备注:// 智能排序 ( price:价格最低 juli:距离最近 ) 默认距离排序
|
||||
...uni.getStorageSync('location'),
|
||||
...this.filterData
|
||||
// siteBrand: "", // 备注:// 石油品牌 ( 1-中国石油 2-中国石化 3-壳牌 4-民营 5-中海油 6-京博 7-中化石油 8-其他 )
|
||||
// channelCode: "", // 备注:// 渠道编码 ( OIL:星油 WJY:万金油 LV:老吕(找油网) TY:团油 YDJY:一点加油(壳牌))
|
||||
// oilProductCode: "" // 备注:// 油号选择 ( 0# 92# 92#)
|
||||
}
|
||||
|
||||
|
||||
async initQRCode() {
|
||||
if (this.timerInstance) {
|
||||
clearInterval(this.timerInstance)
|
||||
this.timerInstance = null
|
||||
}
|
||||
// readOnlySites
|
||||
oilSiteApi.getSiteList(data1).then(res => {
|
||||
if (res.code == 20000) {
|
||||
this.siteList = res.data.list
|
||||
}
|
||||
|
||||
let accountResult = await accountApi.getUserAccount()
|
||||
if (!accountResult.data.length) return
|
||||
|
||||
let params = {
|
||||
companyId: accountResult.data[0].companyId,
|
||||
orderSource: "WECHAT_MINIAPPS",
|
||||
customerId: this.user.id,
|
||||
channelCode: 'XOIL',
|
||||
oilCardNature: accountResult.data[0].oilCardType, //油卡性质
|
||||
accountCardCode: accountResult.data[0].accountCardCode //油卡卡号
|
||||
}
|
||||
|
||||
serve.getOilDriverQrCode(params).then(res => {
|
||||
if (!res.data) return
|
||||
this.qrcodeText = res.data.codeStr
|
||||
})
|
||||
|
||||
|
||||
this.timerInstance = setInterval(() => {
|
||||
serve.getOilDriverQrCode(params).then(res => {
|
||||
if (!res.data) return
|
||||
this.qrcodeText = res.data.codeStr
|
||||
})
|
||||
}, 1000 * 60 * 3)
|
||||
},
|
||||
toDetail(item) {
|
||||
let itemS = JSON.stringify(item)
|
||||
console.log(itemS)
|
||||
uni.navigateTo({
|
||||
url: `/BagStation/pages/stationDetail/stationDetail?item=${itemS}`,
|
||||
fail: (err) => {
|
||||
// console.log(err)
|
||||
},
|
||||
success: () => {
|
||||
// console.log('err')
|
||||
}
|
||||
})
|
||||
hideModal() {
|
||||
clearInterval(this.timerInstance)
|
||||
this.timerInstance = null
|
||||
this.$refs.qrcode._clearCode()
|
||||
this.$emit('hideOneModal')
|
||||
},
|
||||
callShipper() {
|
||||
uni.makePhoneCall({
|
||||
phoneNumber: this.waybillData.shippePhone
|
||||
})
|
||||
},
|
||||
hideModal(name) {
|
||||
this.$emit('hideOneModal', name)
|
||||
},
|
||||
registerContracts() {
|
||||
this.$emit('registerContracts')
|
||||
},
|
||||
toSetLocation() {
|
||||
this.$emit('toSetLocation')
|
||||
},
|
||||
toAuth() {
|
||||
uni.navigateTo({
|
||||
url: '认证路径'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -154,4 +120,8 @@
|
||||
left: 0.2rem;
|
||||
min-width: 100%;
|
||||
}
|
||||
|
||||
.pb30 {
|
||||
padding-bottom: 30rpx;
|
||||
}
|
||||
</style>
|
||||
|
||||
1201
components/tki-qrcode/qrcode.js
Normal file
1201
components/tki-qrcode/qrcode.js
Normal file
File diff suppressed because it is too large
Load Diff
247
components/tki-qrcode/tki-qrcode.vue
Normal file
247
components/tki-qrcode/tki-qrcode.vue
Normal file
@@ -0,0 +1,247 @@
|
||||
<template xlang="wxml" minapp="mpvue">
|
||||
<view class="tki-qrcode">
|
||||
<image v-if="isHaveBg" class="bgs" src="https://xoi-support.oss-cn-hangzhou.aliyuncs.com/星油运营小程序/qr-bg.png" />
|
||||
<canvas class="tki-qrcode-canvas" :canvas-id="cid" :style="{width:cpSize+'px',height:cpSize+'px'}" />
|
||||
<!-- <canvas :id="cid" :width="cpSize" :height="cpSize" class="tki-qrcode-canvas" /> -->
|
||||
<!-- <image v-show="show" :src="result" class="erweima" :style="{width:cpSize+'px',height:cpSize+'px'}" /> -->
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import QRCode from "./qrcode.js"
|
||||
// import indexBackgroundImage from "@/static/img/qr-bg.png"
|
||||
|
||||
let qrcode
|
||||
export default {
|
||||
name: "tki-qrcode",
|
||||
props: {
|
||||
cid: {
|
||||
type: String,
|
||||
default: 'tki-qrcode-canvas'
|
||||
},
|
||||
size: {
|
||||
type: Number,
|
||||
default: 200
|
||||
},
|
||||
unit: {
|
||||
type: String,
|
||||
default: 'upx'
|
||||
},
|
||||
show: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
val: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
background: {
|
||||
type: String,
|
||||
default: '#fff'
|
||||
},
|
||||
foreground: {
|
||||
type: String,
|
||||
default: '#000'
|
||||
},
|
||||
pdground: {
|
||||
type: String,
|
||||
default: '#000'
|
||||
},
|
||||
icon: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
iconSize: {
|
||||
type: Number,
|
||||
default: 40
|
||||
},
|
||||
lv: {
|
||||
type: Number,
|
||||
default: 3
|
||||
},
|
||||
onval: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
loadMake: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
usingComponents: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
showLoading: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
loadingText: {
|
||||
type: String,
|
||||
default: '二维码生成中'
|
||||
},
|
||||
isHaveBg: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
result: '',
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
_makeCode() {
|
||||
let that = this
|
||||
if (!this._empty(this.val)) {
|
||||
qrcode = new QRCode({
|
||||
context: that, // 上下文环境
|
||||
canvasId: that.cid, // canvas-id
|
||||
usingComponents: that.usingComponents, // 是否是自定义组件
|
||||
showLoading: that.showLoading, // 是否显示loading
|
||||
loadingText: that.loadingText, // loading文字
|
||||
text: that.val, // 生成内容
|
||||
size: that.cpSize, // 二维码大小
|
||||
background: that.background, // 背景色
|
||||
foreground: that.foreground, // 前景色
|
||||
pdground: that.pdground, // 定位角点颜色
|
||||
correctLevel: that.lv, // 容错级别
|
||||
image: that.icon, // 二维码图标
|
||||
imageSize: that.iconSize, // 二维码图标大小
|
||||
cbResult: function(res) { // 生成二维码的回调
|
||||
// that._result(res)
|
||||
},
|
||||
});
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '二维码内容不能为空',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
},
|
||||
_clearCode() {
|
||||
// this._result('')
|
||||
qrcode.clear()
|
||||
},
|
||||
_saveCode() {
|
||||
let that = this;
|
||||
if (this.result != "") {
|
||||
uni.saveImageToPhotosAlbum({
|
||||
filePath: that.result,
|
||||
success: function() {
|
||||
uni.showToast({
|
||||
title: '二维码保存成功',
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
_result(res) {
|
||||
this.result = res;
|
||||
this.$emit('result', res)
|
||||
},
|
||||
_empty(v) {
|
||||
let tp = typeof v,
|
||||
rt = false;
|
||||
if (tp == "number" && String(v) == "") {
|
||||
rt = true
|
||||
} else if (tp == "undefined") {
|
||||
rt = true
|
||||
} else if (tp == "object") {
|
||||
if (JSON.stringify(v) == "{}" || JSON.stringify(v) == "[]" || v == null) rt = true
|
||||
} else if (tp == "string") {
|
||||
if (v == "" || v == "undefined" || v == "null" || v == "{}" || v == "[]") rt = true
|
||||
} else if (tp == "function") {
|
||||
rt = false
|
||||
}
|
||||
return rt
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
size: function(n, o) {
|
||||
if (n != o && !this._empty(n)) {
|
||||
this.cSize = n
|
||||
if (!this._empty(this.val)) {
|
||||
setTimeout(() => {
|
||||
this._makeCode()
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
},
|
||||
val: function(n, o) {
|
||||
if (this.onval) {
|
||||
if (n != o && !this._empty(n)) {
|
||||
setTimeout(() => {
|
||||
this._makeCode()
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
cpSize() {
|
||||
if (this.unit == "upx") {
|
||||
return uni.upx2px(this.size)
|
||||
} else {
|
||||
return this.size
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted: function() {
|
||||
if (this.loadMake) {
|
||||
if (!this._empty(this.val)) {
|
||||
setTimeout(() => {
|
||||
this._makeCode()
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
.tki-qrcode {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.erweima {
|
||||
padding: 2%;
|
||||
background: #ffff;
|
||||
border: 1px solid #f1f1f1;
|
||||
}
|
||||
|
||||
.bgs {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
max-width: 100%;
|
||||
z-index: 0;
|
||||
background-color: #ffffff;
|
||||
padding: 2%;
|
||||
}
|
||||
|
||||
.tki-qrcode {
|
||||
position: relative;
|
||||
padding: 8%;
|
||||
background-repeat: no-repeat;
|
||||
/* background-image:url('https://xoi-support.oss-cn-hangzhou.aliyuncs.com/星油运营小程序/qr-bg.png') ; */
|
||||
}
|
||||
|
||||
.tki-qrcode-canvas {
|
||||
display: inline-block;
|
||||
background: 'transparent'
|
||||
}
|
||||
|
||||
/* .tki-qrcode-canvas {
|
||||
position: fixed;
|
||||
top: -99999upx;
|
||||
left: -99999upx;
|
||||
z-index: -99999;
|
||||
} */
|
||||
image {}
|
||||
</style>
|
||||
Reference in New Issue
Block a user