QRCode.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <view class="content" @click="maskClick">
  3. <view class="qrcode">
  4. <!-- <uqrcode ref="uqrcode"></uqrcode> -->
  5. <img :src="imgSrc" alt="" class="img">
  6. <!-- <view class="qrcode-text">客户扫码</view> -->
  7. </view>
  8. </view>
  9. </template>
  10. <script>
  11. import {
  12. mapState
  13. } from 'vuex';
  14. export default {
  15. data() {
  16. return {
  17. imgSrc: ""
  18. };
  19. },
  20. onReady() {
  21. this.$api.doRequest('get', '/commonUser/api/checkSession').then(res => {
  22. console.log("checkSession",res)
  23. if (res.data.data == "INVALID") {
  24. uni.showModal({
  25. title: "登录提示",
  26. content: "Session过期需要重新登录,是否立即登录",
  27. showCancel: true,
  28. confirmText: '登录',
  29. success(e) {
  30. if (e.confirm) {
  31. uni.navigateTo({
  32. url: '/pages/public/login'
  33. })
  34. }
  35. }
  36. })
  37. } else {
  38. this.getQRCode()
  39. }
  40. })
  41. .catch(res => {
  42. if (res.message) {
  43. uni.showToast({
  44. title: res.message,
  45. icon: 'none',
  46. duration: 2000
  47. })
  48. }
  49. });
  50. // console.log(this.userInfo)
  51. // this.$refs
  52. // .uqrcode
  53. // .make({
  54. // size: 300,
  55. // margin:50,
  56. // text: JSON.stringify({
  57. // userName:this.userInfo.userName,
  58. // })
  59. // })
  60. // .then(res => {
  61. // // 返回的res与uni.canvasToTempFilePath返回一致
  62. // console.log(res)
  63. // })
  64. },
  65. computed: {
  66. ...mapState(['hasLogin', 'userInfo'])
  67. },
  68. methods: {
  69. maskClick() {
  70. uni.navigateBack(-1)
  71. },
  72. getQRCode() {
  73. this.$api.doRequest('get', '/identityAuthenticationInfo/generateQRCodeImage').then(res => {
  74. console.log(res)
  75. this.imgSrc = res.data.data
  76. })
  77. .catch(res => {
  78. if (res.message) {
  79. uni.showToast({
  80. title: res.message,
  81. icon: 'none',
  82. duration: 2000
  83. })
  84. }
  85. });
  86. }
  87. }
  88. }
  89. </script>
  90. <style lang="scss">
  91. .content {
  92. background: rgba(0, 0, 0, 0.4);
  93. height: 100vh;
  94. display: flex;
  95. justify-content: center;
  96. align-items: center;
  97. }
  98. .qrcode-text {
  99. text-align: center;
  100. position: relative;
  101. font-size: 24rpx;
  102. font-weight: 400;
  103. color: #878C9C;
  104. top: -40rpx;
  105. }
  106. .qrcode {
  107. position: fixed;
  108. top: 30%;
  109. margin: auto;
  110. }
  111. .img {
  112. width: 400rpx;
  113. }
  114. </style>