裂变星小程序-25.03.04
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.

95 lines
1.8 KiB

  1. <template>
  2. <view class="page">
  3. <navbar title="分享好友" leftClick @leftClick="$utils.navigateBack" />
  4. <view class="flex content">
  5. <image class="bg" :src="imgurl"></image>
  6. <view class="flex btns">
  7. <button class="btn btn-back" @click="$utils.navigateBack">返回</button>
  8. <button plain class="btn btn-save" @click="saveImg" >保存到相册</button>
  9. </view>
  10. </view>
  11. </view>
  12. </template>
  13. <script>
  14. export default {
  15. data() {
  16. return {
  17. imgurl: null,
  18. }
  19. },
  20. onLoad() {
  21. // todo: fetch imgurl
  22. this.imgurl = '../../static/image/center/temp-share.png'
  23. },
  24. methods: {
  25. saveImg(){
  26. this.$authorize('scope.writePhotosAlbum').then((res) => {
  27. this.imgApi(this.imgurl)
  28. })
  29. },
  30. imgApi(image) {
  31. /* 获取图片的信息 */
  32. uni.getImageInfo({
  33. src: image,
  34. success: function(image) {
  35. /* 保存图片到手机相册 */
  36. uni.saveImageToPhotosAlbum({
  37. filePath: image.path,
  38. success: function() {
  39. uni.showModal({
  40. title: '保存成功',
  41. content: '图片已成功保存到相册',
  42. showCancel: false
  43. });
  44. },
  45. complete(res) {
  46. console.log(res);
  47. }
  48. });
  49. }
  50. });
  51. },
  52. },
  53. }
  54. </script>
  55. <style scoped lang="scss">
  56. .page {
  57. background-color: #111317;
  58. height: 100vh;
  59. }
  60. .content {
  61. margin-top: 79rpx;
  62. flex-direction: column;
  63. }
  64. .bg {
  65. width: 598rpx;
  66. height: 1063rpx;
  67. }
  68. .btns {
  69. justify-content: space-between;
  70. margin-top: 53rpx;
  71. width: 598rpx;
  72. }
  73. .btn {
  74. width: 280rpx;
  75. height: 90rpx;
  76. font-size: 36rpx;
  77. color: #FFFFFF;
  78. border-radius: 45rpx;
  79. margin: 0;
  80. &-back {
  81. background-color: #4E5053;
  82. }
  83. &-save {
  84. background-image: linear-gradient(to right, #02DED6, #05D9A2);
  85. }
  86. }
  87. </style>