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.
 
 
 

141 lines
2.8 KiB

<template>
<view class="pageBgImg">
<topNavbar title="个人二维码"></topNavbar>
<view class="pad">
<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;"></image>
</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: 2,
tabArr: [
{text: '教练码', id: 1},
{text: '签到码', id: 2},
{text: '签退码', id: 3},
]
}
},
onShow() {
this.refresh()
// this.test()
},
onPullDownRefresh() {
this.refresh()
},
onHide() {
console.log('清除了')
clearTimeout(this.timer)
this.timer = null
},
beforeDestroy() {
clearTimeout(this.timer)
this.timer = null
// this.refresh = null
},
methods: {
test() {
function newObj(name) {
this.name = name
}
let myname = new newObj('joe')
const dep = this.depClone(myname, newObj)
console.log(dep)
},
depClone(obj, fu) {
let protoType = fu.protoType
},
changeTab(item) {
if(item.id==this.currentType) return
this.currentType = item.id
this.refresh()
},
async refresh() {
const {data: res} = await getQR({type: this.currentType})
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>
.qcode {
width: 100%;
display: flex;
align-items: center;
justify-content: center;
padding: 20rpx 0;
}
.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>