qrcode.vue 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <view class="app">
  3. <view class="pannel fx-h fx-bc fx-ac">
  4. <view class="pannel-body fx-h fx-bc fx-ac">
  5. <view class="fx-r fx-bc" style="width: 100%;margin: 10px;">
  6. <image class="avatar" :src="img == '' ? '/static/chat/group_chat.png' : img" mode="aspectFill"></image>
  7. <view class="nickname">{{name}}</view>
  8. </view>
  9. <view class="hr"></view>
  10. <view class="fx-r fx-bc fx-ac">
  11. <canvas id="qrcode" canvas-id="qrcode" style="width: 300px;height: 300px;" />
  12. </view>
  13. <view class="tip">该二维码7天({{utils.date('m月d日')}})有效,重新进入将更新.</view>
  14. </view>
  15. </view>
  16. </view>
  17. </template>
  18. <style>
  19. .app{padding-top: 40px;}
  20. .pannel{background: #fff;width:calc(100vw - 40px);margin-left: 20px;border-radius:10px;}
  21. .pannel .avatar{width: 40px;height: 40px;border-radius: 4px;margin-left: 10px;}
  22. .pannel-body{position: relative;width: 100%;padding: 20px 0;}
  23. .pannel-body .nickname{color: #000;margin-left: 10px;font-weight: bold;}
  24. .pannel-body .tag{font-size: 14px;color: #737373;margin-top: 10px;}
  25. .hr{border-top: 1px dashed #f1f1f1;height: 1px;width: 100%;;margin: 10px 0;}
  26. .sub-btn{background: #2fbec0;padding: 8px 20px;color: white;display: inline-block;border-radius: 4px; margin-top: 20px;}
  27. </style>
  28. <script>
  29. import {mapState,mapMutations} from 'vuex';
  30. import uQRCode from '@/uni_modules/Sansnn-uQRCode/components/uqrcode/common/uqrcode.js';
  31. //import yuanqiQrCode from '@/uni_modules/yuanqi-qr-code/components/yuanqi-qr-code/yuanqi-qr-code';
  32. export default {
  33. computed: mapState(['user']),
  34. //components: {yuanqiQrCode },
  35. data() {
  36. return {
  37. bm_code:""
  38. }
  39. },
  40. onLoad(options) {
  41. this.name = options.name || "";
  42. this.img = options.img || "";
  43. this.groupId = options.groupId || "";
  44. this.initView();
  45. },
  46. methods: {
  47. ...mapMutations(['checkUserLogin']),
  48. initView:function(){
  49. uni.showLoading({ title:"加载中.." });
  50. this
  51. .request
  52. .post("chatGroupQrcode",{groupId:this.groupId})
  53. .then(res=>{
  54. uni.hideLoading();
  55. if(res.code == 200) {
  56. this.bm_code = res.msg;
  57. uQRCode.make({
  58. canvasId: 'qrcode',
  59. componentInstance: this,
  60. size: 300,
  61. margin: 10,
  62. text: this.bm_code,
  63. backgroundColor: '#ffffff',
  64. foregroundColor: '#000',
  65. fileType: 'png',
  66. errorCorrectLevel: uQRCode.errorCorrectLevel.H
  67. })
  68. .then(res => {
  69. console.log(res)
  70. });
  71. //setTimeout(()=>{this.$refs.yuanqiQRCode.makeImage();},200);
  72. } else {
  73. this.utils.Tip(res.msg);
  74. }
  75. })
  76. .catch(err=>{
  77. uni.hideLoading();
  78. this.utils.Tip("加载失败,请重新尝试");
  79. uni.navigateBack();
  80. });
  81. },
  82. tapSave:function(){
  83. // this.$refs.yuanqiQRCode.save();
  84. },
  85. }
  86. }
  87. </script>
  88. <style>
  89. </style>