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.

132 lines
2.6 KiB

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