qrcode.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <template>
  2. <view class="page">
  3. <view style="text-align: center;height: 320px;width: 260px;margin: 0px auto;padding-top:30px;vertical-align: top;">
  4. <div class="info">
  5. <li>
  6. <image :src="user.avatar" style="height: 50px;width: 50px;border-radius: 5px;vertical-align: middle;"></image>
  7. </li>
  8. <li style='padding-left: 5px;line-height: 25px;;'>
  9. {{user.nickname}}<br>
  10. 账号:{{user.name}}
  11. </li>
  12. </div>
  13. <view class="qrbg">
  14. <image class="qrcode" :src="img" style="width: 180px;height:180px;" />
  15. </view>
  16. <view class="nodata" style="color: #666;;">扫描二维码,添加好友</view>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. import api from "../../library/index.js"
  22. import config from "../../config.js"
  23. export default {
  24. data() {
  25. return {
  26. img: '',
  27. user:'',
  28. }
  29. },
  30. methods: {
  31. },
  32. onLoad(opts) {
  33. this.user = uni.getStorageSync('userInfo');
  34. if(this.user.avatar.indexOf('http')<=-1){
  35. this.user.avatar=config.imgUri+this.user.avatar;
  36. }
  37. api.getMyQrcodeCard({id:this.user.id,'type':'qr_user'}).then(res=>{
  38. var img=res.data;
  39. if(img.indexOf('http')<=-1){
  40. img=config.apiUri+img;
  41. }
  42. this.img = img
  43. })
  44. },
  45. onNavigationBarButtonTap() {
  46. var that=this;
  47. uni.showActionSheet({
  48. itemList:['保存图片'],
  49. success: function (res) {
  50. uni.saveImageToPhotosAlbum({
  51. filePath:that.img,
  52. success: function () {
  53. uni.showToast({
  54. title:'图片已保存到相册',
  55. icon:'none'
  56. })
  57. }
  58. });
  59. }
  60. })
  61. }
  62. }
  63. </script>
  64. <style lang="scss" scoped>
  65. @import "@/static/css/group.css";
  66. .page{
  67. background-color: #fff;
  68. }
  69. .info{
  70. width: 100%;
  71. display: table;
  72. table-layout: fixed;
  73. height: 50px;
  74. line-height: 50px;
  75. text-align: left;
  76. }
  77. .info > li{
  78. display: table-cell;
  79. vertical-align: middle;
  80. overflow: hidden;
  81. text-overflow:ellipsis;
  82. white-space: nowrap;
  83. }
  84. .info > li:first-child{
  85. width: 60px;
  86. }
  87. .info > li:first-child img{
  88. width: 50px;
  89. height: 50px;
  90. vertical-align: middle;
  91. border-radius: 5px;
  92. }
  93. .info > li:nth-child(2){
  94. line-height: 25px;
  95. }
  96. .qrbg{
  97. display: block;
  98. margin: 15px auto;
  99. width: 200px;
  100. height: 180px;
  101. padding: 10px 0px;
  102. background-image:url(../../static/img/qrbg.png);
  103. background-size: 100% 100%;
  104. margin-top: 30px;
  105. }
  106. </style>