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

8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 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;"></image>
  19. </view>
  20. </view>
  21. <!-- <view class="card">
  22. <user-info/>
  23. </view> -->
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. import { getQR } from '@/config/api.js'
  30. export default {
  31. data() {
  32. return {
  33. timer: null,
  34. ossUrl: '',
  35. currentType: 2,
  36. tabArr: [
  37. {text: '教练码', id: 1},
  38. {text: '签到码', id: 2},
  39. {text: '签退码', id: 3},
  40. ]
  41. }
  42. },
  43. onShow() {
  44. this.refresh()
  45. // this.test()
  46. },
  47. onPullDownRefresh() {
  48. this.refresh()
  49. },
  50. onHide() {
  51. console.log('清除了')
  52. clearTimeout(this.timer)
  53. this.timer = null
  54. },
  55. beforeDestroy() {
  56. clearTimeout(this.timer)
  57. this.timer = null
  58. // this.refresh = null
  59. },
  60. methods: {
  61. changeTab(item) {
  62. if(item.id==this.currentType) return
  63. this.currentType = item.id
  64. this.refresh()
  65. },
  66. async refresh() {
  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. }
  88. .card {
  89. padding: 28rpx;
  90. margin-bottom: 24rpx;
  91. }
  92. .refresh_row {
  93. display: flex;
  94. justify-content: flex-end;
  95. align-items: center;
  96. padding: 10rpx 0;
  97. .text {
  98. color: $themC;
  99. font-size: 28rpx;
  100. }
  101. .icon {
  102. width: 24rpx;
  103. height: 24rpx;
  104. margin-left: 6rpx;
  105. }
  106. }
  107. .tabs {
  108. height: 72rpx;
  109. background: #FFFFFF;
  110. border-radius: 16rpx;
  111. display: flex;
  112. line-height: 72rpx;
  113. text-align: center;
  114. color: #ADADAD;
  115. margin: 24rpx 0;
  116. .tab {
  117. flex: 1;
  118. text-align: center;
  119. &.active {
  120. background: rgba(25, 137, 250, 0.1);
  121. border: 2rpx solid #1989FA;
  122. color: $themC;
  123. border-radius: 16rpx;
  124. }
  125. }
  126. }
  127. </style>