paycode.vue 3.2 KB

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