doctorQr.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <view class="content">
  3. <view class="item">
  4. <image mode="aspectFit" :show-menu-by-longpress="true" :src="urls[0]" ></image>
  5. <!-- <view class="btn" @click="savePhoto()">
  6. 保存本地
  7. </view> -->
  8. </view>
  9. </view>
  10. </template>
  11. <script>
  12. export default {
  13. data() {
  14. return {
  15. urls:['https://qinggetai.oss-rg-china-mainland.aliyuncs.com/qgt/20230714/9d83107168544b75b8d8934e913126a1.png']
  16. };
  17. },
  18. onLoad(option) {
  19. },
  20. onShow() {
  21. },
  22. methods: {
  23. savePhoto(){
  24. var that=this;
  25. uni.downloadFile({ //下载文件资源到本地,返回文件的本地临时路径
  26. url: that.urls[0], //网络图片路径
  27. success:(res)=>{
  28. var imageUrl=res.tempFilePath;//临时文件路径
  29. uni.saveImageToPhotosAlbum({ //保存图片到系统相册
  30. filePath: imageUrl,
  31. success: (res) => {
  32. console.log('图片保存成功');
  33. },
  34. fail: (err) => {
  35. console.log('图片保存失败');
  36. }
  37. })
  38. }
  39. })
  40. },
  41. showImg() {
  42. //预览图片
  43. uni.previewImage({
  44. urls: this.urls,
  45. current: this.urls[0],
  46. // 长按图片显示操作菜单,如不填默认为保存相册
  47. longPressActions:{
  48. itemList:[]
  49. }
  50. });
  51. },
  52. }
  53. }
  54. </script>
  55. <style lang="scss">
  56. .content{
  57. height: 100%;
  58. width: 100%;
  59. display: flex;
  60. align-items: center;
  61. justify-content: center;
  62. .item{
  63. display: flex;
  64. flex-direction: column;
  65. align-items: center;
  66. justify-content: center;
  67. width: 100vw;
  68. height: 100vh;
  69. image{
  70. width: 100%;
  71. height:100%;
  72. }
  73. .btn{
  74. margin-top: 30rpx;
  75. background-image: linear-gradient(#ff4545,red);
  76. padding: 30rpx 60rpx;
  77. border-radius: 60rpx;
  78. background-color: red;
  79. color: #fff;
  80. font-size: 30rpx;
  81. font-family: 'PingFangTC-Regular';
  82. font-weight: 600;
  83. }
  84. }
  85. }
  86. </style>