paycode.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. <view class="content">
  11. <view class="ayQrcode" @click="refreshCode">
  12. <ayQrcode
  13. ref="qrcode"
  14. :modal="modal_qr"
  15. :url="qrContent"
  16. @hideQrcode="hideQrcode"
  17. :is_themeImg="true"
  18. themeImg="../static/qrlogo.png"
  19. :h_w_img="65"
  20. :height="250" :width="250" />
  21. </view>
  22. <view class="tip">仅限消费者注册使用</view>
  23. <text class="save">保存本地</text>
  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. timer: null,
  39. }
  40. },
  41. onShow() {
  42. },
  43. onLoad() {
  44. this.qrContent.qrcode = this.vuex_user_info.userid;
  45. // this.qrContent.time = Date.now();
  46. this.qrContent = JSON.stringify(this.qrContent);
  47. let that = this;
  48. // this.timer = setInterval(() => {
  49. // this.refreshCode()
  50. // }, 30000);
  51. },
  52. onUnload() {
  53. // 页面离开时停止计时器
  54. // clearInterval(this.timer)
  55. },
  56. onReady() {
  57. let that = this;
  58. that.showQrcode();//一加载生成二维码
  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_user_info.userid;
  78. this.qrContent.time = Date.now();
  79. this.qrContent = JSON.stringify(this.qrContent);
  80. this.showQrcode()
  81. }
  82. }
  83. }
  84. </script>
  85. <style>
  86. page{
  87. background-color: #005223;
  88. }
  89. </style>
  90. <style lang="scss" scoped>
  91. .content{
  92. text-align: center;
  93. margin: 90rpx 45rpx 24rpx;
  94. background: #FFFFFF;
  95. border-radius: 8rpx;
  96. padding: 100rpx 20rpx;
  97. box-sizing: border-box;
  98. .ayQrcode{
  99. width: 250px;
  100. height: 250px;
  101. }
  102. .tip{
  103. font-size: 24rpx;
  104. font-weight: 400;
  105. color: #999999;
  106. margin-bottom: 40rpx;
  107. }
  108. .save{
  109. padding: 25rpx 98rpx;
  110. font-size: 26rpx;
  111. font-weight: 600;
  112. color: #FFFFFF;
  113. background-color: #00A447;
  114. border-radius: 4rpx;
  115. }
  116. }
  117. </style>