storeQr.vue 4.1 KB

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