Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 

145 rader
3.3 KiB

  1. <template>
  2. <view class="registerCode">
  3. <view class="registerImg">
  4. <image :src="qrCodeUrl+'/customer/getQrCode?appid='+appid+'&page=pages/mine/registerForm&scene='+projectId" mode=""></image>
  5. </view>
  6. <view class="registerBtn" @click="down">
  7. 保存图片到手机
  8. </view>
  9. </view>
  10. </template>
  11. <script>
  12. let domain = require("@/utils/domain")
  13. export default {
  14. data() {
  15. return {
  16. qrCodeUrl: "",
  17. projectId:"",
  18. projectName:"",
  19. appid:"",
  20. };
  21. },
  22. onShow() {
  23. this.projectId = uni.getStorageSync('buildingID').id;
  24. this.projectName = uni.getStorageSync('buildingID').name;
  25. this.appid = uni.getAccountInfoSync().miniProgram.appId;
  26. this.qrCodeUrl = domain.baseUrl;
  27. },
  28. methods: {
  29. down() {
  30. let url = this.qrCodeUrl+'/customer/getQrCode?appid='+this.appid+'&page=pages/mine/registerForm&scene='+this.projectId+'&projectName='+this.projectName
  31. console.log(url)
  32. uni.getImageInfo({
  33. src:url,
  34. success: (res) => {
  35. console.log(res)
  36. uni.saveImageToPhotosAlbum({
  37. filePath:res.path,
  38. success: () => {
  39. uni.showToast({
  40. title: "保存成功",
  41. icon: "none"
  42. })
  43. },
  44. fail: () => {
  45. uni.showToast({
  46. title: "保存失败",
  47. icon: "none"
  48. })
  49. }
  50. })
  51. }
  52. })
  53. // uni.getSetting({
  54. // success:(res)=> {
  55. // if(Object.keys(res.authSetting).length>0){
  56. // if(res.authSetting['scope.writePhotosAlbum']==undefined){
  57. // uni.openSetting({
  58. // success: (res) => {
  59. // console.log("设置权限1",res.authSetting)
  60. // }
  61. // })
  62. // }else{
  63. // if(!res.authSetting['scope.writePhotosAlbum']){
  64. // uni.openSetting({
  65. // success: (res) => {
  66. // console.log("设置权限1",res.authSetting)
  67. // }
  68. // })
  69. // }
  70. // }
  71. // }else{
  72. // return
  73. // }
  74. // }
  75. // })
  76. // uni.downloadFile({
  77. // url,
  78. // success: (res) => {
  79. // console.log(res)
  80. // uni.downloadFile({
  81. // url, //图片地址
  82. // success: (res) => {
  83. // console.log('downloadFile success', res)
  84. // if (res.statusCode === 200) {
  85. // console.log('downloadFile res.statusCode === 200', res)
  86. // uni.saveImageToPhotosAlbum({
  87. // filePath: res.tempFilePath,
  88. // success: function() {
  89. // uni.showToast({
  90. // title: "保存成功",
  91. // icon: "none"
  92. // })
  93. // },
  94. // fail: function() {
  95. // uni.showToast({
  96. // title: "保存失败",
  97. // icon: "none"
  98. // })
  99. // }
  100. // })
  101. // } else {
  102. // console.log('downloadFile res.statusCode !== 200', res)
  103. // }
  104. // }
  105. // })
  106. // }
  107. // });
  108. }
  109. },
  110. }
  111. </script>
  112. <style lang="scss">
  113. .registerCode {
  114. .registerImg {
  115. width: 300rpx;
  116. height: 300rpx;
  117. margin: 130rpx auto;
  118. image {
  119. width: 100%;
  120. height: 100%;
  121. }
  122. }
  123. .registerBtn {
  124. width: 80%;
  125. height: 80rpx;
  126. background: #3384fd;
  127. color: #FFFFFF;
  128. border-radius: 10rpx;
  129. line-height: 80rpx;
  130. text-align: center;
  131. font-size: 30rpx;
  132. margin: 50rpx auto;
  133. }
  134. }
  135. </style>