pay-qrcode.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <template>
  2. <view class="code-container">
  3. <view class="title center">扫一扫,向我付款</view>
  4. <view class="main-content center">
  5. <!-- 收款码 -->
  6. <view class="charge-code center">
  7. <tki-qrcode cid="1" ref="qrcode-charge" :val="id" size="420" :onval="true" :icon="avatar"
  8. :loadMake="true" :usingComponents="true" />
  9. </view>
  10. </view>
  11. <view class="footer center">
  12. <text class="text-xl text-bold">{{shopDetail.name}}</text>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. import tkiQrcode from "tki-qrcode"
  18. export default {
  19. components: {
  20. tkiQrcode
  21. },
  22. computed: {
  23. content() {
  24. let transformStr = (this.id * this.$global.TRANSFORM_PARAMS) * 2
  25. return transformStr + this.secret
  26. }
  27. },
  28. data() {
  29. return {
  30. id: "",
  31. shopDetail: {}, //商户详情
  32. avatar: "",
  33. secret: '000000',
  34. timer: '',
  35. }
  36. },
  37. methods: {
  38. async initAvatat(url) {
  39. return new Promise((reslove, reject) => {
  40. uni.downloadFile({
  41. url,
  42. success: (res) => {
  43. reslove(res);
  44. },
  45. fail: (err) => {
  46. reject(err)
  47. }
  48. })
  49. })
  50. }
  51. },
  52. async mounted(option) {
  53. let res = await this.$api.shop.detail({
  54. id: this.vuex_shopId
  55. })
  56. this.shopDetail = res.data
  57. let avatar = res.data.cover
  58. this.avatar = (await this.initAvatat(avatar)).tempFilePath;
  59. //获取用户ID
  60. this.id = this.$global.QR_PATH + this.$crypto.encrypt(this.vuex_shopId)
  61. //生成动态密码
  62. },
  63. beforeDestroy() {
  64. clearInterval(this.timer);
  65. }
  66. }
  67. </script>
  68. <style>
  69. page {
  70. background-color: #EF9944;
  71. }
  72. </style>
  73. <style lang="scss" scoped>
  74. .code-container {
  75. background-color: #FFFFFF;
  76. border-radius: 16rpx;
  77. // min-height: 900rpx;
  78. min-height: 800rpx;
  79. margin: 60rpx 20rpx;
  80. .title {
  81. border-radius: 25rpx 25rpx 0 0;
  82. height: 100rpx;
  83. width: 100%;
  84. font-size: 35rpx;
  85. color: #FE9644;
  86. background-color: #F7F7F7;
  87. font-weight: 600;
  88. letter-spacing: 3rpx;
  89. }
  90. .footer {
  91. width: 90%;
  92. height: 120rpx;
  93. margin-left: 5%;
  94. border-top: 1rpx dashed #dddddd;
  95. }
  96. .main-content {
  97. width: 100%;
  98. height: 620rpx;
  99. scroll-margin-top: 600rpx;
  100. // overflow: hidden;
  101. .bar-code {
  102. margin-left: 5%;
  103. width: 90%;
  104. height: 150rpx;
  105. }
  106. .qr-code {
  107. width: 100%;
  108. height: 450rpx;
  109. }
  110. .charge-code {
  111. width: 100%;
  112. height: 600rpx;
  113. transition: transform 1s ease-in-out;
  114. }
  115. }
  116. }
  117. </style>