storeQr.vue 3.8 KB

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