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.

135 lines
2.7 KiB

9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
6 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
6 months ago
9 months ago
9 months ago
9 months ago
  1. <template>
  2. <view class="pageBg">
  3. <view class="pageBgImg">
  4. <topNavbar title="个人二维码"></topNavbar>
  5. <view class="pad">
  6. <view class="tabs">
  7. <view class="tab" v-for="(item,index) in tabArr" :key="index" :class="{active: currentType==item.id}"
  8. @click="changeTab(item)">{{ item.text }}</view>
  9. </view>
  10. <view class="card">
  11. <view class="refresh_row" @click="refresh">
  12. <view class="text">刷新二维码</view>
  13. <view class="icon">
  14. <image src="@/static/images/index/ic_shuaxin.png" mode=""></image>
  15. </view>
  16. </view>
  17. <view class="qcode">
  18. <image :src="ossUrl" mode="widthFix" style="width: 500rpx;height: 500rpx;" v-if="ossUrl"></image>
  19. <view class="txt" v-else>正在加载~</view>
  20. </view>
  21. </view>
  22. <!-- <view class="card">
  23. <user-info/>
  24. </view> -->
  25. </view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. import { getQR } from '@/config/api.js'
  31. export default {
  32. data() {
  33. return {
  34. timer: null,
  35. ossUrl: '',
  36. currentType: 2,
  37. tabArr: [
  38. {text: '教练码', id: 1},
  39. {text: '签到码', id: 2},
  40. {text: '签退码', id: 3},
  41. ]
  42. }
  43. },
  44. onShow() {
  45. this.refresh()
  46. // this.test()
  47. },
  48. onPullDownRefresh() {
  49. this.refresh()
  50. },
  51. onHide() {
  52. console.log('清除了')
  53. clearTimeout(this.timer)
  54. this.timer = null
  55. },
  56. beforeDestroy() {
  57. clearTimeout(this.timer)
  58. this.timer = null
  59. // this.refresh = null
  60. },
  61. methods: {
  62. changeTab(item) {
  63. if(item.id==this.currentType) return
  64. this.currentType = item.id
  65. this.refresh()
  66. },
  67. async refresh() {
  68. this.ossUrl = ''
  69. const {data: res} = await getQR({type: this.currentType})
  70. this.ossUrl = res.ossUrl
  71. clearTimeout(this.timer)
  72. if(this.currentType!=1) {
  73. this.timer = setTimeout(()=>{
  74. console.log('刷新了')
  75. this.refresh()
  76. },1000*20)
  77. }
  78. }
  79. }
  80. }
  81. </script>
  82. <style lang="scss" scoped>
  83. .qcode {
  84. width: 100%;
  85. display: flex;
  86. align-items: center;
  87. justify-content: center;
  88. padding: 20rpx 0;
  89. height: 500rpx;
  90. }
  91. .card {
  92. padding: 28rpx;
  93. margin-bottom: 24rpx;
  94. }
  95. .refresh_row {
  96. display: flex;
  97. justify-content: flex-end;
  98. align-items: center;
  99. padding: 10rpx 0;
  100. .text {
  101. color: $themC;
  102. font-size: 28rpx;
  103. }
  104. .icon {
  105. width: 24rpx;
  106. height: 24rpx;
  107. margin-left: 6rpx;
  108. }
  109. }
  110. .tabs {
  111. height: 72rpx;
  112. background: #FFFFFF;
  113. border-radius: 16rpx;
  114. display: flex;
  115. line-height: 72rpx;
  116. text-align: center;
  117. color: #ADADAD;
  118. margin: 24rpx 0;
  119. .tab {
  120. flex: 1;
  121. text-align: center;
  122. &.active {
  123. background: rgba(25, 137, 250, 0.1);
  124. border: 2rpx solid #1989FA;
  125. color: $themC;
  126. border-radius: 16rpx;
  127. }
  128. }
  129. }
  130. </style>