verificationCode.vue 2.9 KB

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