rank-day.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <view class="rank-day-container">
  3. <image
  4. :src="rankDayPath"
  5. mode="widthFix"
  6. class="rank-day-img"
  7. @click="toSave"
  8. ></image>
  9. ></image>
  10. <view class="submit" @tap="toSave">点击保存</view>
  11. </view>
  12. </template>
  13. <script>
  14. export default {
  15. data() {
  16. return {
  17. rankDayPath: ''
  18. }
  19. },
  20. onShow() {
  21. this.rankDayPath = uni.getStorageSync('rankDay')
  22. if(!this.rankDayPath) {
  23. uni.showModal({
  24. content: '查看每日排行错误',
  25. showCancel: false,
  26. success(res){
  27. if(res.confirm) {
  28. uni.navigateBack()
  29. }
  30. }
  31. })
  32. }
  33. },
  34. methods: {
  35. toSave() {
  36. const _this = this
  37. uni.showLoading()
  38. uni.getImageInfo({
  39. src: _this.rankDayPath,
  40. success(res) {
  41. uni.saveImageToPhotosAlbum({
  42. filePath: res.path,
  43. success() {
  44. uni.showModal({
  45. content: "图片保存成功",
  46. showCancel: false
  47. })
  48. },
  49. fail(e) {
  50. uni.showModal({
  51. content: JSON.stringify(e) || '图片保存失败',
  52. content: '图片保存失败',
  53. showCancel: false
  54. })
  55. },
  56. complete() {
  57. uni.hideLoading()
  58. }
  59. })
  60. },
  61. fail(e) {
  62. uni.hideLoading()
  63. uni.showModal({
  64. content: '保存图片失败',
  65. showCancel: false
  66. })
  67. }
  68. })
  69. }
  70. }
  71. }
  72. </script>
  73. <style scoped lang="scss">
  74. page {
  75. display: flex;
  76. flex-direction: column;
  77. .rank-day-container {
  78. flex: 1;
  79. overflow: hidden;
  80. .rank-day-img {
  81. width: 100%;
  82. }
  83. }
  84. .submit {
  85. width: calc(100% - 160rpx);
  86. height: 80rpx;
  87. margin: 30rpx auto 0;
  88. background: rgba(250, 99, 66, 1);
  89. border-radius: 35rpx;
  90. color: #ffffff;
  91. margin-bottom: 10rpx;
  92. font-size: 32rpx;
  93. font-weight: bolder;
  94. line-height: 80rpx;
  95. text-align: center;
  96. padding: 0 30rpx;
  97. }
  98. }
  99. </style>