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.

140 lines
2.8 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
  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;"></image>
  18. </view>
  19. </view>
  20. <!-- <view class="card">
  21. <user-info/>
  22. </view> -->
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import { getQR } from '@/config/api.js'
  28. export default {
  29. data() {
  30. return {
  31. timer: null,
  32. ossUrl: '',
  33. currentType: 2,
  34. tabArr: [
  35. {text: '教练码', id: 1},
  36. {text: '签到码', id: 2},
  37. {text: '签退码', id: 3},
  38. ]
  39. }
  40. },
  41. onShow() {
  42. this.refresh()
  43. // this.test()
  44. },
  45. onPullDownRefresh() {
  46. this.refresh()
  47. },
  48. onHide() {
  49. console.log('清除了')
  50. clearTimeout(this.timer)
  51. this.timer = null
  52. },
  53. beforeDestroy() {
  54. clearTimeout(this.timer)
  55. this.timer = null
  56. // this.refresh = null
  57. },
  58. methods: {
  59. test() {
  60. function newObj(name) {
  61. this.name = name
  62. }
  63. let myname = new newObj('joe')
  64. const dep = this.depClone(myname, newObj)
  65. console.log(dep)
  66. },
  67. depClone(obj, fu) {
  68. let protoType = fu.protoType
  69. },
  70. changeTab(item) {
  71. if(item.id==this.currentType) return
  72. this.currentType = item.id
  73. this.refresh()
  74. },
  75. async refresh() {
  76. const {data: res} = await getQR({type: this.currentType})
  77. this.ossUrl = res.ossUrl
  78. clearTimeout(this.timer)
  79. if(this.currentType!=1) {
  80. this.timer = setTimeout(()=>{
  81. console.log('刷新了')
  82. this.refresh()
  83. },1000*20)
  84. }
  85. }
  86. }
  87. }
  88. </script>
  89. <style lang="scss" scoped>
  90. .qcode {
  91. width: 100%;
  92. display: flex;
  93. align-items: center;
  94. justify-content: center;
  95. padding: 20rpx 0;
  96. }
  97. .card {
  98. padding: 28rpx;
  99. margin-bottom: 24rpx;
  100. }
  101. .refresh_row {
  102. display: flex;
  103. justify-content: flex-end;
  104. align-items: center;
  105. padding: 10rpx 0;
  106. .text {
  107. color: $themC;
  108. font-size: 28rpx;
  109. }
  110. .icon {
  111. width: 24rpx;
  112. height: 24rpx;
  113. margin-left: 6rpx;
  114. }
  115. }
  116. .tabs {
  117. height: 72rpx;
  118. background: #FFFFFF;
  119. border-radius: 16rpx;
  120. display: flex;
  121. line-height: 72rpx;
  122. text-align: center;
  123. color: #ADADAD;
  124. margin: 24rpx 0;
  125. .tab {
  126. flex: 1;
  127. text-align: center;
  128. &.active {
  129. background: rgba(25, 137, 250, 0.1);
  130. border: 2rpx solid #1989FA;
  131. color: $themC;
  132. border-radius: 16rpx;
  133. }
  134. }
  135. }
  136. </style>