paycode.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <view class="pages">
  3. <u-navbar
  4. title="会员码"
  5. :autoBack="true"
  6. :safeAreaInsetTop="true"
  7. >
  8. </u-navbar>
  9. <img class="bg" :src="staticUrl+'/img/paycode-bg.png'" alt="">
  10. <view class="content">
  11. <view class="avatar-wrap">
  12. <u-avatar :src="vuex_member_info.avatar||staticUrl+'/img/avatar.png'" size="138rpx"></u-avatar>
  13. </view>
  14. <view class="name">{{vuex_member_info.name}}</view>
  15. <img class="qrcode-bg" :src="staticUrl+'/img/qrcode-bg.png'" alt="">
  16. <!-- <img class="qrcode" :src="staticUrl+'/img/paycode-bg.png'" alt=""> -->
  17. <view class="ayQrcode" @click="refreshCode">
  18. <ayQrcode ref="qrcode" :modal="modal_qr" :url="qrContent" @hideQrcode="hideQrcode" :height="200" :width="200" />
  19. </view>
  20. <view class="tip u-flex u-row-center" @click="refreshCode">
  21. <img class="refresh-ico" :src="staticUrl+'/img/refresh.png'" alt="">
  22. <text>会员码每30秒自动更新,请在店内消费使用</text>
  23. </view>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. import ayQrcode from "@/components/ay-qrcode/ay-qrcode.vue"
  29. export default {
  30. components:{
  31. ayQrcode
  32. },
  33. data() {
  34. return {
  35. staticUrl:this.$commonConfig.staticUrl,
  36. modal_qr: false,
  37. qrContent: {}, // 要生成的二维码值
  38. params:{
  39. }
  40. }
  41. },
  42. onShow() {
  43. },
  44. onLoad() {
  45. this.qrContent.qrcode = this.vuex_member_info.id;
  46. this.qrContent.time = Date.now();
  47. this.qrContent = JSON.stringify(this.qrContent);
  48. let that = this;
  49. that.showQrcode();//一加载生成二维码
  50. setInterval(this.refreshCode, 30000);
  51. },
  52. methods: {
  53. // 展示二维码
  54. showQrcode() {
  55. let _this = this;
  56. this.modal_qr = true;
  57. // uni.showLoading()
  58. setTimeout(function() {
  59. // uni.hideLoading()
  60. _this.$refs.qrcode.crtQrCode()
  61. }, 50)
  62. },
  63. //传入组件的方法
  64. hideQrcode() {
  65. this.modal_qr = false;
  66. },
  67. refreshCode(){
  68. this.qrContent = {};
  69. this.qrContent.qrcode = this.vuex_member_info.id;
  70. this.qrContent.time = Date.now();
  71. this.qrContent = JSON.stringify(this.qrContent);
  72. this.showQrcode()
  73. }
  74. }
  75. }
  76. </script>
  77. <style lang="scss" scoped>
  78. .bg{
  79. position: fixed;
  80. width: 100%;
  81. height: 100vh;
  82. height: -webkit-fill-available;
  83. left: 0;
  84. bottom: 0;
  85. z-index: -1;
  86. }
  87. .content{
  88. position: relative;
  89. text-align: center;
  90. background-color: #fff;
  91. border-radius: 8rpx;
  92. margin: 150rpx 20rpx 0;
  93. padding: 90rpx 50rpx 80rpx;
  94. }
  95. .avatar-wrap{
  96. position: absolute;
  97. left: 50%;
  98. top: -69rpx;
  99. transform: translateX(-69rpx);
  100. background-color: #fff;
  101. padding: 11rpx;
  102. border-radius: 50%;
  103. }
  104. .name{
  105. font-size: 32rpx;
  106. font-weight: 600;
  107. color: #333333;
  108. line-height: 45rpx;
  109. margin-bottom: 40rpx;
  110. }
  111. // .qrcode{
  112. // position: absolute;
  113. // top: 211rpx;
  114. // left: 102rpx;
  115. // width: 506rpx;
  116. // height: 506rpx;
  117. // }
  118. .ayQrcode{
  119. position: absolute;
  120. top: 211rpx;
  121. left: 170rpx;
  122. width: 400rpx;
  123. height: 400rpx;
  124. }
  125. .tip{
  126. margin-top: 40rpx;
  127. font-size: 24rpx;
  128. font-weight: 400;
  129. color: #999999;
  130. line-height: 33rpx;
  131. .refresh-ico{
  132. width: 27rpx;
  133. height: 27rpx;
  134. margin-right: 10rpx;
  135. }
  136. }
  137. </style>