paycode.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. timer: null,
  41. }
  42. },
  43. onShow() {
  44. },
  45. onLoad() {
  46. this.qrContent.qrcode = this.vuex_member_info.id;
  47. this.qrContent.time = Date.now();
  48. this.qrContent = JSON.stringify(this.qrContent);
  49. let that = this;
  50. that.showQrcode();//一加载生成二维码
  51. this.timer = setInterval(() => {
  52. this.refreshCode()
  53. }, 30000);
  54. },
  55. onUnload() {
  56. // 页面离开时停止计时器
  57. clearInterval(this.timer)
  58. },
  59. methods: {
  60. // 展示二维码
  61. showQrcode() {
  62. let _this = this;
  63. this.modal_qr = true;
  64. // uni.showLoading()
  65. setTimeout(function() {
  66. // uni.hideLoading()
  67. _this.$refs.qrcode.crtQrCode()
  68. }, 50)
  69. },
  70. //传入组件的方法
  71. hideQrcode() {
  72. this.modal_qr = false;
  73. },
  74. refreshCode(){
  75. this.qrContent = {};
  76. this.qrContent.qrcode = this.vuex_member_info.id;
  77. this.qrContent.time = Date.now();
  78. this.qrContent = JSON.stringify(this.qrContent);
  79. this.showQrcode()
  80. }
  81. }
  82. }
  83. </script>
  84. <style lang="scss" scoped>
  85. .bg{
  86. position: fixed;
  87. width: 100%;
  88. height: 100vh;
  89. height: -webkit-fill-available;
  90. left: 0;
  91. bottom: 0;
  92. z-index: -1;
  93. }
  94. .content{
  95. position: relative;
  96. text-align: center;
  97. background-color: #fff;
  98. border-radius: 8rpx;
  99. margin: 150rpx 20rpx 0;
  100. padding: 90rpx 50rpx 80rpx;
  101. }
  102. .avatar-wrap{
  103. position: absolute;
  104. left: 50%;
  105. top: -69rpx;
  106. transform: translateX(-69rpx);
  107. background-color: #fff;
  108. padding: 11rpx;
  109. border-radius: 50%;
  110. }
  111. .name{
  112. font-size: 32rpx;
  113. font-weight: 600;
  114. color: #333333;
  115. line-height: 45rpx;
  116. margin-bottom: 40rpx;
  117. }
  118. // .qrcode{
  119. // position: absolute;
  120. // top: 211rpx;
  121. // left: 102rpx;
  122. // width: 506rpx;
  123. // height: 506rpx;
  124. // }
  125. .ayQrcode{
  126. position: absolute;
  127. top: 211rpx;
  128. left: 170rpx;
  129. width: 400rpx;
  130. height: 400rpx;
  131. }
  132. .tip{
  133. margin-top: 40rpx;
  134. font-size: 24rpx;
  135. font-weight: 400;
  136. color: #999999;
  137. line-height: 33rpx;
  138. .refresh-ico{
  139. width: 27rpx;
  140. height: 27rpx;
  141. margin-right: 10rpx;
  142. }
  143. }
  144. </style>