qrCode.vue 4.3 KB

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