qrCode.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <div class="qrCodeBody">
  3. <div class="whiteBoard">
  4. <div class="qrCodeTitle">互联网私募如何入门?</div>
  5. <div class="qrCodeMsg">活动时间:活动开始时间 — 结束时间</div>
  6. <div class="qrCodeMsg">活动地址:XXXXXXXXXXXXXXXXXXXX</div>
  7. <div class="qrCodeBox">
  8. <img src="https://www.idea-co-sf.com/gardenProduct/image/erweima.png" class="qrCode">
  9. <span class="qrCodeInfo">扫一扫上面的二维码,完成签到</span>
  10. </div>
  11. <div class="bottomBtnBox">
  12. <button class="btn qdBtn">协助签到</button>
  13. <button class="btn commitBtn" @tap="commitImg">保存图片</button>
  14. </div>
  15. </div>
  16. </div>
  17. </template>
  18. <script>
  19. export default {
  20. name: "qrCode",
  21. data(){
  22. return{
  23. }
  24. },
  25. methods:{
  26. commitImg(){
  27. // 假设你已经有一个图片链接或者图片路径
  28. const imageSrc = 'https://www.idea-co-sf.com/gardenProduct/image/erweima.png';
  29. // 下载图片
  30. uni.downloadFile({
  31. url: imageSrc,
  32. success: downloadResult => {
  33. if (downloadResult.statusCode === 200) {
  34. // 获取下载后的图片临时文件路径
  35. let tempFilePath = downloadResult.tempFilePath;
  36. // 保存图片到相册
  37. uni.saveImageToPhotosAlbum({
  38. filePath: tempFilePath,
  39. success: () => {
  40. uni.showToast({
  41. title: '图片保存成功'
  42. });
  43. },
  44. fail: error => {
  45. uni.showToast({
  46. title: '图片保存失败',
  47. icon: 'none'
  48. });
  49. console.log('saveImageToPhotosAlbum fail', error);
  50. }
  51. });
  52. } else {
  53. uni.showToast({
  54. title: '图片下载失败',
  55. icon: 'none'
  56. });
  57. }
  58. },
  59. fail: error => {
  60. uni.showToast({
  61. title: '图片下载失败',
  62. icon: 'none'
  63. });
  64. console.log('downloadFile fail', error);
  65. }
  66. });
  67. }
  68. }
  69. }
  70. </script>
  71. <style lang="scss">
  72. .qrCodeBody{
  73. .whiteBoard{
  74. background: white;
  75. padding: 32rpx;
  76. box-sizing: border-box;
  77. margin-top: 24rpx;
  78. min-height: 1424rpx;
  79. .qrCodeTitle{
  80. color: rgba(24, 23, 42, 1);
  81. font-size: 32rpx;
  82. font-weight: 600;
  83. margin-bottom: 32rpx;
  84. }
  85. .qrCodeMsg{
  86. color: rgba(102, 102, 102, 1);
  87. font-size: 28rpx;
  88. line-height: 42rpx;
  89. }
  90. .qrCodeBox{
  91. display: flex;
  92. flex-direction: column;
  93. align-items: center;
  94. justify-content: center;
  95. margin-top: 134rpx;
  96. margin-bottom: 200rpx;
  97. .qrCode{
  98. width: 440rpx;
  99. height: 440rpx;
  100. }
  101. .qrCodeInfo{
  102. color: rgba(51, 51, 51, 1);
  103. font-size: 28rpx;
  104. margin-top: 8rpx;
  105. }
  106. }
  107. .btn{
  108. width: 654rpx;
  109. height: 96rpx;
  110. display: flex;
  111. align-items: center;
  112. justify-content: center;
  113. font-size: 36rpx;
  114. color: white;
  115. border-radius: 8rpx;
  116. &::after{
  117. border: none;
  118. }
  119. }
  120. .bottomBtnBox{
  121. display: flex;
  122. flex-direction: column;
  123. align-items: center;
  124. }
  125. .qdBtn{
  126. background: rgba(3, 101, 249, 1);
  127. }
  128. .commitBtn{
  129. background: rgba(34, 181, 101, 1);
  130. margin-top: 32rpx;
  131. }
  132. }
  133. }
  134. </style>