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.

139 lines
2.7 KiB

7 months ago
6 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
7 months ago
6 months ago
7 months ago
6 months ago
7 months ago
6 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: 400rpx;height: 400rpx;"></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.$nextTick(()=>{
  43. this.refresh()
  44. })
  45. this.test()
  46. },
  47. onHide() {
  48. console.log('清除了')
  49. clearTimeout(this.timer)
  50. this.timer = null
  51. },
  52. beforeDestroy() {
  53. clearTimeout(this.timer)
  54. this.timer = null
  55. // this.refresh = null
  56. },
  57. methods: {
  58. test() {
  59. function newObj(name) {
  60. this.name = name
  61. }
  62. let myname = new newObj('joe')
  63. const dep = this.depClone(myname, newObj)
  64. console.log(dep)
  65. },
  66. depClone(obj, fu) {
  67. let protoType = fu.protoType
  68. },
  69. changeTab(item) {
  70. if(item.id==this.currentType) return
  71. this.currentType = item.id
  72. this.refresh()
  73. },
  74. async refresh() {
  75. const {data: res} = await getQR({type: this.currentType})
  76. this.ossUrl = res.ossUrl
  77. clearTimeout(this.timer)
  78. if(this.currentType!=1) {
  79. this.timer = setTimeout(()=>{
  80. console.log('刷新了')
  81. this.refresh()
  82. },1000*20)
  83. }
  84. }
  85. }
  86. }
  87. </script>
  88. <style lang="scss" scoped>
  89. .qcode {
  90. width: 100%;
  91. display: flex;
  92. align-items: center;
  93. justify-content: center;
  94. padding: 20rpx 0;
  95. }
  96. .card {
  97. padding: 28rpx;
  98. margin-bottom: 24rpx;
  99. }
  100. .refresh_row {
  101. display: flex;
  102. justify-content: flex-end;
  103. align-items: center;
  104. padding: 10rpx 0;
  105. .text {
  106. color: $themC;
  107. font-size: 28rpx;
  108. }
  109. .icon {
  110. width: 24rpx;
  111. height: 24rpx;
  112. margin-left: 6rpx;
  113. }
  114. }
  115. .tabs {
  116. height: 72rpx;
  117. background: #FFFFFF;
  118. border-radius: 16rpx;
  119. display: flex;
  120. line-height: 72rpx;
  121. text-align: center;
  122. color: #ADADAD;
  123. margin: 24rpx 0;
  124. .tab {
  125. flex: 1;
  126. text-align: center;
  127. &.active {
  128. background: rgba(25, 137, 250, 0.1);
  129. border: 2rpx solid #1989FA;
  130. color: $themC;
  131. border-radius: 16rpx;
  132. }
  133. }
  134. }
  135. </style>