index.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <view class="page_container">
  3. <custom-nav-bar title="二维码" />
  4. <view class="qr_wrap">
  5. <view class="info_row">
  6. <my-avatar :src="sourceInfo.faceURL" :desc="sourceInfo.nickname" :isGroup="sourceInfo.groupID !== undefined" size="46" />
  7. <text class="nickname">{{ sourceInfo.nickname || sourceInfo.groupName }}</text>
  8. </view>
  9. <view class="desc_tip">
  10. <text>{{ getDescTip }}</text>
  11. </view>
  12. <view class="qr_icon">
  13. <uqrcode ref="uqrcode" canvas-id="qrcode" :value="qrLink" :size="160" :options="{ margin: 10 }"></uqrcode>
  14. </view>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. import CustomNavBar from '../../../components/CustomNavBar/index.vue';
  20. import MyAvatar from '../../../components/MyAvatar/index.vue';
  21. import { AddFriendQrCodePrefix, AddGroupQrCodePrefix } from '../../../constant';
  22. export default {
  23. components: {
  24. CustomNavBar,
  25. MyAvatar
  26. },
  27. data() {
  28. return {
  29. sourceInfo: {},
  30. qrLink: ''
  31. };
  32. },
  33. computed: {
  34. getDescTip() {
  35. return this.sourceInfo.groupID === undefined ? '扫一扫下面的二维码,添加我为朋友' : '扫一扫下面的二维码,加入群组';
  36. }
  37. },
  38. onLoad(options) {
  39. const { sourceInfo } = options;
  40. this.sourceInfo = sourceInfo ? JSON.parse(sourceInfo) : this.$store.getters.storeSelfInfo;
  41. this.getQrLink(this.sourceInfo);
  42. },
  43. methods: {
  44. getQrLink(info) {
  45. const prefix = info.groupID ? AddGroupQrCodePrefix : AddFriendQrCodePrefix;
  46. const sourceID = info.groupID ?? info.userID ?? '';
  47. this.qrLink = `${prefix}${sourceID}`;
  48. }
  49. }
  50. };
  51. </script>
  52. <style lang="scss" scoped>
  53. .page_container {
  54. background-color: #f8f8f8;
  55. .qr_wrap {
  56. display: flex;
  57. flex-direction: column;
  58. align-items: center;
  59. margin: 0 44rpx;
  60. margin-top: 96rpx;
  61. padding: 72rpx;
  62. background-color: #fff;
  63. box-shadow: 0px 0px 7px 0px rgba(0, 0, 0, 0.1);
  64. border-radius: 16rpx;
  65. .info_row {
  66. @include vCenterBox();
  67. justify-content: flex-start;
  68. width: 100%;
  69. margin-bottom: 96rpx;
  70. .nickname {
  71. @include nomalEllipsis();
  72. margin-left: 24rpx;
  73. max-width: 600rpx;
  74. }
  75. }
  76. .desc_tip {
  77. font-size: 28rpx;
  78. color: #999;
  79. margin-bottom: 48rpx;
  80. }
  81. .qr_icon {
  82. @include centerBox();
  83. background-image: url('../../../static/images/self_qr_bg.png');
  84. margin-bottom: 48rpx;
  85. width: 180px;
  86. height: 180px;
  87. }
  88. }
  89. }
  90. </style>