index.vue 2.7 KB

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