四零语境前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

126 lines
2.6 KiB

  1. <template>
  2. <view class="share-page">
  3. <!-- <uv-status-bar></uv-status-bar> -->
  4. <!-- 主要内容区域 -->
  5. <view class="content">
  6. <!-- 中间图片 -->
  7. <view class="image-container">
  8. <image
  9. class="share-image"
  10. :src="Qrcode"
  11. mode="aspectFit"
  12. ></image>
  13. </view>
  14. </view>
  15. <!-- 底部固定按钮 -->
  16. <view class="bottom-button-container">
  17. <uv-button :custom-style="{
  18. height: '82rpx',
  19. borderRadius: '198rpx',
  20. background: '#06DADC',
  21. border: '2rpx solid #06DADC',
  22. lineHeight: '82rpx',
  23. fontSize: '36rpx'
  24. }" type="primary" @click="save">保存到相册</uv-button>
  25. <uv-safe-bottom></uv-safe-bottom>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. export default {
  31. data() {
  32. return {
  33. Qrcode: '',
  34. }
  35. },
  36. methods: {
  37. handleShare() {
  38. // 分享逻辑
  39. uni.showToast({
  40. title: '分享功能',
  41. icon: 'none'
  42. })
  43. },
  44. save() {
  45. uni.saveImageToPhotosAlbum({
  46. filePath: this.Qrcode,
  47. success: (res) => {
  48. uni.showToast({
  49. title: '保存成功',
  50. icon: 'success'
  51. })
  52. },
  53. fail: (err) => {
  54. uni.showToast({
  55. title: '保存失败',
  56. icon: 'none'
  57. })
  58. }
  59. })
  60. },
  61. async getQrcode() {
  62. // const res = await this.$api.promotion.qrCode()
  63. // if (res.code === 200) {
  64. uni.getImageInfo({
  65. src: `${this.$config.baseURL}/promotion/qrCode?token=${uni.getStorageSync('token')}`,
  66. success: (image) => {
  67. console.log(image.width);
  68. console.log(image.path);
  69. this.Qrcode = image.path;
  70. console.log(image.height);
  71. }
  72. });
  73. // }
  74. }
  75. },
  76. onShow() {
  77. this.getQrcode()
  78. },
  79. }
  80. </script>
  81. <style lang="scss" scoped>
  82. .share-page {
  83. min-height: 100vh;
  84. background-color: #f5f5f5;
  85. display: flex;
  86. flex-direction: column;
  87. }
  88. .content {
  89. height: 100vh;
  90. flex: 1;
  91. padding-bottom: 200rpx;
  92. display: flex;
  93. align-items: center;
  94. justify-content: center;
  95. .image-container {
  96. // background: red;
  97. display: flex;
  98. // height: 100%;
  99. justify-content: center;
  100. align-items: center;
  101. .share-image {
  102. height: 90vh;
  103. width: 670rpx;
  104. border-radius: 16rpx;
  105. }
  106. }
  107. }
  108. // 底部固定按钮
  109. .bottom-button-container {
  110. position: fixed;
  111. bottom: 0;
  112. left: 0;
  113. right: 0;
  114. padding: 30rpx 40rpx;
  115. background: rgba(255, 255, 255, 0.95);
  116. border-top: 1px solid #F1F1F1;
  117. }
  118. </style>