storeQr.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <template>
  2. <view class="content">
  3. <view class="user-logo">
  4. <image :src="userInfo.avatar" mode=""></image>
  5. <view class="user-name">{{userInfo.nickname}}</view>
  6. </view>
  7. <view class="code-warpper">
  8. <view class="code-content">
  9. <tki-qrcode
  10. :cid="cid"
  11. ref="qrcode"
  12. :val="val"
  13. :size="size"
  14. :unit="unit"
  15. :background="background"
  16. :foreground="foreground"
  17. :pdground="pdground"
  18. :iconSize="iconSize"
  19. :lv="lv"
  20. :onval="onval"
  21. :loadMake="loadMake"
  22. :usingComponents="usingComponents"
  23. @result="qrR"
  24. />
  25. </view>
  26. <!-- <view class="code">
  27. {{val}}
  28. </view> -->
  29. </view>
  30. <view class="btm">
  31. 扫一扫进店铺
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. import tkiQrcode from '@/components/tki-qrcode/tki-qrcode.vue';
  37. import { mapState, mapMutations } from 'vuex';
  38. export default {
  39. comments:{
  40. tkiQrcode
  41. },
  42. data() {
  43. return {
  44. // code: '10250035810',
  45. cid: 'tki-qrcode-canvas', //canvasId,页面存在多个二维码组件时需设置不同的ID
  46. size: 448, //生成的二维码大小
  47. unit: 'upx', //大小单位尺寸
  48. show: true,//默认使用组件中的image标签显示二维码
  49. val: '', //要生成的内容
  50. background: '#ffffff', //二维码背景色
  51. foreground: '#333333', //二维码前景色
  52. pdground: '#333333', //二维码角标色
  53. icon: '', //二维码图标URL(必须是本地图片,网络图需要先下载至本地)
  54. iconSize: 0, //二维码图标大小
  55. lv: 3, //容错级别
  56. onval: false, //监听val值变化自动重新生成二维码
  57. loadMake: true, //组件初始化完成后自动生成二维码,val需要有值
  58. usingComponents: false, //是否使用了自定义组件模式(主要是为了修复非自定义组件模式时 v-if 无法生成二维码的问题)
  59. showLoading: false, //是否显示loading
  60. loadingText: '二维码生成中', //loading文字
  61. src: '', // 二维码生成后的图片地址或base64
  62. ratio: 1, //页面比例用于计算
  63. ctxSrc: '', //要显示的图片
  64. loading: true,//是否载入图片中
  65. canHeight: '',//画布高度
  66. canWeidth: ''//画布宽度
  67. }
  68. },
  69. computed: {
  70. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
  71. },
  72. onShow() {
  73. console.log(this.userInfo)
  74. // 判断是否已经登录
  75. if (this.hasLogin) {
  76. // this.loadBaseData();
  77. // this.getSpreadCount()
  78. console.log(this.userInfo)
  79. // console.log(this.userInfo)
  80. }
  81. },
  82. onLoad(opt) {
  83. this.val = 'hello word'
  84. console.log(this.val )
  85. },
  86. methods: {
  87. // 生成二维码后返回base64
  88. qrR(res) {
  89. this.src = res;
  90. },
  91. }
  92. }
  93. </script>
  94. <style lang="scss" scoped>
  95. page {
  96. height: 100%;
  97. background-color: #fff;
  98. }
  99. .user-logo {
  100. height: 300rpx;
  101. display: flex;
  102. flex-direction: column;
  103. justify-content: center;
  104. align-items: center;
  105. image {
  106. background-color: #eee;
  107. width: 129rpx;
  108. height: 129rpx;
  109. border-radius: 50%;
  110. }
  111. .user-name {
  112. padding-top: 25rpx;
  113. font-size: 34rpx;
  114. font-family: SourceHanSansCN;
  115. font-weight: 400;
  116. color: #2B2B2B;
  117. }
  118. }
  119. .code-warpper {
  120. width: 515rpx;
  121. height: 515rpx;
  122. margin: 0 auto;
  123. border: 3rpx solid #52C696;
  124. // padding-top: 46rpx;
  125. position: relative;
  126. .code-content {
  127. position: absolute;
  128. top: 0;
  129. bottom: 0;
  130. left: 0;
  131. right: 0;
  132. width: 448rpx;
  133. height: 448rpx;
  134. background-color: #eee;
  135. margin: auto;
  136. }
  137. .code {
  138. padding-top: 31rpx;
  139. font-size: 36rpx;
  140. font-family: PingFang SC;
  141. font-weight: bold;
  142. color: #333333;
  143. text-align: center;
  144. }
  145. }
  146. .btm {
  147. padding-top: 45rpx;
  148. font-size: 30rpx;
  149. font-family: PingFang SC;
  150. font-weight: bold;
  151. color: #333333;
  152. text-align: center;
  153. }
  154. </style>