You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
179 lines
4.0 KiB
179 lines
4.0 KiB
<template>
|
|
<view class="pageBgImg">
|
|
<topNavbar title="个人二维码"></topNavbar>
|
|
<view class="pad">
|
|
<view class="adrsCon">
|
|
<view class="adr" v-if="vuex_cityInfo.city" @click="getLatLngFn">{{vuex_cityInfo.city}} <text v-if="vuex_cityInfo.name"> / {{vuex_cityInfo.name}}</text></view>
|
|
<view class="adr" v-else @click="getLatLngFn" style="display: flex;align-items: center;">
|
|
<text>获取定位信息</text>
|
|
<!-- <image src="@/static/images/index/down.png" mode="" style="width: 18rpx;height: 18rpx;margin-left: 6rpx;"></image> -->
|
|
</view>
|
|
<view class="adrsIcon">
|
|
<image src="@/static/images/index/down.png" mode=""></image>
|
|
</view>
|
|
</view>
|
|
<view class="tabs">
|
|
<view class="tab" v-for="(item,index) in tabArr" :key="index" :class="{active: currentType==item.id}"
|
|
@click="changeTab(item)">{{ item.text }}</view>
|
|
</view>
|
|
<view class="card">
|
|
<view class="refresh_row" @click="refresh">
|
|
<view class="text">刷新二维码</view>
|
|
<view class="icon">
|
|
<image src="@/static/images/index/ic_shuaxin.png" mode=""></image>
|
|
</view>
|
|
</view>
|
|
<view class="qcode">
|
|
<image :src="ossUrl" mode="widthFix" style="width: 500rpx;height: 500rpx;" v-if="ossUrl"></image>
|
|
<view class="txt" v-else>正在加载~</view>
|
|
</view>
|
|
</view>
|
|
<!-- <view class="card">
|
|
<user-info/>
|
|
</view> -->
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import { getQR } from '@/config/api.js'
|
|
export default {
|
|
data() {
|
|
return {
|
|
timer: null,
|
|
ossUrl: '',
|
|
currentType: 4,
|
|
tabArr: [
|
|
{text: '签到码', id: 4},
|
|
{text: '签退码', id: 5},
|
|
]
|
|
}
|
|
},
|
|
onShow() {
|
|
this.refresh()
|
|
// this.test()
|
|
},
|
|
onLoad() {
|
|
this.$store.dispatch('getCity')
|
|
},
|
|
onPullDownRefresh() {
|
|
this.refresh()
|
|
},
|
|
onHide() {
|
|
console.log('清除了')
|
|
clearTimeout(this.timer)
|
|
this.timer = null
|
|
},
|
|
beforeDestroy() {
|
|
clearTimeout(this.timer)
|
|
this.timer = null
|
|
// this.refresh = null
|
|
},
|
|
methods: {
|
|
async getLatLngFn() {
|
|
try{
|
|
uni.showLoading({
|
|
title: '正在更新位置...'
|
|
})
|
|
await this.$store.dispatch('getCity')
|
|
this.refresh()
|
|
}catch(e){
|
|
uni.hideLoading()
|
|
}
|
|
},
|
|
changeTab(item) {
|
|
if(item.id==this.currentType) return
|
|
this.currentType = item.id
|
|
this.refresh()
|
|
},
|
|
async refresh() {
|
|
this.ossUrl = ''
|
|
if(!this.vuex_cityInfo.lng) return this.$u.toast('没有获取到您的定位信息')
|
|
const {data: res} = await getQR({type: this.currentType, lng: this.vuex_cityInfo.lng, lat: this.vuex_cityInfo.lat})
|
|
// const {data: res} = await getQR({type: this.currentType, lng: '120.214842', lat: '30.342599'})
|
|
this.ossUrl = res.ossUrl
|
|
clearTimeout(this.timer)
|
|
if(this.currentType!=1) {
|
|
this.timer = setTimeout(()=>{
|
|
console.log('刷新了')
|
|
this.refresh()
|
|
},1000*20)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.adrsCon {
|
|
display: flex;
|
|
align-items: center;
|
|
// width: 180rpx;
|
|
height: 88rpx;
|
|
.adrsIcon {
|
|
width: 17rpx;
|
|
height: 17rpx;
|
|
margin-top: 4rpx;
|
|
}
|
|
|
|
.adr {
|
|
padding-right: 14rpx;
|
|
font-size: 28rpx;
|
|
color: #fff;
|
|
}
|
|
}
|
|
.pageBgImg {
|
|
&::before {
|
|
height: 424rpx;
|
|
}
|
|
}
|
|
.qcode {
|
|
width: 100%;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 20rpx 0;
|
|
height: 500rpx;
|
|
}
|
|
.card {
|
|
padding: 28rpx;
|
|
margin-bottom: 24rpx;
|
|
}
|
|
.refresh_row {
|
|
display: flex;
|
|
justify-content: flex-end;
|
|
align-items: center;
|
|
padding: 10rpx 0;
|
|
.text {
|
|
color: $themC;
|
|
font-size: 28rpx;
|
|
}
|
|
.icon {
|
|
width: 24rpx;
|
|
height: 24rpx;
|
|
margin-left: 6rpx;
|
|
}
|
|
}
|
|
|
|
.tabs {
|
|
height: 72rpx;
|
|
background: #FFFFFF;
|
|
border-radius: 16rpx;
|
|
display: flex;
|
|
line-height: 72rpx;
|
|
text-align: center;
|
|
color: #ADADAD;
|
|
margin: 24rpx 0;
|
|
.tab {
|
|
flex: 1;
|
|
text-align: center;
|
|
|
|
&.active {
|
|
background: rgba(25, 137, 250, 0.1);
|
|
border: 2rpx solid #1989FA;
|
|
color: $themC;
|
|
border-radius: 16rpx;
|
|
}
|
|
}
|
|
}
|
|
</style>
|