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.

178 lines
4.0 KiB

3 weeks ago
3 weeks ago
3 weeks ago
3 weeks ago
  1. <template>
  2. <view class="pageBgImg">
  3. <topNavbar title="个人二维码"></topNavbar>
  4. <view class="pad">
  5. <view class="adrsCon">
  6. <view class="adr" v-if="vuex_cityInfo.city" @click="getLatLngFn">{{vuex_cityInfo.city}} <text v-if="vuex_cityInfo.name"> / {{vuex_cityInfo.name}}</text></view>
  7. <view class="adr" v-else @click="getLatLngFn" style="display: flex;align-items: center;">
  8. <text>获取定位信息</text>
  9. <!-- <image src="@/static/images/index/down.png" mode="" style="width: 18rpx;height: 18rpx;margin-left: 6rpx;"></image> -->
  10. </view>
  11. <view class="adrsIcon">
  12. <image src="@/static/images/index/down.png" mode=""></image>
  13. </view>
  14. </view>
  15. <view class="tabs">
  16. <view class="tab" v-for="(item,index) in tabArr" :key="index" :class="{active: currentType==item.id}"
  17. @click="changeTab(item)">{{ item.text }}</view>
  18. </view>
  19. <view class="card">
  20. <view class="refresh_row" @click="refresh">
  21. <view class="text">刷新二维码</view>
  22. <view class="icon">
  23. <image src="@/static/images/index/ic_shuaxin.png" mode=""></image>
  24. </view>
  25. </view>
  26. <view class="qcode">
  27. <image :src="ossUrl" mode="widthFix" style="width: 500rpx;height: 500rpx;" v-if="ossUrl"></image>
  28. <view class="txt" v-else>正在加载~</view>
  29. </view>
  30. </view>
  31. <!-- <view class="card">
  32. <user-info/>
  33. </view> -->
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. import { getQR } from '@/config/api.js'
  39. export default {
  40. data() {
  41. return {
  42. timer: null,
  43. ossUrl: '',
  44. currentType: 4,
  45. tabArr: [
  46. {text: '签到码', id: 4},
  47. {text: '签退码', id: 5},
  48. ]
  49. }
  50. },
  51. onShow() {
  52. this.refresh()
  53. // this.test()
  54. },
  55. onLoad() {
  56. this.$store.dispatch('getCity')
  57. },
  58. onPullDownRefresh() {
  59. this.refresh()
  60. },
  61. onHide() {
  62. console.log('清除了')
  63. clearTimeout(this.timer)
  64. this.timer = null
  65. },
  66. beforeDestroy() {
  67. clearTimeout(this.timer)
  68. this.timer = null
  69. // this.refresh = null
  70. },
  71. methods: {
  72. async getLatLngFn() {
  73. try{
  74. uni.showLoading({
  75. title: '正在更新位置...'
  76. })
  77. await this.$store.dispatch('getCity')
  78. this.refresh()
  79. }catch(e){
  80. uni.hideLoading()
  81. }
  82. },
  83. changeTab(item) {
  84. if(item.id==this.currentType) return
  85. this.currentType = item.id
  86. this.refresh()
  87. },
  88. async refresh() {
  89. this.ossUrl = ''
  90. if(!this.vuex_cityInfo.lng) return this.$u.toast('没有获取到您的定位信息')
  91. const {data: res} = await getQR({type: this.currentType, lng: this.vuex_cityInfo.lng, lat: this.vuex_cityInfo.lat})
  92. // const {data: res} = await getQR({type: this.currentType, lng: '120.214842', lat: '30.342599'})
  93. this.ossUrl = res.ossUrl
  94. clearTimeout(this.timer)
  95. if(this.currentType!=1) {
  96. this.timer = setTimeout(()=>{
  97. console.log('刷新了')
  98. this.refresh()
  99. },1000*20)
  100. }
  101. }
  102. }
  103. }
  104. </script>
  105. <style lang="scss" scoped>
  106. .adrsCon {
  107. display: flex;
  108. align-items: center;
  109. // width: 180rpx;
  110. height: 88rpx;
  111. .adrsIcon {
  112. width: 17rpx;
  113. height: 17rpx;
  114. margin-top: 4rpx;
  115. }
  116. .adr {
  117. padding-right: 14rpx;
  118. font-size: 28rpx;
  119. color: #fff;
  120. }
  121. }
  122. .pageBgImg {
  123. &::before {
  124. height: 424rpx;
  125. }
  126. }
  127. .qcode {
  128. width: 100%;
  129. display: flex;
  130. align-items: center;
  131. justify-content: center;
  132. padding: 20rpx 0;
  133. height: 500rpx;
  134. }
  135. .card {
  136. padding: 28rpx;
  137. margin-bottom: 24rpx;
  138. }
  139. .refresh_row {
  140. display: flex;
  141. justify-content: flex-end;
  142. align-items: center;
  143. padding: 10rpx 0;
  144. .text {
  145. color: $themC;
  146. font-size: 28rpx;
  147. }
  148. .icon {
  149. width: 24rpx;
  150. height: 24rpx;
  151. margin-left: 6rpx;
  152. }
  153. }
  154. .tabs {
  155. height: 72rpx;
  156. background: #FFFFFF;
  157. border-radius: 16rpx;
  158. display: flex;
  159. line-height: 72rpx;
  160. text-align: center;
  161. color: #ADADAD;
  162. margin: 24rpx 0;
  163. .tab {
  164. flex: 1;
  165. text-align: center;
  166. &.active {
  167. background: rgba(25, 137, 250, 0.1);
  168. border: 2rpx solid #1989FA;
  169. color: $themC;
  170. border-radius: 16rpx;
  171. }
  172. }
  173. }
  174. </style>