popupCode.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. const util = require("../../../../utils/util");
  2. const app = getApp();
  3. Component({
  4. properties: {
  5. show: {
  6. type: Boolean,
  7. observer: function (newVal) {
  8. this.setData({ showCode: newVal });
  9. }
  10. },
  11. headImg: {
  12. type: String,
  13. observer: function (newVal) {
  14. this.setData({ headImg: newVal });
  15. }
  16. },
  17. methodView:{
  18. type: Number,
  19. observer: function (newVal) {
  20. this.setData({ methodView: newVal });
  21. }
  22. }
  23. },
  24. data: {
  25. height:'80%',
  26. showCode:false,
  27. headImg:'',
  28. methodView:0
  29. },
  30. methods: {
  31. // 弹窗关闭
  32. closeCode(e){
  33. this.triggerEvent("close", e.detail);
  34. },
  35. saveImage(e){
  36. let self = this;
  37. wx.downloadFile({
  38. url:e.currentTarget.dataset.img,
  39. success(res) {
  40. wx.saveImageToPhotosAlbum({
  41. filePath:res.tempFilePath,
  42. success:(res)=>{
  43. util.showTips('已保存至相册!')
  44. setTimeout(() => {
  45. self.triggerEvent("close", false)
  46. }, 500);
  47. }
  48. })
  49. },
  50. fail(res){
  51. util.showTips('保存失败!')
  52. }
  53. })
  54. }
  55. }
  56. })