verificationCode.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <view class="verificationCode">
  3. <view class="receiptCode-wrap">
  4. <view class="receiptCode-wrap-inner">
  5. <view class="code-bg">
  6. <uqcode ref="uqcode" class="code-img"/>
  7. <view class="msg">
  8. <view class="code">有效期:<uni-countdown :second="second" @timeup="getCode" class="num"/></view>
  9. <view>核销码:{{ code }}</view>
  10. <!-- <view>haha@qq.com</view> -->
  11. </view>
  12. </view>
  13. <!-- <button class="inputButton" @click="saveImgFile(qr_code)">保存到相册</button> -->
  14. </view>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. import { post } from "@/request/api.js";
  20. var app = getApp();
  21. var appEv = app.$vm.$options;
  22. import uqcode from "@/components/uqrcode/uqrcode.vue";
  23. export default {
  24. name: "verificationCode",
  25. data() {
  26. return {
  27. qr_code: "",
  28. account: "",
  29. order_id: "", //订单ID
  30. code: "",
  31. modal_qr: false,
  32. second: 0,
  33. };
  34. },
  35. components: {
  36. // ayQrcode,
  37. uqcode
  38. },
  39. onLoad(e) {
  40. this.order_id = e.id;
  41. this.getCode();
  42. },
  43. methods: {
  44. getCode() {
  45. if (this.order_id) {
  46. post("my/orderCollate", {
  47. order_id: this.order_id,
  48. }).then((res) => {
  49. uni.hideLoading();
  50. if (res.code === 0) {
  51. this.code = res.data.data.code;
  52. this.$refs.uqcode.createCode(this.code);
  53. this.second = res.data.data.end_time - new Date().getTime() / 1000;
  54. // this.showQrcode();
  55. }
  56. });
  57. }
  58. },
  59. // showQrcode() {
  60. // let _this = this;
  61. // this.modal_qr = true;
  62. // setTimeout(function () {
  63. // _this.$refs.qrcode.crtQrCode();
  64. // }, 50);
  65. // },
  66. // hideQrcode() {
  67. // this.modal_qr = false;
  68. // },
  69. },
  70. };
  71. </script>
  72. <style scoped lang="scss">
  73. .verificationCode {
  74. padding:0rpx 40rpx;
  75. }
  76. .receiptCode-wrap {
  77. margin-top: 20rpx;
  78. padding-bottom: 40rpx;
  79. }
  80. .receiptCode-wrap-inner {
  81. // background: #eee;
  82. border-radius: 48rpx;
  83. padding: 40rpx;
  84. .code-bg {
  85. padding: 52rpx 0rpx;
  86. border-radius: 48rpx;
  87. background: #dad6d6;
  88. .code-img {
  89. display: flex;
  90. flex-direction: row;
  91. justify-content: center;
  92. margin: 0 auto;
  93. margin-bottom: 36rpx;
  94. // border-radius: 32rpx;
  95. }
  96. }
  97. }
  98. .inputButton {
  99. margin-top: 30rpx;
  100. background-color: #18bb88;
  101. color: #fff;
  102. font-size: 32rpx;
  103. height: 96rpx;
  104. line-height: 96rpx;
  105. border-radius: 50rpx;
  106. }
  107. .msg {
  108. text-align: center;
  109. .code {
  110. margin-bottom: 6rpx;
  111. .num{
  112. display: inline-block;
  113. }
  114. }
  115. }
  116. </style>