storeQr.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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: false, //监听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. }
  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. onLoad(opt) {
  85. my({}).then(({data}) =>{
  86. this.id = data.id;
  87. })
  88. this.val = this.baseURL + '/index/pages/index/index?store_id=' + this.id
  89. console.log(this.val )
  90. },
  91. methods: {
  92. // 生成二维码后返回base64
  93. qrR(res) {
  94. this.src = res;
  95. },
  96. }
  97. }
  98. </script>
  99. <style lang="scss" scoped>
  100. page {
  101. height: 100%;
  102. background-color: #fff;
  103. }
  104. .user-logo {
  105. height: 300rpx;
  106. display: flex;
  107. flex-direction: column;
  108. justify-content: center;
  109. align-items: center;
  110. image {
  111. background-color: #eee;
  112. width: 129rpx;
  113. height: 129rpx;
  114. border-radius: 50%;
  115. }
  116. .user-name {
  117. padding-top: 25rpx;
  118. font-size: 34rpx;
  119. font-family: SourceHanSansCN;
  120. font-weight: 400;
  121. color: #2B2B2B;
  122. }
  123. }
  124. .code-warpper {
  125. width: 515rpx;
  126. height: 515rpx;
  127. margin: 0 auto;
  128. border: 3rpx solid #52C696;
  129. // padding-top: 46rpx;
  130. position: relative;
  131. .code-content {
  132. position: absolute;
  133. top: 0;
  134. bottom: 0;
  135. left: 0;
  136. right: 0;
  137. width: 448rpx;
  138. height: 448rpx;
  139. background-color: #eee;
  140. margin: auto;
  141. }
  142. .code {
  143. padding-top: 31rpx;
  144. font-size: 36rpx;
  145. font-family: PingFang SC;
  146. font-weight: bold;
  147. color: #333333;
  148. text-align: center;
  149. }
  150. }
  151. .btm {
  152. padding-top: 45rpx;
  153. font-size: 30rpx;
  154. font-family: PingFang SC;
  155. font-weight: bold;
  156. color: #333333;
  157. text-align: center;
  158. }
  159. </style>